File permission settings in Linux



December 27, Ding You year Name: Wang Guang

1. The file grants access to the following three types of users:

File owner (owner/u) User in the same group (g) Other users (0)

2. View the file permissions command:

ls -l

3. The meaning of the authority represented by the characters:

– General permissions:
r: file (read); directory: (browse)
w: file (write); directory: (with delete, move directory permissions)
x: file (execute); directory: (enter)
-: no With this permission
– special permission:
SUID: Executable With this permission, all system resources that can be used by the owner of the file can be freely accessed
SGID: The effect is the same as SUID, except that the owner is replaced by the group
Sticky:/tmp and /var/tmp directory for all users to temporarily access files, each user has full access to this directory

4. Three permission setting methods:

– Text setting method:
chmod [u/g/o/a] [+/-/=] [r/w/x/s/t] [file/directory name]
[a: means all users, system default value ;u+s: set file SUID; g+s: set file GID; o+t: set file Sticky]
– digital setting method:
- common permission example:
change file to all permissions: chmod [777] [file name] [r:4; w:2; x:1; -:0; ]
- Example of special permission:
change file with SUID permission: chmod [4000] [file name]
Change file with SUID, SGID, Sticky permission: chmod [7000 ] [filename] [SUID:4; SGID:2; Sticky:1]

– Change the ownership law of a file/directory:
- Change file owner: chown [username] [filename]
- Change file user group: chown [ :/.group name] [file name] / chgrp [group name] [file name]
- Change the owner and user group: chown [user name. group name] [file name]
-R: Modify the subordinate files in the directory together




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939163&siteId=291194637