In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The editor today takes you to understand how Linux modifies file permissions. The knowledge points in the article are introduced in great detail. Friends who feel helpful can browse the content of the article together with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Follow the editor to learn more about "how to modify file permissions in Linux".
Everything in the Linux system is a file, and each file has specific permissions. Only the user who uses the permissions can make corresponding operations on the file.
Specific methods for Linux to modify file permissions
Each file mainly deals with three groups of permissions, namely users (user), user groups (group), and other users (other).
The user (u) is the owner of the file and usually has permission to operate all the files
A user group (g) is a collection of multiple users and may have partial access to files, which is equivalent to sharing files among users.
Other (o) means anyone other than the owner of the file and members of the user group
Using ls-l, you can display information about file types, permissions, owners and groups in the current directory.
The first column means-(filetype)-(user)-(group)-(other). Each group of permissions corresponds to a three-digit binary number. The first bit indicates read (r) permission, the second bit indicates write (w) permission, and the third bit indicates execution (x) permission (if the file is executable). If the file is executable, the corresponding bit is set to 1 (otherwise 0), indicating that the current object has this permission.
1: user read / write execution:-rwx--, generally speaking, for data files, the user's permission for rw-, executable files and scripts is rwx For the user, there is also a special permission called setuid, where he can appear the permission x, and the setuid (S) permission allows the executable to be executed with the permissions of its owner, even if the executable is run by another user, the sequence is:-rwS-- if the permission is granted.
2: user group read and write executable:-- rwx-, for a user group, it has a special permission called setgid (S), which allows us to run the file using any valid user group, provided that the group needs to have the same group permissions as the file,-- rwS-.
3: other users:-rwx
One: use chmod (change mode) to set file permissions:
-x words 1, words 2, words 4; words 5, words 5, words 6, words 7
If you set permissions: rwxrw-r-
1:chomd 764 filepath
2:chmod u=rwx, g=rw, otakr filepath; chmod ugo=r,g=w filepath
Add or delete permissions to the file:
1: add executable permissions to users and user groups (+):
Chmod upright x, gallex filepath
2: delete (-) executable permissions for the user group:
Chmod GMurx fielpathchmod g=u-r filepath means to set the permissions of the user group to the same permissions as the user, but remove the r permission
3: add / remove executable permissions to all permission categories (i.e. users, user groups, other users) of (a)
Chmod axix filepath
II: change of ownership (change owner)
1: use chown to change the ownership of a file. Ordinary users do not have the permission to change the owner of other people's files, nor do they have the right to change the owner of their own file to someone else. Only the system administrator (root) has such permission: chown user:group filepath (user, group is the new user and user group)
2: set stickiness bit (sticky bit) to the directory
Sticky bit: the directory has a special permission called sticky bit. If the sticky bit is set in a directory, only the user who created the directory can delete files in the directory. It appears in the execution permission location in other user groups. When setting the execution permission-rwt, when the execution permission is not set-rwT,chmod adept dirname
3: set ownership and file permissions recursively, using the option-R
Chmod 764. -R chown user:group. -R complement: file type:-normal file d directory (directory); c character device (char); b block device (block); l symbolic link (link) s socket (socket) p pipe (pipe)
Thank you for reading, the above is the whole content of "how to modify file permissions in Linux". Friends who learn to learn to hurry up to operate it. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.