背景
在linux中,chmod和chown都可以用来设置权限,但是两者的侧重点是不同的。chmod用来设置文件/文件夹的读写权限,比如用777权限更改某些文件的读写权限;而chown是用来设置文件/文件的用户组,比如授权某些用户,进行用户权限管理。
chmod使用指令
使用方式:chmod [-cfvR] [–help] [–version] mode file
说明:Linux/Unix的档案存取权限分为三级:档案拥有者、群组、其他。利用chmod可以控制档案如何被他人存取
mode:权限设定字串
通过chmod --h
查看
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.
With --reference, change the mode of each FILE to that of RFILE.
-c, --changes like verbose but report only when a change is made
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--no-preserve-root do not treat '/' specially (the default)
--preserve-root fail to operate recursively on '/'
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display this help and exit
--version output version information and exit
Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.