I know that there is no difference in 0022 and 022 referring to link. I have file 1.c, with permissions 0066. But when I change the mode of file 1.c to 1066, and then when I check the permissions of file with ls -l, it effects the permissions. Each time different permission bits are changing with change in this first digit. What actually it signifies?

[vm4 ~]# ls -l 1.c
----rw-rw- 1 root root 10 Dec 23 22:48 1.c
[vm4 ~]# chmod 1066 1.c
[vm4 ~]# ls -l 1.c
----rw-rwT 1 root root 10 Dec 23 22:48 1.c
[vm4 ~]# chmod 2066 1.c
[vm4 ~]# ls -l 1.c
----rwSrw- 1 root root 10 Dec 23 22:48 1.c
[vm4 ~]# chmod 5066 1.c
[vm4 ~]# ls -l 1.c
---Srw-rwT 1 root root 10 Dec 23 22:48 1.c
  • 3
    Is this a question about umask or about chmod, or about what 1066 means in relation to chmod? And please, don't post images of text. – Kusalananda Feb 13 '17 at 11:25
  • Are you confused by the output of man chmod? – user13757 Feb 13 '17 at 11:31
  • It is about what 1066 means in accordance with chmod. Yeah and I will take care of not including images. newbie...Sorry. – mahesh bhosale Feb 13 '17 at 11:34
  • No. I just want to know, how many digits are there for permission of file. Some times we give it 3 digits, but with umask, it gives 4 digits. What the first digit signifies? @Dr Eval. – mahesh bhosale Feb 13 '17 at 11:42

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 -.

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.

- 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


The extra bits are the set-user-ID bit, set-group-ID bit and sticky bit. See man 2 chmod for more information. The S for the set-user-ID bit is shown with a capital S because the corresponding x bit is not set.

Not the answer you're looking for? Browse other questions tagged or ask your own question.