Introduction to the Command Line – Part 1

I made the mistake of learning how to code before knowing what the Terminal is for, and what the Command Line does. It’s like fishing without knowing how to use a fishing rod.

 

fishing with hands
(Source: Dailymail)

 

Let me tell you my story. When I first started using Meteor, an open source platform for building apps, I had to install Meteor on my computer, which required me to open my Terminal app. I had to create a project, run it, then release it. All these required me to run commands – which means I had to know how to type these commands – which also means I had to know how to even access my Terminal app in order to run these commands. Now, do you get my drift?

 

Without basic knowledge of the command line, I found myself blindly copying and pasting everything. Soon enough, I gave up using Meteor, perhaps one of the simplest things to use in the first place.

 

If you’re a total noob like me, you should continue reading.

 

So, what is the Command Line?

 

The command-line interface (CLI) is a tool for you to type text commands to perform specific tasks on your computer, making it do precisely what you want.

 

Do not confuse this with the graphical user interface (GUI), which allows you to physically interact with certain elements on your computer (e.g. clicking a button). Simply put, you’re using the GUI almost 90% of the time when surfing the web.

 

For those already familiar with CLI and GUI, a question that may have crossed your mind is “Why should I learn the command line, which is so backward? The GUI is easier and much more sophisticated.”

 

You’re actually quite right. However, not all tasks are best suited to a GUI, and using a CLI will be better. (e.g. data manipulation, manage cloud servers).

 

Opening the Command Line interface

 

Now let’s get back to the command line. The user interface where you type your text into – is called a shell. If you’re a Linux or Mac user, you’ll be familiar with the Terminal application, which has the Bash shell.

 

I’m a Mac user, so I’ll show you what the Terminal should look like. If you’re a Mac user too, you should be able to access the Terminal application through Finder > Applications > Utilities > Terminal (or simply search for “Terminal” using Spotlight).

 

Terminal application on mac
(Source: tutsplus)

 

Now let’s run some commands

 

Try typing ls now and press enter. Do not type the $ sign. This is simply a common convention to denote what command should be run.

 

ls simply means “list”. Your screen should show you a list of files in your working directory.

 

If you want to see which working directory you are currently in, type pwd, which means “print working directory”.

 

Now try typing cd Documents and press enter. It means “change directory”. If you pass it an argument, you will be brought to the Documents folder in your computer.

 

And the fun has just started

 

Congratulations. You’ve successfully run some commands. If you would like to learn more, you can visit these links (they’re my personal favorites):

Linux Commands
GitTower Command Line 101
Free Engineer – Learn UNIX in 10 minutes

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *