Multiple /usr/sbin's in the PATH

From /etc/bash.bashrc.local on my system. This is “standard”. I DID NOT create it. All that was in it was the PATH setting. I added the comments… naturally. :stuck_out_tongue:

I was getting /usr/sbin in my $PATH 3 times. So I checked where they were set

and commented them out till I only got one /usr/sbin in my $PATH.

Well, after commenting this one out … I GOT NONE!! -But- IF I add

it back I get /usr/sbin added for every terminal that I open. This one

will be commented out and I’ll set it in profile.local.


That was found in version 13.1. Now then, IF any of you find this also to be a problem in 13.2 – you can report it as a bug and be the hero. I have not been able to use 13.2 so I can not test it.


And where is the problem? It is cosmetic issue at the best.

I do not have a /etc/bash.bashrc.local at all here on a system where I installed 13.1 from scratch a year ago and upgraded to 13.2 now.

I do have it on my other system IIRC, have to check later what exactly it contains.
IIRC there was a setting in YaST to enable/disable adding /usr/sbin/ to the users’ path. Not sure whether this still exists, but it may be the reason why you have that line in there (it might be a left-over from earlier versions).

But regarding you having /usr/sbin in the PATH 3 times, apparently that script is run 3x for some reason.
It is only called once here (if it exists) in /etc/bash.bashrc. Maybe you have some more scripts in /etc/profile.d/ or /etc/bashrc.d/ that call it? (maybe some xxx.rpmnew or xxx.rpmsave file e.g.)

I’m not seeing that file (currently running 13.2).

I normally use “csh”.

I used CTRL-ALT-F1 to get a console command line session.
I logged in as root. I did “echo $PATH” to see my path. It was:


and that looks fine to me.

The file


does not exists by default but should one create it then it will be source by /etc/bash.bashrc assuming your default log-in shell is bash which is the default.

Check it by running:

grep /etc/bash.bashrc.local /etc/bash.bashrc

The output should be something like this.

# will be lost during system upgrades.  Instead use /etc/bash.bashrc.local
bash) test -s /etc/bash.bashrc.local && . /etc/bash.bashrc.local ;;

If you did not create that file then check which package it belongs to, if it was indeed created by a package.

rpm -qf /etc/bash.bashrc.local

But packages should not touch anything that has local in it, it is for the local sysadmins.
Any way back to your issue the PATH should not be added in ~/.bashrc nor /etc/bash.bashrc or /etc/bash.bashrc.local since it is for interactive shell ie everytime you open a shell ie the tty’s it will get sourced, which will then add the path again and again. The proper place to put it is in ~/.profile or /etc/profile and /etc/profile.local. for packages there is /etc/profile.d

head -n11 ~/.bashrc

should give some hints :wink:


If you did not create that file then check which package it belongs to, if it was indeed created by a package.

As I wrote already, I think in earlier versions YaST had a setting somewhere to add /usr/sbin to the path of normal users, which created that file if enabled.

I had a look meanwhile on my other system, and indeed I have it here (with just “PATH=$PATH:/usr/sbin”). It is from 2011, and not owned by any package:

wolfi@amiga:~> ls -l /etc/bash.bashrc.local 
-rw-r--r-- 1 root root 21 Mar 11  2011 /etc/bash.bashrc.local
wolfi@amiga:~> rpm -qf /etc/bash.bashrc.local
file /etc/bash.bashrc.local is not owned by any package

And no, I didn’t create it manually.

On my system I see /usr/sbin/ twice in the PATH when I run “echo $PATH” in a Konsole inside KDE, but only once when I login to text mode.
I think what happens is that /etc/bashrc.bashrc (which in turn calls /etc/bashrc.bashrc.local) is run on login, and whenever you start a bash (e.g. indirectly via konsole). So if you run bash inside a graphical session, /usr/sbin is in that bash’s path twice.
If you run another bash inside that bash, it will be there three times and so on.

But as has been written already, in this particular case it’s mainly cosmetic. Something to remember though if you add your own stuff to /etc/bash.bashrc.local (or ~/.bashrc for that matter). :wink:

Right, some demo :slight_smile:

check your users own PATH before doing something else.

unset path;IFS=: read -ra path <<< "$PATH"; printf '%s
' "${path@]}"

Create a bin directory inside /tmp

mkdir /tmp/bin

Now add that bin directory path in ~/.bashrc

echo 'PATH=$PATH:/tmp/bin' >> ~/.bashrc

Then run

exec bash

Which should re read all the config files upon log-in.

Check the PATH again

unset path;IFS=: read -ra path <<< "$PATH"; printf '%s
' "${path@]}"

Now repeat the exec as many times as you want and check the path every time :wink:

The top of file /etc/bash/bashrc says:

PLEASE DO NOT CHANGE /etc/bash.bashrc There are chances that your changes

will be lost during system upgrades. Instead use /etc/bash.bashrc.local

for bash or /etc/ksh.kshrc.local for ksh or /etc/zsh.zshrc.local for the

zsh or /etc/ash.ashrc.local for the plain ash bourne shell for your local

settings, favourite global aliases, VISUAL and EDITOR variables, etc …

I think suse might have provided a sample of this file many years ago. I really like how suse documented the files in the past. I’ve carried it along to maintain our own customizations. I also carry it along to other distributions and just source it from bash.bashrc. I like to keep the distribution files clean. If I modify I always make a backup first.

I always only add to the PATH if it does not exist. Something like:

case ":$PATH:" in
  *:/FILE:*) # already exists
    export PATH

Isn’t the user PATH set by distributions in /etc/environment or /etc/login.defs, and assuming bash shell, modified for the system by the user in bash.bashrc.local (sourced by /etc/bash/bashrc), and lastly by the user in $HOME/.bashrc? Bash manpage gives more detail (see FILES). There’s also a manpage for login.defs.

An interesting side note on bin directories here:

Within parts of the Linux community there is a push to move the content from /bin, /sbin, /lib, and /lib64 into the counterpart directories in /usr, see The case for the usr merge. This page is intended to track work being done, collect concerns and best practices.