1. Create a file myfile.sh with touch command, then ls-l command to view the file
It contains three permission bits in each set of characters:
r read permission
w write / change permissions
X execute permission to the script or program
2. Use the command to change the permissions chomd file
The general format of the chmod command is:
chmod [WHO] operator [permission] filename
W HO meanings are:
U file owner permissions.
g group with user privileges.
o other user rights.
All a user (file owner, the same group and other users).
operator meanings:
+ increase in permissions.
- Cancel permission.
= Set permissions.
permission meanings:
r read permission.
w write permission.
x execute permission.
s file owner and group set - ID.
* t sticky bit.
l to file locking, so that other users can not access.
u, g, o for the file owner, and the other group of users with a user's operation.
3. The document is a set of permissions to add executable permissions: chmod u + x myfile.sh
4. add to all users read, write, execute permissions: chmod a + rwx myfile.sh
5. recover user group read and write permission: chmod g-rw myfile.sh
Absolute Mode
The general form of hmod absolute mode command is:
chmod [mode] File
which mode is an octal number.
In absolute mode, the rights section has a different meaning. Each authority with a bit octal number to represent
有一个计算八进制权限表示的更好办法,如下图所示
1.我们经常用的给文件授予777的权限,即就是给每一个用户授予读、写、可执行的权限
先收回文件所有用户的读、写、执行权限:chmod a-rwx myflile.sh
再执行 chmod 777 myfile.sh ,给所有用户收取读、写、执行权限
还可以通过使用- R选项连同子目录下的文件一起设置:
chmod -R 777 /test/* 这样就可以一次将/test目录下的所有文件连同各个子目录下的文件的权限,全部设置为文件属主和同组用户可读和写,其他用户只读。使用 - R选项一定要谨慎,只有在
需要改变目录树下全部文件权限时才可以使用。