From LQWiki
Jump to: navigation, search

The path is the full listing of the file hierarchy that leads to a file (the directory + filename).


  • '/usr/bin/happyexec' is the full (absolute) path to the file happyexec.
  • 'foo/bar/happyexec' is a relative path - note the missing '/' at the beginning of the path - to the file called happyexec. Relative, in this case, means relative to the current directory (e.g. the current directory path can be prefixed to this to get a absolute path).

The current directory or path can be shown by running the command pwd. To change the path, use cd. '..' refers to the directory one level up and '.' to the current directory. The home directory, /home/username, can also be written as '~'.

Environment path

The environment path is where the system is looking for programs to run. It is usually an environment variable named PATH which is set in your shell. Also see setenv. If you type echo $PATH the directories that will be searched are listed. The first program that matches your command will be used.

Using an environment path is a time saver (you don't have to type the full path and look for the program manually), but could also be a security hazard (somebody could change your shell path or place a command in a directory that is searched first and easily replace it with a command that is harmful).

For more explanation about the naming of the paths, see directory and file extensions.

Other uses of path

Path can also mean bang path or explicitly routed Internet address; a node-by-node specification of a link between two machines. Though these are now obsolete as a form of addressing, they still show up in diagnostics and trace headers occasionally (e.g. in NNTP headers).