1

I was trying to add a new path to my bashrc file but I have seemed to messed something up. after I $ source ~/.bashrc I no longer can use the commands ls, mv, cp, cat, vi, and probably others that I haven't tried yet. Is there anyway I can reset the path so it all comes back?

[rn1041@cluster ~]$ ls
-bash: ls: No such file or directory
[rn1041@cluster ~]$ rm
-bash: rm: No such file or directory
[rn1041@cluster ~]$ cp
-bash: cp: No such file or directory
[rn1041@cluster ~]$ mv
-bash: mv: No such file or directory
[rn1041@cluster ~]$ echo path
path
Richard
  • 13
  • 1
  • 4

2 Answers2

3

Most commonly used commands (including the ones you tried) are in /bin, so you can run them by typing /bin/ls, etc.

P.S. What you meant to do is echo "$PATH".

2

Here is an original, untouched ~/.bashrc from CentOS 6.

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

You probably meant to do something like this:

export PATH=$PATH:your/path/here
canon
  • 69
  • 1
  • 1
  • 4
  • And what he probably did instead was, `export PATH=/your/path/here`. By the way, it's advisable to [quote variable assignments when using `export`](http://unix.stackexchange.com/a/97569/135943). – Wildcard Mar 18 '16 at 06:26
  • It's *advisable* to quote *all* references to shell variables (unless you have a good reason not to, and you’re sure you know what you’re doing).  P.S. As a special case, it's unnecessary for simple assignments, like `FOO=$BAR`, but it doesn't hurt, and it's better for a beginner to get into the habit of always doing it. – G-Man Says 'Reinstate Monica' Mar 18 '16 at 19:57
  • P.S. Another common mistake is `export PATH=PATH:/your/path/here`. – G-Man Says 'Reinstate Monica' Feb 16 '17 at 19:13