drwxrwxr-x 2 root music 4096 Jun 22 12:10 /usr/local/share/music
所以目前music群组就拥有了对music目录的读写权限,music的成员bill和jane也具有相同的权限,其他用户可以查看该目录,而不能修改该目录。
1
2
3
4
5
修改默认掩码:仍然有一个问题,在当前权限下,每个用户创建的文件和目录拥有bill和jane的常规权限;
touch 12;ls -l
-rw-r--r-- 1 bill music 0 Jun 22 12:20 12
由于系统中默认掩码是0022,导致该用户组的其他成员不能写入该文件,所以需要把bill和jane的默认掩码值修改为0002。
drwxrwxr-x 2 bill music 4096 Jun 22 12:25 bill
drwxrwxr-x 2 jane music 4096 Jun 22 12:24 jane
此时创建的文件和目录都具有正确的权限,允许用户组内成员在music目录下创建文件和目录。
groupmod修改用户组属性123456 添加用户至用户组
adduser USER GROUP(sudo adduser mountzf music)添加已存在的用户至已存在的用户组
usermod –G/-g GROUP USER(usermod命令用来改变用户账号状态)123
如果一个用户同时属于多个用户组,那么用户可以在用户组之间切换,以便具有其他用户组的权限。用户可以在登录后,使用命令newgrp切换到其他用户组,这个命令的参数就是目的用户组。例如:newgrp root 删除用户
deluser USER
--remove-home remove the users home directory and mail spool
--remove-all-files remove all files owned by user
--backup backup files before removing.
--backup-to target directory for the backups. Default is the current directory.
--system only remove if system user
userdel [options] LOGIN
-f, --force force removal of files, even if not owned by user
-h, --help display this help message and exit
-r, --remove remove home directory and mail spool
-R, --root CHROOT_DIR directory to chroot into
-Z, --selinux-user remove any SELinux user mapping for the user
kill -9 [pid]删除进程号为[pid]的进程。123456789101112131415 删除用户组
delgroup GROUP
deluser --group GROUP
--system only remove if system group
--only-if-empty only remove if no members left
groupdel [options] GROUP123456 从用户组中删除用户
deluser USER GROUP(sudo deluser mountzf music)但是不能从主用户组中移除12查看用户组
cat /etc/group music:x:1001:mountzf,jane同时可以显示该用户组中的用户成员(不包括以该组为主组的成员)
groups 查看当前用户所属的用户组,当前用户组排在最前面
groups user 查看用户user所属的用户组1234 查看用户
id/whoami查看当前用户
w/who查看当前登录的用户