# Git 101: Shell Commands Mastery

# Why learn Shell commands ?

* Shell commands allows for faster execution of tasks, more flexibility, portability, consistency, debugging and better version control.
    
* It is a valuable skill for developers, especially those who work on the command line or in a CI/CD environment.
    

# Let's start 🚀

The directory (folder) structure I am using in this demonstration is as shown below.

```bash
--> interests   
    |
    --> web-series
    |        -> breaking-bad.txt
    |        -> dark.txt
    |        -> wednesday.txt
    --> anime 
    |        -> naruto
    |        -> one-punch-man.txt
    |        -> .hidden-file
    --> movies
    |         --> fictional
    |           |     -> avengers-endgame.txt
    |           |     -> tenet.txt
    |         --> action
    |           |     -> rrr.txt
    |           |     -> black-adam.txt
```

If you want to follow along with the me, download the Shell Script code here: [https://drive.google.com/file/d/1WBlP7DNVG3LIRQzsbRf6UNbLA8blu6QB/view?usp=sharing](https://drive.google.com/file/d/1WBlP7DNVG3LIRQzsbRf6UNbLA8blu6QB/view?usp=sharing)

```bash
# FOR THOSE WHO ARE FOLLOWING HANDS ON    

# check if the file is downloaded and code exists
# cat command is used to display the contents of the file
cat script.sh 
bash script.sh
cd ./interests
# you are now inside "interests" directory
# You are ready to continue with hands-on
```

## cd

This command is used to navigate between the directories, back and forth.

**Case 1:** You are in "/interests" directory and you want to move inside "/anime"

```bash
# dot refers to current directory
cd ./anime
# now you are at: interests/anime
```

**Case 2:** You are in "/interest" directory and you want to move inside "/movies/action"

```bash
# going through multiple directories
cd ./movies/action
# now you are at: interests/movies/action 
```

**Case 3:** You are in "/movies/action" directory and you want to move inside "/movies/fictional"

```bash
# you are at: interests/movies/action
cd ../
# now you are at: interests/movies 

cd ./movies/fictional
# you are at: interests/movies/fictional
```

## ls

This command lists the content of the provided directory (along with the path). If no directory is specified, it defaults to current directory. Give '-a' as an option to see the hidden files, if any.

**Case 1:** You are inside "/interest" directory

```bash
ls 
# output: web-series anime movies

ls ./movies/fictional
# output: avengers-endgame.txt tenet.txt
```

**Case 2:** You are inside "/interest/anime" directory

```bash
ls -a
# output: .hidden-file  naruto  one-punch-man.txt
```

## pwd

This commands shows the present working directory. Basically it shows the path from root directory to current directory.

**Case 1:** You are in "/interest/movies/action"

```bash
pwd
# output: /home/harsha/interests/movies

cd ../
# now you are at: /home/harsha/interests
```

## touch

This command creates an empty file(s) with name(s) specified.

```bash
touch money-heist.txt
touch narcos.txt friends.txt
ls
# output: breaking-bad.txt  dark.txt  friends.txt  money-heist.txt  narcos.txt  wednesday.txt
```

## mkdir

This command creates an empty directory.

**Case 1:** You are inside "interest/movies"

```bash
mkdir romance
ls
# output: action fictional romance
```

## rm

This command deletes the file specified. Using -rf as an option, it deletes the directory specified.

**Case 1:** You are inside "interests/web-series"

```bash
rm money-heist.txt
ls
# output: breaking-bad.txt  dark.txt  friends.txt  narcos.txt  wednesday.txt

cd .. 
# now you are at: interests

rm -rf web-series
ls
# output: anime movies
```

# Conclusion

Damn, you've reached this point 🥳👏. This shows that you are a keen learner🔥. Now do not stop here. There is much more to learn in Git.

If you want a short, sweet and a simple intro to the world of Git, do checkout: [https://h4rsha.hashnode.dev/all-the-basics-you-need-to-start-working-with-git](https://h4rsha.hashnode.dev/all-the-basics-you-need-to-start-working-with-git).

Writing blogs is not as simple as we think 🥲. It requires planning, resources, understanding and most importantly TIME🧑‍💻. I would be very much grateful, if you could just share this blog post among your fellow peers (Linkedin, Facebook, Whatsapp, etc). Thank You ❤️
