Exercise
Putting Scripts on the PATH Exercise
Task
Give yourself a scripts directory that
every new shell can find, so the scripts you write later
run by name.
- Hosts
-
workstation, thenservera
-
Inspect the current PATH
PATHis a list of directories separated by colons. Bash searches them left to right and the first match wins.echo $PATH -
Find where PATH is already set
Open
~/.bashrcand search forPATH. Red Hat already customizes it here, which is why/home/student/binis on your list. You are about to do the same thing a few lines lower.less ~/.bashrc /PATH -
Add a directory for this shell only
Create the directory and append it to
PATH. Naming$PATHon the right keeps everything that was already there.mkdir -p ~/scripts PATH=$PATH:~/scripts echo $PATH -
Confirm it disappears in a new session
Log out of
serveraand log back in. Nothing wrote that line to a file, so the new session starts without it.exit ssh servera echo $PATH -
Persist it in ~/.bashrc
Add the same line to the end of
~/.bashrc, then log out and back in to confirm a new session picks it up.vim ~/.bashrcPATH=$PATH:~/scriptsexit ssh servera echo $PATH