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

I try to edit .bashrc to view the C-compilers that I installed before. But after opening the new terminal I am stuck with strange error.

I am unable to ls the files/directories and nothing works. It hangs with the following error message on command line:

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

Can anyone please assist me ?

share|improve this question
The likely error was in attempting to change the path variable (with a syntax error), from within .bashrc. Instead, I suggest using .profile, and base your effort on the existing content. – david6 Jul 14 '13 at 10:19

You've probably messed up your .bashrc file and now you can't open a terminal anymore, because this file is used to set up your shell.

  1. Boot into recovery mode. How do I boot into recovery mode?

  2. Remount your system with write access:

    sudo mount -o remount,rw /
  3. Copy the pristine .bashrc file from /etc/skel into your homedir to fix this. See Where are the pristine, untouched contents of a 12.04 .profile file? (also answers .bashrc), e.g.:

    cp /etc/skel/.bashrc ~username/
    chown username: ~username/.bashrc
share|improve this answer
Why recovery? If he can login to the graphical session, why don't simply use a filemanager? And why to use sudo in recovery mode? Also using gnome-terminal -x bash --norc is a simpler option than recovery mode. – enzotib Jul 14 '13 at 10:25
@enzotib Will you still be able to log in to graphical session without proper PATH settings? I highly doubt that. So, unless he has another user on the system with sudo privileges (or plain root user activated), you'll have to use the recovery console. That's why. And thanks for the sudo in the commands in my answer, that's indeed not correct. fixed. :) – gertvdijk Jul 14 '13 at 10:27
@enzotib Also, if you think you have a better alternative, write it as an answer. :) – gertvdijk Jul 14 '13 at 10:28
I have a graphical session as well as am able to open the terminal.When I write "vi .bashrc" its not work and show the following message. Command 'vi' is available in '/usr/bin/vi' The command could not be located because '/usr/bin' is not included in the PATH environment variable. vi: command not found Can anyone answer me in a simple way?? – HASSAN Jul 14 '13 at 10:36

If you are still logged in, or can login to the graphical session without problems, then you can copy the file /etc/skel/.bashrc to your home directory (be aware that hidden files are not shown by default in the file manager.

As an alternative, press F2 then launch the command

cp /etc/skel/.bashrc /home/your-username

If these methods do not work, then you have to follow the method shown by @gertvdijk.

share|improve this answer
+1. Sounds like a quicker solution to try first. – gertvdijk Jul 14 '13 at 10:35
I found the solution by editing the .bashrc by following the full path of editor /usr/bin/gedit /home/YOUR_USER_NAME/.bashrc Thanks to all, specially @Slem – HASSAN Jul 14 '13 at 15:57
@HASSAN: what was wrong or difficult to do in my suggestion? – enzotib Jul 14 '13 at 16:01
@enzotib I try but it didn’t work. May I couldn't got what you actually said. – HASSAN Jul 15 '13 at 6:30

Could be the same problem: Try resetting your path with this command:

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


share|improve this answer
Please, could you add more details from the solution that you have found? Try to explain it with your words, it a sign of a thought answer. – Danibix Apr 23 at 16:00
I think the answer is very clear. The error message says "/usr/bin is not included in the PATH environment variable" and this is "resetting the path". Are you suggesting that a "thoughtful answer" would require an explanation of PATH? Surely there is a balance between a "complete answer" and one that is "direct and to the point"? – Ray Apr 23 at 16:33

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.