FactorPad
Build a Better Process

Linux cd Command Summary with Examples

Linux cd allows you to change the current directory.
  1. Purpose - Learn what cd is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with cd.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 23, 2021
In this tutorial on Linux cd, 8 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / cd-command.html


An ad-free and cookie-free website.


Examples of the Linux cd command

Beginner

To change directories at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux cd Command Summary with Examples (3:39)

Video Script

The Command and Why You Need It

Our eighth word, or command to memorize is cd from the category Navigation.

cd allows you to change the current directory. In our last two videos we used pwd to print the working directory, then ls to list files, now it's time for a command to explore Linux directories.

Common Linux cd Options
-options description
Options are infrequent

It may help to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The cd command has only 3 options and the interesting stuff is in the arguments, so we'll spend more time in the terminal.

Before that, note, there are absolute and relative references. Absolute means you use cd to change directories from the root, and relative means you change directories from where you sit.

So why is cd an important command? Well, cd is the main command for moving around. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows 10.

Here we go, start with pwd to find out where you are currently.

$ pwd /home/paul

Next, let's try an absolute reference. Type cd /bin and try the ls from video 7 and see if any files look familiar.

$ cd /bin $ pwd /bin $ ls

Now, to use cd for relative path changes just know that one dot . means the current directory and two dots .. means one directory above. So if we do cd .. and cd .., where does that take you? To the root.

$ cd /home/paul $ pwd /home/paul $ cd .. $ cd .. $ pwd /

And last, because we only have time to scratch the surface with cd here, in the description below please find a link to the Linux Cheat Sheet, that supplements this series. There you will find a description of about 20 standard directories on most Linux distributions. As homework, please use this to navigate around.

A Final Tip

Okay now you know how to use cd. And you know the syntax for commands, options and arguments.

One last tip about the cd command. If you can't find a tidy help manual for cd, which is common, we'll help you in our next video.

Okay, thanks for visiting today. I hope this was a fun introduction to the cd command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Subscribe at YouTube and follow @factorpad to be notified about new opportunities to learn.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / cd-command.html


linux cd command
linux cd examples
cd linux
unix cd
linux change directory
cd unix
cd linux options
cd directory
linux command cd
cd home
linux directory structure
linux file system structure
linux file system
linux file structure

A newly-updated free resource. Connect and refer a friend today.