$ chmod 640 foo.txt
User | Group | Other | |
---|---|---|---|
Read | +400 | +40 | +4 |
Write | +200 | +20 | +2 |
Execute | +100 | +10 | +1 |
Show permissions on linux:
$ stat foo.txt
$ stat -c '%a %n' foo.txt
Show permissions on BSD:
$ stat -x foo.txt
$ stat -f '%OLp' foo.txt
+4000
executes with the privileges of the file’s owner.+2000
executes with the privileges of the file’s group.+1000
for directories, allows the contents to only be moved or deleted by the directory or file owner (or root). Typically set on /tmp to keep users from messing with each other’s files.(The sticky bit was originally introduced to keep the text segment of an executable remain resident in memory, to make subsequent execution of that program start faster. This behavior is no longer widely supported.)