Centos 7 change directory commands

Published: December 1, 2025 (Updated: Dec 1, 2025)

Enjoying this content? Subscribe to the Channel!

Linux File System Fundamentals: Essential Navigation Commands You Must Know


Welcome back to Darren’s Tech Tutorials!

If you’re serious about using Linux, whether it’s for servers, development, or just everyday computing, the very first skill you need to master is navigation. Think of the Linux command line as a powerful car, and the navigation commands as your steering wheel. Without them, you’re stuck in the garage!

In this comprehensive guide, we are going deep into the terminal to cover the fundamental commands required to move efficiently through the Linux file system. While this tutorial uses CentOS 7, these commands are completely universal across virtually all Linux distributions, including Ubuntu, Fedora, and Debian.

Let’s get started and learn how to master movement in the terminal!

Knowing Where You Are: The pwd Command

Before you start moving, you always need to know your starting point. That’s where the pwd command comes in.

The pwd command stands for Print Working Directory. It simply outputs the full absolute path of the directory you are currently sitting in. This is your anchor point in the file system.

How to Use pwd

Using it couldn’t be simpler:

pwd

Example Output:

/home/darren

This output confirms that your current location is the ‘darren’ directory inside the ‘home’ directory. Getting into the habit of running pwd frequently will prevent you from getting lost during complex operations.

Mastering Movement: The cd (Change Directory) Command

The cd command is the workhorse of file system navigation. It allows you to change your current location (your working directory) to any other directory on the system.

1. Moving to Specific Directories (Absolute Paths)

An absolute path starts from the root of the file system (/). No matter where you are currently located, using an absolute path will take you precisely where you intend to go.

# Move directly to the system configuration directory
cd /etc

2. Moving Within Your Current Path (Relative Paths)

A relative path is defined relative to where you currently are. If you are in /home/darren and you want to move into a directory called Documents inside your current location, you simply type:

cd Documents

You do not need to type /home/darren/Documents.

3. Jumping Back Up One Level

To move up one directory level (the parent directory), use the special notation .. (dot dot).

If you are in /home/darren/Documents, running this command will take you back to /home/darren:

cd ..

4. Returning Home Quickly

The home directory is where most of your personal work resides (/home/username). You can instantly return to your home directory from anywhere on the system using two quick shortcuts:

# Shortcut 1: Just 'cd' alone
cd

# Shortcut 2: Using the tilde (~)
cd ~

Seeing What’s Inside: The Power of ls

Once you arrive at a new location, how do you know what files and subdirectories are available? That’s the job of the ls command (short for list).

Running ls by itself will display the contents of the current working directory in a simple, organized column format.

Essential ls Options (Flags)

To make ls truly useful, you need to use flags (or options). These provide much more detail about the files and their permissions.

Option Meaning Example Use
-l Provides a long listing format, showing detailed information like permissions, owner, group, size, and modification date. ls -l
-a Lists all files, including hidden files (which start with a dot, like .bashrc). ls -a
-la A highly popular combination that provides a long listing of all files, including hidden ones. ls -la

We highly recommend getting into the habit of using ls -la frequently, as it gives you the complete picture of any directory’s contents.

Switch Quickly: The cd - Shortcut

If you’ve been navigating a complex directory structure, you often find yourself needing to jump back and forth between two specific directories. Instead of typing out the full path or relying on multiple cd .. commands, Linux offers a fantastic shortcut: cd - (change directory hyphen).

The cd - command allows you to switch quickly between the current and previous directory.

How the Shortcut Works

  1. You are in /etc/httpd.
  2. You run cd /var/log.
  3. You run cd -. You are instantly back in /etc/httpd.
  4. You run cd - again. You are instantly back in /var/log.

This simple command can save countless keystrokes and significantly speed up your workflow!

Summary and Next Steps

Congratulations! You now have the essential toolkit necessary to move around the Linux file system like a professional. You’ve mastered:

  • pwd: To confirm your current location.
  • cd: To change your working directory.
  • ls: To view the contents of any directory.
  • cd -: To quickly toggle between two locations.

These commands are the absolute foundation of Linux usage. I highly encourage you to open your terminal right now and start practicing these movements until they become second nature.

To follow along with these and other tutorials, remember that we used the CentOS 7 operating system. If you haven’t installed it yet, you can follow my installation guide here: https://youtu.be/qZXZepdUjRI

You can also find a handy cheat sheet with all the commands discussed in this tutorial on my website: http://darrenoneill.eu/?p=335

If you found this tutorial helpful, be sure to hit the like button, share this post, and subscribe to Darren’s Tech Tutorials for more clear and accessible technology guides! Happy navigating!