Can't execute terminal commands: "the command 'sudo' is available in '/usr/bin/sudo'"

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.


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:

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

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?


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.