What is Command Line?

What is Command Line?
Image by Danni Liu adapted from Andrea Piacquadio/ Canva

I have expressed my fear of the command line in a couple of my blogs. This fear isn't uncommon. Apparently, it's a common concern among individuals who are new to it. I read somewhere that there is even a term for it! It's terminal phobia.

I'm scared of it because I know I lack understanding of how the command line works. I find it incredibly intimidating. I think I'll cause severe damage to my computer if I enter the wrong commands, even though I've been told that it's extremely safe. The horrifying interface reinforces this fear! I mean, just look at this!!!

Window Command Prompt
Window Command Prompt

I've decided to now act like a buffalo, not a cow, and charge towards my command line storm and demonstrate this through my blog. What is this buffalo and cow thing? It's a motivational story by Rory Vaden, called "The Buffalo Charge the Storm"
It's about overcoming adversity and building resilience. It may be a bit much for this situation, but it's a great story to remember in life's challenging times. The story goes that when a storm comes, the buffalo and cow herds can sense it coming from a distance. The cow would try and run away from the storm. We know that cows are extremely slow, so they get caught in the storm for prolonged periods, increasing suffering and frustration experienced because they are running in the same direction as the storm. On the other hand, the buffalos charge towards the storm and run through the storm, minimizing the suffering and pain experienced.
If you haven't seen this story told by Roy Varden, I encourage you to watch it. It's a short 4-minute video that will pay good dividends. 😊

When faced with adversity in the future, I hope you choose the mindset of a buffalo and face it head-on. Don't avoid it or passively wait for it to pass like the cows.

With that said, in this blog, I'm going to cover the following:

  • What is Command Line?
  • Benefits of Command Line
  • How to Bring Up the Command Line Interface
  • Are commands the same across different operating systems?
  • What are some common command lines?

What is Command Line?

The command line, also known as the terminal or console, is a way to communicate with a computer. Instead of using a mouse and clicking on icons, you type in specific words and phrases, called "command" into a program called a terminal or shell and hit enter. The computer then follows those instructions to perform a specific task, like opening a program or copying a file. For instance, you could download YouTube videos in the terminal.

Benefits of Command Line

I think we can agree that the command line looks highly intimidating. I believe there is a steep learning curve. Just think of the truckloads of commands one have to remember! The consensus from the community of users has expressed that it's a powerful tool, it's extremely flexible and a productivity multiplier.

Here is a list of benefits of the command line, it's by no means exhaustive:

  • Efficiency: The command line allows you to do things on your computer faster and more directly by typing commands rather than clicking through menus or icons.
  • Automation: With the command line, you can create simple programs called "scripts" that can perform repetitive tasks for you, so you don't have to do the same thing over and over.
  • Greater control: The command line gives you a more powerful way of controlling your computer, such as managing the programs that are running, and configuring system settings.
  • Access to Powerful Tools: Many data analysis tools and software, such as R and Python, can be run from the command line.

How to Bring Up the Command Line Interface

Here are some of the ways to bring up the command line interface in different operating systems:

Windows

  • Press the Windows key + R on your keyboard to open the Run dialogue box. Type cmd and press Enter to open the Command Prompt.
  • In Search dialogue box, type Command Prompt

Mac OS

  • Open Finder and navigate to the Applications > Utilities folder. Double-click the terminal application to open the command-line interface.

Linux

  • Press Ctrl + Alt + T on your keyboard to open the terminal.
  • Right-click on the Desktop and select Open Terminal or Open in Terminal from the context menu.

Are Commands the Same Across Different Operating Systems?

The commands used in the command line can vary between different operating systems. Though some commands may be similar across different systems, the syntax and options for those commands may be different. For example, the command to list the files in a directory is ls on macOS and Linux, but it is dir on Windows.

Additionally, some commands may not be available on certain operating systems, or the functionality of a command may be different.

That being said, many basic commands like cd, ls, and mkdir are similar across different operating systems. It's ok if you don't know what these commands do. I'll explain them shortly.

There is documentation on the commands for the specific operating system available for people to consult so don't ever feel the need you have to remember them all.

Common Command Lines

Here I have compiled a list of 9 common commands and their equivalents in the three operating systems.

Command Description Windows Mac OS Linux
List files and directories dir ls ls
Change directory cd cd cd
Print working directory cd pwd pwd
Create a new directory md mkdir mkdir
Copy file or directory copy cp cp
Move or rename file or directory move mv mv
Remove a file or directory del rm rm
Display the contents of a file type cat cat
Clear the terminal screen cls clear clear

Be careful with the command rm/ del. Use it with caution. It'll remove the files permanently. It won't appear in your trash can or anywhere to restore!

You can find a list of all the commands here:

Have a play in the command line. If you enter an invalid command, the command line will just throw an error message. Try executing the common commands I shared above. My favourite of the ones shared is mkd/ md (make directory). It's like doing magic! In the terminal, type cd Desktop so that you're on your Desktop, and then type mkd test if you're using macOS, and md test for window and watch what happens on your Desktop.

There is another neat thing I came across that you can try out. Type the command cd(change directory) in your terminal and drag any folder into the terminal; it'll print the path of the folder in the terminal.

The Command line tool is definitely cool, but I don't think it's for everyone. It's probably not something I would want to invest the time to learn it well, at least not at this stage. But I think it's beneficial to have a general understanding, particularly given that I'm in a very technical field.