繁体   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