The difference between su and su -

来源:互联网 发布:java连接rac io异常 编辑:程序博客网 时间:2024/05/18 00:42
"su" is equivalent to "su root"
"su -" is equivalent to "su - root"

"su -" or "su - root"

when you use this command, you are given a new login shell from the Linuxserver, which is the same as you logout from the existing user and perform a fresh login. if you type "pwd", you will notice that you are in rootdirectory /root. The environment path will be also change to root's environment.

"su" or "su root"

if you "su" only then basically you just temporary "borrow" the root permission without having all the rootenvironmentsetting. You will notice that you are not having sbin path. Which means some root commands you issue at this environment might not work.