我已經sudo su
在終端機中輸入了,然後我輸入了whoami
,終端機說我是root用戶。那麼這是否意味著sudo su
我成為了 root 用戶,或者我錯過了什麼?
答案1
是的。答案在man su
:
SYNOPSIS
su [options...] [-] [user [args...]]
DESCRIPTION
su allows to run commands with substitute user and group ID.
When called without arguments su defaults to running an interactive shell as root.
請注意,建議執行此操作的方法是sudo su -
,因為它使用登入 shell 環境啟動 root shell:
-, -l, --login
Starts the shell as login shell with an environment similar to a real login:
o clears all environment variables except for TERM
o initializes the environment variables HOME, SHELL, USER, LOGNAME, PATH
o changes to the target user's home directory
o sets argv[0] of the shell to '-' in order to make the shell a login shell
或sudo -i
按照指示直接運行在這個答案中。