Navigation
10 min
A path starting with / is absolute — it always means the same
location, measured from the filesystem root, no matter where you
currently are. A path that doesn't start with / is relative — it's
measured from your current directory. Two special relative names show up
constantly: . means "this directory" and .. means "one directory up."
~ is shorthand for your home directory, so cd ~ (or plain cd with no
argument) always takes you home. mkdir -p creates a whole chain of
nested directories in one call, making any missing parent along the way
instead of erroring.
mkdir -p projects/app/src
cd projects/app/src
pwd
# /home/user/projects/app/src
cd ../..
pwd
# /home/user/projects
cd .. always means one level up from wherever you currently are — it's relative, so the same command means something different depending on your current directory.
From your home directory, create the nested directories `projects/app/src` in a single command, then move into `src` using a relative path, and print your current absolute location.
What's the difference between `cd projects` and `cd /projects`?
You can navigate directory trees using absolute paths, relative paths, and the ~/../. shorthands.