Going back to the days of DOS, if you wanted to run a program from the command line that resided in a directory other than the current one, you
had two choices. Either supply the full path to the program, eg: c:\windows\command\qbasic.exe, or add the location of the program to your system
"Path". Each time you enter a command to run an application, the computer first searches in your current directory for it, and then in the path,
before running it, or returning a "File not Found" error. The same is true for Linux. Ideally we could place every directory on the Hard Disk in
the path, but this would be ridiculous. The computer would take an age
searching through your hard disk trying to find it!
A simpler solution was thought up a few years back. Put all the programs you are going to use into one directory, and add that directory to
the path. An example of a directory in the path is "/usr/bin" ... this is where little programs like 'ls' and 'vi' are kept. The one where anything
you add, after installing Linux, is "/usr/local/bin". The bin in each case refers to "Binaries", or programs you can run. I found after my Installation
of RedHat 5.0 (Im running 5.1 now), that /usr/local/bin wasn't in the path. So after a quick consultation with a friend, heres how we worked it out :
- From the command line, type vi /etc/profile
- About 5 lines down, the locations of the path are present. To add another one, just go to the end of that line before the inverted commas, put
a colon in, and then type the full path of the directory you want to add
- Save the file and exit
- Go out on the beer to celebrate
And thats it. Its really quite easy when you think about it, unfortunately no one tells you what all the files in /etc/ do, you just have to learn them
as time goes on ...
You may find the following helpful:
Learn more about vi
Syntax highlighting in ViM, mappings and the vimrc file
Vi filters, search & replace and more...
ViM: Variable/Word completion, indenting, macros and function navigation.
About the author, Owen Kelly.
Rather than adding the path for each working directory, use a single "." (period) so scripts can be called from any current directory (when the current directory is not in the path).