I want to add some aliases to my OSX command line environment for easier navigation when in the root prompt (sudo su to root). On the Bourne Again Shell (/bin/bash), I can edit /var/root/.bash_profile. But with the Bourne Shell (/bin/sh), what script do I edit for that?

  • Have you tried creating a new file .sh_profile? I don't know whether it'll help but maybe it will. Just a random guess. – Brick May 30 '16 at 4:22
  • Didn't work. I found the answer and am posting it in a sec. – Volomike May 30 '16 at 4:30
  • Would using sudo -s be an option (which would start a root shell with the current value of $SHELL)? – nohillside May 30 '16 at 6:34

This answer comes close to answering the question, but I need to start using sudo su - instead of sudo su in order to switch from regular user to root or the /var/root/.profile script won't execute.

Now, unless Apple changes this, regular users by default will get the Bash shell, instead of the Bourne shell, which is unlike the root user. So, for those users, simply editing ~/.bash_profile will work fine.

  • 1
    I'd like to point out that /bin/sh is not the Bourne shell on OS X or any other modern Unix or Unix-like OS. /bin/sh is a POSIX compliant shell which the Bourne shell is not. If the aliases exist in your current environment then just use sudo -s instead of creating a .profile in root's home folder.. – fd0 May 30 '16 at 18:31

You must log in to answer this question.

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