-bash: PATH: command not found
Matthew Harrington
I hope someone can help me solve this problem.
I am working on a mac and recently I was trying to use the export path function in .bash_profile to help me run a command from any directory in the terminal. This was my first time doing this and I did something wrong as all my commands stopped working. I managed to fix this issue using some code I found online and I also deleted the incorrect line of code I added in the .bash_profile. But now each time I open up the terminal I notice this error message.
Last login: Mon Feb 15 16:27:45 on ttys003 -bash: PATH: command not found
I am not sure what this means exactly. All my commands work fine, but I would like to fix this as I am concerned it may cause problems in the future.
Any advice would be appreciated!
31 Answer
Linux, Bash, the PATH variable - basics.
To display the content of the PATH environment variable, try this:$ echo $PATH | tr ':' '\n'
by default, before any changes this will display something similar to:
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin... all of which are common system-wide locations (folders) containing 'executable files'.
To add a folder, e.g. $HOME/bin/, of your own to that list; you may place a statement in e.g. $HOME/.bash_aliases - assuming that e.g. $HOME/.bashrc actually looks for and executes that file (which normally IS the case).
Use any text editor to either create .bash_aliases or add to it; the actual command would be$ nano $HOME/.bash_aliases
(where 'nano' is a small, easy to use and freely available text editor, $ sudo apt install nano would install it in a Debian based Linux).
type export PATH=$HOME/bin:$PATH onto a new line, last in the file, hold CTRL and hit X, then answer Y (for yes) to save the file.
With that done, next bash shell you start will look for files to execute in your $HOME/bin/ folder.
The files in that folder needs to be either compiled binaries or correctly formed script files, and also have the x flag set for user (you) - see man chmod - example use, usual settings: $ chmod 755 $HOME/bin/filename .