Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is related to another open question. My echo $PATH gives me an output which is like


But running


gives me an output like

Command 'ifconfig' is available in '/sbin/ifconfig'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with your user account.
ifconfig: command not found

after running command like given in other question

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

it runs ifconfig but blocks other commands of ruby rails or rvm.

Seeking help how to resolve this. Also why this happens?

share|improve this question
plz add the output of following command to the question: cat /etc/environment – binW Apr 10 '12 at 12:06
BTW what Ubuntu version are you using? – binW Apr 10 '12 at 12:13
Why this happens, is because your export command is overwriting your existing path. If you want to keep your existing path and append to it, you need a missing piece of magic: export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gam‌​es" compare that to what is in your question and you will see what's wrong. – gabe. Apr 24 '14 at 14:34

Try the command below

export PATH=$PATH:/usr/sbin

OR (if you want to set all the paths)

export PATH=$PATH:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin:/usr/games
share|improve this answer
please read carefully again my question what i have written. – Sahil Grover Apr 10 '12 at 10:44
add this line to your ~/.bashrc: export PATH=$PATH:/usr/sbin – konrad Apr 10 '12 at 11:02
@konard sorry, it is not working. – Sahil Grover Apr 10 '12 at 11:10
After editing your rc files, I usually type source ~/.rcFileName to reload the changes. – theTuxRacer Jan 21 '13 at 8:09

Your original $PATH (the line you posted is not very readible):


You have /usr/local/bin, /usr/bin and /bin. As you already found out ifconfig is inside /sbin.

So where that path is set you also need to include /sbin.

See rubygems docs on how to do this.

share|improve this answer
and how do i do that ?? – Sahil Grover Apr 10 '12 at 10:32

/sbin is normally part of path. Other distros like fedora dont have it in PATH for normal users but I think Ubuntu always does. I will suggest you check your /etc/environment file and see if it is valid and has /sbin added to path. When I run cat /etc/environment, I get following output:

adnan@adnan-laptop:~$ cat /etc/environment 

As you can see /sbin is already part of PATH environment variable. If your file has the same contents then check its permissions otherwise add /sbin to PATH in this file. For me the permissions are:

adnan@adnan-laptop:~$ ls -l /etc/environment 
-rw-r--r-- 1 root root 79 2009-10-29 01:55 /etc/environment
share|improve this answer
its same over here all things – Sahil Grover Apr 11 '12 at 14:31
Like Sahil, /etc/environment exists, has the correct permissions, and has the correct PATH inside it - but for some reason, all of a sudden, bash no longer uses it after a reboot today. – Izkata Mar 30 '14 at 14:37

You could easily solve this by adding /sbin to $PATH. The more important point is that, you should not have /sbin in the path by default.

See this page for a description of why: /sbin directory definition

/sbin contains system utilities that should be run by root or using sudo authority. So if you want to see your network configuration simply type:

sudo /sbin/ifconfig

You will be prompted for your password and then ifconfig will run.

share|improve this answer

What is the PATHvariable?

PATH is a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command. The order of paths in this variable indicates the order in which the command will be searched, in case there is a program by the same name in multiple directories the one located in the folder closest to the beginning of the list (left side) will be executed.

The reason why you got other commands blocked (from ruby rails and rvm) is because you executed this:

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

resulting in a PATH that does not contain the folders of such programs, namely:


What you should do instead is add /sbin to you own PATH.

How to add /sbin to PATH

As the PATH is basically always in the environment you don't need to export it, you just need to add the /sbin directory to it. In order to do that you can execute in your bash


your path now should look something like this:


This change will not be permanent though, once your close your current session PATH will be reloaded with the previous value. In order to make it permanent you should add this change to your ~/.profile file. One way of doing it is the following:

echo 'PATH="$PATH:/sbin"' >> ~/.profile

Now you just need to execute the content of "~/.profile" in the current shell.

source ~/.profile

You are ready to go, not only your current shell but all your future sessions will have the PATH containing the directory.

Why did i use ~/.profile instead of ~/.bashrc?

This concept can be useful for you:

  • ~/.profile is the place to put stuff that applies to your whole session, such as programs that you want to start when you log in (but not graphical programs, they go into a different file), and
    environment variable definitions.

  • ~/.bashrc is the place to put stuff that applies only to bash itself, such as alias and function definitions, shell options, and prompt settings. (You could also put key bindings there, but for bash they normally go into ~/.inputrc.)

You cant get more information about this topic here.

Should you have /sbin in your PATH?

I'm not going to discuss here if /sbin should or should not be in PATH by default because that can turn out to be not a very productive discussion to be had here. I have it, you can have it if you want. Your call.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.