Sudo su vs. sudo su - in Ubuntu 14.04
Hello!
I've always been using either sudo or sudo su. And today I found out that there's also a sudo su - option. That it changes the pwd and sets the root's environment too. In regards to the latter, would it make any difference if I'm trying to do under root: a) delete files; b) change attributes of files; c) install and uninstall applications; d) edit config files; e) delete root's trash OR... no matter what, I should always add a hyphen after "su" and not adding it is just a bad habit (as some say)? |
I suggest you to read the man page of sudo and su.
You will see: sudo — execute a command as another user, and su - change user ID or become superuser sudo su - are the two commands combined together and usually it is not required. One wanted to use either sudo or su. https://kb.iu.edu/d/amyi http://askubuntu.com/questions/37619...-which-is-used http://www.howtogeek.com/111479/htg-...tween-sudo-su/ |
Hi,
I would suggest using sudo -i. It is a safe to keep track of who logged in as root on a system. |
OK, thanks for your replies!
|
(if you really want to say thanks just click on yes)
|
The su utility allows you to become root or any other user (you will be required to enter the root or other user password).
su, by itself, is extremely limited in terms of PATH and other environment settings: Code:
fubar-trona-/home/trona: su [I]su -/I], however, is "as if you logged in as the user on the console." Note the difference: Code:
fubar-trona-/home/trona: su - sudo is a sort of one-shot utility; you run something once and that's that (pretty much). Either su or su - will stay in effect until you exit. Doesn't make much sense to use them in series. Hope this helps some. |
All times are GMT -5. The time now is 10:00 PM. |