su与sudo的区别



su与sudo的区别
 
今天在用gvim(ubuntu12.04)的时候出现如下错误,以前都没出现这个错误,而且打开时gvim会白屏,等很久才正常显示.
刚开始没有在意,google了一下用gvim -f就可以解决,正常使用.
  www.2cto.com  
后来使用的时候有出现下面的错误
\GConf-WARNING **: Client failed to connect to the D-BUS daemon:
Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
google了一下说是没有以 root 身份使用 dbus。
 
奇怪了,我明明就是root权限。
以前一直用sodu -i 切换到root权限,今天不知怎么的在写一个自动登录的脚本的时候心血来潮用su root 得到root权限,难道这里出问题了?
果然:
su 和 sudo 的区别:
1.共同点:都是root用户的权限;
2.不同点:su仅仅取得root权限,工作环境不变,还是在切换之前用户的工作环境;sudo是完全取得root的权限和root的工作环境。
  www.2cto.com  
su - root 和 su root(su)有什么区别?
su - root:表示人以root身份登录
just like login as root, then the shell is login shell,
which mean it will expericene a login process,
usually .bash_profile and .bashrc will be sourced
su root:表示与root建立一个链接,通过root执行命令
like you open an interactive shell in root name
then only .bashrc will be sourced.
最直接的区别就是su目录还是原先用户的目录
但是su或su - root后目录就变为root用户的主目录了。

相关内容

    暂无相关文章