A beginner's guide to the command line

Search for a command to run...

Thank you. 😊
Command line gives power.. I am in ever ending arguments with folks using tortoise git tool over gitbash..😂
Nice writeup.. Useful one!
Thank you. 👨💻 Git bash is best for sure.
2022 was a year full of learnings for me. It was about solving problems, lots of iterations, making solid fundamentals, and growing up as a person. Even though it feels like this year went really fast and I have a very vague memory of it, this is my ...

Finally, the wait is over. Last year I built and launched Tabwave, a mindful productivity chrome extension that replaces your browser's new tab. It has been my passion project for a long time. And now it has become even more mindful and beautiful. Af...

The modern web has evolved over the years with new tools and technologies. We are introduced to new approaches to rendering websites and apps. With the rise of frameworks like NextJs and Remix, SSR has gained a lot of popularity in the last few years...

If you are following me for a while you know I love building side projects. And every time I decided to build one, I didn't know how it will turn out in the end. But one thing is for sure, it all started with a half-baked idea. half baked idea? what...

Did you know you can create GraphQL APIs within minutes without writing a single line of code? Well, I didn't. Thanks to the Hasura X Hashnode hackathon. Now I know and so you will. Hi there, In this blog post I will talk about why and how I built a ...

Have you seen those 🕵️♂️ hackers hacking systems in sci-fi movies? Isn't it cool? It's usually a computer genius typing on the blank screen(actually terminal), a lot of binary numbers, green text, and other cool stuff. I remember I used to impress my friends just by using the terminal in front of them.

😂 Well, we are not going to discuss hacking here. Sorry, I know.
We will be discussing the superpowers of using the command line, why you should learn how to use it, some basic commands you should know, and some more interesting stuff. Let's get started.

Command-line Interface (CLI) 💻 is a text-based interface used to interact with software and operating system by typing commands into the interface and receive a response in the same way.
It is a program that allows users to type text commands instructing the computer to do specific tasks. The command-line interface is the original way of talking to our machine. Don't get confused with the terms command line and terminal. They are often used interchangeably to indicate a text-based interface for navigating your operating system. Command-line is very windows centric terminology, whereas the terminal is very mac centric.
If you have Windows installed in your system, I would suggest using Git bash instead of the default command prompt.
It allows you to use Unix/Linux commands on a Windows computer. Also, you can customize it as you want or choose different themes and all. I am using the 🧛♂️ Dracula theme and I am loving it. Try it and thank me later.

GUI stands for Graphical User Interface whereas CLI stands for Command Line Interface. There is a huge debate among developers on GUI vs CLI. GUI is visually intuitive. I know. And beginners tend to learn how to use a GUI faster than a CLI as it is more user-friendly. There is certainly nothing wrong with using GUIs.
But once you overcome the beginner phase and understand the potential of the command line interface, you will start appreciating how CLI makes your work easy and efficient at the same time.
We don't just use the command line because it's cool. Using a command line, you can perform almost all the same tasks that can be done with a GUI. Also, it is faster than the GUI, uses fewer resources, and gives more control of what you're doing.
As a developer, we most likely use the command line for
The command line is the only place you can run all Git commands as most of the GUIs implement only a partial subset of Git functionality for simplicity. And you’ll eventually need to use Git through the command line for advanced tasks.
For example, if you need to fix complex merge conflicts, rebase branches, merge manually, or undo and roll back commits, you’ll need to use Git from the command line and then push your changes to the remote server.
git push origin master
You can compile and execute your code on the command line. For example, To run a Python script store in a ‘.py’ file in the command line, we have to write ‘python’ keyword before the file name in the command prompt.
python hello.py
There will be many situations where you have to use only CLI. For instance, you need some node modules. As npm is a command-line package manager for Node, you have to use the command line to install it like
npm install whatever-thing
NPM does not have a GUI. Every package has to be installed via npm command.
If you are using some framework or library or creating something with frontend as well as backend, You will need a command line to start a server. For example, while using create-react-app we need to do
npm start
There are hundreds of different commands that can be used in a command line. And we will be discussing a few of them.
Note: I am using Git bash, so we will use Unix/Linux commands here. Although I will share the equivalent windows command too.
pwd prints the name of the working directory, a directory or folder in which you are currently in. Right now I am in a folder named dev. So it will print the complete path of the dev folder.

ls command is used to display the list of all files and subdirectories contained in a specific directory. For windows, dir command does the same.


cd command is known as change directory command. It is used to change the current directory. The syntax is [ cd directory_name ]. For windows, it's the same command.

Here I changed to the app directory. You can check using pwd command. It will give the path of a new directory now. i.e. /c/Users/Rutik/Desktop/dev/app
There is another version of the cd command. cd .. command is used to move to the parent directory of the current directory, or the directory one level up from the current directory. “..” represents parent directory.

So now I am back at the parent directory of app folder. i.e. /c/Users/Rutik/Desktop/dev
The mkdir command allows us to create or make new directories. mkdir stands for “make directory". The syntax is [ mkdir folder_name ]. For windows, it's [ md folder_name ] command.

Here we created a new folder named icons in the dev folder.

touch command is used to create a file without any content. The file created using touch command is empty. The syntax is [ touch file_name ]. For windows, the command is a bit different. Its [copy nul file_name].

We created a new index.html file in the dev folder.

To open a file in the browser we simply use the start command. It's syntax is [ start file_name ]. For windows, it's the same command. Depending on the file type, it will open in the respective program. Here It will open index.html file in the default browser.

The rm command is used to delete files. rm stands for remove. The syntax is [ rm file_name]. Once you delete the file then you cannot recover the contents of files and directories. For windows, the command is [ del file_name ].

And it's gone. index.html file is deleted from the dev folder.

Normally, rm wouldn’t delete the directories but when used with -r option, it will delete. -r stands for recursive. It will delete all the files and sub-directories recursively of the parent directory. The syntax is [rm -r folder_name ]. For windows, it's [rmdir folder_name ].


clear command is used to clear the terminal screen. It doesn’t take any argument. For windows, the command is [ cls ].

The use of tab will help you speed up typing commands. Just hit Tab while typing a command, option, or file name and the command line will automatically complete what you're typing or suggest options to you.

Using the up and down arrow keys, you can recall previously-entered commands to the command line.

You can Run a Program on Command line using the start command.

The program's name must be the file's system name, not its shortcut name (for example, Command Prompt's system name is cmd). Common program names are
Notepad - notepad
Paint - mspaint
Task Manager - taskmgr
File Explorer - explorer
Believe it or not, but using the command line gives you 🦸♂️superpowers. There are far more things that we can do using the command line. So, learning the command line will surely give you an advantage. So try exploring it.
I keep writing about the things I learned and applied. So you can connect with me on Twitter, Github or Linkedin. Also, subscribe to my newsletter and stay up-to-date with my latest blog posts.
⚡ Happy learning!