3

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 ?

david6
  • 14,499
HASSAN
  • 33
  • 1
  • 4
  • 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

3 Answers3

3

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.

enzotib
  • 93,831
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 ~/.profile file? (also answers .bashrc), e.g.:

    cp /etc/skel/.bashrc ~username/
    chown username: ~username/.bashrc
    
gertvdijk
  • 67,947
  • 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
0

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

(Source)

David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • 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 '16 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 '16 at 16:33