Yes, there is a difference between 0022 and 022. Not for umask, but yes for chmod.
The permissions are described by three letters per user, group,and others.
That is usually rwxrwxrwx
(or -
where needed) in a ls
output:
$ touch 1.c
$ ls 1.c
-rw-r--r-- 1 user user 0 Feb 13 09:01 1.c
Where each set bit is shown by a letter, and unset bits are shown with -
.
Therefore:
rwx means 111 which is binary for an octal value of 7.
rw- means 110 which is binary for an octal value of 6.
r-- means 100 which is binary for an octal number of 4.
But beside the basic rwx, there are some other letters which represent additional permissions to be set. Those permissions are also 3 bits, and are written like a four digit octal number and represented as this:
For files:
0644 ==> rw-r--r--
1644 ==> rw-r--r-T # sticky bit (ignored in linux)
0644 ==> rw-r--r--
2644 ==> rw-r-Sr-- # Group ID does not match.
0655 ==> rw-r-xr-x
2644 ==> rw-r-sr-x # Run with group ID: SGID
0644 ==> rw-r--r--
2644 ==> rwSr--r-- # User ID does not match.
0755 ==> rwxr-xr-x
2744 ==> rwsr-xr-x # Run with User ID: SUID
Full permissions (7):
$ chmod 7777 1.c; ls -l 1.c
-rwsrwsrwt 1 user user 0 Feb 13 09:01 1.c
For directories:
SGID means that new files inside this dir will inherit group owner.
SUID Mostly ignored in Linux and Unix. BSD varies.
Sticky Protect files inside from being modified by a different user.
Links:
- Sticky bit
In Linux: the Linux kernel ignores the sticky bit on files.
When the sticky bit is set on a directory, files in that directory may only be unlinked or renamed by root or the directory owner or the file owner.
- SetUID and SetGID
- Directories and the Set-User-ID and Set-Group-ID Bits
- System Administration Guide: Security Services
umask
or aboutchmod
, or about what1066
means in relation tochmod
? And please, don't post images of text. – Kusalananda Feb 13 '17 at 11:251066
means in accordance withchmod
. Yeah and I will take care of not including images. newbie...Sorry. – lsbmsb Feb 13 '17 at 11:34umask
, it gives 4 digits. What the first digit signifies? @Dr Eval. – lsbmsb Feb 13 '17 at 11:42