---
title: "Part 1 [pwd & cd] - Know your commands"
date: 2019-10-19
url: https://devsv.in/blog/know_your_commands_pwd_cd/
tags: ["linux", "terminal", "knowyourcommands"]
description: "If you are an developer, you are most likely to encounter the terminal with the scary green fonts at least once in your life. This series will act as an beginners guide to all basic linux commands and their usage."
---

# Part 1 [pwd & cd] - Know your commands

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](#pwd)** & **[cd](#cd)** commands.

<br/>

![Shut Up and Take my money meme](https://devsv.in/_astro/shut_up_take_money.7uXl7_1H_2ucOTy.webp)

<br/>

## pwd

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

**Syntax:**

```bash
pwd
```

**Usage:**

```bash
$ pwd
/home/subin
```

---

## cd

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

**Syntax:**

```bash
cd [optional directory path]
```

**Usage:**

- `cd [absolute_path]` - Changes the current working directory to the mentioned absolute path

```bash
$ 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.

```bash
$ 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.

```bash
$ 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

```bash
$ cd /home/subin/Download

$ pwd
/home/subin/Download

$ cd

$ pwd
/home/subin
```

- `cd /` - Changes the current working directory to root directory.

```bash
$ 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.

```bash
$ 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.

```bash
$ 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
- Part 1 - [pwd & cd](https://devsv.in/blog/know_your_commands_pwd_cd/)
- Part 2 - [echo & ls](https://devsv.in/blog/know_your_commands_ls_echo/)
- Part 3 - [touch & mkdir](https://devsv.in/blog/know_your_commands_touch_mkdir/)
* 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
```
