Navigating the Linux Filesystem
New Linux administrators often feel lost because they cannot see the filesystem visually. The solution is not a GUI file manager — it is four commands: pwd, ls, cd, and find. Master these and you can navigate any Linux server confidently, even a system you have never seen before.
Absolute vs relative paths
Every file on Ubuntu has two types of addresses: absolute and relative.
| Type | Starts with | Example | Meaning |
|---|---|---|---|
| Absolute | / | /etc/nginx/nginx.conf | Full path from the root of the filesystem |
| Relative | Anything else | nginx/nginx.conf | Path relative to your current directory |
Special path shortcuts:
| Shortcut | Meaning |
|---|---|
. | Current directory |
.. | Parent directory (one level up) |
~ | Your home directory (/home/username) |
- | Previous directory (used with cd -) |
# Show your current location in the filesystem
pwd
Output
/home/irfan
The cd command
# Go to an absolute path
cd /var/log
# Go to a relative path (from current directory)
cd nginx # Goes to /var/log/nginx if you were in /var/log
# Go to your home directory (all three are identical)
cd
cd ~
cd $HOME
# Go back to the previous directory
cd -
# Go up one level
cd ..
# Go up two levels
cd ../..
# Go to a path with spaces in the name (use quotes)
cd "/var/lib/mysql data"
💡 TIP:
cd -is one of the most useful navigation shortcuts. It works exactly like the Back button in a browser — one press returns you to where you were before your lastcd. Use it when jumping between two directories repeatedly.
The ls command
ls is the command you will run hundreds of times per day. The flags that matter most:
# Basic listing
ls /etc
# Long format: permissions, owner, size, date, name
ls -l /etc
# Long format including hidden files (starting with .)
ls -la /home/irfan
# Human-readable file sizes (K, M, G instead of bytes)
ls -lh /var/log
# Sort by modification time, newest first
ls -lt /var/log
# Reverse sort (oldest first)
ls -ltr /var/log
# Recursive: list all files in directory and subdirectories
ls -R /etc/nginx/
Understanding the ls -la output
drwxr-xr-x 2 root root 4096 Jun 10 09:00 nginx
-rw-r--r-- 1 root root 1823 Jun 10 09:00 nginx.conf
lrwxrwxrwx 1 root root 34 Jun 10 09:00 sites-enabled -> ../sites-available/default
↑ ↑ ↑ ↑ ↑ ↑
type+perms links owner group size date name
File types:
d = directory
- = regular file
l = symbolic link
c = character device
b = block device
Finding files with find
find is the most powerful file search tool on Linux. It searches the filesystem in real time (no index) and supports filtering by name, type, size, owner, permissions, and modification time.
# Find files by name
find /etc -name "nginx.conf"
# Find files by name pattern (case-insensitive)
find /var/log -iname "*.log"
# Find only files (not directories)
find /home -type f -name "*.sh"
# Find only directories
find /var -type d -name "cache"
# Find files modified in the last 24 hours
find /var/log -mtime -1
# Find files larger than 100 MB
find /var -size +100M
# Find files owned by a specific user
find /home -user irfan
# Find files with specific permissions
find /etc -perm 777
Combining find with actions:
# Print the size of each .log file over 10 MB
find /var/log -name "*.log" -size +10M -exec du -sh {} \;
# Delete files older than 30 days in /tmp
find /tmp -type f -mtime +30 -delete
# Show the 10 largest files in /var
find /var -type f -printf "%s %p
" | sort -rn | head -10
Finding files with locate
locate uses a pre-built index for fast searches. It is much faster than find for simple name searches but only searches files that existed when the index was last updated.
# Install if not present
sudo apt install mlocate
# Update the index (run this after installing new software)
sudo updatedb
# Find a file by name
locate nginx.conf
# Case-insensitive search
locate -i php.ini
# Show only files that actually exist (exclude deleted files in the index)
locate -e nginx.conf
📝 NOTE:
locatecan return results for files that no longer exist if the database has not been updated. Always uselocate -eto filter out stale results, or runsudo updatedbfirst.
Finding commands with which and whereis
# Find where a command binary is installed
which nginx
which python3
Output
/usr/sbin/nginx
/usr/bin/python3
# Find binary, man page, and source locations
whereis nginx
Output
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/doc/nginx
# Find which package owns a binary
dpkg -S $(which nginx)
Output
nginx-core: /usr/sbin/nginx
Disk usage navigation
When disk space is low, these commands help you find what is using it:
# Show disk space on all mounted filesystems
df -h
# Show total disk usage of a directory
du -sh /var/log
# Show disk usage of each item in a directory, sorted
du -sh /var/log/* | sort -h
# Find the top 10 largest directories under /var
du -h /var --max-depth=2 2>/dev/null | sort -rh | head -10
# Show inode usage (important when many small files exist)
df -i
Example: finding what is filling /var
$ du -sh /var/* 2>/dev/null | sort -rh | head -5
8.2G /var/lib
2.1G /var/log
450M /var/cache
120M /var/backups
48M /var/snap
Conclusion
Navigating the Linux filesystem is a four-command skill: pwd tells you where you are, ls shows what is there, cd moves you around, and find locates any file anywhere. Once these are instinctive, navigating an unfamiliar Ubuntu server feels natural rather than frustrating.
FAQ
Is Navigating the Linux Filesystem important for Ubuntu administrators?+
Yes. It supports practical Ubuntu administration because it connects directly to server reliability, security, troubleshooting, or daily operations.
Should I practice this on a live server?+
Use a lab VM first. After you understand the command output and rollback path, apply the workflow carefully on real systems.
What should I do after reading this article?+
Run the practice commands, write down what each one shows, and continue to the next article in the Ubuntu roadmap.
Need help with Ubuntu administration?
Work directly with Muhammad Irfan Aslam for Ubuntu Server, Linux, cloud, Docker, DevOps, CI/CD, or infrastructure troubleshooting support.
Hire Me for Support