1

i tried saving aliases (see below) for the root user in .bash_profile to /var/root/.bash_profile and restarting Terminal, but it didn't work. where does the .bash_profile file need to be to maintain persistent aliases in the terminal?

$ cat /var/root/.bash_profile
alias grep='grep --color=always'
alias net='sudo netstat -ap tcp && sudo lsof -Pn -i4'

my specifications:

sh-3.2# system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: OS X 10.8.5 (12F45)
      Kernel Version: Darwin 12.5.0
      Boot Volume: lily
      Boot Mode: Normal
      Computer Name: lily’s MacBook Air
      User Name: System Administrator (root)
      Secure Virtual Memory: Enabled
      Time since boot: 12:37
  • hmm, nope, that didn't work. but thank you for the suggestion – lily May 7 '18 at 7:48
  • that didnt work either. should there be a .bashrc in the /var/root/ directory? i just noticed theres no bashrc – lily May 7 '18 at 7:54
  • thanks. sourcing the file definitely works, but its not persistent. when i quit Terminal completely and restart it, then $ sudo su to get root, the aliases arent available anymore – lily May 7 '18 at 8:08
  • thanks! using .profile (not .bash_profile) with $ sudo -i works! if you put it in an answer ill gladly accept it – lily May 7 '18 at 8:19
1

The proper config file name of the standard root shell (i.e. sh) is .profile. So change the name of .bash_profile to .profile:

mv /var/root/.bash_profile /var/root/.profile
source /var/root/.profile

This is working logging in as root in the GUI.


Trying to sudo su in a sudoer's shell won't fetch root's .profile file. Use sudo -i instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .