File or directory permissions under Linux 1.1 Description of permissions
1, Linux file or directory permissions are controlled by 9 permissions, every three bits for a group, that is, the file is the main (owner= owner = user) R, W, x, user group (group= group = family) R, W, X; others (other= = not in the same group) R, W, X;
2. Permission Group description
3, R=read=4=cat; W=write=2=echo x=exexute=1 '-' = no permission;
Special permissions: T, T, S, s, x, X, +, etc.;
4, which user creates the file its user or the owner is who, the file group is the user or the user group;
5, users, groups, permissions are relative to the file or directory;
1.2 Creating a simulated environment 1.2.1 test preparation
Groupadd incahome = Create a group that is a home for users and files under root;
Useradd oldboy-g incahome = Add users to the Incahome group;
Useradd oldgirl-g Incahome = = Add users to the Incahome group;
Useradd test = Create a user outside the group
If the Oldboy user exists, execute the following command:
Usermod g Incahome Oldboy
ID Oldboy???
uid=500 (Oldboy) gid=500 (Oldboy) group =500 (Oldboy)
ID Oldgirl
uid=509 (Oldgirl) gid=508 (incahome) group =508 (Incahome)
ID Test
uid=504 (test) gid=504 (test) group =504 (test)
1.2.2 File Creation Test preparation
Mkdir/oldboy = = = created under root
echo "Echo oldboylinux." >/oldboy/test.sh Create a file under root, the user and group of the file are root
Ls-l/oldboy/test.sh
chmod +x/oldboy/test.sh = Give script file permission to execute;
Test One:
Open root, Oldboy, Oldgirl, test user-clone tag--su-user or logout re-login
Ls-l/oldboy/test.sh ===send to four session boxes logout
-rwxr-xr-x
Conclusion One:
Oldboy, Oldgirl, and test are other outsiders for the root user or root group (home), so three users see the third permission, R and X, that cannot be written
Test Two:
Chown oldboy.incahome/oldboy/test.sh = = = Let Oldboy become the owner of the file, incahome become the home or group of the file
Ls-l/oldboy/test.shtxt = = = under Oldboy user
-rwxr-xr-x 1 Oldboy incahome .../oldboy/test.sh
Conclusion: The user = owner of the Oldboy has R, W, X
Ls-l/oldboy/test.sh = = under Oldgirl user
-rwxr-xr-x 1 Oldboy incahome .../oldboy/test.sh
Conclusion: Oldgirl users have R and X, can not W, with the owner of the file Oldboy the same group, is the user group = family
Ls-l/oldboy.txt = = = under test user
-rwxr-xr-x 1 Oldboy incahome .../oldboy/test.sh
Conclusion: Test=other, same as user group Oldgirl permissions, R and X, cannot w
File and directory permissions on Linux systems