Conquering the computer


September 5, 2022

You’re probably thinking, ‘What is a terminal?!?’. The terminal is an interface that lets you access the command line.

What is a terminal?

Essentially it lets you make folders and move things, without touching a mouse. If you can’t open Finder or Windows Explorer, you can access files in the terminal. You can access the terminal in RStudio, or in your Applications folder. In Jurassic Park, when Lex Murphy is hacking the computer to get the park running again, she is using a terminal. All computers up until the mid-nineties used terminals, and terminals alone. Unix systems are still used today, now they are called Linux (Macs are also Linux/Unix systems). Luckily, you won’t be closing any doors to keep dinosaurs out via computer, but knowing how to use the terminal is a very good skill to know!

From Giphy


Where are you?

Let’s start by learning the basic commands. First up, directories. You need to know how to switch directories, and how to see which directory you are in. You can see your present working directory by typing pwd in the terminal. Your path may look different:

> pwd

pwd is useful to make sure you are in the correct directory when you move folders and files.

How to Change Directories

The command to change directories is cd. It is short for change directories. Type a tilde (~) into the terminal after cd. That will get you to your home directory. After that, type pwd, just to see what directory you are in.

> cd ~
> pwd

Try and get yourself deeply nested in folders, inside folders, inside folders, inside folders, inside folders, etc. Then try running cd with a tilde after. The command cd ~ is a very useful shortcut.

What about backwards?

You can always move forward using cd (only one directory at a time), but you cannot move backwards. In Finder or Windows Explorer, get deeply nested into folders. Now, we are going to get back to the home directory without a tilde. I nested 6 layers back, but yours may be different. Now, type cd/ .. into the terminal. That should have moved you back a layer. But if you are nested far, far, far inside your computer, typing / .. a million times is going to be hard. Don’t worry! We can stack the command! Stack /.. the amount of times you went back a layer. Eventually, you will be at the home directory

> cd /../../../../..

That is basically how you move around in the terminal.



What are directories? Directories are the files on your computer, you can look at them in Finder, the Windows equivalent to Finder, and the terminal. Let’s make a new file called practice_shell using mkdir. That means make directory.

> mkdir practice_shell

Text Files

Great! Now, we are going to make a text file using .txt as a suffix, using the command touch, to make the text file. Call the text file filler.txt:

> touch filler.txt

Moving Files

Now, we have a .txt file and a folder to put it in. The filler.txt file should not have appeared in the practice_shell, if it did, move it somewhere else, preferably back one layer. How do we move files into folders? We do that by using mv, or move, like this:

> mv filler.txt / practice_shell

The slash is to tell the computer that we want to move the text file into the practice_shell. It always goes like this

> mv thing you want to move / place you want to move it

Moving Directories

We move directories the same way we move .txt files or any other files. We first need to make another directory to put practice_shell into. Call it practice2:

> mkdir practice2

Now, move the directory practice_shell into practice2 with mv:

> mv practice_shell / practice2

What’s in there?


Currently, there is nothing in the filler.txt. We will change that now, so we can see items inside of it. Navigate to filler.txt through the terminal using cd:

> cd ... # This one depends on where you made the file
> cd practice 2
> cd practice_shell

Now, type open filler.txt. This will open the file. Type filler text into it (include one #, one &, and hi in it). Now, we are going to run cat into the terminal.The name comes from its function to concatenate files, or chain them together, but we are just going to be running it to list things. Put cat into the terminal, like this:

> cat filler.txt

If you typed something into filler.txt, it should show what is in there!


There is another way to show what is in a file. ls, or listing. It the terminal, type filler.txt after ls. This will not show the same thing as cat, as it is just listing files. If you type ls filler.txt, it will only return filler.txt

> ls filler.txt

If you ran ls on a file holding the file with filler.txt, it would return more than filler.txt. Run ls on practice2. It should show practice_shell. If you run ls on practice_shell, it will show filler.txt.

> ls practice2

Listing files is good to do, that way you can see what is in the file and make sure you’re in the right place.

Removing Files


When you remove a file it is permanent. Gone. Never to be seen ever. Make sure you remove the right file.

We are going to be removing the file practice2, as it is a practice file. First, you need to move to wherever you put practice2 (use ls). We remove files with the command rm, or remove, but because practice2 is a directory, we have to use rm -r, like this:

> rm -r practice2

We will never be able to see that file ever. If you run ls in the terminal, it should not show practice2. If you ever want to remove files, you can just use rm.

Now you should have the basic gist of what a terminal is and how to use a terminal. This is not all to learn about the terminal, just basic commands that are helpful for using a computer.

Header image: Gortu at English Wikipedia, Public domain, via Wikimedia Commons