I have been using Ubuntu 12.04 for quite a while and have never had a problem come at me out of the blue like this. I'm trying to install python 3.2 on my Ubuntu system and every time I run the code to compile the python source, I get this error:

'Command 'sudo' is available in '/usr/bin/sudo'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
sudo: command not found'

I've also tried running gksudo command to view what my environment shows but I pretty much get the same error.

  • I bet you'll probably get the same error when you try to run your applications through command line. What's the output of cat /etc/environment?
    – Alaa Ali
    Aug 29, 2013 at 4:50
  • Could you tell us what program are you trying to execute? Some programs change the PATH variable, but without the name we couldn't be sure.
    – Braiam
    Aug 30, 2013 at 15:37

4 Answers 4


As the error say, you should add /usr/bin directory to your PATH environment variable. To do this, run the following command in terminal:

export PATH=$PATH:/usr/bin

After you can use sudo, you can edit /etc/environment file to make the change permanent, so, run in terminal:

sudo nano /etc/environment

to edit the file. Make sure that the path is something like this:


Save and close the file with Ctrl+X and press Y when you are asked.

See also: How to add a directory to the PATH?

  • This isn't permanent though, right? If he restarts, it'll go away again.
    – Alaa Ali
    Aug 29, 2013 at 4:49
  • 1
    Yes. The permanent settings for your user are probably in ~/.profile, ~/.bashrc, ~/.pam_environment or ~/.xsessionrc. Settings for all users are probably in /etc/profile, /etc/profile.d/*, /etc/environment, /etc/bash/bashrc, /etc/lightdm/xsession. Probably one of your users files overrides the default system wide settings. If you have another user or the guest account enabled, try with the other user and see if the problem exists for that other user too. If not, check your own users startup script files.
    – soulsource
    Aug 29, 2013 at 5:03
  • 1
    It worked perfectly. Thank you very much! But, could you please add more information on how to make this change permanenr??? Thanks in advance.
    – OscaRoCa
    Apr 6, 2014 at 3:16
  • I got this error: MY_USER_NAME is not in the sudoers file. This incident will be reported. , I'm not the admin .. what I have to do ..
    – Minions
    Jul 23, 2018 at 14:29

I got the problem and fixed it by editing my .bashrc file

  1. Open up your .bashrc file using nano

    $ nano ~/.bashrc
  2. Add the following line to the .bashrc file

    export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:   /usr/local/games"
  3. Press Ctrl+X to save the file

  4. It will ask to chnage the file, press y and Enter.

You're done.

  • 1
    Do not manipulate files in your home directory (~) using sudo. It can create more problems than it can solve.
    – Melebius
    Jul 23, 2018 at 14:51
  • @Melebius, like what problems? Jun 21, 2020 at 19:36
  • @SirajAlam This one, for example.
    – Melebius
    Jun 22, 2020 at 4:28

When you want to add a new value to the PATH system variable, you most likely add a new line to ~/.bashrc or ~/.bash_profile files.

For example, if you want to add /opt/netbeans/bin to PATH, you must add this line to the end of ~/.bashrc file:

export PATH=$PATH:/opt/netbeans/bin

Let's break this line down.

  • export PATH - Here we refer to the PATH variable
  • = - We want to assign it a new value using the = operator (The rest of the string is the value that will be stored in the PATH)
  • $PATH - We assign the variable PATH to the value that was in the variable before the current command
  • : - We add a separator for the new value
  • /opt/netbeans/bin - And add a new value to the PATH

You must see all of your refers to the PATH variable in the ~/.bashrc or ~/.bash_profile files and make sure that you expand -

export PATH=$PATH:/opt/netbeans/bin

and not overwrite like this -

export PATH=/opt/netbeans/bin

the PATH variable

You must make sure, in every reference to the PATH you use $PATH: and your additional value after it

If it doesn't work, you may do something like this:

  • Make sure, there is something like the next variable in /etc/environment file and it never redefined in this file:
  • Add missing paths from the above PATH variable to your PATH variable located in the /etc/environment

Before testing after each change in files don't remember to update your configs.

For example for ~/.bashrc file:

source `~/.bashrc`
  • Thank you, I assumed I had overwritten the path and you confirmed it. Fixed login issue. Aug 5, 2021 at 15:32

This is an old thread but I got here following the same problem. In my case I most likely accidently edited a line in the ~/.bashrc file. By fixing the following line to appear as in the picture it solved my problem: [1]: https://i.stack.imgur.com/V3vq0.png (mine had the ':' in the wrong place).

I don't think there is a need to add a line, just make sure the line with the PATH is correct(unless you also have your own scripts saved somewhere).

In order to get to the ~/.bashrc you can either use graphical methods (make sure to show hidden files) and go to the home folder. OR - use export PATH=$PATH:/usr/bin to enable some commands temporarily as was suggested here earlier, then open ~/.bashrc using

nano ~./bashrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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