With a handful of commands and a trick or two, you can move around the Linux file system with ease and never get lost. Credit: Thinkstock One of the first things Linux users need to learn is how to move around the Linux file system and, eventually, how to make it even easier to move around the file system. This post describes both the basic commands you need and some smart moves to make navigating easier. Absolute and relative paths Before we get moving, it’s important to understand the difference between absolute paths (like /home/jdoe) and relative paths (like images/photos and ..). Absolute paths always begin with a / that, of course, represents the base of the file system. If the specified path doesn’t start with a /, it’s relative. Here are some examples of both relative and absolute paths: /tmp /home/jdoe/poems reports .. . Fortunately, getting back home is about the easiest thing you can ever do. You just type cd (change directory) without any arguments and you’ll end up there. Using pwd No matter where you’re headed, it always helps to know where you’re starting from. The pwd command tells you where you are right now. If you just logged in, that will be your home directory. If you’ve been exploring the file system for a while, it could be anywhere that your user account allows you to go. After all, you can’t enter a directory if you don’t have read access. When you use the pwd command to determine your current location, it will tell you where you are situated in the file system using an absolute path. $ pwd /home/justme/images The only complication is that, if you move into a directory using a symbolic link and ask where you are, cd will show you the location using the link. $ ln -s /tmp/test testdir $ cd testdir $ pwd /home/shs/testdir You can, however, try a command like the one below to see where you really are in the file system: $ pwd /home/shs/testdir $ echo $( dirname $(realpath "symlink") ) /tmp/test Using the tree command To get a bigger picture of where you are at any point in time, you can use the tree command. It will display a multi-level view of the files and directories in your current location, providing you with insights into the directory and its contents. $ tree . ├── bin ├── file1 ├── file2 ├── file3 ├── myfile ├── mypipe0 └── testdir -> /tmp/test Using cd The cd (change directory) command will move you into any directory you ask to move to as long as 1) it exists and 2) you have the execute permission. You can only list files if you have read access. The requested location might be a specific full path, a directory relative to your current location or a location that is pointed to by a symbolic link. Here are some examples: $ cd /tmp $ pwd /tmp $ cd $ pwd /home/justme $ cd .. $ pwd /home Using ~ Another way to move back into your home directory is to type cd ~ and, of course, press return. This works because the ~ (tilde) key represents your home directory. That said, this use of ~ isn’t the only thing it’s good for. You can also use ~ to reference your home directory when you’re somewhere else. Here’s an example: $ pwd /tmp $ cp report ~ This command will copy the file named “report” into your home directory quicker than you could type "/home/justme". Making it easier If there are locations in the file system that you need to move into fairly frequently, don’t sit there typing command like "cd /development/docs/reports" to get there. Instead, create a symbolic link with a command like that shown below to move yourself there faster and more easily. $ ln -s /development/docs/reports ~/reports Afterwards, you can get to the directory by typing “cd reports” (or "cd ~/reports if you're not starting from your home directory) and copy files from it with a command like one of these: $ cp reports/latest . The first command copies the file to your current location. The second copies it to your home directory. You can also use the symbolic link to move into the directory whenever you need to and regardless of where you are: $ cd ~/reports $ ls -ltr | tail -1 -rw-rw----. 1 justme justme 22 Aug 22 11:11 report Wrap-up It’s relatively easy (that’s not meant as a pun!) to move around the Linux file system, but good to know that you don’t need to rely on absolute pathnames to get you where you want to go or to copy files to or from other directories. Related content how-to How to find files on Linux There are many options you can use to find files on Linux, including searching by file name (or partial name), age, owner, group, size, type and inode number. By Sandra Henry Stocker Jun 24, 2024 8 mins Linux opinion Linux in your car: Red Hat’s milestone collaboration with exida With contributions from Red Hat and critical collaborators, the safety and security of automotive vehicles has reached a new level of reliability. By Sandra Henry Stocker Jun 17, 2024 5 mins Linux how-to How to print from the Linux command line: double-sided, landscape and more There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options. By Sandra Henry Stocker Jun 11, 2024 6 mins Linux how-to Converting between uppercase and lowercase on the Linux command line Converting text between uppercase and lowercase can be very tedious, especially when you want to avoid inadvertent misspellings. Fortunately, Linux provides a handful of commands that can make the job very easy. By Sandra Henry Stocker Jun 07, 2024 5 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe