Absolute and relative file paths
Under Linux®, file paths are used to specify the location of files and directories in the file system. There are two types of paths: absolute paths and relative paths.
Absolute paths
An absolute path specifies the complete location of a file or directory from the root directory /. It always begins with a slash / and provides the complete path to the destination.
Examples of absolute paths:
/home/Administrator/documents/report.txt/etc/ssh/sshd_config/proc/cmdline
Regardless of where you are currently located in the file system, an absolute path always points to the same location.
Relative paths
A relative path specifies the location of a file or directory relative to your current working directory. It does not begin with a slash /.
Special directory symbols:
.(one point) - refers to the current directory..(two points) - refers to the higher-level, higher-order directory (one level higher)~(tilde) - refers to your home directory
Examples of relative paths:
If your current directory is /home/Administrator:
documents/report.txt- refers to /home/Administrator/documents/report.txt./documents/report.txt- same as above (current directory explicit)../Administrator/documents/report.txt- goes up one level and then down again~/documents/report.txt- uses the home directory abbreviation
Command | Description |
|---|---|
| Use |
| Use |
| Use |
| Execute |
| Use |
| Run |
| Use |
| Try |
| Try |