Skip to content

Instantly share code, notes, and snippets.

@ahadshafiq
Created April 19, 2013 23:23
Show Gist options
  • Save ahadshafiq/5423925 to your computer and use it in GitHub Desktop.
Save ahadshafiq/5423925 to your computer and use it in GitHub Desktop.
Random notes on PATH, bash
echo $PATH
PATH tells Bash where to look to find the executables like "ls" -
usually , they'll be somwehre like /usr/bin
You need to add those directories to your PATH to make them work.
path needs to list all the locations where binary files are found
eg: bin;usr/bin;/usr/local/bin. If you want to change your shell
then instead of PATH=/usr/bin/ksh you need
Code:
SHELL=/usr/bin/ksh
If you want to add a line to the PATH, do it like:
Code:
PATH=$PATH:/new/path:/another/new/path
The $PATH bit means it includes what the currently set path is.
What you put in changed the path, rather than adding to it.
The bash shell can use several configuration files.
There are the default startup/configuration files in /etc (eg /etc/profile).
These are intended to provide reasonable default settings. You can tailor your
bash shell environment by creating specially named files in your home directory.
These are:
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
When you login, the configuration files are searched for and read in an ordered
fashion (/etc/profile -> ~/.bash_profile -> ~/.bash_login -> ~/.profile)
In this manner your setting will add to or override the defaults.
When you are starting a bash shell after logging in, the ~/.bashrc file will
be read if it exists.
Typically one creates any of ~/.bash_profile, ~/.bash_login, ~/.profile for
settings that are needed for all of your bash shells. ~/.bashrc is reserved
for setting the environment specifically for your interactive shells. bash
reads the login configuration files just once at login. ~/.bashrc is read
for each startup of an interactive shell.
Can use 'which ruby' or 'which chef-solo' or 'which' any executable to find out its
path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment