What Is in a UNIX Pathname?
UNIX is a multitasking operating system -- an operating system that can run more than one program at a time -- written by Ken Thompson and Dennis Ritchie in 1969. UNIX keeps executable program files in many different places, and a UNIX pathname tells the operating where to look when you request a particular program.
-
Absolute and Relative Pathnames
-
A UNIX pathname describes the location of a file or directory in a UNIX filesystem. The pathname consists of a series of directory names separated by forward slashes and delimited by colons. An absolute pathname is a pathname that starts with a slash character and starts at the uppermost directory of the filesystem, known as the root directory. A relative pathname, on the other hand, does not start with a slash and starts from the current working directory.
PATH Variable
-
A UNIX pathname is defined by an environment variable called "PATH," and you can find its current value by typing "echo $PATH" at the UNIX shell command prompt. A UNIX pathname typically contains the names of just two or three directories, such as "/bin, /usr/bin" and "/usr/local/bin." Increasing the number of directories in the pathname reduces the likelihood of "command not found" errors, but may increase the likelihood of activating a malicious computer program known as a trojan.
-
Program Execution
-
When you request a particular program, the UNIX shell -- the command programming language that provides an interface to the operating system -- checks if any character in the command is a slash character. If it is, the shell assumes the command is a pathname and executes it accordingly. If not, the shell prefixes the command with the first directory name in the search path, followed by a slash, and attempts to execute it. The shell repeats this process for each directory in the pathname and executes the first corresponding program it finds.
Precautions
-
Trojan horses are typically introduced to a UNIX system by users, rather than system staff, so users protect themselves by setting the PATH variable carefully. To reduce the likelihood of activating a trojan, execute any program that isn't a UNIX system program by specifying the full, absolute pathname. Similarly, don't include directories that can be written to by everyone in your pathname, if possible. If you must include such directories, make sure that they follow the directories that contain system programs in the pathname; earlier entries in the pathname take precedence over earlier ones. Finally, don't include the directory "." in the pathname, as the UNIX shell interprets it as the current work directory.
-
References
- Indiana University: In Unix, what is my path, and how do I set or modify it?
- Dictionary.com: UNIX
- "Learning the UNIX Operating System"; Jerry Peek, et al.; 2002
- ACSAC; Reflections on UNIX Vulnerabilities; Matt Bishop