实践题脚本,创建用户和组并验证
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user