Linux file default permissions

A view of the default permissions command
umask
View default permissions
0022
The first 0: file special permissions
022: File default permissions
 
Default permissions for two files
1. The file cannot create an unexecuted file by default, and the execution permission must be manually granted
2. Therefore, the default file permissions are up to 666
3. The default permissions need to be converted into letters and then subtracted
4. The default permission after the file is created is 666 minus the umask value
 
Three-file default permission calculation method


 
 
Default permissions for four directories
1. The default permission of the directory is up to 777
2. The default permissions need to be converted into letters and then subtracted
3. The default permission after creating the file is 777 minus umask
E.g:
The default maximum permission of the directory is 777, and the umask value is 022
-rwxrwxrwx minus -----w--w- equals -rwxr-xr-x
 
5. Modify the value of umask
Temporary modification
umask 0002
permanent modification
vi /etc/profile
 
Six actual combat
[root@localhost /]# su - user1
Last login: Sat Aug 5 09:11:39 CST 2017 from 192.168.0.101 on pts/1
[user1@localhost ~]$ ls
123
[user1@localhost ~]$ umask
0002
[user1@localhost ~]$ touch abc
[user1@localhost ~]$ ll
total 0
drwxr-xr-x. 2 root root 16 Aug 5 09:48 123

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326187540&siteId=291194637