How to switch between users on one terminal?

How about using the su command?
$ whoami
user1
$ su - user2
Password:
$ whoami
user2
$ exit
logout
If you want to log in as root, there's no need to specify username:
$ whoami
user1
$ su -
Password:
$ whoami
root
$ exit
logout
Generally, you can use sudo to launch a new shell as the user you want; the -u flag lets you specify the username you want:
$ whoami
user1
$ sudo -u user2 zsh
$ whoami
user2

sudo -s gives you a shell like susudo -i simulates login like su -. Can be combined with -u $user,

留言

這個網誌中的熱門文章

NMEA標準格式 -- GPS

網路 Transformer 的用途

cut,sed,awk 字串處理