View previous topic :: View next topic |
Author |
Message |
veggie2u Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/422d2b653db05efd51d88.jpg)
Joined: 16 Oct 2002 Posts: 212 Location: Minneapolis/MN USA
|
Posted: Tue Nov 09, 2004 8:34 pm Post subject: su - or su root? |
|
|
What is the best way to assume root privileges? They don't appear to be exactly the same, and I am wondering what the difference is. This came up when I was trying to find out where to put alias' for root in the equivelant of a .bashrc file. What are the locations of the equivalent of a .bashrc file for root when getting there via 'su -' vs 'su root'? And is one of those the same as if you log in as root? _________________ http://www.cyberward.net
http://www.annieandchris.net |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
BlackEdder Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/18387544340ac9a5f1b27a.jpg)
Joined: 26 Apr 2004 Posts: 2588 Location: Dutch enclave in Egham, UK
|
Posted: Tue Nov 09, 2004 8:38 pm Post subject: |
|
|
I always use su -, because that way it also loads the root path, and you won't have to specify the path to root only commands. I think this is caused because su- also excecuted .bash_profile. The downside is though that you will go to /root |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
inode77 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/25726459413f9f821f473.gif)
Joined: 20 Jan 2004 Posts: 1303 Location: Heart of Europe
|
Posted: Tue Nov 09, 2004 8:38 pm Post subject: |
|
|
su => root with user environment
su - => root with root environment
type "export" and compare for example the path once when user and once when root
the location for a root .bashrc would be /root, but since root does not have a bash_profile that will invoke .bashrc you'll have to copy both files from a user skel to get it working. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Dolio l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/gallery/Austin_Powers/Austin_Powers_-_Mustafa.gif)
Joined: 17 Jun 2002 Posts: 650
|
Posted: Tue Nov 09, 2004 8:43 pm Post subject: |
|
|
If you're using sudo (and you should be), there's also the option of
That gives you a root shell after you type your own password, so you could even disable root login (ala OSX or Ubuntu) and still get a root shell when necessary.
One advantage of sudo is that it uses your own shell and profile. I use zsh, so sudo -s puts me in zsh with my familiar prompt and aliases and stuff, and I don't need to keep the root profile/shell in sync with mine.
The only thing I had to do was add some stuff like:
Code: | if [[ `whoami` == "root" ]]; then
path=(/sbin /usr/sbin $path)
fi |
So that I could get access to an extended command set while I'm root (although some people will tell you that you should type full paths for everything while you're root, just in case).
If you're sticking with su, "su -" should be pretty close to logging in as root. It sources the root profile and moves you to root's home directory, which is often inconvenient for me, because I want to be root in the directory I'm already in. _________________ They don't have a good bathroom to do coke in. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
pjp Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/1154772887439692d88303b.jpg)
Joined: 16 Apr 2002 Posts: 20589
|
Posted: Wed Nov 10, 2004 4:28 pm Post subject: |
|
|
Moved from Other Things Gentoo. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|