Skip to content
BENIBIX Learn

cd

Infrastructure⌨️ Linux & the Command LineFiles and Folders

Also known as cd Command, Change Directory, Change Folder

A command that moves you into another folder. Two dots go up one.

Think of it like

Think of it like walking from one room to another. You are now in a new room.

Example

Lucy needs the web server's logs. She types cd /var/log/nginx, then ls to see them.

Why it matters

It is how you get around a server. Almost every task starts with a cd.

Definition

The cd command moves you into another folder. Its name is short for change directory. You type cd and then the path, like cd /var/log. Two dots, .., take you up one folder. The sign ~ takes you home. After cd, every command runs from the new folder.

Example code

console
$ cd /var/log
$ cd ..
$ pwd
/var
Move into the log folder, then up one. Now you are in /var.
Each cd moves the marker to a new folder. The arrow shows one move down the tree.

Common mistake

Forgetting the slash at the start. cd var looks inside the current folder, but cd /var starts from the root.

Key takeaways

  1. 1
    Move in. cd and a path.
  2. 2
    Move up. cd .. goes up one.
  3. 3
    Go home. cd ~ from anywhere.

Learn it properly