Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know it's not best practice, but on my dev system I login as root. What's the equivalent of the .bashrc file so I can alias some functions?

I've found the /etc/bash.bashrc & /etc/bash.bashrc.local but I'm not sure where to plop my commands.

Running x86_64 SUSE.

thanks, mjb.

share|improve this question
add comment

4 Answers

up vote 8 down vote accepted

Probably best to put them in ~/.bashrc . It seems root doesn't get the normal ones by default in some distros, but you just cp /etc/skel/.bash* ~ to fix that.

share|improve this answer
    
There we go --- I didn't know about the skel directory. Do you happen to know if that's the default? If I edit it, will it work universally if the user doesn't have a ~/.bashrc ? –  mjb Apr 10 '11 at 19:30
    
@mjb That's where new accounts get their default home directory. The useradd tool copies files from there. It is otherwise not used. You can add and alter stuff in there if you want every newly created user to have a different set of files. Think of it as the new user home dir template. –  Keith Apr 11 '11 at 3:57
    
brilliant - thanks Keith. –  mjb Apr 12 '11 at 18:59
add comment

Normally the .bashrc file for the root user should be there: /root/.bashrc
If it is not the case, you can copy the 2 following files into /root, then you can edit the .bashrc file as you want.

cp /etc/skel/.bash_profile /root
cp /etc/skel/.bashrc /root
share|improve this answer
add comment

Instead of using /root/.bashrc try using /root/.profile — it's the same thing, just a different name.

Also, if you are using su to get into root it may not be reading the .bashrc or .profile – just issuing su will not run the login scripts. try doing

su -
share|improve this answer
1  
I beg to differ that a profile and bashrc are "the same thing". –  slhck Jun 27 '12 at 7:39
add comment

How about the home dir of root that is /root/?

From some aspects, root is just another user (just better, and allowed more). root has a home dir, but it is not like the other users in /home/, but simply /root/ so root:s .bashrc is therefore /root/.bashrc

The ones in /etc is system specific settings for all users, including root.


Thanks to grawity to point out that you can use ~root points to the root home dir, regardless of where it is.

You can test that with

$> echo  ~root
/root

So even thou /root will work on 99% on the systems out there ~root is probably more portable and will probably work on 100%.

~root/.bashrc
share|improve this answer
1  
Sometimes it is in /home. It's best to use ~root/.bashrc to refer to the file in root's homedir. –  grawity Apr 8 '11 at 19:39
5  
The root home directory isn't in /home because in some *nix systems, /home is on a separate partition from the system drive and is not necessarily mounted. –  CarlF Apr 8 '11 at 19:40
    
You highlight why I was so confused --- there is no /root/.bashrc on this build. –  mjb Apr 10 '11 at 19:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.