Q: How can I change the root-shell?

A: You don't.

Although it is very well possible to change the root-shell and the disadvantages may not seem really clear, the only answer remains: Why would you if you can get the same result in a different and more secure way? Experienced admins do as little as possible as root. Actually they only use root privileges. So there is no need what so ever to customize the root account.

Quoting Arthur Gabrowski:

  There is no reason for not changing the root shell except
that it's not kosher to be logged in as root.

Quoting myself:

  Don't use the rootshell, use rootpermissions

Get your root like this:

Don't log in as root, log in as user and use su -m (and not su -) whenever root-permissions are required. You will notice straight away you are still using the same shell except that the $ has now become a # indicating you are working with root privileges.

You may notice that program x does not seem to be there anymore. Truth is that it is still there. Look at /sbin/programname or /usr/sbin/programname. Normally you don't have to use those programs as user so the path of those programs is not added to the $PATH. Programs in these directories can be executed without having to specify the path.

    $ echo $PATH
    /bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin

Now all you have to do is change your .bash_profile to change the path when it detects you became root. For example add this line to the end of your ~/.bash_profile and you will have a shell that behaves exactly as you would like.

    if [ $(id -u) -eq 0 ]; then
        export PATH=${PATH//./}:/usr/sbin:/sbin
    fi

The ${PATH//./} part will search and remove any dot that may be found in your PATH. This is a very good security measure. Suppose somebody would drop a file named ls in some directory that would do something very nasty and "." is in root path.

Or even better: use sudo:

I usually use sudo to do things with root permisions. This has the advantage that I can execute one single command as root. Or raise my user account to root level without even entering a password, which can be rather tedious as well.

To make sudo available for you proceed like this:

    EDITOR=nano

Or whatever your favorite editor may be.

    visudo

And now add a line like:

    han     ALL=(ALL) NOPASSWD : ALL

And you gave me full root access to your system. If you have to share the PC with others people you can remove the NOPASSWD keyword and you will have to give your user password for every sudo-command.

If you have to do more than one thing you can sudo -s, and you have a root shell.

Q:But I want tab-completion and history

A: chsh -s /bin/ksh

Q: And what about single user mode?

A: exec ksh

In single usermode only the / partition is mounted. People who have /usr on a separate partition will notice that for example bash is not available. Most of the time you don't have to do very much in single user mode so having a full shell is not really interesting. But to make you feel at home you can do the following:

Q: And what if I really really want to change the root-shell.

A: *Sigh*

Ok, at least you have read this story. Don't complain to me if you broke stuff. Here it is:

First you have to copy the static version of bash to /bin and then you have to issue the following magic command as root:

    # chsh -s /bin/bash

Valid HTML 4.01!