7 Must Know Terminal Commands
Tags: linux, mac, windows, terminal
Published: 2020-07-15 15:10:40

{% youtube y4JoGfvFz-g %}

If you want to get into Software Development, one thing you should know is **_how to use Terminal?_** 
Yes, it could be Mac's Terminal, Linux's Terminal, or Windows terminal(not exactly, but run Git Shell or Cmder on Windows).
Don't worry I have your back here, just follow this article, and trust me, you'll thank me later for reading this post.

First of all, lets understand what is terminal?

# What is Terminal?
Terminal is a program on your Operating system which lets you navigate throughout your computer’s folders and files, most importantly runs commands to help you perform your task. 

# Open Terminal
First and foremost, we need to open Terminal, it could be different depending on your OS, and here I trust you, you can open Terminal. 

Okay, need help, please follow the below steps depending on you OS:

If you are on a Mac, hit "command + space bar" and you’ll get the computer’s "Search" bar. Once that pops up, type in "Terminal" and hit "Enter".
**Mac's Terminal**
![Mac Terminal](https://dev-to-uploads.s3.amazonaws.com/i/dy4b9xv5ows7itwdqsut.png)

If you are on Linux, hit "The Windows logo key" (also known as Windows-, win-, start-, logo-, flag-, or super- key) and type "Terminal" and open the program by clicking on it.
**Linux Terminal**
![Linux Terminal](https://dev-to-uploads.s3.amazonaws.com/i/frkpbuehly9z4cguglti.png)

If you are on Windows, search "Git Shell" or "Cmder" depending on what you have installed.
**Cmder Terminal on Windows**
![Cmder Terminal on Windows](https://dev-to-uploads.s3.amazonaws.com/i/iuwho861c356vsfcci66.png)

# Must know Terminal Commands

1. `pwd`
2. `cd`
3. `ls`
4. `mkdir`
5. `touch`
6. `clear`
7. `man`

And stay away from `rm`, but here I'll teach you how to master that command and use only when really needed.

## 1 `pwd` 

The `pwd` command, stands for "Print Working Directory" You type in that command on terminal, and it will print out the exact file path for the file or folder you are in.
![pwd](https://dev-to-uploads.s3.amazonaws.com/i/aa5ajq60iyrzeq43r9hw.png)

## 2 `cd`

The `cd` command, stands for "Change Directory". There are multiple ways you could use `cd` commands. Here are those:
* `cd` or `cd ~`: Will take us to the Home directory.
* `cd ..`: Will move us back to the parent folder.
* `cd ../test`: Will move us back and take us to `test` folder.
* `cd <folder name>`: Will take us to the `<folder name>` folder.
![cd](https://dev-to-uploads.s3.amazonaws.com/i/0bp8qovapk92gmkoup8f.png)

## 3 `ls`

The `ls` command is the list command, it shows what's present in a folder/directory. Again, `ls` could be used in many ways. Here are few which you might want to use:
* `ls`: it will show us everything in that folder.
* `ls -a`: it will show the hidden files along with the other listed previously.
* `ls -l`: it will display in a long listing format
![ls](https://dev-to-uploads.s3.amazonaws.com/i/pgdpg2d1uc57bqyhuiwd.png)

## 4 `mkdir`

The `mkdir` command, stands for "Make Directory". It will create the new folder/directory in that place from where it is run. So always check whether you are at right place using `pwd`.
![mkdir](https://dev-to-uploads.s3.amazonaws.com/i/jnyxaojptk9rh5x1phwd.png)

## 5 `touch`

The `touch` command is for creating file, there are multiple ways you can create a file. But `touch` is an easiest. Here's how
![touch](https://dev-to-uploads.s3.amazonaws.com/i/maznpe2ob6ibmqzs7ppr.png)

## 6 `clear`

The `clear` command does what the name say, it "clears" your terminal. It's always a good practice to work in a neat and clean environment.
Once run, the terminal would look like
![clean terminal](https://dev-to-uploads.s3.amazonaws.com/i/vylj9ctuxu9piwprqo5a.png)

Or you can use Keyboard shortcut for this, `Ctrl + L` it is faster on most of the terminals.

## 7 `man`

The `man` command, is an interface to the system reference manuals, this is something which you should use to understand how a command works and what parameters to be used to get the best out of that command. And to be a master of terminal, always refer to this command.
![man ls](https://dev-to-uploads.s3.amazonaws.com/i/51tsnjo8y12xkysinxg1.png)
![man ls description](https://dev-to-uploads.s3.amazonaws.com/i/p8yj1y346nl9iuovdlb4.png)

Now, as said, **STAY AWAY FROM `rm` COMMAND**

So, here are a few ways you can use `rm` in necessary situations.
* `rm <filename>`: Remove(Delete) the file.
* `rm -i <filename>`: It will ask before deleting a file. Remember to use `-i`, so it gives you some time to double-check before deleting. `rm -i` will ask before deleting each file.
* `rm -r <foldername>`: It will recursively delete a directory and all its contents. (normally rm will not delete directories, while `rmdir` will only delete empty directories)
* `rm -f`: this will forcibly delete files without asking; this is mostly useful if you have rm aliased to `rm -i` but want to delete lots of files without confirming each one.

Deadliest combination **`rm -rf <foldername>`**. Always avoid this command, and never run as `root` user.

With these terminal commands, you are good to go and get ready to explore the learning paths.

Here's a [diagram](bit.ly/3gPAOYH), which shows what are the paths one could take in `Computer Science`.

And at last, keep learning, keep sharing.