Linux / BSD Shell Doesn’t Recognize Newly Installed Binaries
If you have installed a new binary on your Linux or BSD system and the shell doesn't recognize it, it's likely because the binary is not in your system's PATH. Here's how you can add the directory containing the binary to the PATH:
- Determine the directory that contains the binary. For example, if you installed a new binary called
fooin the directory/usr/local/bin, the directory to add to thePATHwould be/usr/local/bin. - Open your shell's configuration file with a text editor. The name and location of the configuration file depends on the shell you are using. Here are the files you should edit for common shells:
- Bash:
~/.bashrcor~/.bash_profile - Zsh:
~/.zshrc - Korn shell (ksh):
~/.kshrc - C shell (csh):
~/.cshrc
~/.bashrcfile with a text editor:nano ~/.bashrc - Bash:
- Add the following line at the end of the file, replacing
/path/to/binary/directorywith the directory that contains the binary you installed:export PATH=$PATH:/path/to/binary/directoryFor example, if you installed the binary
fooin the directory/usr/local/bin, you would add the following line:export PATH=$PATH:/usr/local/bin - Save and close the file.
- Reload the configuration file for your shell:
- Bash:
source ~/.bashrc - Zsh:
source ~/.zshrc - Korn shell (ksh):
source ~/.kshrc - C shell (csh):
source ~/.cshrc
source ~/.bashrc - Bash:
- Try running the binary again. It should now be recognized by the shell.
