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 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
1  
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
add comment

2 Answers 2

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
add comment

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
1  
@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
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.