0

I'm using VMWare, and running debian and whenever I run a new terminal my commands like "ls" seem to be lost.

I've tried the solutions listed here for instance: https://apple.stackexchange.com/questions/22859/bash-ls-command-not-found

When I do:

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

it works temporarily.

When I do:

cd ~
nano .bash_profile
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH

-- the file changes and the save reflects but when I open a new terminal the commands are forgotten again.

Edit:

rowen@debianRhys:~$ echo $PATH 
/home/rowen/bin:PATH


source .bash_profile
bash: dircolors: command not found
6
  • 1
    By "When I do...", you mean you follow the actual instructions of the answer, is this correct? Because the part you quoted here is not the same as the answer. If you did follow those instructions, it may be that the profile file is not ".bash_profile" but possibly ".bashrc". Or even ".profile" if your shell is not actually bash. – LSerni Feb 24 at 8:07
  • Yes, I follow the instructions, putting that line of code into .bash_profile with nano and then saving it. It says bash: ls: command not found, so I figure it is bash. So should I try edit all of those files with that line? – Rhys Feb 24 at 8:13
  • 1
    Open a new terminal and run echo "$PATH". Run source .bash_profile and check again. Edit your question and add the output. Also try to add it to .bashrc instead. – pLumo Feb 24 at 10:27
  • I tried as you said, editing .bashrc. I added the line to the top of the code. There's actually code in this file though as opposed to the '.bash_profile'. I noticed it has these 3 lines at the bottom: 'PATH=~/bin:PATH PATH=~/bin:PATH PATH=~/bin:PATH' – Rhys Feb 25 at 11:40
  • It is clear from your update that you have added the word PATH at the end of the shell's search path. This is likely due to a forgotten $. Double check your .bash_profile file. In a previous comment, you mention PATH=~/bin:PATH (etc.). This should definitely be PATH=~/bin:$PATH. – Kusalananda Feb 25 at 11:44
1

From comments it was made clear that the user had one or several lines in their ~/.bash_profile file saying

PATH=~/bin:PATH

This would clear the PATH variable, resetting it to a list of paths that are not generally useful.

This would easily be remedied ty prefixing PATH with $ in the value assigned to the PATH variable:

PATH=~/bin:$PATH

This prepends ~/bin to the value of $PATH, rather than discarding the old value completely.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.