
假設機器有兩個使用者:
- 愛麗絲(管理員)
- 鮑伯(標準用戶)
當Bob登入時,Alice如何修改根檔案(即使Bob沒有此權限sudo
)?
愛麗絲嘗試過:
$ sudo vim /etc/hosts
[sudo] password for Bob:
Bob is not in the sudoers file. This incident will be reported.
答案1
使用su
:
su - alice
sudo vim /etc/hosts
從man su
:
The su command is used to become another user during a login session.
Invoked without a username, su defaults to becoming the superuser. The
optional argument - may be used to provide an environment similar to
what the user would expect had the user logged in directly.
有關更多信息,請參閱
man su
和維基百科。