Securing Systems with Users, Groups, and Permissions
156
[root@rhel-instance
]# ls -l file.txt-rw-r-----. 1 root root 0 Mar 11 22:30 file.txt[root@rhel-instance
]# chmod 0600 file.txt[root@rhel-instance
]# ls -l file.txt-rw-------. 1 root root 0 Mar 11 22:30 file.txtAs we said before, the default configuration of permissions is set by umask. We can very easily seethe value:
[root@rhel-instance
]# umask0022[root@rhel-instance
]# umask –Su=rwx,g=rx,o=rxAll the newly created files have execute permissions removed (With
this umask, 0022, the one provided by default in RHEL, we will have write permissions for group and others also removed (Even when it is not
recommended to change umask, we could give it a try to learn how it works. Let’s start by using the most permissive umask, 0000, to see how all read and write permissions are assigned to newly created files:
[root@rhel-instance
]# umask 0000[root@rhel-instance
]# touch file2.txt[root@rhel-instance
]# ls -l file2.txt-rw-rw-rw-. 1 root root 0 Mar 11 22:33 file2.txtNow, let’s use the more restrictive umask for group and others permissions:
[root@rhel-instance
]# umask 0066[root@rhel-instance
]# touch file3.txt[root@rhel-instance
]# ls -l file3.txt-rw-------. 1 root root 0 Mar 11 22:33 file3.txtIf
we try a higher number, it won’t work and will return an error:
[root@rhel-instance
]# umask 0088-bash: umask: 0088: octal number out of range Checking, reviewing,
and modifying file permissions157
You can see that the effect of 0066 and 0077 is the same:
Share with your friends: