簡體   English   中英

sudo -i:為什么給出了root shell?

[英]sudo -i: why does this give a root shell?

運行sudo -i我最終在Linux機器上有了一個root shell。

但是,閱讀-i選項時,它會顯示:

 -i, --login
                 Run the shell specified by the target user's password database entry as a login shell.  This means that
                 login-specific resource files such as .profile or .login will be read by the shell.  If a command is
                 specified, it is passed to the shell for execution via the shell's -c option.  If no command is speci‐
                 fied, an interactive shell is executed.  sudo attempts to change to that user's home directory before
                 running the shell.  The command is run with an environment similar to the one a user would receive at
                 log in.  The Command Environment section in the sudoers(5) manual documents how the -i option affects
                 the environment in which a command is run when the sudoers policy is in use.

我不清楚。

為什么target user root?

sudo su什么不同?

因為“ root”是默認用戶。 重點來自我。

-u用戶,--user =用戶

以默認目標用戶( 通常為root )以外的用戶身份運行命令。 用戶可以是用戶名,也可以是帶有'#'字符的數字用戶ID(UID)(例如,UID 0為#0)。 當將命令作為UID運行時,許多外殼程序要求使用反斜杠('\\')對'#'進行轉義。 某些安全策略可能會將UID限制為密碼數據庫中列出的UID。 sudoers策略允許未設置密碼庫中的UID,只要未設置targetpw選項。 其他安全策略可能不支持此功能。

sudo su以用戶指定的身份(默認為root)有效地執行su命令。

su命令用於在登錄會話期間成為另一個用戶。 在沒有用戶名的情況下調用su會默認成為超級用戶。

當您以``root''身份運行su (由於使用sudo )時,系統並不會要求您使用密碼來證明您的身份-許多系統不允許'root'通過輸入!來使用密碼登錄! /etc/shadow字段2中。

“!” –該帳戶已被密碼鎖定,用戶將無法通過密碼身份驗證登錄,但仍然可以使用其他方法(例如ssh密鑰)

此外,即使root 確實具有密碼訪問權限,但在具有多個管理員的系統或共享開發系統上,共享密碼也不是理想的選擇。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM