← 返回命令列表

Linux command

delgroup 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Delete a group

sudo delgroup [groupname]

Remove user from group

sudo delgroup [username] [groupname]

Delete system group

sudo delgroup --system [groupname]

Delete only if empty

sudo delgroup --only-if-empty [groupname]

说明

delgroup removes a group from the system or removes a user from a group. It's the Debian/Ubuntu counterpart to groupdel with additional safety features. When called with just a group name, it deletes the group. With both user and group names, it removes the user from that group without deleting the group.

参数

--system
Only act if the target is a system group (fail otherwise). Also affects creation logic in adduser.
--only-if-empty
Only remove the group if it has no members.
--backup
Back up any files deleted (for use with deluser; kept for symmetry).
--backup-to _dir_
Place backups in _dir_ instead of the current directory.
--remove-home
(deluser) remove the user's home directory. Listed here only for reference.
--group
Force removal of a group even when a user name was given. Avoids ambiguous invocations.
-q, --quiet
Suppress informational messages.
-v, --verbose
More verbose progress output.
--conf _FILE_
Use an alternate `deluser.conf` configuration file.
--help
Display help information.
--version
Display version.

FAQ

What is the delgroup command used for?

delgroup removes a group from the system or removes a user from a group. It's the Debian/Ubuntu counterpart to groupdel with additional safety features. When called with just a group name, it deletes the group. With both user and group names, it removes the user from that group without deleting the group.

How do I run a basic delgroup example?

Run `sudo delgroup [groupname]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --system do in delgroup?

Only act if the target is a system group (fail otherwise). Also affects creation logic in adduser.