在 Linux Ubuntu 上,当我在终端运行sudo su
或sudo su -
系统创建一个具有新控制的新会话时pts
,即
ubuntu@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
ubuntu@ubuntu:~$
ubuntu@ubuntu:~$ uname -a
Linux ubuntu 5.15.0-124-generic #134-Ubuntu SMP Fri Sep 27 20:20:17 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@ubuntu:~$
ubuntu@ubuntu:~$ ps
PID TTY TIME CMD
143254 pts/0 00:00:00 bash
143302 pts/0 00:00:00 ps
ubuntu@ubuntu:~$
ubuntu@ubuntu:~$ sudo su -
root@ubuntu:~#
root@ubuntu:~# ps
PID TTY TIME CMD
143304 pts/1 00:00:00 sudo
143305 pts/1 00:00:00 su
143306 pts/1 00:00:00 bash
143316 pts/1 00:00:00 ps
root@ubuntu:~#
这是预期的行为吗?
根据评论中的要求:
$ ps
PID TTY TIME CMD
146202 pts/0 00:00:00 bash
146231 pts/0 00:00:00 ps
$ sudo -s
root@ubuntu:/home/ubuntu# ps
PID TTY TIME CMD
146233 pts/1 00:00:00 sudo
146234 pts/1 00:00:00 bash
146240 pts/1 00:00:00 ps