Absolute vs. Relative Paths
When you move around the Linux file system, you always refer to locations using paths. A path is a route to a file or directory.
Absolute paths
An absolute path starts from the root directory / and fully specifies the location, regardless of where you currently are.
/home/alex/Documents
/var/log
/etc/ssh/sshd_configAbsolute paths are unambiguous: they always point to the same place.
Relative paths
A relative path is interpreted from your current working directory (your “current location”). It does not start with /.
Documents
projects/app
../DownloadsRelative paths are convenient for short navigation when you are already near the target directory.
Continue in our app.
You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.
Or continue reading below...Download the app
Special Path Shortcuts: ., .., and ~
Linux provides a few special path components that make navigation faster.
. (current directory)
. refers to the directory you are currently in. It is often used when you need to explicitly say “from here”.
ls ... (parent directory)
.. refers to the parent of the current directory (one level up).
cd ..You can chain it to go up multiple levels.
cd ../..~ (home directory)
~ expands to your home directory (for example, /home/alex). It works anywhere in a path.
cd ~
cd ~/DownloadsThis is especially useful when you want to jump back to a known location without typing the full absolute path.
Confirming Your Location with pwd
pwd prints your current working directory as an absolute path. Use it whenever you are unsure where you are before running commands that create, move, or delete files.
pwdExample output might look like this:
/home/alex/projectsMoving Around with cd
cd changes your current directory. Think of it as “teleporting” your shell to a different folder so that relative paths are interpreted from there.
Common cd patterns
Go to an absolute location:
cd /etcGo to a relative location:
cd projectsGo up one directory:
cd ..Go to your home directory (two common ways):
cd cd ~
After any cd, run pwd to confirm you landed where you expected.
Listing Contents with ls
ls lists files and directories. On its own, it shows a simple list of names.
lsYou can also list a specific directory without moving into it.
ls /var
ls ~/DownloadsUseful ls flags
ls -l (long listing)
-l shows detailed metadata for each item: permissions, link count, owner, group, size, timestamp, and name.
ls -lls -a (include hidden files)
Files starting with a dot (like .bashrc) are hidden by default. Use -a to include them.
ls -aNote that . and .. will also appear in this listing because they are real directory entries.
ls -h (human-readable sizes)
-h is typically used with -l to show sizes in KB/MB/GB rather than raw bytes.
ls -lhCombining flags
You can combine flags to get a detailed view including hidden files with readable sizes.
ls -lahInterpreting File Metadata from ls -l
A long listing looks like this:
-rw-r--r-- 1 alex staff 2480 Jan 12 09:41 notes.txt
drwxr-xr-x 2 alex staff 4096 Jan 15 14:03 scriptsRead the columns from left to right:
File type and permissions (first field, e.g.,
-rw-r--r--ordrwxr-xr-x):The first character indicates type:
-for a regular file,dfor a directory.The remaining characters are permissions in three groups: owner, group, others.
Link count (e.g.,
1or2): how many directory entries point to this file/directory.Owner (e.g.,
alex): the user who owns the file.Group (e.g.,
staff): the group associated with the file.Size (e.g.,
2480or4096): file size in bytes (or human-readable units if you used-h).Timestamp (e.g.,
Jan 12 09:41): typically the last modification time.Name (e.g.,
notes.txtorscripts): the file or directory name.
Quick permission reading practice
Take drwxr-xr-x:
dmeans it is a directory.rwx(owner) means the owner can read, write, and enter the directory.r-x(group) means group members can read and enter, but not write.r-x(others) means everyone else can read and enter, but not write.
For a regular file like -rw-r--r--, “enter” does not apply; instead, the execute bit controls whether the file can be run as a program/script.
Mini-Lab: Navigate a Folder Tree and Capture Listings
In this mini-lab, you will move through a provided folder tree, list hidden files, and save a long listing for review. The commands below assume you have a lab directory named nav-lab in your home directory. If your instructor provided a different name or location, adjust the paths accordingly.
1) Start in your home directory and verify location
cd ~
pwd2) Inspect the top level of the lab folder
ls nav-lab
ls -l nav-labWithout changing directories, you just confirmed what is inside nav-lab and saw metadata with -l.
3) Enter the lab folder and confirm where you are
cd nav-lab
pwd4) Practice relative navigation with . and ..
ls .
ls ..ls . lists the current directory; ls .. lists the parent directory (likely your home directory).
5) Move down into a subdirectory, then back up
Choose a subdirectory name you saw in step 2 (example: projects).
cd projects
pwd
cd ..
pwd6) List hidden files
From inside nav-lab, run:
ls -aLook for dotfiles such as .config, .notes, or similar items included in the lab.
7) Create a long listing with readable sizes and save it for review
Capture a detailed listing (including hidden files) into a text file named listing.txt inside the lab directory:
ls -lah > listing.txtNow verify that the file exists and inspect its metadata:
ls -l listing.txtIf you want to confirm the lab captured what you expected, list the directory again and ensure listing.txt appears.
ls