前言:本篇是 Linux 基本操作篇章的内容!
笔者使用的环境是基于腾讯云服务器:CentOS 7.6 64bit。
学习集:
借助:su 指令实现用户切换!
1. 基本语法
指令基本语法:
- su name
2. 基本用法
su name
/* name:为指定切换到的用户名 */
3. 注意点
- root 用户可无需输入密码直接切换到任何用户。
- 非 root 用户间切换及普通用户切换到 root 用户,需要输入对应密码!
- 切换用户若无密码,可通过先切换到root 用户,再通过 root 用户切换到无密码用户。
4. 补充:切换用户操作实例测试
/* 创建测试用例 */
[root@VM-12-16-centos ~]# adduser User1
[root@VM-12-16-centos ~]# adduser User2
[root@VM-12-16-centos ~]# passwd User1
Changing password for user User1.
New password:
BAD PASSWORD: The password fails the dictionary check - it does not contain enough DIFFERENT characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@VM-12-16-centos ~]# passwd User2
Changing password for user User2.
New password:
BAD PASSWORD: The password fails the dictionary check - it does not contain enough DIFFERENT characters
Retype new password:
passwd: all authentication tokens updated successfully.
/* 用户切换操作:root => 其他 */
[root@VM-12-16-centos ~]# su User1
/* 普通用户间的切换 */
[User1@VM-12-16-centos root]$ su User2
Password:
[User2@VM-12-16-centos root]$
5. 相关文章或系列推荐
相关文章:
2. Linux :: 【基础指令篇 :: 用户管理:(1)】::添加用户 :: adduser ;
3. Linux :: 【基础指令篇 :: 用户管理:(2)】::设置用户密码(及本地Xshell 登录云服务器操作演示) :: passwd ;
4. Linux :: 【基础指令篇 :: 用户管理:(3)】::删除用户 :: userdel ;