0

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!

3
  • 2
    It would help if you actually post the files you've edited and commands used.
    – BulletBob
    Feb 15, 2021 at 9:04
  • 2
    Probably PATH = where it should be PATH=. Without knowing the exact code this is the best guess. Feb 15, 2021 at 9:12
  • Thanks for your replies! Unfortunately I couldn't remember the exact code I used as it was a week ago. I ended up using codementor. I had Omid Amirihosseini fix the issue for me in a zoom session and I highly recommend him! I had somehow broken the path so it did take a bit of troubleshooting. Hope this info helps someone else!
    – Heidi
    Feb 18, 2021 at 4:06

1 Answer 1

0

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 .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .