Back to the command reference

cd

FilesBeginner In simulator In real Linux

Change the current directory

Name: cd = change directory

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

cd is a shell builtin that changes the working directory. It has to be built in, because a child process cannot change its parent shell's directory.

Without an argument it goes to $HOME; cd - returns to the previous directory. The shell updates the PWD and OLDPWD variables as it goes.

Syntax

cd [DIR]

Common options

~Home directory (plain cd goes there too)
..Parent directory
-Previous directory
-PGo to the physical directory (symbolic links resolved)
-LFollow the path as written, symbolic links included (the default)

Examples

  • $ cd projects/web

    Go into a nested directory

    Explain
  • $ cd ..

    Go up one level

    Explain
  • $ cd -

    Jump back to the previous directory

    Explain

Related