Andy Regan Ramblings of an Irish Sysadmin

25Feb/100

Quickly Reset Linux File and Directory Permissions

Just a quick post so I can keep these commands handy (since I keep forgetting them). These will allow you to quickly set different permissions for all files (or all folders) within a specific directory in Linux.

Reset File Permissions

$find /path/to/directory/ -type f -exec chmod 644 {} \;

Reset Directory Permissions

$find /path/to/directory/ -type d -exec chmod 755 {} \;

Reset Permissions on 777 PHP Files Only

$find /path/to/directory/ -name \*.php -perm 777 -type f -exec chmod 644 {} \;

22Feb/090

First Post and SMS Ping Script

Thanks for visiting!  The main purpose of this blog (right now) is as an archive for useful technical bits and pieces I've come across and don't want to forget.  Hopefully, you might find some of these useful, too.   This is my first post and I'd like to start by sharing a handy little script-foo I learned.

Over Christmas, the Compsoc admin team reinstalled our backup server.  We created a fairly large (~3.6T RAID5) /home partition which took forever to build when the server booted for the first time.  Rather than keep checking into the server room I figured "Wouldn't it be handy if I could just get a text when the server comes up?".

I decided to use a great tool called o2sms by Mackers that's installed on Compsoc's webserver.  It allows you to send text messages via the command line.  The following script intermittently pings the backup and sends an SMS to the specified number when a ping returns successfully:

$while ! ping -W 1 -c 1 IPAddress 2>&1 >/dev/null; do true; done && echo “Scorpio is UP” | meteorsms mynumber

Its a simple little diddy ain't it?  Run it in a screen and you can detach, logout and go about your day.  Drop the ! and it will send an SMS if  a ping fails (maybe the servers down).  You could also replace ping with another event, such as a certain user logging in (users | grep andrewjregan) or if you recieve a new mail.