Ubuntu禁用了root?

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
ukid
帖子: 22
注册时间: 2011-02-08 4:11

Ubuntu禁用了root?

#1

帖子 ukid » 2011-03-02 1:49

是这样吗?sudo时候应该输入root密码而不是当前用户的密码,而Ubuntu却选择后者;su时又需要输入root密码,这样风格不一致让人迷糊,而且sudo输入当前用户迷你嘛是存在安全风险的,普通用户就可以用sudo破坏系统,似乎Red Hat的版本是严格按照切换到哪个用户就输入哪个用户的密码来操作的。
头像
AutoXBC
帖子: 1744
注册时间: 2007-10-23 12:54

Re: Ubuntu禁用了root?

#2

帖子 AutoXBC » 2011-03-02 2:11

你理解有误。sudo 是 su 到某个用户然后 do 他有权限 do 的事情,所以只需要那个用户的密码,至于可以 do 什么取决于 root 在 /etc/sudoers 中的设定。如果你所在的用户没被赋予破坏系统的权限,你 sudo 过去一样什么都做不了。

事实上 su 也不是你理解的需要 root 密码,取决与你想 su 到哪个用户,因为大家常常 su 到 root,所以会有 su 就是到 root 的误解。
 su
  
  1.作用
  
  u的作用是变更为其它使用者的身份,超级用户除外,需要键入该使用者的密码。
  
  2.格式
  
  u [选项]... [-] [USER [ARG]...]
ukid
帖子: 22
注册时间: 2011-02-08 4:11

Re: Ubuntu禁用了root?

#3

帖子 ukid » 2011-03-02 2:37

nobody@localhost:~$ sudo -i
[sudo] password for nobody:
root@localhost:~#whoami
root

第一段能再详细些吗?我这里从nobody切换到root,为什么问我要nobody的密码而不是root密码?
头像
枫叶饭团
帖子: 14683
注册时间: 2010-06-16 1:05
系统: Mac OS X
来自: Tencent
联系:

Re: Ubuntu禁用了root?

#4

帖子 枫叶饭团 » 2011-03-02 7:51

ubuntu 默认root密码是随机的,如果要root密码?用猜?
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: Ubuntu禁用了root?

#5

帖子 tenzu » 2011-03-02 8:58

如果你不是系统管理员,或者这台电脑不是你的私人物品,你是不应该拥有root权限的
jtshs256
帖子: 22323
注册时间: 2010-07-19 21:41
系统: OS X

Re: Ubuntu禁用了root?

#6

帖子 jtshs256 » 2011-03-02 9:18

没装sudo的路过……
躺平
ukid
帖子: 22
注册时间: 2011-02-08 4:11

Re: Ubuntu禁用了root?

#7

帖子 ukid » 2011-03-02 9:20

枫叶饭团 写了:ubuntu 默认root密码是随机的,如果要root密码?用猜?
可是我用
root@localhost:~#passwd
重设了root密码,怎么改动才能让sudo问root密码呢?
头像
灰色小狼
帖子: 4585
注册时间: 2008-12-06 10:38
系统: Arch

Re: Ubuntu禁用了root?

#8

帖子 灰色小狼 » 2011-03-02 9:31

sudo不是切换到root再去做某件事,输入密码不过是对正在操作计算机的人进行一个身份验证,所以让sudo问root密码是不可能的,sudo跟root本来就毫不相干
上次由 灰色小狼 在 2011-03-02 9:54,总共编辑 1 次。
头像
懒蜗牛Gentoo
论坛版主
帖子: 7353
注册时间: 2007-03-02 17:36
系统: Linux Mint

Re: Ubuntu禁用了root?

#9

帖子 懒蜗牛Gentoo » 2011-03-02 9:41

ukid 写了:nobody@localhost:~$ sudo -i
[sudo] password for nobody:
root@localhost:~#whoami
root

