It is the true nature of the struggle to be accused of doing good deeds and still persist. --Balzac
the content of this lecture: file owner, group, other group
Each user in Linux must belong to a group and cannot be independent of the group. In Linux , each file has the concept of owner, group, and other groups.
I. Owner of the file
Typically, the creator of the file, who created the file, becomes the owner of the file naturally.
You can see the owner of the file by using the [Ls-ahl] command
You can also modify the owner of the file by using [chown username file name ]
Second, the group
When a user creates a file, the group in which the file is located is the group that the user is in.
Use the [Ls-ahl] command to see all groups of files
You can modify the group where the file is located by using [chgrp Group name file name ] .
Third, other groups
Except for the owner of the file and the user in the group, the other users of the system are other groups of files.
Let's take a look at an example and create three users to put in two groups
1, add a group can only operate under root Groupadd group name
Groupadd Policemangroupadd Tufei
How to view an existing group: Vi/etc/group Cat/etc/group (cat can only see can not write, vi can see change)
2. Create user and add to specified group
USERADD-G Group name User name
Useradd-g policeman Jinuseradd-g policeman Danuseradd-g policeman Lin
Change the user's group
Usermod-g Tufei Lin
View all user information: VI/etc/passwd cat/etc/passwd
Note:/bin/bash the shell parser that the user is using
-|rw-|r--|r--1 Dan policeman one Dec 9 09:32 Mytest1.java
The first character represents the file (-), directory (d), link (l)
1 represents 1If it is a file, and if it is a folder, it displays a total of several files under this folder.
The permissions are divided into three categories:Rreadable with4Express;Wcan be written with2Express;xexecutable with1represents
command to change permissions: chmod 755 dan : Give dan permission rwxr-xr-x (refers to folder access)
chmod 755 Mytest1.java gives mytest1.java permission rwxr-xr-x (refers to a file)
Change owner (chown) and user group (chgrp) commands:
chown xiaoming ABC: Change the owner of ABC to xiaoming
chgrp Root ABC: Change the group that the ABC belongs to is root
chown root./abc: Change ABC the owner of this directory is root
chown–r root./ABC: Change the ABC directory and the owner of all files and directories below it is root
V: Linux Owner