Monday, October 26, 2009

Linux File Permissions Quick Examples (chmod howto)

$ ls -l
___t all files and their permissions.

[properties] [links]__[owner] _[group]__ [size]_ [date modified] __[filename]
drwxr-xr-x____2____ scott____staff____68____Sep 7 07:00__ __temp
-rw-r--rwx____ 1___ _scott ___ staff __ _ 23 ____Sep 4 16:59 ____ temp.txt
-rw-rwxr--____ 1 ____scott _ __staff ____23 ____Sep 4 17:03 ____temp2.txt
-rwxr--r--___ _ 1 _ __scott _ __staff ____23____ Sep 4 17:05 ____ test3.txt

properties:__ [d]______[rwx]___[rwx]__[rwx]
___________[filetype][owner][group][other]
r: read
w: write
x: execute (add if you want to execute a script file, for instance)

$ chmod gu+wx file.txt
___add write and execute privilege to the group and owner
$ chmod o-rw file.txt
___take away read and write privileges for others
$ chmod g=rw,o=r temp.txt
___set group to read & write, others to just read
$ chmod 755 temp.txt
___number codes: (r = 4,w = 2,x = 1).
___7 => rwx for owner (4+2+1)
___5 => r-x for group (4+1)
___5 => r-x for others
$ chmod -R a=rw mydir
___change all (user, group and others) to rw, recursively including all files in mydir

No comments: