Sudo

使用其他使用者登錄時啟用超級使用者

  • March 26, 2014

假設機器有兩個使用者:

  • 愛麗絲(管理員)
  • 鮑勃(標準使用者)

當 Bob 登錄時,Alice 如何修改根文件(即使使用 ,Bob 也沒有此權限sudo)?

愛麗絲嘗試過:

$ sudo vim /etc/hosts
[sudo] password for Bob: 
Bob is not in the sudoers file.  This incident will be reported.

使用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

維基百科

引用自:https://unix.stackexchange.com/questions/121618