当你使用sudo时,它不会询问你root的密码,它会询问
输入您的密码。
您必须最近通过身份验证。这可以很容易地改变这一点,以便它每次都对您进行身份验证:
sudo visudo
# that will open /etc/sudoers in vi/vim
# type the following to search the file:
/Defaults
# hit n to go to next result
# Find line that says:
Defaults env_reset
# and change it to:
Defaults env_reset,timestamp_timeout=0
# 0 is time in minutes
如果您对nano 更满意,您也可以使用nano /etc/sudoers,不过我建议您研究一下vim。 nano 和 vim 的区别就像 microsoft notepad 和 sublime/caret 的区别一样。
# Vim cheat sheet for this tutorial
i # insert mode
ESC # exit insert mode (and other modes)
:wq # write changes (w) quit (q)
# a little more advanced:
:%s/search/replace/gc
# replace all instances of search and ask for confirmation:
http://vim.wikia.com/wiki/Search_and_replace
那么是什么阻止了你 sudo'ing 一切并模仿同样的东西
使用 root 直接登录到 root 的功能
密码?
好问题!您显然是 sudoers 组的一员。大多数发行版(linux\unix 的发行版)都有这个组作为轮子。查看usermod 为用户更改此设置。
您可以在/etc/sudoers中确认群组名称:
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
# ^^^ ENSURE THAT THIS IS COMMENTED OUT (or not present) ^^^
不授予用户 sudo 访问权限会阻止这种情况。
这也是一件好事:
每个人和他们的兄弟在他们的系统上都有一个root 帐户,许多脚本小子试图暴力破解root 帐户以及其他常见的用户名,例如postgres。锁定 root 帐户以减轻 ssh 暴力攻击符合您的最大利益。这可以通过passwd -l(RAN AS ROOT)来完成。
拥有 sudo 用户后,您仍然可以执行管理任务,例如安装软件和创建新用户。
显然root 在任何地方都有完全权限,但它是
不方便su到root,做你需要做的,然后su返回
到您的普通用户名。
如果您要以 root 身份执行扩展任务,我建议:
sudo -i
# do whatever you need to do
^D
# CTRL+D This will terminate your current shell and take you back
# to your previous shell whereas su root and su username will take
# you two shells away from your initial session. This probably won't
# effect you besides MAYBE session history (I am not sure about that).
一如既往地小心,因为作为超级用户,你真的会搞砸你的系统。
关于你的标题问题:
超级用户和root的区别
Ubuntu99 很好地总结了这一点:
https://askubuntu.com/a/592838/212470