ColdFusion Developer Week 2012

Adobe's second ColdFusion Developer Week kicks off today, June 4, and continues through Friday, June 8, 2012. Whether you're a new or experienced CFML developer, there's probably more than one session you'll find very interesting and useful. From basics to advanced language features, as well as frameworks and a focus on the new ColdFusion 10 release, there's just loads of good stuff, all provided via free online Webinars.

Check out the sessions and schedule, and sign up.

Like last year, I'll be presenting Improve Your Apps Through Unit Testing, tomorrow.

I also hope to revive this sleepy blog with some more interesting tid-bits soon, so stay tuned! It's been a busy year, but I've queued a number of topics for blog posts, so hopefully I can catch up a little in the near future.

Bash Script to Set Sensible Directory/File Permissions

Every once in a while a directory structure's permissions just get messy (or an archive I download and extract has stupid permissions, like making every single file executable). So I'll occasionally want to chmod 755 all directories and chmod 644 all files. If you're new to file system permissions in Linux, let me translate that goal. For every directory I want the owner to be able to read/write/execute (execute allows to cd into directory) and both group and all others to have read/execute permissions. For every file I want the owner to have read/write permissions and both the group and all others to have read-only permission. The Ubuntu Community Documentation has a good File Permissions page that covers this in more detail.

That same documentation has a Recursive chmod using find, pipemill, and sudo section that details precisely the two commands I need, but I hate to waste time finding this link and carefully remembering what I want to do. So, I've whipped up a simple Bash script that simply accepts a directory path as its only parameter and prompts me to confirm before making the permission changes. Here it is.


# exit this bash script if any statement returns a non-true return value (same as: set -e)
set -o errexit

if [ -z "$1" ]; then
    echo "ERROR: Must pass parameter of path to directory (which will have permissions set accordingly; 755 directories and 644 files)."
    echo "USAGE: $0 /path/to/directory"
    exit 1

echo "Working recursively with directory $1 this script will chmod 755 all directories and chmod 644 all files."

read -p "Okay to continue (y/n)? "
if [ "$REPLY" != "y" ]; then
    exit 1

echo "Starting..."

find "$1" -type d -print0 | xargs -0 chmod 755
find "$1" -type f -print0 | xargs -0 chmod 644

echo "Done."

exit 0

Since I'll often need to run this script as root, I've taken a few extra steps to protect it by making it owned and executable only by root:

sudo chown root:root
sudo chmod 744

So, from the directory containing this script (as you can see I've named mine, here's an example usage:

sudo ./ ~/directory-to-clean-up-permissions

If your directory has strange owners and/or groups set, you can quickly clean that up recursively as well. For example:

sudo chown -R jkrug:jkrug ~/directory-to-clean-up-permissions

BlogCFC was created by Raymond Camden.