FactorPad
Faster Learning Tutorials

Linux cd command summary with examples

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.
Paul Alan Davis, CFA, October 6, 2016
Updated: July 26, 2018
In this tutorial, 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 Next

~/ home  / tech  / linux essentials  / cd command


The Linux cd command

Beginner

To change directories at the Linux command line.

Video Tutorial

Linux cd command summary with examples (3:39)

Videos can also be accessed from the YouTube Playlist.

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.

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 to be notified about new opportunities to learn.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the cd command, hit Back.
  • To find out why there's no manual page for cd and move on to tutorial #9 on bash, click Next.

~/ home  / tech  / linux essentials  / cd command



 
 
Keywords:
linux cd command
change directories in linux
linux relative path
linux absolute path
linux navigation
linux directory structure
cd linux
unix cd
cd command
cd directory
linux file system structure
linux file structure
linux cd home