« March 15, 2006 | Main | March 30, 2006 »

March 19, 2006

Reference: Chmod and permissions in *nix

This is more or less for my reference, just so that I don't have to look it up all of the time. Behold, a chmod reference for Linux and Unix:

CHMOD
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.

-c, --changes like verbose but report only when a change is made
--no-preserve-root do not treat `/' specially (the default)
--preserve-root fail to operate recursively on `/'
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display this help and exit
--version output version information and exit

Each MODE is one or more of the letters ugoa, one of the symbols +-= and
one or more of the letters rwxXstugo.

Users Breakdown:
d = directory
u = user
g = group
o = others

d|uuu|ggg|ooo

Permissions Breakdown:
d = directory
r = read
w = write
x = execute

d|rwx|rwx|rwx

Mode Key:
1 = --x
2 = -w-
3 = -wx
4 = r--
5 = r-x
6 = rw-
7 = rwx

Examples:
1. Set a file to be executable by everyone:
$ chmod 555 filename
Sets: -r-xr-xr-x

2. Set a file to be read/write-able by the owner and readable by everyone else:
$ chmod 644 filename
Sets: -rw-r--r--

3. Open all permissions on a file:
$ chmod 777 filename (Note: Very dangerous to do...)
Sets: -rwxrxwrxw

One last note:
If you see permissions with a "d" in front of them, this represents that the file is in fact a directory, as seen in the example below:

Directory: /usr/bin
Permission: drwxr-xr-x

~out...

Posted by ed at 03:22 PM | Comments (0)