what is group password in linux
在linux中,组密码是组管理员的密码,加密后的组密码默认保存在“/etc/gshadow”文件中。组密码可以使用gpasswd命令进行设置或移除,只需执行“gpasswd 组名”命令进入组密码设置模式,输入两次密码即可;而执行“gpasswd -r 组名”命令可移除群组的密码,执行“gpasswd -R 组名”命令让群组的密码失效。
本教程操作环境:linux7.3系统、Dell G3电脑。
在linux中,组密码是组管理员的密码。
用户设置密码是为了验证用户的身份,而用户组设置密码主要是用来指定组管理员的。
由于系统中的账号可能会非常多,root 用户可能没有时间进行用户的组调整,这时可以给用户组指定组管理员,如果有用户需要加入或退出某用户组,可以由该组的组管理员替代 root 进行管理。但是这项功能目前很少使用,我们也很少设置组密码。如果需要赋予某用户调整某个用户组的权限,则可以使用 sudo 命令代替。
加密后的组密码默认保存在 /etc/gshadow
文件中。
/etc/gshadow 文件
我们借助 Vim 命令查看一下 /etc/gshadow文件中的内容:
[root@localhost ~]#vim /etc/gshadow root::: bin:::bin, daemon daemon:::bin, daemon ...省略部分输出... lamp:!::
文件中,每行代表一个组用户的密码信息,各行信息用 ":" 作为分隔符分为 4 个字段,每个字段的含义如下:
组名:加密密码:组管理员:组附加用户列表
组名
同 /etc/group 文件中的组名相对应。
组密码
对于大多数用户来说,通常不设置组密码,因此该字段常为空,但有时为 "!",指的是该群组没有组密码,也不设有群组管理员。
组管理员
从系统管理员的角度来说,该文件最大的功能就是创建群组管理员。那么,什么是群组管理员呢?
考虑到 Linux 系统中账号太多,而超级管理员 root 可能比较忙碌,因此当有用户想要加入某群组时,root 或许不能及时作出回应。这种情况下,如果有群组管理员,那么他就能将用户加入自己管理的群组中,也就免去麻烦 root 了。
不过,由于目前有 sudo 之类的工具,因此群组管理员的这个功能已经很少使用了。
组中的附加用户
该字段显示这个用户组中有哪些附加用户,和 /etc/group 文件中附加组显示内容相同。
组密码的设置或移除--gpasswd命令
为了避免系统管理员(root)太忙碌,无法及时管理群组,我们可以使用 gpasswd 命令给群组设置一个群组管理员,代替 root 完成将用户加入或移出群组的操作。
gpasswd 命令的基本格式如下:
[root@localhost ~]# gpasswd 选项 组名
表 1 详细介绍了此命令提供的各种选项以及功能。
选项 | 功能 |
---|---|
选项为空时,表示给群组设置密码,仅 root 用户可用。 | |
-A user1,... | 将群组的控制权交给 user1,... 等用户管理,也就是说,设置 user1,... 等用户为群组的管理员,仅 root 用户可用。 |
-M user1,... | 将 user1,... 加入到此群组中,仅 root 用户可用。 |
-r | 移除群组的密码,仅 root 用户可用。 |
-R | 让群组的密码失效,仅 root 用户可用。 |
-a user | 将 user 用户加入到群组中。 |
-d user | 将 user 用户从群组中移除。 |
从表 1 可以看到,除 root 可以管理群组外,可设置多个普通用户作为群组的管理员,但也只能做“将用户加入群组”和“将用户移出群组”的操作。
【例 1】
#创建新群组 group1,并将群组交给 lamp 管理 [root@localhost ~]# groupadd group1 <-- 创建群组 [root@localhost ~]# gpasswd group1 <-- 设置密码吧! Changing the password for group group1 New Password: Re-enter new password: [root@localhost ~]# gpasswd -A lamp group1 <==加入群组管理员为 lamp [root@localhost ~]# grep "group1" /etc/group /etc/gshadow /etc/group:group1:x:506: /etc/gshadow:group1:$1$I5ukIY1.$o5fmW.cOsc8.K.FHAFLWg0:lamp:
可以看到,此时 lamp 用户即为 group1 群组的管理员。
相关推荐:《Linux视频教程》
The above is the detailed content of what is group password in linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →
