实践题脚本,创建用户和组并验证

This commit is contained in:
王堃营
2026-10-07 21:07:53 +08:00
commit 94274b3ead
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# 创建组 testgroup
sudo groupadd testgroup
# 创建用户 testuser,-m 表示同时创建家目录
sudo useradd -m testuser
# 把 testuser 加入 testgroup,-a 表示追加、-G 表示附加组
sudo usermod -aG testgroup testuser
# 验证:看 testuser 是否已经在 testgroup 里
id testuser