← 返回命令列表

Linux command

groupmod 命令

安全

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

常用示例

Example

sudo groupmod -n [new_group] [group_name]

Example

sudo groupmod -g [new_id] [group_name]

说明

groupmod modifies the attributes of an existing group on the system. It can change the group name, group ID (GID), or group password. When changing GID, files owned by the group are NOT automatically updated. You must manually find and update file ownership using commands like find / -gid OLDGID -exec chgrp NEWGROUP {} \;. Changing a group name has no effect on file ownership since files reference groups by GID, not name.

参数

-g, --gid _GID_
Change group ID to _GID_
-n, --new-name _NAME_
Change group name to _NAME_
-o, --non-unique
Allow non-unique GID
-p, --password _PASSWORD_
Set encrypted group password
-R, --root _CHROOT_DIR_
Apply changes in chroot environment
-P, --prefix _PREFIX_DIR_
Apply changes in prefix directory

FAQ

What is the groupmod command used for?

groupmod modifies the attributes of an existing group on the system. It can change the group name, group ID (GID), or group password. When changing GID, files owned by the group are NOT automatically updated. You must manually find and update file ownership using commands like find / -gid OLDGID -exec chgrp NEWGROUP {} \;. Changing a group name has no effect on file ownership since files reference groups by GID, not name.

How do I run a basic groupmod example?

Run `sudo groupmod -n [new_group] [group_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -g, --gid _GID_ do in groupmod?

Change group ID to _GID_