1, the basic authority UGO
? 1. Permission Setting object: Genus (U) Group (g) Others (O) owner (A (u+g+o))
? 2, the type of permission: read: r=4 write: w=2 execution: x=1 number plus minus sum to get the number,
? You get two of the files and more than two of the permissions. For example, the number 5, that is, "read" and "Write" permissions
? 3. Set permissions
1.更改权限
? (a) Use of symbols
? Syntax: chmod object (u/g/o/a) Assignment (+/-/=) permission type (r/w/x) file/directory
? 4, increase the execution rights: #chmod u+x file1//u is the primary group, X is executed, File1 is the newly created file
? 5. Delete Execute permissions: #chmod u-x file1//u is the primary group, X is execute, FILE1 is the newly created file
? Note: U is the main group, you can also change to G or O or a
? 6, write the program: #vim file1
? echo "Hello World"
? Read-p "Please enter your name:" Name
? echo "$name is the god of men."
? Note: After the File1 file is written, it can be run with bash file or directly with./Run, bash file can run the program directly,
? However, there is a situation where permissions are insufficient. At this point, you need to add permissions to the owner or affiliate group or someone else.
? 7. Assigning permissions to Numbers
? chmod 644/tmp/file1
? It means to assign permission to read, write and write. The number 6 means "Read + write"
? Note: The permissions are displayed as 9-bit, the first three digits correspond to the main, the middle three is the group, the next three bits correspond to others.
? 8. Remove Permissions
###### # chomd u-x file1
? This means removing the owner's execution rights, similar to removing the owner's R (read), W (write) permission
? If it's #chomd g-x file1 '
意思是去除属组的执行权限,其他的同理。
? Other modification Exercises:
? [[email protected] tmp]# chmod a=rwx file1//Everyone equals read and write execution
? [[email protected] tmp]# chmod a=-file1//Everyone has no permissions
? [[email protected] tmp]# chmod ug=rw,o=r file1//genus Main group equals read/write, others read only
? [[email protected] tmp]# ll file1//view file permissions in long mode
? -rw-rw-r--1 Alice it 10-25 16:45 file1//Show Results
? 9, change the owner, belong to the group
? =chown: Set who a file belongs to, owner
? Syntax: Chwon user name. Group name File
? [Email protected] ~]# chown alice.hr file1//change to master, genus Group
? [[email protected] ~]# chown Alice File1//change to Owner
? [[email protected] ~]# chown. HR file1//change only Group
? =CHGRP: Sets the group to which a file belongs
? Syntax: CHGRP group name file-R is recursive meaning
? [Email protected] ~]# CHGRP it file1//change file group
? [Email protected] ~]# Chgrp-r it dir1//change file group
? Example:
? To set permissions for the access directory of the HR department, the requirements are as follows:
? 1.root Users and HR group employees can read, write, execute
? 2. Other users do not have any permissions
? Operation Idea:
? 1 Creating groups
? 2 Creating a user
? 3 Modifying the owner and the genus Group
? 4 Setting permissions
? [Email protected] ~]# Groupadd HR
? [Email protected] ~]# useradd hr01-g HR
? [Email protected] ~]# useradd hr02-g HR
? [Email protected] ~]# mkdir/home/hr
? [Email protected] ~]# chgrp hr/home/hr
? [Email protected] ~]# chmod 770/home/hr
? [Email protected] ~]# ll-d/home/hr/
? DRWXRWX---. 2 root hr 4096 March 14:26/home/hr/
Linux system Configuration and service management--rights management