🧙‍♂️Command Line Wizard: All you need to know about Bash and Terminal.

Adarsh RajAdarsh Raj
4 min read

Hello There,

A few weeks ago, I barely knew anything about the command line. I was intimidated by the black-and-white screen that developers seemed to use like a Magic Spell.

But now?

I spend most of my coding time inside the terminal, running commands, automating tasks, and feeling like a real Command Line Wizard. 🧙‍♂️

In this post, I’ll walk you through everything I’ve learned about Bash and Terminal—especially if you're just getting started.

Before we Start this i would highly recommend you to write the commands in a notebook cuz you will for sure forget a f**k ton of them.


🚀 First Things First: Why Bash?

Bash (Bourne Again SHell) is a command line interpreter that lets you interact directly with your operating system. It’s powerful, efficient, and lets you automate literally anything—from managing files to deploying full-stack apps.

If you’re on Windows, don’t worry. You can install WSL (Windows Subsystem for Linux) to enjoy the full Bash experience. I highly recommend installing Ubuntu from the Microsoft Store. It changed my workflow completely.


📍 Basic Bash Commands (That Changed Everything for Me)

pwd - Print Working Directory

$ pwd

This shows you where you are in the system.


ls - List Files and Folders

shCopyEdit$ ls         # simple list
$ ls -l      # detailed list
$ ls -lt     # sort by modified time
$ ls *.json  # match specific pattern
$ ls -lR | grep .json  # recursively find JSON files

Think of this as your terminal’s version of opening a folder.


cd - Change Directory

$ cd folder1
$ cd ../    # move up one level
$ cd ../../ # move up two levels

Just like double-clicking into folders, but faster.


mkdir - Make Directory

$ mkdir newFolder
$ mkdir folder1 folder2 folder3
$ mkdir -p fullstack/frontend/scripts

You can even create multiple nested folders in one go with -p.


touch - Create New Files

$ touch app.js
$ touch index.html style.css script.js
$ touch nested/folder/file.txt

Useful for starting new files without opening any editor.


cat - Read and Write File Content

$ cat file.txt          # read
$ cat > file.txt        # overwrite
$ cat >> file.txt       # append

Great for quick file edits or viewing contents.


mv - Move or Rename

$ mv file.js folder/
$ mv oldName.js newName.js

Move files or rename them. Simple and powerful.


cp - Copy Files

$ cp file.js folder/
$ cp -r folder1/ folder2/

Use -r to copy folders recursively.


rm - Delete Files or Folders

$ rm file.js
$ rmdir emptyFolder/
$ rm -rf folder/  # delete folder and all contents

Be careful with rm -rf — it’s permanent.


🔐 Permissions with chmod

Permissions are important. Here’s how to manage them.

$ chmod u+x script.sh       # user execute
$ chmod g+wx index.js       # group write+execute
$ chmod ugo+rwx file.js     # all permissions
$ chmod 777 file.js         # everyone can do everything

In numeric terms:

  • 7 = rwx, 6 = rw-, 5 = r-x, 0 = ---

  • So chmod 755 gives full access to owner, read/execute to others.


📢 Other Super Useful Commands

echo

$ echo "Hello, World!"
$ echo $PATH

Prints to terminal. Use it to debug or display variable values.


head & tail

$ head index.js     # first 10 lines
$ tail index.js     # last 10 lines
$ tail -n +15 index.js | head -5  # lines 15 to 20

Quickly peek at top/bottom of large files.


wc - Word Count

$ wc index.js

Shows number of lines, words, and characters.


grep - Search Within Files

$ grep "Hello" index.js
$ grep -v "error" index.js          # show lines without "error"
$ grep -A 5 "function" index.js     # show 5 lines after match
$ grep -c "let" index.js            # count occurrences
$ grep -o "import" index.js         # show only matched word

Grep is insanely powerful for searching through codebases.


history

$ history

View your command history. Great for reusing long commands.


🧠 Bash Scripting — Your First Automation

You can create a .sh file and write scripts in Bash!

# script.sh
#!/bin/bash
echo "Setting up project..."
mkdir new_project
cd new_project && touch index.html

Run it:

$ bash script.sh

Boom. You've just automated your project setup.


🧹 Other Handy Tools

clear - Clean Up Terminal

$ clear

nvm & npm - JavaScript Devs, Take Note

$ nvm install node
$ npm install express

If you're into JavaScript/Node.js, these are essential.


node - Run JavaScript Files

$ node index.js

Run your scripts directly from the terminal.


🧑‍💻 Final Thoughts

A few days ago, the terminal was scary. Now it's where I feel most productive. Whether you're a beginner or looking to level up, Bash will transform how you code, automate, and build.

If you're on Windows, go install WSL and start exploring the Linux world right from your PC.

And don’t forget — becoming a Command Line Wizard doesn’t take magic. Just practice and curiosity.

1
Subscribe to my newsletter

Read articles from Adarsh Raj directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Adarsh Raj
Adarsh Raj