nix:pathvars
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| nix:pathvars [2020/01/06 15:37] – kauffman | nix:pathvars [2020/01/06 16:00] (current) – kauffman | ||
|---|---|---|---|
| Line 36: | Line 36: | ||
| </ | </ | ||
| - | ==== Intro the the PATH variable ==== | + | ===== Intro the the PATH variable |
| Generally your search path for binaries will look something like the below. | Generally your search path for binaries will look something like the below. | ||
| Line 63: | Line 63: | ||
| - | ===== Manipulating the PATH variable | + | ===== Setting up an Example |
| Your shell will allow you manipulate the order in which these paths appear. It's as simple as setting a variable. | Your shell will allow you manipulate the order in which these paths appear. It's as simple as setting a variable. | ||
| Line 76: | Line 76: | ||
| </ | </ | ||
| - | We will place our example script that echo's 'Hello World!' | + | We will place our example script that echo's 'Hello World!' |
| < | < | ||
| #!/bin/bash | #!/bin/bash | ||
| Line 82: | Line 82: | ||
| </ | </ | ||
| + | and make it executable. | ||
| < | < | ||
| - | chmod +x ~/bin/hello | + | user@linux1: |
| </ | </ | ||
| + | Now that we have our executable '' | ||
| + | |||
| + | As you may have guessed we will want to add (pre or postpend) '' | ||
| + | |||
| + | ===== Manipulating the PATH variable ===== | ||
| + | |||
| + | < | ||
| + | $ export PATH=$PATH: | ||
| + | </ | ||
| + | |||
| + | To test we will need the shell to reevaluate $PATH. | ||
| + | < | ||
| + | $ hash -r | ||
| + | </ | ||
| + | |||
| + | Now we can see that '' | ||
| + | < | ||
| + | user@linux1: | ||
| + | / | ||
| + | |||
| + | user@linux1: | ||
| + | Hello World! | ||
| + | </ | ||
| + | |||
| + | ===== Making the change permanent ===== | ||
| + | Add the following line to a file called '' | ||
| + | |||
| + | | ||
| + | |||
| + | This will postpend our custom path to the search path every time we launch a bash login shell. You can replace '' | ||
| + | If you'd like to prepend just move your path in front of '' | ||
| + | export PATH=$HOME/ | ||
/var/lib/dokuwiki/data/attic/nix/pathvars.1578346631.txt.gz · Last modified: 2020/01/06 15:37 by kauffman