one, through the setting of permissions to achieve directory sharing
In Linux, the file permissions can be fully protected by the file owner, or the content can be shared to the users who want to share. The following examples illustrate:
1, first create a group under root privileges, three users, add three users all to the same group
Groupadd Gongxiang (Create a group that is a group of Gongxiang)
Useradd-g Gongxiang Zhangsan (Create a user Zhangsan join the affiliate group Gongxiang)
Useradd-g Gongxiang Zhangsi (Create a user ZHANGSI join the affiliate group Gongxiang)
Useradd-g Gongxiang Zhangwu (Create a user ZHANGWU join the affiliate group Gongxiang)
2. Create a directory and modify its directory permissions
Mkdir-p/app/ceshi (Create directory, if you create a directory file under root, the group default to root, you need to manually modify the additional group Gongxiang)
CHGRP Gongxiang/app/ceshi (Modify directory append group to Gongxiang)
chmod 775/app/ceshi (to sub-directory Ceshi set the corresponding permissions, the file owner rwx, the group rwx, other users r-x, do not want other users to enter the directory can be directly set to---)
chmod G+s/app/ceshi (set special permissions to subdirectories Ceshi Sgid, the file created by the user in the directory defaults to the subordinate group of the directory, not to the primary group that inherits the owner)
3, enter any user in the directory to create files, see the files belong to additional groups, go to other users, to see whether the created files can be shared, in the same group of users can have set permissions.
Su-zhangsan (enter Zhangsan user)
TOUCH/APP/CESHI/ABC (Create an ABC file in the Ceshi directory)
Cd/app/ceshi
ll (view the group to which the catalog file belongs)
Second, umask default permission settings
1. When we create a file in Linux, the file has its own default permissions. or create files and directories under the/app directory. :
Mkdir/app/ceshi2 (Create subdirectory Ceshi2)
ll/app/(Show permissions for file directories)
The default permission is 755 after the directory is currently created, why 755? This is a umask setting.
Umask (Displays the default value of the current umask)
The full permission of the file is 777, and here we can see the default value of the file permission when the full permission minus the default value of Umask.
2, modify the default value of Umask
By modifying the default value of Umaks, we can reduce the number of permissions that are set on newly created files.
Vim. BASHRC (in the current root directory, go to file Modify Umask configuration, modify and restart to take effect)
Currently in a normal user, modify umask only for one user.
You can modify the value of Umask for all users at root.
Vim/etc/bashrc
Enter on the last side of the configuration file, and here you can set the umask for all users.
Three, the combination explanation of the Authority rwx
file |
r-- |
-w- |
--x |
rw- |
R-x |
-wx |
rwx |
Role |
User-only Read |
Users can modify
|
No effect |
can read and write |
Readable and executable |
Equivalent to-w- |
Full permissions |
Directory |
r-- |
-w- |
--x |
rw- |
R -x |
- WX |
rwx |
Role |
Short Column Directory contents |
No effect |
Access to catalogue |
=r--only |
Can be long listed and entered |
You can create and delete |
Full permissions |
Permissions settings and functions for files in Linux