LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

cd

change the current working directory

TLDR

Change to directory
$ cd [/path/to/directory]
copy
Go to home directory
$ cd
copy
Go to previous directory
$ cd -
copy
Go up one directory
$ cd ..
copy
Go up two directories
$ cd ../..
copy

SYNOPSIS

cd [-L|-P [-e] [-@]] [directory]

DESCRIPTION

cd (change directory) is a shell built-in command that changes the current working directory. It updates the shell's current directory and the PWD environment variable.The command is fundamental for navigating the filesystem in shell sessions.

PARAMETERS

directory

Path to change to (default: $HOME)
-
Change to previous directory (OLDPWD)
-L
Follow symbolic links (default)
-P
Use physical directory structure (don't follow symlinks)
-e
With -P, exit with error if the current directory cannot be determined
-@
Present extended attributes as a directory (on supported systems)

SPECIAL DIRECTORIES

~

Home directory ($HOME)
~user
Specified user's home directory
.
Current directory
..
Parent directory
-
Previous directory

ENVIRONMENT VARIABLES

PWD

Current working directory
OLDPWD
Previous working directory
HOME
User's home directory
CDPATH
Search path for cd command

INSTALL

sudo apk add execline
copy
brew install execline
copy
nix profile install nixpkgs#execline
copy

CAVEATS

Shell built-in (behavior varies by shell). Spaces in paths need quoting. Symbolic links can be confusing (-P vs -L). No cd command history by default. Cannot cd to files, only directories.

HISTORY

cd has been a shell built-in command since the earliest Unix shells in the 1970s, essential for directory navigation.

SEE ALSO

pwd(1), pushd(1), popd(1), dirs(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid