Basic introduction 1.Linux group
Each user in Linux must belong to a group, outside the group do not operate independently. In Linux every file there , the owner's group, other groups concepts. In addition to the owner of the file and all user groups, other users of the system are the other group of files.
2. file / directory owner
General file creator, who created will naturally become the owner of the file.
- ls -ahl (see the owner of the file)
Example: Create a group police, and then create a user tom, tom on the police group, and then create a file with tom ok.txt
groupadd police
useradd -g police tom
passwd tom (you will be prompted password)
Touch ok.txt
LS-AHL can see ok.txt owner is tom (third row displays the owner of each file) - Modify the file owner
chown username filename
Example: Using root create a file test.txt, and then modified to owner tom
chown tom test.txt
3. Create a group
groupadd animal
useradd -g animal fox
4. File / Directory's group
- Check the file / directory where the group: ls -ahl (fourth row is set)
- Modify the file's group chgrp group file name
using the root user to create files orange.txt, to see which group belongs, and then modify it to the police group
chgrp police orange.txt
5. Change the user's group (root privileges)
usermod -g group name user name
usermod -d directory name of the user name
example: tom to modify animal group
id tom (see gid)
usermod -g animal tom
the above mentioned id tom
6. Introduction of basic rights
ls -l displayed in the following:
-rw-r---R & lt Tom Police. 6. 1. 1 dated 5 21:07 ok.txt
-rw-r–r-- | 1 | tom | police | 6 | At 21:07 on January 5 | ok.txt |
---|---|---|---|---|---|---|
look down | File indicates that the number of hard links; catalog indicates the number of subdirectories | user | user group | If the file size is a directory 4096 | Last Modified | file name |
-rw-r-r - (0-9 parameters of 10 bits) as follows:
- File Type: d / - / l / c / bl: soft connection -: normal file c: character device (keyboard, mouse) d: Contents B: block file (hard disk)
- 1-3 bits determine the owner (the owner of the file) have access to the file; user
- 4-6 belonging group is determined (the same user group) have access to the file; Group
- 7-9 bits identify other users who have access to the file; other
Detailed rwx permissions:
- rwx role to file
[r] read read view;
[w] write can be modified, but it does not mean that you can delete, you can delete the premise is the directory where you have write permissions;
[x] execute can be executed - rwx role to the directory
[r] can be read, ls
[w] can write, you can modify, create internal directory, delete, rename
[x] can enter the directory
7. Modify permission -chmod
- +, -, = change
u: owner g: All groups o: others a: (sum of u / g / o's) owner
chmod u = rwx, g = rx , o = x file directory name
chmod o + w file directory name
chmod ax file directory name
, for example:
to read and write permission to the owner of the file abc executed, to read where the group execute permission to other groups read execute permissions
chmod u = rwx, g = rx , o = rx
to file abc the owner remove execute permissions, increased group write permissions
chmod ux, g + w abc
to all users abc files add read permissions
chmod a + r - By changing the digital rights
rules: R & lt = 2. 4 W = X =. 1, rwx. 4 + 2 = + =. 7. 1
the chmod = rwx U, G = RX, X = O file directory name
corresponding to the file directory name chmod 751
Example: /home/abc.txt file permissions modified to rwxr-xr-x, to use digital means to achieve
chmod 755 /home/abc.txt
8. Modify the file owner
chown newowner file tom abc.txt change file owner chown
chown newowner: owner and all groups newgroup file change file
-R if it is a directory that erupted files or directories recursively into force chown -R tom / mytest
9. modify the file's group
chgrp newgroup file
chgrp animal /home/abc.txt
chgrp -R animial /mytest
Learn finishing in Linux .