Linux文件权限和umask

1、DeterminingFile Access Privileges查看文件权限:

Linux文件权限和umask_第1张图片

修改权限

chmod [options] symbolic-mode file-list (象征性模式)


Eg: chmod a+x 1.sh

 

chmod [options] octal-mode file-list (八进制模式)


Eg :chmod 740 1.sh (owner read,write,execut ; group only read ; others no permission)

 

2、掌握umask命令的用法和原理。

umask: 指定在建立文件时预设的权限掩码。般来说,umask命令是在/etc/profile文件中设置的,每个用户在登录时都会引用这个文件,所以如果希望改变所有用户的umask,可以在该文件中加入相应的条目。如果希望永久性地设置自己的umask值,那么就把它放在自己$HOME目录下的.profile或.bash_profile文件中。

Theaccess permission value on executable file or directory is computed by(可执行文件或目录的访问权限值计算)

file access permission = 777 –mask

 

Theaccess permission value on other file is computed by:(其他文件访问权限值计算)

file access permission = 666 –mask

 

CurrentValue of the mask(当前访问值)

$ umask

777

 

set mask(设置访问值)

$ umask xxx 其中x x x为000 - 777。

下面是一个例子,假设这次umask值为022:
1) 文件的最大权限rwx rwx rwx (777)
2 ) u m a s k值为022 - - - -w- -w-
3) 目录权限rwx r-x r-x (755) 这就是目录创建缺省权限
4) 文件权限rw- r-- r-- (644) 这就是文件创建缺省权限

你可能感兴趣的:(linux)