In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the basic authority and attribution of CentOS system management". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the basic authority and ownership of CentOS system management"?
Basic authority and attribution relationship
Second, the permissions of files and directories
Third, the setting of permissions: chmod,umask,mkdir-m
Fourth, the owner and group of files and directories: chown,chgrp
Extend:
Linux system Administration _ additional Control permissions:
Linux system Administration _ users and user groups:
Linux system Management _ ACL access Control:
One: basic authority and attribution relationship
1. Access permissions:
-read: allow viewing content-read
-write: allow content to be modified-write
-executable: allow running and switching-excute
Note: executable permissions for directories, the corresponding location has x permissions, which means whether you can enter the directory.
For files, there is x permission, which means that the file is executable, such as the x permission in the owner permission of the program (command).
2, attribution relationship:
-owner: the user who owns this file or directory-user
-Group: the group that owns this file or directory-group
-other users: users other than owners and groups-other
Final permissions: access rights and ownership relationships jointly determine the final permissions
Two: permissions for files and directories
[root@localhost/] # ll-d / etc/passwd / boot/
Drwxr-xr-x4rootroot1024 2013-07-10 / boot/ directory
-rw-r--r--1rootroot 1681 02-17 10:23 / etc/passwd / / document
1 2 3 4 5 6 7 8
The first paragraph: d represents the target as the directory,-represents the target bit file
The second paragraph: rwxr-xr-x: permission bits for files and directories
Note: a total of nine digits, the first three are the permissions of user (owner), the middle three are the permissions of group (the group to which they belong), and the last three are the permissions of other (other users).
Where r is marked by the number 4pm w is 2pm x is 1
The third paragraph: for files, the number of hard links
For directories, how many directories are there under that directory, including hidden directories. " And "..".
Paragraph 4: the owner, that is, the owner of the file or directory
The fifth paragraph: belong to the group
Paragraph 6: the size of the file, by default, in bit (bytes)
Paragraph 7: for the time of final revision
Paragraph 8: name of the file or directory
Three: set basic permissions: chmod, umask and mkdir-m
1Magnechmod command
-format: chmod [ugoa] [+-=] [rwx] file / directory
Chmod [nnn] files / directories (n represents the digital form of permissions)
Common option:-R: recursively change permissions
-- reference=: uses specified files or directories as templates (this is not important)
Example:
1. Modify the relevant attributes of Desktop and set them with character permissions and numeric permissions, respectively.
[root@localhost] # ll-d Desktop/
Drwxr-xr-x 3 rootroot 4096 02-16 03:40 Desktop/
[root@localhost] # chmod gourmet Omury RX Desktop/
[root@localhost] # ll-d Desktop/
Drwxrwx--- 3 rootroot 4096 02-16 03:40 Desktop/
[root@localhost ~] # chmod 755 Desktop/
[root@localhost] # ll-d Desktop/
Drwxr-xr-x 3 rootroot 4096 02-16 03:40 Desktop/
2, create an executable file and give the owner x permission
[root@localhost ~] # echo "echo Hello World" > test.sh
[root@localhost ~] # ll-lh test.sh
-rw-r--r-- 1 rootroot 17 02-18 21:12 test.sh
[root@localhost ~] # chmod + x test.sh / / + x defaults to the owner to add this permission
[root@localhost ~] # ll-lh test.sh
-rwxr-xr-x 1 rootroot 17 02-18 21:12 test.sh
[root@localhost ~] #. / test.sh
Hello World
[root@localhost ~] #
2sparumask command: default permission to create a new file or directory
-General files do not give x execution permission by default
-everything else depends on the umask setting
-umask value can be set (for temporary, umask 0027 umask value is set to 0027, which can be viewed using umask)
Note 1: since files are not given x permission by default, the maximum permission to create a new file is 666 and the maximum permission to create a directory is 777.
Note 2: the default value of umask is 022 (--- wmurw-w -), that is to say:
The default permissions when creating a new file are:
The difference between rw-rw-rw-and---w-- w-is rw-r-r -.
The default permissions when creating a new directory are:
Is the difference between rwx rwx rwx and---w-- w -, that is, rwx r-x r-x; that is, 755
Example:
[root@localhost ~] # umask
0022
[root@localhost ~] # mkdir mulu1
[root@localhost ~] # touch file1.txt
[root@localhost] # ll-d mulu1/ file1.txt
-rw-r--r--1 root root 0 02-18 21:22 file1.txt / / default file permission is 644
Drwxr-xr-x2 root root 4096 02-18 21:21 mulu1/ default directory permissions are 755
[root@localhost ~] # umask 0027 / / set the umask value to 0027
[root@localhost ~] # umask
0027 / / the umask value is 0027 after modification
[root@localhost ~] # mkdir mulu2 / / create the directory again after modifying the umask value
[root@localhost ~] # touch file2.txt / / modify the umask value and create the file again
[root@localhost] # ll-d mulu2/ file2.txt
-rw-r-1 root root 0 02-18 21:28 file2.txt
Drwxr-x---2 root root 4096 02-18 21:28 mulu2/
[root@localhost ~] #
You can see that when the umask value is set to 0027, the other user will no longer have any permissions on the permissions of the created directories and files.
3mkdir-m
Mkdir is to create a directory. The-m parameter can directly specify the permissions of the directory to be created.
Mkdir
Fourth, the owner and group of files and directories: chown,chgrp
1Query Chown: sets the attribution of a file or directory
-format: chown belongs to master file or directory / / modify the owner of the file or directory
Chown: a group that belongs to a group file or directory / / modifies a file or directory
Chown owner: the owner and group of the group file or directory / / modify the file or directory
-R option: recursively modify permissions
-- reference option: use the specified directory or file as the template (for understanding)
Example:
First modify the permissions of file1.txt
Then use file1.txt as a template to modify the permission owner and user group of the file2.txt file.
[root@localhost ~] # touch file1.txt
[root@localhost ~] # touch file2.txt
[root@localhost ~] # ll file*
-rw-r--r-- 1 rootroot 0 02-18 21:43 file1.txt
-rw-r--r-- 1 rootroot 0 02-18 21:43 file2.txt
[root@localhost ~] # useradd user1
[root@localhost ~] # chown user1:user1 file1.txt / / modify the owner of file1.txt to user1
/ / Group is user1
[root@localhost ~] # ll file*
-rw-r--r-- 1 user1user1 0 02-18 21:43 file1.txt
-rw-r--r-- 1root root 0 02-18 21:43 file2.txt
[root@localhost ~] # chown-- reference file1.txt file2.txt / / file2.txt will copy the properties of file1.txt
[root@localhost ~] # ll file*
-rw-r--r--1 user1 user1 0 02-18 21:43 file1.txt
-rw-r--r--1 user1 user1 0 02-18 21:43 file2.txt / / owner and group are and
/ / file1.txt is the same
2Magnechgrp: sets the group to which the file or directory belongs
Chgrp group file or directory: modify the group to which the file or directory belongs
Note: equivalent to chown: group files or directories
[root@localhost ~] # ll file*
-rw-r--r--1 user1 user1 0 02-18 21:43 file1.txt
-rw-r--r--1 user1 user1 0 02-18 21:43 file2.txt
[root@localhost ~] # chgrp root file1.txt file2.txt / / modify the owners of file1 and file2
[root@localhost ~] # ll file*
-rw-r--r--1 user1 root 0 02-18 21:43 file1.txt / / owner becomes root
-rw-r--r--1 user1 root 0 02-18 21:43 file2.txt / / owner becomes root
[root@localhost ~] #
At this point, I believe you have a deeper understanding of "what is the basic authority and attribution of CentOS system management". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.