Use the Linux terminal to navigate throughout your computer

Learn to navigate from directory to directory in the Linux terminal.
34 readers like this.
Move around your computer

CC BY-SA Seth Kenlon

To navigate through the directories of your computer in a graphical interface, you're probably used to opening a window to get "into" your computer, and then double-clicking on a folder, and then on a subfolder, and so on. You may also use arrow buttons or keys to back track.


To navigate through your computer in the terminal, you use the

cd command. You can use cd .. to move one directory back, or cd ./path/to/another/folder to jump through many folders into a specific location.

The concept of a URL, which you use on the Internet already, is actually pulled directly from POSIX. When you navigate to a specific page on some website, like http://www.example.com/tutorials/lesson2.html, you are actually changing directory to /var/www/imaginarysite/tutorials/ and opening a file called lesson2.html. Of course, you open it in a web browser, which interprets all that weird-looking HTML code into pretty text and pictures. But the idea is exactly the same.

If you think of your computer as the Internet (or the Internet as a computer, more appropriately), then you can understand how to wander through your folders and files. If you start out in your user folder (your home, or ~ for short) then everywhere you want to go is relative to that:

$ cd ~/Documents
$ pwd
/home/tux/Documents

$ cd ..
$ pwd
/home/tux

This requires some practise, but after a while it becomes far faster than opening and closing windows, clicking on back buttons and folder icons.

Auto-completion with Tab

The Tab key on your keyboard auto-completes names of directories and files you're starting to type. If you're going to cd into ~/Documents, then all you need to type is cd ~/Doc and then press Tab. Your shell auto-completes uments. This isn't just a pleasant convenience, it's also a way to prevent error. If you're pressing Tab and nothing's being auto-completed, then probably the file or directory you think is in a location isn't actually there. Even experienced Linux users try to change directory to a place that doesn't exist in their current location, so use pwd and ls often to confirm you are where you think you are, and that your current directory actually contains the files you think it contains.

What to read next
Seth Kenlon
Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time.

2 Comments

Something else about autocompletion is that if you type

cd E followed by tab, nothing may happen if there is more than one directory starting with E. Tap the Tab key a second time and you will see a display of the possible choices, AND afterward your
cd E comes back for you to finish the command.

cd - (hyphen) is also a quick way to get to the last directory you were in.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.