Getting Comfortable with the Command Line

Originally published on 03 November, 2020 by Jacob Stordahl

The terminal, or command line, is simply a way to interact with your computer. While you're likely used to using a GUI, or Graphical User Interface, the terminal uses CLIs, or Command Line Interfaces. We use the terminal to access & run these CLIs to perform different tasks. It's important to define some key terms that may have you confused. You'll often hear people use terminal, command line, & shell and it may be hard to tell the difference. The terminal is the actual piece of software that you're typing in, whether it be built into your text editor, or a stand alone piece of software; the command line is the text line within the terminal where you are actually typing, and the shell is the protocol by which your terminal communicates with your computer. It's important to remember the differences here, as it will help you understand how these parts work together to create a really useful tool. Alright, now that those terms are cleared up, lets look at what terminal we're going to be using.

If you're using a Mac you already have a built-in terminal app that works just fine, however, a great alternative that I personally use is hyper. If you're running Windows, Microsoft just released Windows Terminal which you should definitely check out! And if you're running Linux you probably skipped this post entirely, so I'll move on. When you boot up your terminal you'll get something that looks like this...

22:48:35 -username-~: [

This is called the 'prompt', which gives you some contextual information about your terminal. I have my prompt configured to print the time, the logged in user, the file path back to the root and then the opening ~: [. After the square bracket is where our command starts.

The first concept we're going to cover is creating files and folders. The way it was explained to me the first time, is that you create a file by touch-ing it into existence.

touch newfile.txt

Running this command will generate an empty file named newfile.txt. If you wanted to create multiple file at once, you simply concatinate the other file names onto the command. This is something you might use if you create a certain type of project often...

touch index.html style.css index.js

A lot of bash commands make more sense to me personally when I sound them out, including how we create a new folder...

mkdir new-folder

This command stands for 'Make Directory'; a directory is what the terminal calls a folder. The next important skill is to be able to move between folders, however, before you can move to a new folder, you have to know where you are and what's around you. We do this by running two commands...


pwd stands for 'Print Working Directory', which will print the name of the folder you're currently located in. ls stands for 'List' and will list out all files & folders in the current working directory. So now that we know where we are and what's around us, we can 'Change Directory'...

cd ./path/to/directory

Now that we've changed into a new directory, you'll see that our prompt has changed to reflect the absolute path back to the users root folder. It will look something like this...

22:48:35 -username-~/path/to/directory: [

This is how we can keep track of where we are within our machine. Some other quick, useful tips are;

  1. cmd + k will clear the terminal
  2. you can use the up & down arrows to look through previous commands you've run
  3. if you ever need to see hidden files or folders use ls -a
  4. ctrl + c will kill any process running in the terminal.

I hope this helped you get a little more comfortable using the command line, and I want to encourage you to start trying to use the terminal!

© 2021 Jacob Stordahl | built with Steel