Linux Commands You Need to know Part 1: Navigation
Tags: tutorial, linux, learning, beginners
Published: 2022-04-06 17:36:21

---
title: "Linux Commands You Need to know Part 1: Navigation"
published: true
description: "Getting started with Linux? In this series we're going to learn helpful Linux commands so you're not lost at the command prompt. We'll start with navigation."
tags: tutorial, linux, learning, beginners
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxjwawhhndzrqdpv0ni2.jpg
canonical_url: https://www.allhandsontech.com/linux/linux-commands-navigation/
series: Learning the Linux Command Line
---

The command prompt in Linux can be intimidating. It's one of the reasons many people avoid trying Linux if they come from a Windows or Mac environment. For years you had to know the command prompt very well to use Linux, so many people avoided it.

This series will tackle the mystery of the command prompt, and help you learn how to use Linux better and faster.

Popular Linux distributions like [Ubuntu](https://ubuntu.com/download), [Pop!_OS](https://pop.system76.com), [Fedora](https://getfedora.org/en/workstation/download/), etc., are very graphical. You don't have to do much with the command prompt to use Linux. However, it's still a valuable skill to have, especially if you're developing software or websites in Linux. In this series, we will dive into Linux commands, how they are used, and why we use them.

If you can't navigate around the file system, you can't do much. So in part one of this series, we'll learn how to explore the file system from the prompt.

Here is a typical file system in Linux:

!["Helpful Linux Commands"][0]

You'll notice it looks a lot like Windows and Mac. However, if you notice at the top where it says `/home/jeremy`, there is a file structure there, and that's what we're going to explore. Note that in Linux, we usually call folders "directories." They're the same concept, but it can be confusing at first.

Let's dive into some well known commands for navigation.

We will learn:

- How to <a href="#pwd">tell where you are in the filesystem</a>
- <a href="#cd">Change your location</a>
- <a href="#ls">Show the objects in a directory</a>
- <a href="#home">Return to your home folder</a>
- <a href="#tree">Visualize the file system</a>

---
<h2 id="pwd">1. pwd</h2>

#### _Purpose: to show where you are located on the filesystem_

This stands for "print working directory," it tells you where you're at on the file system. It's handy because it's easy to get "lost" on the file system.

usage:

`pwd`

When I run pwd on my machine, it shows I'm in /home/jeremy:

!["Helpful Linux Commands"][1]

---
<h2 id="cd"> 2. cd</h2>

#### _Purpose: to navigate the file system_

This stands for "change directory," and it allows you to navigate.

usage

`cd (name of the directory you want to go to)`

Now this one has more than a few interesting options.

You can go into the next folder up by typing its name.

`cd [name of directory]`

So if I'm in `/home/jeremy` and I want to go to `games` I would just type in `cd games`.

!["Helpful Linux Commands"][2]


That's a *relative* path. If I want to do an *absolute* path, I will type in `cd /home/jeremy/games`.

Now I'm in that directory. What if I want to go directly to my Go bin folder? I would type in

`cd /usr/local/go/bin`

and you'll move directly to that folder:

!["Helpful Linux Commands"][3]

You can cd into a directory above where you are, or explicitly.

You can also go down one directory by typing

`cd ..`

If you want to go down two directories, you can do that too.

So let's say you're in `/usr/local/go/bin` and you want to go to `/usr/local` you would type:

`cd ../..`

!["Helpful Linux Commands"][4]

And there you have it! `cd` is a great navigation tool.

---
<h2 id="ls">3. ls</h2>

#### _Purpose: to list the objects in a directory_

The `ls` command lists all the objects in a directory. So, we're in our `/usr/local` directory. If we type in `ls` we'll see this:


!["Helpful Linux Commands"][5]

This isn't super helpful. I prefer something like `ls -la` which shows "all" of the information about the objects:

!["Helpful Linux Commands"][6]

If you want to show what's in the directories as well, type `ls -R`

!["Helpful Linux Commands"][7]

If you want to search for a specific file name or extension, use the `*` symbol. Let's say I want to find every .toml file in my directory.

I type in `ls -la *.toml`. The asterisk means "everything that has .toml" at the end:

!["Helpful Linux Commands"][8]

Or, we can look for "every file with the name staging in it" by typing `ls -la *staging*`

!["Helpful Linux Commands"][9]

ls is a simple command that can be very powerful.

---
<h2 id="home">4. ~</h2>

Ok, so `~` isn't a command, but something you append to commands. It simply means "home".

if you type in `cd ~` it will take you to your home directory:

!["Helpful Linux Commands"][10]

Not only that, you can create directories using ~ as a shortcut for home. You can navigate to directories under your home directory with ease.

Let's say I'm in /etc/X11/init and doing some work. But I want to get to a specific directory in my home directory.

Instead of typing out `cd /home/jeremy/repos/JeremyMorganDotCom`,

I can type `cd ~/repos/JeremyMorganDotCom` as a shortcut.

!["Helpful Linux Commands"][11]

This may seem like a small thing but can add up to big savings once you get into the habit of using it.

---
<h2 id="tree">5. tree</h2>

Tree is a helpful command for visualizing a file system. As a note: this command doesn't come with all Linux distributions. You may need to install it. It's a great way of visualizing the directory layout in the filesystem where you're at. Here's an example in a repository of one of my projects.

To use it, you type:

`tree`

!["Helpful Linux Commands"][12]

I haven't used this one as much, but it can be helpful for confusing filesystem layouts.

## Conclusion

Here are the typical commands for navigating in Linux. I encourage you to try them out and get comfortable with moving around. If you haven't installed Linux yet, you can still get some practice doing this. Here are some options so you can try it out on your Windows or Mac machine:

1. Open [Terminal](https://support.apple.com/guide/terminal/open-or-quit-terminal-apd5265185d-f365-44cb-8b09-71a064a42125/mac) on your Mac. It's the same commands.
2. Install [WSL](https://docs.microsoft.com/en-us/windows/wsl/install) (Windows Subsystem for Linux) and get a Linux installation within Windows.
3. Use [Virtualbox](https://www.virtualbox.org/wiki/Downloads) and create a virtual Linux installation

These are some ways you can try out Linux virtually risk-free. If you've already been bitten by the Linux bug, start expanding your skills with our [Linux Fundamentals Path](https://www.pluralsight.com/paths/skill/linux-fundamentals-1?utm_source=allhandsontech&utm_medium=organic-web&utm_campaign=allhandsontech) where you can advance your Linux skills quickly.

You can test your Linux skills to see where you're at:

!["Helpful Linux Commands"][13]

I scored a 203, so I still have some room to grow. What's your score? [Take your SkillIQ now.](https://www.pluralsight.com/redeemlink/genericV4?redemptionId=7a28c861-d736-41d3-842a-28a97d8e5714&mac=368c7cca1cac8158bae0da91fa137b5d01891402f7f7119a10a6a8be938da98a&utm_source=allhandsontech&utm_medium=organic-web&utm_campaign=allhandsontech)

Have any questions? Comments? [Let me know!](https://www.twitter.com/jeremycmorgan)

--Jeremy




[0]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cty38bvimq4mqf4bovge.png
[1]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1mb5z3x9ox6prwswzrch.png
[2]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrubfmlionmhh864wfbq.png
[3]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3mvneh3yjur292ww9ppg.png
[4]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mn7v3xjig50cmnjj0yxg.png
[5]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7n8cfidchy04le54pwm.png
[6]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1zp23ybh8q96epnsux2.png
[7]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnlk1buzwggq4zz9wehb.png
[8]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tzlc4iy5ga90ocjd12q.png
[9]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60cwnw8n1pvq6ziort8n.png
[10]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pzx2nakzwiud1xa4vuh.png
[11]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zg0envv2zhrd6tye2nf3.png
[12]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oxnm3on7nb17intsp2b2.png
[13]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grm7kskbaqb6qxsxp913.png