Can you completely explain the nine permissions bits on UNIX or Linux files?
Each file in UNIX or Linux has the nine permission bits as follows:
ls -l /etc/hosts
Sample outputs:
-rw-r--r-- 1 root root 401 2009-12-20 12:08 /etc/hostsThe Entry Type
There are total 10 bits -rw-r--r--:
The file mode printed under the -l option consists of the entry type (1st bit) and the permissions (9 bits). The entry type character describes the type of file, as follows:
- - Regular file.
- b Block special file (stored in /dev).
- c Character special file (stored in /dev).
- d Directory.
- l Symbolic link.
- p FIFO.
- s Socket.
- w Whiteout.
Examples
Show directory type with the ls command:
ls -ld /etc
Sample outputs:
drwxr-xr-x 170 root root 12288 2010-02-24 11:39 /etcShow block device type (hard disk) with the ls command:
ls -l /dev/sda
Sample outputs:
brw-rw---- 1 root disk 8, 0 2010-02-24 11:32 /dev/sdaThe Permissions Bits
The next three fields are three characters each for
- File owner permissions
- File group permissions
- Other permissions (not part of both owner or group)
Each field has three character positions as follows:
- r : The file is readable; if - it is not readable.
- w : the file is writable; if -, it is not writable.
- S : If in the owner permissions, the file is not executable and set-user-ID mode is set. If in the group permissions, the file is not executable and set-group-ID mode is set.
- s : If in the owner permissions, the file is executable and set-user-ID mode is set. If in the group permissions, the file is executable and set group-ID mode is set.
- x : The file is executable or the directory is searchable.
- - : The file is neither readable, writable, executable, nor set-user-ID nor set-group-ID mode, nor sticky.
These next two apply only to the third character in the other permissions.
- T The sticky bit is set (mode 1000), but not execute or search permission.
- t The sticky bit is set (mode 1000), and is searchable or executable.
References:
- ls command man page
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 1 comment… read it below or add one }
It understands very well.
Could you please elaborate about small t and big T and same for small s and big S?