
bash Beginnings
|
215
To make changes such as this one stick, you’ll need to make a permanent change to
your
PATH. This can be done by an individual user in the .bashrc file located in the
user’s home directory, or by the system administrator in a system-wide startup file
(usually located in the /etc directory); just add a statement to the file like the com-
mand just shown.
Alternatively, you could move the hello script to one of the directories already in the
PATH. However, these directories are usually protected so that only the root user can
put files there, to preserve security.
For a script more complex than hello (i.e., almost any script), either method has
security implications. If
. is in your PATH, you run the risk that if someone else puts a
different script named hello in another directory and you blunder into that directory
and type hello, you’ll execute the other user’s hello and not the one you intended.
The correctness of the script is also a concern. We’re reasonably sure about what our
hello script does now, but we might not be after adding a hundred more lines.
A common practice is to put your own scripts in a directory like /usr/local/bin or a pri-
vate ~/bin rather than a system directory like /bin, /sbin,or/usr/bin. To add this direc-
tory to your
PATH permanently, add a line like the following at the end of your .bashrc
file:
export PATH=$PATH:/usr/local/bin
I/O Redirection
I/O