The basics are, well, basic. Yet these fundamental commands and skills are critical for day-to-day work on Linux systems. Sometimes new users are overwhelmed by the details of managing Linux from the command line. What they need is a quick overview or reminder to get them going. The fancy options come later.
To that end, this article gives you eight basic filesystem navigation concepts and commands integral to file management.
What is a path?
Before learning how to navigate the filesystem, it's good to know how Linux organizes data. Navigation is based on the concept of paths. These paths specify what directories to traverse to reach a particular subdirectory or file. The path basically says: go here, go here, go here, and you'll find this.
There are two types of paths: Absolute paths and relative paths.
Absolute path
An absolute path is a complete path to a resource, beginning at the filesystem's root. The filesystem root is represented as a single forward slash: /
This path defines the directory listing from the top of the filesystem. It's best used in scripts, directory mounting commands, and when you might be confused about exactly how to get to a given destination.
Relative path
Relative paths vary by your location in the filesystem, hence the term relative. Therefore, the directories specified in the path change depending on where you are and where you're going. One of the best ways to think about it is to assume you are already partway down the absolute path, and the relative path just defines the rest of the way to the destination.
For example, if you're already in your home directory (for me, that's /home/damon
), and you want to find an OGG file in the Rock
subdirectory of the Music
directory, then you don't have to specify /home/damon
—that's already traversed. You just need to specify the rest of the path relative to where you are now. So, the relative path in that situation would be Music/Rock
.
8 commands to navigate your Linux filesystem
The following commands are essential knowledge for any Linux user (not just sysadmins). Give them a try and add them to your daily routines.
Find your location
The secret to navigation, whether it's through a mountain chain or the Linux filesystem, is to know where you are. It's very difficult to get somewhere if you don't know where you're starting.
The first command to help with this is pwd
. This command displays the present working directory, letting you know where you are now. From there, you could use an absolute or relative path to get to the desired directory.
Another useful command is tree
. The tree
command displays filesystem information in a similar manner to a graphical interface. This can be handy for new Linux users who are more used to the hierarchical filesystem display in other operating systems.
Go somewhere else
Now that you know where you are and how to use paths to define where you want to go, it's time to cover the cd
(change directory) command. This command moves you to the specified directory, changing your present working directory location.
For example, to use an absolute path to move to the /etc/ssh
directory, type the following command:
$ cd /etc/ssh
By using the absolute path, it doesn't matter where in the filesystem you currently are.
Take a shortcut
Shortcuts can be handy when it comes to navigation. Linux has been around a long time now (30+ years), and Unix even longer. Over the decades, many shortcuts have been created to make navigation easier. Three of them are:
- Single dot, or
.
- Double dot, or
..
- Tilde, or
~
The single dot represents the present working directory, or where you are right now. Say you're in your home directory and you want to copy the sshd_config
file from /etc/ssh
. You can specify it with just a dot because you're copying the file to your current directory. The command looks like this:
$ sudo cp /etc/ssh/sshd_config .
Double dots represent the parent directory, or the directory immediately above the current one in the filesystem. If there's a subdirectory named Rock
in the Music
directory, then Music
is the parent directory of Rock
. As another example, consider where log files are stored: /var/log
. In that case, var
is the parent directory of log
(and the filesystem root /
is the parent of var
).
So, to move from the current Rock
directory to the Music
directory above it, type:
$ cd ..
This is much quicker than defining the entire absolute path:
cd /home/damon/Music
[ Keep all your essential commands at your fingertips; download the Linux common commands cheat sheet. ]
Similarly, the tilde character ~
represents the current, logged-on user's home directory. To copy the sshd_config
file from /etc/ssh
to your home directory (no matter where in the filesystem I'm presently located), type:
$ cp /etc/ssh/sshd_config ~
Again, quicker than cp /etc/ssh/sshd_config /home/damon
.
The tilde works with the cd
command, too, so you can move to your home directory quickly:
$ cd ~
However, cd
itself assumes your home directory if you don't specify an argument, so you can actually jump home with just cd
by itself.
Know the essentials
Experienced Linux users will find this summary pretty trivial (though you may find some time-saving tricks in fundamentals writeups such as this), but for new Linux users, commands such as these are essential. They cover basic concepts and tasks that we all do daily.
Do you know other critical file navigation tricks and commands? Consider sharing them by writing an article for Enable Sysadmin; for more information or to submit an article, contact the editorial team at enable-sysadmin@redhat.com.
About the author
Damon Garn owns Cogspinner Coaction, LLC, a technical writing, editing, and IT project company based in Colorado Springs, CO. Damon authored many CompTIA Official Instructor and Student Guides (Linux+, Cloud+, Cloud Essentials+, Server+) and developed a broad library of interactive, scored labs. He regularly contributes to Enable Sysadmin, SearchNetworking, and CompTIA article repositories. Damon has 20 years of experience as a technical trainer covering Linux, Windows Server, and security content. He is a former sysadmin for US Figure Skating. He lives in Colorado Springs with his family and is a writer, musician, and amateur genealogist.
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit