O'Reilly logo

Perl for Web Site Management by John Callender

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unix File Permissions

Back at my Unix command prompt, I try typing the name of the script to run it:

[jbc@andros jbc]$ hello.plx
hello.plx: Permission denied.

Hmm. Welcome to the world of Unix file permissions. This is one of the trickier parts of making the transition to Unix. If you’re an impatient person, just type the following command:

[jbc@andros jbc]$ chmod 700 hello.plx

and go on to the next topic. If you want to know what’s really going on, though, (which I strongly recommend, since it will save you much trouble later), keep reading.

In Unix, you can have three different types of permissions with respect to a particular file: read permission, write permission, and execute permission. Read permission lets you read the file (you need me to tell you that?), write permission lets you make changes to the file, and execute permission, in the case of a script or program, lets you actually run it.

So, that’s the first half of the permissions story. The second half is this: the three types of permission can be set to “on” or “off” for each of three different sets of people: the file’s owner (you, in the case of the scripts you’ve created), members of the file’s group (which we’re going to ignore for now), and everyone else in the world (which we’re also going to ignore for now).

Check the permissions on a file by entering ls -l filename, with filename being replaced by the name of the file. To look at the permissions on my hello.plx script:

[jbc@andros jbc]$ ls -l hello.plx

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required