Chapter 2. Linux Key Commands

Cd (Change Directory)

Cd (Change Directory)
Tag:

The cd (Change Directory) command is used to change the working directory. On the GUI, you can use your mouse to select a directory or file through Finder on Mac or Explorer on Windows. On the CUI, you need to use your keyboard to move your Working Directory to a different location with the cd command.

Special Characters to specify directories

Before explaining the cd command syntax, it is important to learn some special characters used for specifying certain directories.

cd-Change-Directory

  • / (slash): root directory
  • . (dot): working directory
  • .. (double dot): parent directory
  • ~ (tilde): user's home directory

The cd command

As you can see below, the command syntax is simple. You can use both an absolute path and a relative path to specify the directory path.

Command Line - INPUT
cd [directory path]

Here are some examples of the cd command

To go to the root directory

Command Line - INPUT
cd /

To go to the parent directory

Command Line - INPUT
cd ..

To go to the home directory

Command Line - INPUT
cd ~

If you don't add a directory path, your working directory goes to the home directory as well.

Command Line - INPUT
cd

To go to the child directory named directory_a

Command Line - INPUT
cd directory_a

The cd (Change Directory) command is used to change the working directory. On the GUI, you can use your mouse to select a directory or file through Finder on Mac or Explorer on Windows. On the CUI, you need to use your keyboard to move your Working Directory to a different location with the cd command.

Special Characters to specify directories

Before explaining the cd command syntax, it is important to learn some special characters used for specifying certain directories.

cd-Change-Directory

  • / (slash): root directory
  • . (dot): working directory
  • .. (double dot): parent directory
  • ~ (tilde): user's home directory

The cd command

As you can see below, the command syntax is simple. You can use both an absolute path and a relative path to specify the directory path.

Command Line - INPUT
cd [directory path]

Here are some examples of the cd command

To go to the root directory

Command Line - INPUT
cd /

To go to the parent directory

Command Line - INPUT
cd ..

To go to the home directory

Command Line - INPUT
cd ~

If you don't add a directory path, your working directory goes to the home directory as well.

Command Line - INPUT
cd

To go to the child directory named directory_a

Command Line - INPUT
cd directory_a
Tag: