Modify file permissions under Linux, ownership

Linux and Unix is a multiuser operating system, so the ownership rights and implementation of the file becomes necessary; each file is mainly dealing with three sets of permissions are the user (user), a user group (group), other users (other )

 

User (u) is the owner of the file, usually operating authority for all files

User Group (g) is a collection of a plurality of users may have access to the file section, equivalent to share files between users

Other (o) refers to a file other than the owner and user group members of any person

 

Use ls -l to display the many types of information files in the current directory, permissions, owners, and groups including;

The first column of the meanings :-( filetype) --- (user) --- (group) --- (other), each binary number corresponds to a permission of three, the first bit represents that it has read (r) is permission, the second bit indicates write permission (w), the third digit is authorized to perform (x) (if the executable file); when the corresponding bit has the appropriate permission is set to 1 (0 otherwise ), represents the current object with this permission

 

1: The user can read and write execution: -rwx ------, generally speaking, for the data file, the user's permissions rw-, executable files and scripts permission to rwx; For users, also has a called the special permissions setuid, the position of authority he is to appear x, setuid (S) permission allows an executable file with its own authorized person to perform, even if the executable file is run by other users, if they are given permission to the sequence is: -rwS ------

2: User Group perform read and write: ---- --- rwx, the user group for which a special permissions referred setgid (S) It allows us to use any of a valid user group to run the file , provided that the group requires the same set of permissions required to file ,, ---- rwS ---

3: Other User: ------- rwx

 

A: Use the chmod (change mode) to set file permissions:

--x=1;-w-=2;r--=4; r-x=5; rw-=6;rwx=7;

If you set permissions: rwxrw-r--

1:chomd 764 filepath

 

2:chmod u=rwx, g=rw, o=r filepath; chmod ugo=r,g=w filepath

 

Permission to add or remove permissions for files:

1: Add executable permissions to users and groups (+):

chmod u+x, g+x filepath

 

2: Delete (-) executable permissions user group:

chmod g-x fielpath

chmod g = ur filepath intended to set permissions for the user group to the user the same privileges, but deletion permission r

 

3: for all (a) category of permissions (ie user, group, others) add / remove executable permissions

chmod a+x filepath

 

Two: Change Ownership (change owner)

1: Use the chown change file ownership, the average user does not have permission to change the owner of the file to others, nor permission to be the owner of your own files is set to change others, only the system administrator (root) have permission to do so : chown user: group filepath (user, group of new users and groups)

 

2: to catalog the sticky bit (sticky bit)

Sticky bit: directory has special authority called the sticky bit, if a directory has the sticky bit, only the user who created the directory can delete files in the directory. It appears in the other user group execute permission position. When the executable permission ------- rwt, when no execute permissions set ------- rwT, chmod a + t dirname

 

3: recursively set ownership and file permissions, use the option -R;

chmod 764 . -R

chown user:group . -R

 

Complement: file types: - Normal d directory file (directory); c character device (char); b block device (block); l symbolic link (link) s socket (socket) p conduit (pipe)

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/hongbo-tao/p/11812139.html