Korean

cd — Linux basic command

Linux / Basic Linux commands / cd.html

Basic Linux commandsOriginalRegistered 2026-10-19T09:00:00+09:00

A command to change the current working directory to another directory.

Basic Information

Command Namecd (change directory)
One-line IntroductionA command to change the current working directory to another directory.
ProvidedBash/Zsh shell built-in command (included by default in all Linux distributions)
Official Documentationhttps://man7.org/linux/man-pages/man1/cd.1p.html
Supported Operating SystemsLinux, macOS, BSD, WSL (shell built-in)
InstallationIncluded by default (no separate installation required)
ClassificationLinux basic command (tags: directory navigation, shell, Linux, basic)

What is this command?

cd is short for change directory, a shell built-in command that moves the current working directory to another location. It is a core tool for Linux file navigation.

It supports both relative and absolute paths, and you can use special symbols like ~ (home), - (previous directory), and .. (parent).

What problems does it solve?

  • Navigate to and work in other directories.
  • Quickly return to the previous directory.
  • Move to the home directory.
  • Move to the parent directory.

Key Features

Absolute Path Navigation

Move to a full path starting with /.

  • Usage Scenario: When you know the exact location.
  • Result Obtained: Move to the same path from anywhere.
  • Limitations: You must know the exact path.

Relative Path Navigation

Use paths relative to the current location.

  • Usage Scenario: When exploring around the current directory.
  • Result Obtained: Move quickly with shorter paths.
  • Limitations: You must know the current location for correct operation.

Special Symbols (~, -, ..)

~ indicates home, - indicates previous directory, and .. indicates parent directory.

  • Usage Scenario: When quickly moving to frequently visited locations.
  • Result Obtained: Reduce typing and move quickly.
  • Limitations: - may behave differently depending on the shell.

PROMPT Directory Display

After navigation, the current directory is displayed in the shell prompt.

  • Usage Scenario: When working while continuously checking the current location.
  • Result Obtained: Never lose track of your working location.
  • Limitations: The display method varies based on prompt settings.

Installation and Execution

Verify Default Installation

It is built into all shells.

# cd is a shell built-in command
type cd

# Result: cd is a shell builtin

Set Directory Display in Shell Prompt

Configure the prompt to display the current directory.

# Add to ~/.bashrc
export PS1='\u@\h:\w\$ '

# Apply changes
source ~/.bashrc

Practical Usage Examples

Basic Navigation

Navigate directories using absolute and relative paths.

# Absolute path navigation
cd /var/log

# Relative path navigation
cd ../documents

# Move to home directory
cd ~
# or
cd

Using Special Symbols

Quickly move using ~, -, .. symbols.

# Home directory
cd ~

# Return to previous directory
cd -

# Parent directory
cd ..

# Current directory (do nothing)
cd .

Abbreviated Directory Names

Navigate using only the unique leading characters recognized by the shell.

# To move to /var/log
# Assuming there are logs and log under /var
cd /var/lo    # Auto-complete to select /var/log

# Auto-complete with Tab key
cd /var/TAB