Skip to content

Instantly share code, notes, and snippets.

@jhomme

jhomme/blog.md Secret

Created December 8, 2020 11:07
Show Gist options
  • Save jhomme/98a6225ba245f8f42ef123dde499ac6b to your computer and use it in GitHub Desktop.
Save jhomme/98a6225ba245f8f42ef123dde499ac6b to your computer and use it in GitHub Desktop.

How to use the Linux cd command plus essential options

In this installment of "Conquer The Command Line" we talk about how to use the Linux cd command.

Whenever you want to point to a new directory, type cd <directory>, where ` is the directory you want to work with. cd will move you into that directory.

When you use cd to move into a new directory, the prompt may change to reflect that you have done so. You can also use the pwd command to display the directory you have moved to.

Memory Aid: Think "change directory"

Essential Options

I was unable to find any special options for cd, because it is such a simple command. It does as advertized: move you to a new directory.

Special Directory Names

Notice that when I introduced cd, I talked about it with a directory name after it. That's because when you type cd by itself, it moves you to to your home directory. Your home directory is the place where the system keeps the files and directories that belong to you. Linux has some special names for directories. Here are some examples of cd commands that use them:

  • cd ..: move toward the root by one folder. The root is /. For Windows users, think of this as the current drive with no directory name after it.
  • cd ~: go to your home directory, same as cd by itself.
  • cd -1: go to the last directory you were working with.

Linux has another special name for a directory, ., which points to the current directory, but you wouldn'w want to use cd to go there, since you'd already be there.

What Now?

Hopefully this post has helped you take one more step in conquering the command line. I welcome any feedback.

This post was originally written at https://www.jimhomme.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment