Basic Linux Navigation: Using cd, pwd, and ls Safely

Basic Linux Navigation: Using cd, pwd, and ls Safely

If you’ve just logged in to a Linux server and you’re staring at a blinking cursor thinking, “Now what?” — you’re in the right place.

This is for you if you’re new to the command line, running a VPS or small server, and you just want to understand where you are and how to look around without breaking anything.

Good news: the three commands you need to start — pwd, ls, and cd — are simple, powerful, and (used as we’ll use them here) safe.

Step 1: Log in and understand what you’re looking at

First, you need to be logged in to your Linux server.

On most hosts, you’ll get an IP address and a password for your server. Then you connect over SSH from your own computer.

From a terminal on your machine, that usually looks like:

ssh root@your_IP

Replace your_IP with the real server IP address your provider gave you.

Depending on your host, there may also be a web-based console in their control panel. That opens a terminal in your browser connected directly to the server.

Once you’re in, you’ll see a prompt something like this:

root@your_hostname:~#

This line is important:
root is the user you’re logged in as.
your_hostname is your server’s name.
~ means you’re in your home directory.
– The # is the prompt symbol where you type commands.

You are always in some location in the server’s file system. Every command you run that deals with files depends on this current location.

Think of it like a file explorer on your desktop: when you have a folder open, everything you do (copy, delete, open) applies to that folder unless you tell it otherwise.

Step 2: Use pwd to see where you are

First command: pwd.

Type:

pwd

Then press Enter.

pwd means “print working directory”. It tells you the full path of where you are in the file system.

Example output might look like:

/root

That’s the full address of your current directory.

Why this matters: before you run anything that changes files, you should know where you are. If you’re used to clicking around folders, pwd is like looking at the address bar in your file manager.

Use pwd whenever you’re not sure where you are. No harm in running it as often as you like — it only shows information, it doesn’t change anything.

Step 3: Use ls to see what’s in the current folder

Next up: ls.

Type:

ls

Then press Enter.

ls means “list”. It shows the files and folders in your current directory.

This is like opening a folder in your file explorer and seeing what’s inside — names only, nothing changes.

A couple of useful ways to run ls

Again, we’ll keep it simple and safe. Just a few basic variations:

ls      # list items in the current directory

You might see something like:

file1.txt  file2.log  myfolder

Each name is either a file or a folder (directory). For now, just treat them all as “things in this location”.

You can also list another directory without moving into it.

ls /      # list contents of the root (top-level) directory

This is like peeking into another folder without going there.

ls is read-only as we’re using it. You can run it freely without fear of breaking anything.

Step 4: Use cd to move around the file system

Now the fun part: moving around.

cd means “change directory”. It’s like double-clicking a folder in a file explorer.

The general idea:

cd some_folder

That moves you from where you are now into some_folder, if that folder exists.

4.1 Move into a subfolder

Start by listing where you are:

pwd
ls

Look for a folder name in the ls output.

Then:

cd that_folder

After that, confirm:

pwd
ls

This combination (run pwd, ls, then cd, then pwd and ls again) is a good rhythm when you’re learning. It keeps you aware of where you are at all times.

4.2 Go back up one level

To go up one directory (to the parent folder), use:

cd ..

The .. means “the directory above this one”.

Then you can check again:

pwd
ls

Using cd .. a few times from wherever you are will eventually bring you towards the top of the file system.

4.3 Go to your home directory

No matter where you are, you can jump to your home directory with:

cd ~

Then:

pwd

You’ll see the path to your home directory, which is what that ~ in the prompt represents.

This is a useful “safe base” to return to.

4.4 Go to a directory using its full path

Sometimes you want to jump to a directory directly, not step-by-step.

You can do that with an absolute path — the full address starting from the top of the file system.

Example:

cd /var

Then check:

pwd
ls

Any path starting with / is an absolute path from the root of the file system.

Paths without a leading / are relative to where you are right now.

Step 5: Think in paths (like addresses for folders)

Every directory has a path, like an address.

/ is the very top — the root of the file system.

Your home directory has a full path (for example, pwd might show something like /root).

When you use cd, you’re telling the system “move me to this address”.

  • cd foldername → go into a folder inside where I am now.
  • cd .. → go up one level.
  • cd /something → go to /something from the top.
  • cd ~ → go to my home directory.

You can mix these patterns.

The key idea: when you type a path, the shell interprets it based on where you are unless it starts with / or ~.

That’s why it’s good practice to:

  1. Run pwd before doing something important.
  2. Run ls to make sure the folder or file you want is actually there.
  3. Then run your command.

Step 6: Safety basics while you’re learning

Just by using pwd, ls, and cd the way we’re doing here, you’re in very safe territory.

These commands are for navigation and viewing, not for editing or deleting.

Still, a few habits now will save you headaches later when you start doing more:

  • Always confirm your location with pwd before running commands that change files.
  • Use ls first to make sure the file or folder name is correct.
  • Don’t run commands you don’t understand, especially as root.

If you’re experimenting heavily, try things in a test directory inside your home folder instead of system paths.

For example:

cd ~
mkdir test
cd test
pwd

Now you’re in a spot that’s generally safe to play in.

Step 7: Build a simple navigation habit

Let’s put it all together into a small, repeatable flow.

Try this sequence after you log in:

  1. Check where you are:
    bash
    pwd

  2. See what’s there:
    bash
    ls

  3. Pick a folder from the list and move into it:
    bash
    cd folder_name

  4. Confirm again:
    bash
    pwd
    ls

  5. Go back up when needed:
    bash
    cd ..

  6. Return home any time you’re lost:
    bash
    cd ~
    pwd

If you repeat this a few times, your brain will start to map the server layout the same way you know your folders on a desktop.

You don’t have to memorize everything — just remember:

  • pwd = where am I?
  • ls = what’s here?
  • cd = move somewhere else.

Wrap-up

You’ve just covered the three basic tools you need to explore a Linux server from the command line:

  • pwd to see exactly where you are.
  • ls to see what’s in that location.
  • cd to move around between directories.

These are the foundations for everything else you’ll do on a server — editing configs, managing websites, checking logs, all of it.

Once you’re comfortable with pwd, ls, and cd, you’ll feel a lot less lost every time you open a terminal.

If this worked for you, keep CrushEdge handy for the next fix.

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.