Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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 Aug 29 '13 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 '13 at 15:37
add comment

2 Answers 2

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 my path?

share|improve this answer
    
This isn't permanent though, right? If he restarts, it'll go away again. –  Alaa Aug 29 '13 at 4:49
    
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 '13 at 5:03
    
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 at 3:16
add comment

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

  1. Open up your .bashrc file using nano

    $ sudo 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.

share|improve this answer
add comment

Your Answer

 
discard

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.