Home

cd

cd stands for change directory and is a command used to switch the shell’s current working directory. In most Unix-like shells it is a builtin; it is not a separate program. Its primary purpose is to update the shell’s working directory for subsequent commands.

Its syntax is simple: cd [directory]. If directory is omitted, the command changes to the user’s home

The command typically updates environment variables such as PWD to reflect the new working directory, and OLDPWD

Cross-platform notes: in Windows, the equivalent functionality is provided by the built-in cd command in Command

Historically, cd has been a core feature of Unix shells since early implementations and remains a fundamental

directory.
If
a
dash
is
supplied
(cd
-),
it
returns
to
the
previous
directory
in
many
Unix-like
shells.
Paths
can
be
absolute
or
relative.
Relative
paths
start
from
the
current
directory,
while
absolute
paths
begin
at
the
filesystem
root.
Many
shells
support
tilde
expansion,
so
cd
~/projects
goes
to
the
projects
folder
in
the
home
directory.
stores
the
previous
one.
The
exact
expansion
rules
and
behavior
can
vary
by
shell,
so
users
should
consult
their
shell’s
documentation
for
specifics.
Prompt
and
by
Set-Location
in
PowerShell.
Windows
paths
use
backslashes
and
may
require
additional
options
to
change
drives
(for
example,
/d
in
some
contexts).
In
PowerShell,
cd
is
an
alias
for
Set-Location
and
generally
supports
similar
navigation
semantics.
command
for
navigating
the
filesystem.
It
is
commonly
used
together
with
commands
such
as
pwd,
pushd,
and
popd
to
manage
directory
context.