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 > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How do I modify file permissions in Linux? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Linux and Unix are multi-user operating systems, so it is necessary to realize the permissions and ownership of files. Each file mainly deals with three groups of permissions, namely, user, group, and other users.
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). When you have the corresponding permission, the corresponding bit is set to 1 (otherwise it is 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 use any valid user group to run the file, 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:
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 fielpath
Chmod 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 execute permission-rwt, when not setting the execute permission-rwT,chmod adept dirname
3: set ownership and file permissions recursively, using the option-R
Chmod 764. -R
Chown user:group. -R
Supplement: 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)
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
After reading the above, do you know how to modify file permissions in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.