Exploring cd - Linux Commands

| 2 min read

What is the β€˜cd’ Command?

The cd command, an abbreviation for change directory, holds a distinguished position as one of the most fundamental and frequently employed commands in the Linux ecosystem. It serves as the primary means for traversing the intricate directory structure of the Linux file system.

How Does it Work?

cd [Directory]

Directory represents the destination directory you want to navigate to. You can specify either an absolute path or a relative path

  • Absolute Path: An absolute path starts from the root directory (’/’) and specifies the full directory hierarchy leading to the target directory.
  • Relative Path: A relative path, on the other hand, is specified relative to your current working directory.

Moving to a Specific Directory

cd ~/Documents
cd ..
cd /

Returning to the Previous Directory

Let’s illustrate this with an example:

  • Suppose you start in your home directory (/home/user).
  • You navigate to the Documents directory:
cd Documents
# Now you're in /home/user/Documents
  • Then, you decide to move to another directory, let’s say dev:
cd dev
# Now you're in /home/user/Documents/dev
  • If you want to return to the previous directory which is the Documents directory in this case, you can use the cd - command:
cd -

Thank you!

Thank you for your time and for reading this