2

l have trouble with my PATH variable:

each time l run command like pip, bash, mkdir ..

for instance

The command could not be located because '/bin' is not included in the PATH environment variable.
bash: command not found

other example :

dpkg: warning: 'sh' not found in PATH or not executable
dpkg: warning: 'rm' not found in PATH or not executable
dpkg: warning: 'tar' not found in PATH or not executable
dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 5 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)

does this command solves the problem ?

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

each time l need to run this command , how to solve that ?

This command:

/bin/grep PATH ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_login /etc/profile /etc/bash.bashrc /etc/environment

returns:

/root/.bashrc:export PATH="/root/anaconda3/bin"
/bin/grep: /root/.bash_profile: No such file or directory
/bin/grep: /root/.bash_login: No such file or directory
/etc/environment:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
terdon
  • 100,812
  • Are you sure its not permission issue? What is the result of ls -l /bin/bash? – Romeo Ninov Apr 26 '17 at 08:55
  • 2
    @RomeoNinov that's irrelevant. Vincent, please [edit] your question and post the output of this command: /bin/grep PATH ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_login /etc/profile /etc/bash.bashrc /etc/environment. You have changed your PATH and that will have happened in one of those files. – terdon Apr 26 '17 at 08:59
  • @terdon, please see my update – vincent Apr 26 '17 at 09:20

1 Answers1

2

The problem is in /root/.bashrc, specifically this line:

export PATH="/root/anaconda3/bin"

First of all, what in the world are you doing adding anaconda to root's PATH? You really don't want to be using root as your main user! Anyway, that line doesn't add /root/anaconda3/bin to root's PATH, it replaces the PATH with /root/anaconda3/bin and nothing else. So the only command that root can run are the ones in /root/anaconda/bin. What you wanted to do, presumably, was add it. So, change the line above to:

export PATH="$PATH:/root/anaconda3/bin"

Since your PATH is currently messed up, you will need to use the full paths to the relevant commands. For example, to open the file using nano:

/bin/nano /root/.bashrc

Or, if you are not actually logged in as root (as you shouldn't be):

/usr/bin/sudo /bin/nano /root/.bashrc

Then correct the line, open a new terminal (or log out and log back in) and everything should work again.

terdon
  • 100,812