centos-adjust file and directory permissions

View file permissions ls -l text.txt ll file/ll -d directory
View directory permissions ls -ld testdir

1. Interpretation of permissions

-rw-r–r--. 1 root (owner) root (owner group) text.txt
drwxr-xr-x. 2 root root testdir directory

 -    rw-    r--   r---  .
d  rwx  r-x  r-x     .

Field 1: File type-common file d directory l symbolic link b block device
Field 2: file owner's permission to the file
rwx
file: read read file write write file executable permission
directory: you can view the contents of the directory and add or delete files You can enter the directory.
Field 3: Permissions of the group to which the file belongs.
Field 4: Permissions of other users (neither the owner of the file nor a user in the group to which the file belongs)

2.chmod method

chmod object arithmetic operator permission file
Object: u (owner) g (belonging to the group) o (other user permissions) a (all)
arithmetic operator:-+ =
permission: rwx (4 2 1)

chmod 777  text1.txt

Change the file owner to tom, and change the owner group to tom group
chown user file
chgrp group file

The sticky bit sgid suid permission The
sticky bit is
assigned to the directory. Only the creator can delete the files created in the directory. chmod o+t The directory is assigned the sticky bit

sgid has the authority for the creation of a directory. The group of files created in the directory inherits the group of the parent directory
chmod g+s test

suid is established for the executable file
Who allows the file, has the permissions of the group the file belongs to
chmod u+s test.txt

The process of adding a new user:
1./etc/group
2./etc/passwd
3./etc/shadow
4./home/xxxx

chattr +i file add immutable attributes (locked)
-i unlock
the highest authority of the directory 777
file 666

/etc/profile
/etc/bashrc

Guess you like

Origin blog.csdn.net/tansty_zh/article/details/108016653