Section 5.20. Superseding Standard Utilities


[Page 195 (continued)]

5.20. Superseding Standard Utilities

Users often create a "bin" subdirectory in their home directory and place this subdirectory before the traditional "bin" directories in their PATH setting. This allows them to supersede default GNU utilities with their own "homebrewed" versions, since they will be located by the search process ahead of their standard counterparts. If you choose to do this, you should take great care, as scripts run from a shell expect to use standard utilities and might be confused by the nonstandard utilities that actually get executed. In the following example, I inserted my own "bin" directory into the search path sequence, and then overrode the standard "ls" utility with my own version:

$ mkdir bin           ...make my own personal "bin" directory. $ cd bin              ...move into the new directory. $ cat > ls            ...create a script called "ls". echo my ls ^D     ...end-of-input. $ chmod +x ls         ...make it executable. 
[Page 196]
$ echo $PATH ...look at the current PATH setting. /bin:/usr/bin:/usr/sbin $ echo $HOME ...get pathname of my home directory. /home/glass $ PATH=/home/glass/bin:$PATH ...update. $ ls ...call "ls". my ls ...my own version overrides "/bin/ls". $ _


Note that only this shell and its child shells would be affected by the change to PATH; all other shells would be unaffected.




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net