Absolute and Relative paths

Опубликовано: 26 Май 2026
на канале: Chris Gregg
5,301
24

This is a description of the difference between absolute and relative paths on a unix system. Absolute paths start from the root directory and look like this:

/afs/.ir/users/c/g/cgregg/cs107/assignments/assign0/hello

They aren't fun to type, and often we refer to files by their "relative" path, using the three shortcuts, ~ (home directory), . (current directory), and .. (parent directory).

From my home directory, the above file would simply be:

~/cs107/assignments/assign0/hello

If was in the assign0 directory, the hello file is just:

./hello

And if I was in a sibling directory, assign1 to the assign0 folder, the hello program would be at:

../assign0/hello