Friday, October 31, 2008

File permissions, chmod

Things to test with chmod.

drwxr-xr-x A typical directory
uuugggooo User Group Other
421421421 Bit values

* 1 --x Execute
* 2 -w- Write
3 -wx Write Execute
* 4 r-- Read
5 r-x Read Execute
6 rw- Read Write
7 rwx Read Write Execute

Use '-' or '+' to change permissions:
chmod u+x adds 1 to User if not already 1,3,5 or 7
chmod o-w subtracts 2 from Other if not already 1,4 or 5
chmod ugo+rwx adds 1,2 and 4 to all if not already 7


Use 'stat' to list more stuff about a file, like access rights in octal:

$ stat -c%a unixtime.txt
644
$ stat -c%A\ %h\ %U\ %G\ %s\ %z\ %n unixtime.txt
-rw-r--r-- 1 ker ker 300 2008-10-31 00:23:14.000000000 +0100 unixtime.txt
$ ls -lF --full-time unixtime.txt
-rw-r--r-- 1 ker ker 300 2008-10-31 00:23:14.000000000 +0100 unixtime.txt

See, looks like the output of 'ls -lF --full-time'

0 comments: