rwx permissions. However, in some scenarios, the single rwx permission may not be flexible enough, and the special permission s is also used. For example, the /etc/shadow file stores the encrypted passwords of all users in the system, so access to this file cannot be directly granted to all users. However, ordinary users do need to change their passwords, so the SUID permission can be introduced to allow users to change their own passwords./etc/shadow file is not directly granted. Instead, the operation is performed through /usr/bin/passwd, so the SetUID (SUID) permission must be granted first. You can use ls to check:ls -l /usr/bin/passwd
-rwsr-xr-x. 1 root root 31984 Mar 31 23:51 /usr/bin/passwd
rws instead of rwx. When s appears in the position of x, it is called SetUID Bits or SUID. Its characteristics are as follows:/usr/bin/passwd command, they temporarily gain root permissions to run the command and complete the password modification.chmod u+s filename # Symbolic notation, where + indicates adding the permissionchmod 4755 filename # Numeric notation, corresponding to the number 4
chmod u-s filename # Symbolic notation, where - indicates removing the permissionchmod 755 filename # Numeric notation
ls -ld command. In the following example, the directory /shared/project has been assigned the SGID permission through chmod 2755:ls -ld /shared/project
drwxr-sr-x. 2 root root 4096 May 6 15:03 /shared/project
r-s, where s appears in the position of the user group execute permission x, indicating that the directory has been assigned the SGID permission.chmod g+s dirname # Symbolic notation, where + indicates adding the permissionchmod 2755 dirname # Numeric notation, corresponding to the number 2
chmod g-s dirname # Symbolic notation, where - indicates removing the permissionchmod 755 dirname # Numeric notation
/tmp directory:ls -ld /tmp/
drwxrwxrwt. 7 root root 140 May 6 15:03 /tmp/
t, indicating that the SBIT permission is set for this directory. At this point, when users create a file or directory under this directory, only themselves and root users have permission to delete it, preventing others from deleting it.chmod o+t dirname # Symbolic notation, where + indicates adding the permissionchmod 1755 dirname # Numeric notation, corresponding to the number 1
chmod o-t dirname # Symbolic notation, where - indicates removing the permissionchmod 755 dirname # Numeric notation
umask to view the default umask value of the current system:umask
0022
umask 0037 # Takes effect temporarily
/etc/bashrc to modify the existing umask line, or add a umask setting at the end of the file (effective for all users). For example, to change the umask value to 0037, add the following line at the end of /etc/bashrc:umask 0037
~/.bashrc file. After the modification is complete, log in again or run the following command to make the configuration take effect immediately:source /etc/bashrc
/etc/profile are only executed when a user logs in for the first time, while changes to /etc/bashrc are executed every time a user logs in and loads the shell.rwx permissions to owner/group/others for each file and directory. Building upon this, ACL adds a set of finer-grained access control rules to each file and directory, allowing you to configure different access permissions for different users and groups.sudo dnf install acl
getfacl command. For example, to view the ACL settings of file1:getfacl file1
# file: file1# owner: root# group: rootuser::rw-group::r--other::r--
setfacl command. For example, to grant the user opencloudos read, write, and execute permissions on file1:sudo setfacl -m u:opencloudos:rwx file1
file1 again:getfacl file1
# file: file1# owner: root# group: rootuser::rw-user:opencloudos:rwxgroup::r--mask::rwxother::r--
user:opencloudos:rwx line has been added, indicating that the user opencloudos has read, write, and execute permissions on file1. Meanwhile, ACL automatically generates a mask entry, which represents the maximum effective permissions for all users and groups in the ACL.devteam group:sudo setfacl -m g:devteam:rw file1
sudo setfacl -x u:opencloudos file1
sudo setfacl -b file1
sudo setfacl -d -m u:opencloudos:rx /shared/project
/shared/project directory, the user opencloudos will automatically obtain read and execute permissions.sudo setfacl -R -m u:opencloudos:rwx /shared/project
피드백