Post

Navigating the File System in Bash

Commands you will learn:

  • pwd
  • ls
  • cd

PWD

To find out where we are in the command line, we run pwd. pwd means: Print Working Directory, this basically meanse it will tell us the directory we are working in. On a macOS Computer, this command returns something like this:

1
/Users/<your name>

Everyone gets a different output because not everyone has the same username.

LS

Now that we know where we are, let’s find out what is in the directory we’re working in. To do that, run: ls The command output can look something like this.

1
Desktop      Documents    Downloads    exam2023.pdf meme.png

It will list all the files and directories in the directory we are working in.

CD

Now that we know where we are, and what is around us, let’s move into one of those directories. Let’s move into the Downloads directory. We would run: cd Downloads. This moves us into our desired directory.

To move back a directory, we would run: cd ..

Imagine we want to move back all the way into the home directory, we would run: cd .

Make sure your command is cd and not cd

This post is licensed under CC BY 4.0 by the author.