Alias as root not working

Hi. I’ve just installed the desktop edition on my laptop. I like to use Midnight Commander to navigate around while using a terminal to avoid lots of typing of paths. In many distributions - and Clear Linux is no exception - this doesn’t work automatically, because exiting mc dumps you back at the directory you were in when you launched it, instead of the one you navigated to while mc was running. The solution is usually simple - in the case of Clear it’s the same as Fedora: alias mc=’. /usr/libexec/mc/mc-wrapper.sh’

Normally I would stick this line in /etc/bash.bashrc, and it would work for all users. I did try creating an /etc/bash.bashrc and sticking that line in, but it didn’t work.

As a normal user I can put the line in ~/.bashrc and it works. But as root, the alias is not implemented from /root/.bashrc for some reason.

Am I missing something (other than a modern method of navigating round file systems!)?

(By the way I am getting to root access via su -, not sudo -i, not that it makes any difference to this issue.)

Thanks in advance

Rob

You can create and put it at /etc/profile file or create the directory /etc/profile.d and place the file there.

Also you can read:

from man bash

       When  bash is invoked as an interactive login
       shell, or as a non-interactive shell with the
       --login  option,  it first reads and executes
       commands from the file /etc/profile, if  that
       file  exists.   After  reading  that file, it
       looks for ~/.bash_profile, ~/.bash_login, and
       ~/.profile, in that order, and reads and exe‐
       cutes commands from the first one that exists
       and  is readable.  The --noprofile option may
       be used when the shell is started to  inhibit
       this behavior.

2 Likes

Excellent, thank you very much. It works perfectly. Problem solved.