OS X 10.6.8, if I use Bash Process Substitution as 'root', it just doesn't work.

  • Is it supposed to be so?
  • Why?

Note: here's what I mean... "<(list)"

mysql -D robottinosino < <(echo 'select robot from tino_sino;') 

/* a contrived example, admittedly, as you could swap the echo and mysql using a simple pipe... I could not think of a better one off the top of my head */


  • I am logging on as root like so:

    "sudo su -"

(incidentally, is there a better way if I want to stay logged on?)

  • I am not on Bash so my question is really stupid and the comment below caught the problem instantly! :(

echo $0 yields "-sh" :(

I guess this question could just be deleted at this point or metamorphosed into:

"how to I properly log in as 'root' using bash?" (perhaps editing /private/etc/passwd? that does not seem to work. or... sudo bash -l?)

  • You don't log in using a shell of your choice, the system runs the shell specified for that user. That said, sudo bash or su -c bash is the closest you get to logging in using a shell. The shell is in passwd as a per-user setting of the shell to run when the user logs in (and you can change that, either by hand or using some tool for user settings management).
    – njsg
    Jul 13, 2012 at 16:49

2 Answers 2


If you want to change the shell, run chsh -s /bin/bash

If you want to run the shell once while logged in as root just run bash or /bin/bash

chsh after changing roots shell:

# Changing user information for root.
# Use "passwd" to change the password.
# Open Directory: /Local/Default
Login: root
Uid [#]: 0
Gid [# or name]: 0
Generated uid: FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000
Home directory: /var/root
Shell: /bin/bash
Full Name: System Administrator
Office Location:
Office Phone:
Home Phone:
  • Seems that bash is a standard binary on my OSX system, but I may be incorrect, double check your path.
    – Tim
    Jul 13, 2012 at 16:52
  • I don't know about OS X, but some systems use a statically-linked sh as root's shell so that it can run during a recovery boot even if libraries aren't available (eg. on an unmounted /usr filesystem). See also, the toor account: freebsd.org/doc/en_US.ISO8859-1/books/faq/…
    – mrb
    Jul 13, 2012 at 16:54
  • I must comment that I tried editing /etc/passwd and replacing /bin/sh to a path to bash but it got ignored... (possibly /etc/passwd is not how a shell is selected on OS X?) Jul 13, 2012 at 17:10
  • 1
    @Robottinosino check my output above, it is stored in open directory. /etc/passwd is there for other reasons.
    – Tim
    Jul 13, 2012 at 17:13
  • 1
    @Robottinosino that is the incorrect syntax. Do chsh -l /Local/Default -s /opt/local/bin/bash or just chsh -s /opt/local/bin/bash will suffice.
    – Tim
    Jul 13, 2012 at 17:33

If you are not using bash, you can't use that bash feature.

You could start using sudo bash to go root instead, or sudo bash -l to go root with a login shell, to read bash configuration.

  • You can also change root's shell to the bash, or just invoke it when logged in as root (shells are just programs, you can launch a shell from inside a shell (just run bash), the only thing that happens is that when you leave it you're back to the shell you launched bash from)
    – njsg
    Jul 13, 2012 at 16:47
  • 1
    I avoided suggesting changing the shell. Some systems default to sh for recovery shells, in particular systems where they include a statically-linked sh in /bin, and libraries might be unavailable during recovery (eg. because they're on unmounted filesystems like /usr).
    – mrb
    Jul 13, 2012 at 16:51
  • I want my switching to root to be an interactive login in all effects (e.g. on OS X, reading .profile in preference to .bashrc...) Will your solution do this? Jul 13, 2012 at 17:09
  • Ah, no, you'd need to use sudo bash -l for that. A little awkward, unfortunately.
    – mrb
    Jul 13, 2012 at 17:13
  • Actually, sudo bash -l does look like an interactive login, does read root's .profile BUT... it keeps $HOME as /Users/robottinosino rather than /var/root?! Jul 13, 2012 at 17:23

You must log in to answer this question.

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