Cheatsheets
HomeWriteupsResourcesCheatsheets
Linux
Linux
  • Know Yourself and Your System
    • id
    • logname
    • uname
    • w
    • who
    • whoami
  • Surfing / Knowing Your File System
    • cd
    • df
    • du
    • ls
    • pwd
    • stat
    • tree
  • Knowing About Files / Commands
    • alias
    • file
    • info
    • whatis
    • apropos
    • man
    • help
    • history
    • script
  • Manipulating Files / Directories
    • touch
    • mkdir
    • rm
    • rmdir
    • cp
    • mv
    • ln
  • Interacting with Files
    • cat
    • head
    • less
    • middle
    • more
    • tail
  • STROPS / Text Manipulation
    • awk
    • cut
    • grep
    • jq
    • join
    • paste
    • sed
    • sort
    • tr
    • uniq
    • xargs
    • xclip
    • wc
    • tee
    • echo
    • comm
    • diff
    • patch
    • aspell
    • Combos
  • Formatting the Output
    • nl
    • fold
    • fmt
    • pr
    • printf
  • Searching / Finding
    • find
    • locate
    • which
    • whereis
    • type
  • Web Interaction
    • curl
    • wget
  • xxd
  • References
Powered by GitBook
On this page
  • Introduction
  • Syntax
  • Important Flags
  • Examples

Was this helpful?

  1. Surfing / Knowing Your File System

cd

cd linux command cheatsheet by Thamizhiniyan C S

Introduction

This command is used to change the current working directory.


Syntax

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


Important Flags

Flag
Description

-L

Force symbolic links to be followed.

-P

Use the physical directory structure without following symbolic links.

-e

Exit with a non-zero status if the current directory can't be determined (when using -P).

-@

Show a file with extended attributes as a directory containing the attributes.

The default behaviour of the cd command 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.


Examples

Command
Description

Move inside a subdirectory in Linux. Replace `[directory_name]` with the desired directory.

Change the directory to the root directory using `/` as an argument.

Change the directory to the home directory from any location in the Linux System.

Change back to the default working directory. No arguments needed.

Move to the parent directory or one level up from the current directory.

Change to a new directory and list its contents simultaneously.

Change to a new working directory.

Return to the previous working directory.

Change to another user's Home directory.

Change to a directory with spaces in the name using single quotation marks.

Change to a directory with spaces in the name using backslashes.

PreviouswhoamiNextdf

Last updated 12 months ago

Was this helpful?

cd [directory_name]
cd /
cd ~
cd
cd ..
cd [path to directory] && ls
cd [path to directory]
cd -
cd ~[username]
cd 'Directory name with blank spaces'
cd Directory\ name\ with\ blank\ spaces