"sudo bash" won't execute in RHEL 5

Solution Verified - Updated -


  • Red Hat Enterprise Linux 5


  • When we run "sudo bash"
    • In rhel6 will execute /root/.bashrc but in rhel5 won't execute. (We test from using alias command)


  • If target account's profile is used, '-H' option needs to be specified to use root account's ".bashrc".
    In RHEL5 '-H' option needs to be added since it is not the default:
$ sudo -H bash
   -H          The -H (HOME) option requests that the security policy set the HOME environment variable to the
               home directory of the target user (root by default) as specified by the password database.
               Depending on the policy, this may be the default behavior.

To make it act as in RHEL6 without -H option, /etc/sudoers needs to be added with the line:

Defaults      always_set_home

By adding the above line in /etc/sudoers, following commands will use the .bashrc in the target account:

$ sudo bash

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.