The Command Line, A Boon To Programmers

Priyanshu Saraf
4 min readSep 30, 2020

--

The command line is an amazing tool, and it can be used to achieve great things. Even If you are a really advanced programmer or a really basic programmer, you should know about the command line and how you can boost your productivity with it.

What Is The Command Line?

The command line is a tool which gives you full control of your PC. Although, just looking at that black screen often times terrifies beginner programmers. Some people think of it to be the equivalent of the dark web.

It is nothing of that sort

You do not have to be terrified of the command line. It is a really important tool for developers and it makes you really productive.

With the command line, You can:

  • Make folders/files
  • Rename your folders/files
  • Delete your folders/files
  • Download packages for your code

And a lot more…

So, Lets start Learning about it!

How Do I Open The Command Line?

For Mac users:

Open Terminal using Spotlight Search. One of the quickest and easiest ways to open Terminal on Mac is with Spotlight Search. 1) If you have the Spotlight Search button in your menu bar, click it. Otherwise, you can use the keyboard shortcut Command + Space. 2) Type in “Terminal”. This should open up the command Line for you.

For Windows Users:

There are actually quite a few ways to open the command prompt in windows. My favorite way, which is also a really unknown way of doing this is by pressing the start key and typing R while holding the windows key.

This opens up the following window:

Now, for me, by default I get “cmd” typed in. If you do not get that, do not worry, you can type “cmd” in the box. This should open up the command line for you.

How Do I Make A New Folder?

For making a new folder, we have a command called “mkdir”.

mkdir <file name>

Now, mkdir stands for “make directory”, which is just another name for folder.

Remember: Do not put in the <>, just type out the directory name.

I am just going to call my directory “happy-Wednesday”

How Do I Navigate Inside Of The Folder?

For navigation inside the command line, we use something called “cd”

In our case, we are going to get in the happy-Wednesday directory.

We do that like so:

cd happy-Wednesday

How Do I Make A New File?

For making a new file, we use a command called “touch” in Mac and “echo” on Windows. The syntax is like such for Mac

touch "hello-world"

For windows:

echo > "hello-world"

How Do I Check Whether The File Was Formed Or Not?

For checking all the files in a directory, we use the command “ls”. It is just ls, and you do not have to worry about suffixing this with anything.

How Do I Rename My File?

For renaming files, we use a command called “mv”

Say that I do not want to name my file “hello-world”, and I want it to be called “Hello-Priyanshu”, well, we can do that in no time with the command mv. Here is the syntax:

mv hello-world hello-priyanshu

Here, the first parameter is the file which we want to rename, and the second one is the new name

How Do I Delete My File?

To delete my file, what we can do is use a command called “rm”. If we want to remove the file entirely from the computer, then we can suffix the command with a “-r” flag.

Because our hello-priyanshu file is basically useless, I am going to delete it permanently. To do that, we are going to do the following:

rm -r hello-priyanshu

How Do I Get Out Of My Current Directory?

For getting out of your current directory, you can use the “cd” command again. You can do the following to get out of the current directory and go to its parent directory:

cd ..

For getting out of the current directory and for getting out the parent directory, you can do this:

cd ../..

That is it for the basics of command line.

I hope that you found value from this.

Thanks!

--

--

Priyanshu Saraf
Priyanshu Saraf

Written by Priyanshu Saraf

Blogger, freelancer, and Tutor! Let’s connect on instagram! Here’s my handle: @saraf_priyanshu_

No responses yet