第一段能再详细些吗?我这里从nobody切换到root,为什么问我要nobody的密码而不是root密码?
因为nobody被赋予了临时变身成root的特权,你再创建的其他的普通用户试试,看还能不能sudo成root
虽然世上没有完美的东西,但这并不影响我们追求完美,因为只有偏执狂才TMD能成功。
10.04新手入门——笨兔兔讲述自己的故事
头像
灰色小狼
帖子: 4585
注册时间: 2008-12-06 10:38
系统: Arch

Re: Ubuntu禁用了root?

#10

帖子 灰色小狼 » 2011-03-02 9:48

sudo allows a permitted user to execute a command as
the superuser or another user, as specified in the
sudoers file. The real and effective uid and gid are
set to match those of the target user as specified in
the passwd file and the group vector is initialized
based on the group file (unless the -P option was
specified). If the invoking user is root or if the
target user is the same as the invoking user, no
password is required. Otherwise, sudo requires that
users authenticate themselves with a password by
default (NOTE: in the default configuration this is the
user's password, not the root password). Once a user
has been authenticated, a time stamp is updated and the
user may then use sudo without a password for a short
period of time (5 minutes unless overridden in
sudoers).

sudo determines who is an authorized user by consulting
the file /etc/sudoers.
头像
smallapple
论坛版主
帖子: 7868
注册时间: 2009-03-28 15:12

Re: Ubuntu禁用了root?

#11

帖子 smallapple » 2011-03-02 9:49

ukid 写了:
枫叶饭团 写了:ubuntu 默认root密码是随机的,如果要root密码?用猜?
可是我用
root@localhost:~#passwd
重设了root密码,怎么改动才能让sudo问root密码呢?
修改 /etc/sudoers,加上一行

代码: 全选

Defaults	rootpw
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: Ubuntu禁用了root?

#12

帖子 leeaman » 2011-03-02 9:51

root不需要sudo的...sudo什么会问root密码,root等级比可以用sudo的sudoer高级的
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
头像
灰色小狼
帖子: 4585
注册时间: 2008-12-06 10:38
系统: Arch

Re: Ubuntu禁用了root?

#13

帖子 灰色小狼 » 2011-03-02 9:51

1.sudo可以使受限用户以超级用户或其他用户身份执行一个命令
2.在默认情况下,sudo要求用户输入自己的密码来证明身份
3.sudo通过/etc/sudoers来验证谁是授权用户
头像
灰色小狼
帖子: 4585
注册时间: 2008-12-06 10:38
系统: Arch

Re: Ubuntu禁用了root?

#14

帖子 灰色小狼 » 2011-03-02 9:53

If sudo is run by root and the SUDO_USER environment
variable is set, sudo will use this value to determine
who the actual user is.
如果root用户运行sudo,sudo会通过SUDO_USER来判定用户的真实身份
chenxing
帖子: 152
注册时间: 2006-01-03 18:23
联系:

Re: Ubuntu禁用了root?

#15

帖子 chenxing » 2011-03-02 17:02

ukid 写了:是这样吗?sudo时候应该输入root密码而不是当前用户的密码,而Ubuntu却选择后者;su时又需要输入root密码,这样风格不一致让人迷糊,而且sudo输入当前用户迷你嘛是存在安全风险的,普通用户就可以用sudo破坏系统,似乎Red Hat的版本是严格按照切换到哪个用户就输入哪个用户的密码来操作的。
这是个老问题了,你用自己的密码可以root做的事情,是因为在配置文件中说了你是受信任的用户,不是所有的普通用户都能这样做。这样可以确保你在平时没有root权限,避免误操作。而在做系统管理时可以用sudo完成,也并不复杂。

一般来讲,sudo就是用你自己的密码的,因为是该用户被授权了以其它用户的名义做事情,该用户未必掌握其它用户的密码。而su是切换成其它用户,这两者并不是完全相同的。
以Wiki模式创建中文Linux文档,欢迎加入 http://linux-wiki.cn
回复