Beginner Package: bash builtin

cd

Change the current working directory.

Syntax

cd [directory]

Description

cd is a shell builtin that moves you to a different directory. Run with no arguments it returns you to your home directory, and cd - returns you to the previous directory you were in.

Examples

cd /var/log
Move into a specific directory
cd
Return to your home directory
cd -
Jump back to the previous directory
cd ..
Move up one directory level

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux

Put it into practice

Learn this in context