chmod

0表示没有权限,1表示可执行权限,2表示可写权限,4表示可读权限
数字与字符对应关系如下:
r=4,w=2,x=1
若要rwx属性则4+2+1=7
若要rw-属性则4+2=6;
若要r-x属性则4+1=5
命令:
chmod 751 file 
说明:给file的属主分配读、写、执行(7)的权限,给file的所在组分配读、执行(5)的权限,给其他用户分配执行(1)的权限
常用 chmod 755 file

r读 w写 x执行   a所有用户(默认) +增加权限 -删除权限

给所有用户添加可执行的权限 chmod a+x filename 

chmod --help
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
  or:  chmod [OPTION]... OCTAL-MODE FILE...
  or:  chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.

  -c, --changes           like verbose but report only when a change is made
      --no-preserve-root  do not treat `/' specially (the default)
      --preserve-root     fail to operate recursively on `/'
  -f, --silent, --quiet   suppress most error messages
  -v, --verbose           output a diagnostic for every file processed
      --reference=RFILE   use RFILE's mode instead of MODE values
  -R, --recursive         change files and directories recursively   chmod -Rf /usr/bin/fuck
      --help     display this help and exit
      --version  output version information and exit

Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.

Report bugs to <bug-coreutils@gnu.org>.

chmod -R 755  dirname   给目录dirname及其子目录所有文件授权755

chmod +x * 给当前目录下所有文件授可执行权限

原文地址:https://www.cnblogs.com/rusking/p/3624450.html