If you are an developer, you are most likely to encounter the terminal with the scary green fonts at least once in your life.

Having a basic understanding on Linux CLI commands will allow any user to navigate around the Linux with ease. This series will act as an beginners guide to all basic linux commands and their usage.

This post will focus on pwd & cd commands.

Shut Up and Take my money meme

pwd

pwd stands for Print Working Directory. It prints the path of the current working directory, starting from the root.

Syntax:

pwd

Usage:

$ pwd
/home/subin

cd

cd stands for Change Directory. This command is used to change the current working directory.

Syntax:

cd [optional directory path]

Usage:

  • cd [absolute_path] - Changes the current working directory to the mentioned absolute path
$ pwd
/home/subin

$ cd /home/subin/Download

$ pwd
/home/subin/Download
  • cd [relative_path] - Changes the current working directory to the path relative to the current directory.
$ pwd
/home/subin

$ cd Download

$ pwd
/home/subin/Download
  • cd ~ - Changes the current working directory to the user home directory which is /home/subin in my case.
$ cd /home/subin/Download

$ pwd
/home/subin/Download

$ cd ~

$ pwd
/home/subin

$ cd ~/Documents

$ pwd
/home/subin/Documents
  • cd - Works similar to cd ~, changes the current working directory to the user home directory
$ cd /home/subin/Download

$ pwd
/home/subin/Download

$ cd

$ pwd
/home/subin
  • cd / - Changes the current working directory to root directory.
$ pwd
/home/subin

$ cd /

$ pwd
/
  • cd .. - This command is used to move one level up from the current directory, or to move to the parent directory of current directory.
$ pwd
/home/subin

$ cd ~/Downloads/movie

$ pwd
/home/subin/Downloads/movie

$ cd ..

$ pwd
/home/subin/Downloads

$ cd ../Documents

$ pwd
/home/subin/Documents
  • cd - - This command takes you back to the previous working directory.
$ pwd
/home/subin

$ cd ~/Downloads/movie

$ pwd
/home/subin/Downloads/movie

$ cd ~

$ pwd
/home/subin

$ cd -

$ pwd
/home/subin/Downloads/movie

All Parts of this series

  • More comming soon.

Note: All examples above are based on below imaginary directory structure.

.
├── home
│   └── subin
│       ├── .bashrc
│       ├── .config
│       ├── Downloads
│       │   └── movie
│       │       └── some_movie.mp4
│       ├── Desktop
│       ├── Documents
│       │   └── test_doc.txt
│       ├── Music
│       └── Pictures
├── lib
├── opt
└── tmp