sudo su Login Bash Shell

Hi folks.

I'm trying to set some root aliases in .bash_profile, but they are not loading when I sudo su. So, that file isn't being loaded, even though I'm in the bash shell. In ~ I have the following options so far:

Code:
-rw-------   1 root  wheel   797 Dec 26 12:42 .bash_history
-rw-r--r--   1 root  wheel   848 Dec 26 10:58 .bash_profile
-rw-r--r--   2 root  wheel   966 Nov 11  2014 .cshrc
-rw-r--r--   1 root  wheel   149 Nov 11  2014 .k5login
-rw-r--r--   1 root  wheel   297 Nov 11  2014 .login
-rw-r--r--   2 root  wheel   257 Dec 26 12:42 .profile

I'm not sure which one I should enter this into:

source ~/.bash_profile

Any insight appreciated.

Cheers
 
Just created a .bashrc file and sourced .bash_profile, and it works.

Outside of this workaround, which files are loaded for an interactive non-login shell?

Cheers
 
Apart from the above I'd also recommend against changing the root shell from csh into something else outside the base system. It's not bad practice perse, but it can have it's advantages to leave things as they are.

First; csh is more feature rich than sh. Both shells are also available in /rescue in case something goes wrong. So in case you do end up in a fail situation then having some understanding about csh could very well get you out of nasty situations a lot easier than if you'd have to rely on sh.

Second; my guess is that you're using Bash on your regular user account and especially then I'd advice you to keep separate shells. Sure: it may be easier on you, but the extra hurdle can sometimes also save you from nasty mistakes. Using a different shell as root is also an ideal way to remind yourself that you're (still) using the root account.

Third; using the root account shouldn't be a common thing to do in the first place meaning that in an ideal situation the moments when you would use more advanced shell features are pretty rare. Of course no situation is the same, but most I do as root on my system is using portmaster to update my port collection and optionally rebuilding the base system.

Just my 2 cents obviously.
 
I'd also recommend against changing the root shell from csh into something else outside the base system. It's not bad practice perse
There are way too many things that can go wrong and be difficult to fix, so yes, it could be called bad practice.
 
There are way too many things that can go wrong and be difficult to fix, so yes, it could be called bad practice.

Good practice is already prepared in the default /etc/passwd: the "toor" user ("root" spelled backwards). Give her the bash shell and log in as "toor" when you want to use the bash shell, and log in as "root" in critical situations.
 
Back
Top