一、su 命令:
The su command is used to become anotheruser during a login session. Invoked without a username, su defaults tobecoming the superuser. The optional argument - may be used to provide anenvironment similar to what the user would expect had the user logged indirectly.
su 命令用于进行帐号的切换,默认情况下将切换到root帐户。该命令是否带参数“-“区别如下:
1) su
使用su命令不加任何参数,可直接切换到root帐号,但此时的当前目录仍是图中所示的/proc/tty目录,并未发生改变。
2)su -
当前目录发生改变,变成root帐户的home目录。
二、sudo 命令:
sudo 命令在ubuntu中使用的比较频繁,主要作用是:sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. 也就是允许在不发生帐户切换的前提下,使得当前帐户拥有执行命令的权限。
本文详细介绍了Linux系统中su、su-和sudo三个命令的区别。su命令用于切换用户,不加参数默认切换到root,加'-'会改变当前目录至root的home目录。sudo命令则允许普通用户在不切换账号的情况下以超级用户或其他指定用户权限执行命令。

4495

被折叠的 条评论
为什么被折叠?



