Difference between revisions of "Linux Shell Environment Path"
m |
m |
||
Line 11: | Line 11: | ||
note: In the past we used ~/.bash_profile and had to include "export PATH" | note: In the past we used ~/.bash_profile and had to include "export PATH" | ||
− | IF THAT DOESN'T WORK | + | Look at /etc/profile which is used for each new user directory created. It has a script still looking for .bash_profile so it appears that if a .bash_profile is created, the script will identify its existence and use it. |
+ | |||
+ | IF THAT DOESN'T WORK - THIS WILL ... | ||
vi ~/.bashrc | vi ~/.bashrc | ||
PATH="/myscripts:$PATH" | PATH="/myscripts:$PATH" | ||
− | + | Note that .bashrc is executed every time a bash shell is opened and .bash_profile only if it's a login shell. | |
− | + | ||
− | + | ||
If you "sudo bash" then your custom path directories have vanished! /etc/sudoers is configured to replace your PATH with a default one. You have a couple options, either remove Defaults secure_path= from /etc/sudoers or add your custom directory to the secure_path in /etc/sudoers. For some stupid reason when you visudo the /etc/sudoers file opens in nano! stupid! | If you "sudo bash" then your custom path directories have vanished! /etc/sudoers is configured to replace your PATH with a default one. You have a couple options, either remove Defaults secure_path= from /etc/sudoers or add your custom directory to the secure_path in /etc/sudoers. For some stupid reason when you visudo the /etc/sudoers file opens in nano! stupid! |
Revision as of 15:26, 7 December 2019
The current path environmental variable can be viewed
echo $PATH
capital letters on PATH. Want to know if a command is in $PATH?
which command
Need to add a directory path to the shell path statement for your own scripts?
- Per user shell
vi ~/.profile
Look for the line with a comment about "set PATH so it includes user's private bin directories" and add your custom path in there like this: ( added /myscripts to the path )
PATH="$HOME/bin:$HOME/.local/bin:/myscripts:$PATH"
note: In the past we used ~/.bash_profile and had to include "export PATH"
Look at /etc/profile which is used for each new user directory created. It has a script still looking for .bash_profile so it appears that if a .bash_profile is created, the script will identify its existence and use it.
IF THAT DOESN'T WORK - THIS WILL ...
vi ~/.bashrc PATH="/myscripts:$PATH"
Note that .bashrc is executed every time a bash shell is opened and .bash_profile only if it's a login shell.
If you "sudo bash" then your custom path directories have vanished! /etc/sudoers is configured to replace your PATH with a default one. You have a couple options, either remove Defaults secure_path= from /etc/sudoers or add your custom directory to the secure_path in /etc/sudoers. For some stupid reason when you visudo the /etc/sudoers file opens in nano! stupid!
sudo update-alternatives --config editor
Will allow you to fix the stupid editor default (idiots at Ubuntu and Mint don't you think nano is for dosy people?)
sudo visudo
keywords: bash path bashrc bash_profile bash_history command set