玩转Redhat Linux 8.0系列 | 管理本地用户帐户

素材来源:Redhat Linux 8.0培训教材《RH124》、《RH134》和《RH294》

玩了5-6年的Linux,现在再来温习一遍RHCE培训教材,按照指导完成实验并与大家分享。

附上汇总贴:玩转Redhat Linux 8.0系列 | 合集_热爱编程的通信人的博客-CSDN博客


1 从workstation,以student用户身份打开连接servera的SSH会话。

[student@workstation ~]$ ssh student@servera
student@servera's password: 
Activate the web console with: systemctl enable --now cockpit.socket

This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register

Last login: Sat May 20 20:33:17 2023 from 172.16.190.227
[student@servera ~]$

2 在servera上, 使用sudo切换到root,以转换到root用户的shell环境。

[student@servera ~]$ sudo su -
[sudo] password for student: 
[root@servera ~]# 

3 创建operator1用户, 再确认它存在于系统中。

[root@servera ~]# useradd operator1
[root@servera ~]# tail /etc/passwd
chrony:x:979:978::/var/lib/chrony:/sbin/nologin
flatpak:x:978:977:User for flatpak system helper:/:/sbin/nologin
colord:x:977:976:User for colord:/var/lib/colord:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:976:975::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
student:x:1000:1000:student:/home/student:/bin/bash
operator1:x:1001:1001::/home/operator1:/bin/bash
[root@servera ~]# 

4 将operator1的密码设为redhat。

[root@servera ~]# passwd operator1
Changing password for user operator1.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@servera ~]# 

5 创建另外两个用户operator2和operator3。将它们的密码设为redhat。

5.1 添加operator2用户。将operator2的密码设为redhat。

[root@servera ~]# useradd operator2
[root@servera ~]# passwd operator2
Changing password for user operator2.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@servera ~]#

5.2 添加operator3用户。将operator3的密码设为redhat。

[root@servera ~]# useradd operator3
[root@servera ~]# passwd operator3
Changing password for user operator3.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@servera ~]# 

6 更新operator1和operator2用户帐户, 使它们分别包含Operator One和Operator Two注释。验证是否已成功添加注释。

6.1 运行usermod -c,以更新operator1用户帐户的注释。

[root@servera ~]# usermod -c "Operator One" operator1
[root@servera ~]# 

6.2 运行usermod -c,以更新operator2用户帐户的注释。

[root@servera ~]# usermod -c "Operator Two" operator2
[root@servera ~]# 

6.3 确认operator1和operator2用户的注释已分别反映到其用户记录中。

[root@servera ~]# tail /etc/passwd
colord:x:977:976:User for colord:/var/lib/colord:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:976:975::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
student:x:1000:1000:student:/home/student:/bin/bash
operator1:x:1001:1001:Operator One:/home/operator1:/bin/bash
operator2:x:1002:1002:Operator Two:/home/operator2:/bin/bash
operator3:x:1003:1003::/home/operator3:/bin/bash
[root@servera ~]# 

7 删除operator3用户, 以及该用户的任何个人数据。确认已成功删除该用户。

7.1 从系统中删除operator3用户。

[root@servera ~]# userdel -r operator3
[root@servera ~]# 

7.2 确认已成功删除operator3。

[root@servera ~]# tail /etc/passwd
flatpak:x:978:977:User for flatpak system helper:/:/sbin/nologin
colord:x:977:976:User for colord:/var/lib/colord:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:976:975::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
student:x:1000:1000:student:/home/student:/bin/bash
operator1:x:1001:1001:Operator One:/home/operator1:/bin/bash
operator2:x:1002:1002:Operator Two:/home/operator2:/bin/bash
[root@servera ~]# 

请注意, 前面的输出不显示operator3的用户帐户信息。

7.3 从root用户的shell退出, 以返回到student用户的shell。

[root@servera ~]# exit
logout
[student@servera ~]$

7.4 从servera注销。

[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$

猜你喜欢

转载自blog.csdn.net/guolianggsta/article/details/131305503