4用户和组管理
- 格式:doc
- 大小:40.50 KB
- 文档页数:5
实验四 Linux用户和组的管理
步骤:掌握用户添加的命令useradd和设置密码passwd,用户组的添
加和改变。gpasswd把用户添加到其他组中。用newusers批量添加
用户,用chpasswd 批量设置用户的口令。groupadd添加工作组
gpasswd添加用户到该组中。
运行结果:
(一)
1. 建立用户testgdlc成功,设置密码为123456
2. 该用户的主目录为
testgdlc:x:500:500::/home/testgdlc:/bin/bash
testgdlc:x:500:500::/home/share:/bin/bash
3. 用户的基本组为root
testgdlc:x:500:0::/home/share:/bin/bash
4. 用户的shell为
testgdlc:x:500:0::/home/share:/bin/tcsh
5. 要求把该用户加到mail组和news组
#cat /etc/group|grep mail
mail:x:12:mail,testgdlc
mailnull:x:47:
# cat /etc/group|grep news
news:x:13:news,testgdlc
(二)
1.添加用户
stu00:x:520:520::/home/stu00:/sbin/nologin
stu01:x:521:521::/home/stu01:/sbin/nologin
stu02:x:522:522::/home/stu02:/sbin/nologin
stu03:x:523:523::/home/stu03:/sbin/nologin
stu04:x:524:524::/home/stu04:/sbin/nologin
stu05:x:525:525::/home/stu05:/sbin/nologin
stu06:x:526:526::/home/stu06:/sbin/nologin
2.
This account is currently not available.
用户都不能以shell方式登录系统
(三)
1. workgroup1:x:487:
2.
1)正在将用户“root”加入到“workgroup1”组中
workgroup1:x:487:root
2)正在将用户“testgdlc”加入到“workgroup1”组中
workgroup1:x:487:root,testgdlc
执行的命令
(一)
1.#useradd testgdlc
#passwd testgdlc
123456
123456
2.#cat /etc/passwd|grep testgdlc
#usermod -d /home/share testgdlc
#cat /etc/passwd|grep testgdlc
3.
#usermod -g root testgdlc
#cat /etc/passwd|grep testgdlc
4.
#usermod -s /bin/tcsh testgdlc
#cat /etc/passwd|grep testgdlc
5.# gpasswd -a testgdlc mail
正在将用户“testgdlc”加入到“mail”组中
#gpasswd -a testgdlc news
正在将用户“testgdlc”加入到“news”组中
(二)
1.
1)#touch usefile
#touch userpwdfile
2)#vi userfile
stu00:x:520:520::/home/stu00:/sbin/nologin
stu01:x:521:521::/home/stu01:/sbin/nologin
stu02:x:522:522::/home/stu02:/sbin/nologin
stu03:x:523:523::/home/stu03:/sbin/nologin
stu04:x:524:524::/home/stu04:/sbin/nologin
stu05:x:525:525::/home/stu05:/sbin/nologin
stu06:x:526:526::/home/stu06:/sbin/nologin
3)#vi userpwdfile
stu00:123456
stu01:123456
stu02:123456
stu03:123456
stu04:123456
stu05:123456
stu06:123456
4)#newusers userfile
5)#chpasswd < userpwdfile
6)#cat /etc/passwd | grep stu
2.#su stu00
#su stu01
#su stu02
(三)
1.groupadd -r workgroup1
cat /etc/group |grep workgoup1
2.1)gpasswd –a root workgroup1
cat /etc/group |grep workgroup1
2)gpasswd –a testgdlc workgroup1
cat /etc/group |grep workgroup1
疑难小结:ftp用户的使用,用户组的添加和批量添加