歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> su 與 sudo的區別

su 與 sudo的區別

日期:2017/2/28 15:42:29   编辑:Linux教程

今天在用gvim(Ubuntu 12.04)的時候出現如下錯誤,以前都沒出現這個錯誤,而且打開時gvim會白屏,等很久才正常顯示.剛開始沒有在意,google了一下用gvim -f就可以解決,正常使用.

後來使用的時候有出現下面的錯誤
\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的工作環境。

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用戶的主目錄了。

Copyright © Linux教程網 All Rights Reserved