系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
-
YeLee
- 论坛版主
- 帖子: 26406
- 注册时间: 2008-08-13 8:48
- 系统: Fundu i64
- 来自: 东海硇州,一双管钥。
-
联系:
#2
帖子
由 YeLee » 2012-04-30 10:13
man sudo
-i [command]
The -i (simulate initial login) option runs the shell
specified by the password database entry of the target user
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
specified, an interactive shell is executed. sudo attempts
to change to that user's home directory before running the
shell. The security policy shall initialize the
environment to a minimal set of variables, similar to what
is present when a user logs 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.
su?通过sudo运行su,用的是当前用户密码,而su默认是root密码。
-
zf123
- 帖子: 322
- 注册时间: 2011-05-31 17:35
#3
帖子
由 zf123 » 2012-04-30 10:19
让我来说吧:
sudo : 暂时切换到超级用户模式以执行超级用户权限,提示输入密码时该密码为当前用户的密码,而不是超级账户的密码。不过有时间限制,Ubuntu默认为一次时长15分钟。
su : 切换到某某用户模式,提示输入密码时该密码为切换后账户的密码,用法为“su 账户名称”。如果后面不加账户时系统默认为root账户,密码也为超级账户的密码。没有时间限制。
sudo -i: 为了频繁的执行某些只有超级用户才能执行的权限,而不用每次输入密码,可以使用该命令。提示输入密码时该密码为当前账户的密码。没有时间限制。执行该命令后提示符变为“#”而不是“$”。想退回普通账户时可以执行“exit”或“logout” 。
我知道的就这么多,不知道有没有帮助你。
-
photor
- 论坛版主
- 帖子: 11004
- 注册时间: 2008-04-26 12:41
#4
帖子
由 photor » 2012-04-30 10:28
人家是问“sudo su”和“sudo -i”的区别,2、3楼答非所问

-
YeLee
- 论坛版主
- 帖子: 26406
- 注册时间: 2008-08-13 8:48
- 系统: Fundu i64
- 来自: 东海硇州,一双管钥。
-
联系:
#5
帖子
由 YeLee » 2012-04-30 10:29
-
qy117121
- 论坛版主
- 帖子: 50587
- 注册时间: 2007-12-14 13:40
- 系统: Winbuntu
- 来自: 志虚国乌由市
-
联系:
#6
帖子
由 qy117121 » 2012-04-30 10:32
photor 写了:人家是问“sudo su”和“sudo -i”的区别,2、3楼答非所问

-
男菜鸟
- 帖子: 1382
- 注册时间: 2008-12-16 14:01
- 来自: 漂在江湖
#7
帖子
由 男菜鸟 » 2012-04-30 11:06
mark
-
onshoestring
- 论坛版主
- 帖子: 4666
- 注册时间: 2009-09-06 5:53
#8
帖子
由 onshoestring » 2012-04-30 11:08
简单说就是shell环境不一样,具体要看看鸟哥的linxu私房菜第十一章,login shell 和 non-login shell的区别。
su non-login shell
sudo -i simulate initial login
The -i (simulate initial login) option runs the shell specified by the password database entry of the target user as a login shell.
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.
-
jtshs256
- 帖子: 22323
- 注册时间: 2010-07-19 21:41
- 系统: OS X
#9
帖子
由 jtshs256 » 2012-04-30 11:09
su 的比较怪,貌似既不是 login 又不是 nonlogin,sudo -i 是 login shell 吧…
躺平
-
xiajiwai
- 帖子: 13
- 注册时间: 2011-08-08 0:14
#10
帖子
由 xiajiwai » 2012-04-30 13:54
多谢楼上的几位!!我的问法有问题,不好意思。
我问的的确是“sudo su”和“sudo -i”的区别,望高手们能更通俗点的指点一下小弟。
-
自由建客
- 帖子: 13468
- 注册时间: 2008-07-30 23:21
- 系统: Debian stable AMD64
#11
帖子
由 自由建客 » 2012-04-30 17:32
看来有必要写篇《sudo 论》了!
-
onshoestring
- 论坛版主
- 帖子: 4666
- 注册时间: 2009-09-06 5:53
#12
帖子
由 onshoestring » 2012-04-30 18:37
xiajiwai 写了:多谢楼上的几位!!我的问法有问题,不好意思。
我问的的确是“sudo su”和“sudo -i”的区别,望高手们能更通俗点的指点一下小弟。
水平低只能看到:
sudo -i 直接运行sudo命令加-i参数
sudo su 运行sudo命令给su命令提权,运行su命令。
sudo -i 运行结果 PWD=/root
sudo su 运行结果 PWD=/home/用户名(当前用户主目录)
-
ahwad
- 帖子: 1116
- 注册时间: 2009-05-06 0:36
#14
帖子
由 ahwad » 2012-04-30 20:34
还是3L 说的明白,mark