Skip to main content

cd command

cd - Change Directory

Changes the shell working directory.

Usage: cd [OPTION]... [dir]

$ cd --help
cd: cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.

Options:
-L force symbolic links to be followed: resolve symbolic
links in DIR after processing instances of `..'
-P use the physical directory structure without following
symbolic links: resolve symbolic links in DIR before
processing instances of `..'
-e if the -P option is supplied, and the current working
directory cannot be determined successfully, exit with
a non-zero status
-@ on systems that support it, present a file with extended
attributes as a directory containing the file attributes

The default is to follow symbolic links, as if `-L' were specified.
`..' is processed by removing the immediately previous pathname component
back to a slash or the beginning of DIR.
  • Change your working directory to Folder1

    username@linux:~/guides$ cd Folder1
    username@linux:~/guides/Folder1$
  • Go back one directory

    username@linux:$ cd ..
    username@linux:~/guides$
  • Go to home directory

    username@linux:~/guides$ cd ~
    username@linux:~$
  • Go to previous directory (in above example case)

    username@linux:~$ cd -
    username@linux:~/guides$