In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to modify file permissions and groups in Linux. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
In Linux, everything is a file (the directory is also a file), and each file has readable (read), writable (write), and execute (execute) permissions to the user. The execution of the directory indicates whether you have permission to enter the directory, and the executable of the file indicates whether the file can be run. Files are subordinate to a user and a user group, and each file has specific permissions for the owner, group, and other user groups of the file.
As shown in the figure above, except for the first character that represents the file type, the following characters are all in groups of three, which is a combination of the three parameters of "rwx". [r] stands for readable (read), [w] for writable (write), and [x] for executable (execute). At the same time, they also correspond to a number, [r] corresponds to 4, [w] corresponds to 2, and [x] corresponds to 1. These numbers can be used when modifying file permissions. If they do not have a permission in [rwx], they will be replaced with a minus sign [-].
The first group is the operation right of the file owner to the file, the second group is the operation right of the group to which the file belongs to the file, and the third group is the operation right of the users of other groups to the file. For example: if the permission data of a file is "rwxr-xr--", then the first three characters indicate that the owner of the file can read, write and perform three operations on the file, the middle three characters indicate that the group to which the file belongs can read and execute the file, and the last three characters indicate that users in other groups can only read the file.
Change file permissions: chmod
Use the command chmod to change the permissions of a file. There are 9 read and write operations for three types of users (themselves, groups, and others) corresponding to the permissions of a file. The permissions of each group are added together to get a number. For example, the number corresponding to [rwxrwx---] is:
Owner = rwx = 4 "2" 1 = 7group = rwx = 4 "2" 1 = 7 others =-= 0 "0" 0
As long as the user has write permission to the file, the user can update the operation permissions of other users on the file, command:
Chmod [- R] xyz file or directory
Xyz: the sum corresponding to the sum of three types of user permission values.
-R: make continuous recursive changes, that is, all files in the subdirectory will change.
For example:
[root@www ~] # ls-al .bashrc-rw-r--r-- 1 root root 395 Jul 4 11:45. Bashrc [root@www ~] # chmod 777 .bashrc # changed to all users can read and write to execute [root@www ~] # ls-al. Bashrc-rwxrwxrwx 1 root root 395 Jul 4 11:45 .bashrc
Chmod can not only change file permissions digitally, but also use symbols to change file permissions. U, g, o, an are abbreviations for user, group, others, all (for all users), r, w, x are abbreviations for read, write, and execute, respectively, so chmod can receive these abbreviated characters to change file permissions.
U g + (increase) rchmod o-(remove) w file or directory a = (assignment) x
For example:
# give yourself read and write execution permissions, read and execute operations to user groups and others, chmod upright RWX journal goblrx .bashrc # append write permissions to all users chmod aquiw .bashrc # remove write permissions to all users chmod Amurw .bashrc
Change the group chgrp
Change the group of files using the chgrp command, which is the abbreviation of change group, command format:
Chgrp [- R] groupname dirname/filename
-R recursively changes directories and subdirectory files. Groupname must be a group in the / etc/group file in the system.
# update the group of all files in the current directory and subdirectory to mysql group chgrp-R mysql.
Change the file owner chown
The person who changes the ownership of the file uses the chown command, which is the abbreviation of change owner, command format:
Chown [- R] owner dirname/filename
Or
Chown [- R] owner:group dirname/filename
The chown command can change not only the owner of the file, but also the group of files, simply by adding the name of group to the owner.
# change install.log to mysql user chown mysql install.log# change install.log to root user and root group chown root:root install.log what is Linux system Linux is a free-to-use and free transmission UNIX-like operating system, is a POSIX-based multi-user, multi-tasking, multi-threading and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
The above is the editor for you to share how to modify file permissions and groups in Linux, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.