Introduction to using command line if you're a complete beginner
Computers are great because using the mouse or touch devices we can do a lot of work, leaving the keyboard to typing our emails, blog posts or reports.
Once upon a time, this didn’t exist. Computers were only accessed using the keyboard, typing weird and cryptic messages, called commands, in a terminal.
This was true when computers were big as entire rooms, but also was true when the first personal computers started becoming affordable and they would start with a BASIC command prompt.
Today, well hidden and never used by consumers, we still have this way of using our computer.
We can do so using a terminal.
macOS comes with an app called Terminal, appropriately named.
Microsoft provides an app called Windows Terminal.
And Linux users know their terminals very well.
The terminal is not just for programmers. It’s essential for every professional computer user, because it unlocks you things that are impossible to do with a GUI (Graphical User Interface).
Oh, I mention GUI. The acronym for the terminal is CLI (Command Line Interface).
There is not just one terminal. You wish. Instead, we have lots and lots of different terminal interfaces, called shells.
We have Bash, ZSH, Fish Shell, CSH, and many more. But the most popular ones are Bash and ZSH.
Bash is often the default, and until very recently it was the default macOS shell, but now it’s been changed to ZSH.
My favorite shell, to be honest, is Fish Shell. I really like it because it’s simple, straightforward, comes with great defaults, and also a web-based configuration. I don’t have time to spend configuring my shell prompts and colors manually and when something works out of the box, I take it.
The terminal is also the way you access a server. You can create a VPS server on Amazon or DigitalOcean or where you want, and you can access it using SSH, the secure protocol to connect to a remote shell.
You use the shell locally but you could actually be connected to a server at the other side of Earth, which is pretty cool. Except some delay, if the connection is a bit laggy.
This is my macOS shell:
I can list all the files in my home folder by typing
ls and pressing enter:
I can change the current working directory to another folder using the
And every time I don’t know how to use a command, I type
man <command> to get the manual:
This is a man page. Although I find man pages to contain too much information, as this is 1 of 14 screens of explanation for the
Most of the times when in need I use this site called tldr pages: https://tldr.sh/. It’s a command you install, then you run it like this:
It just gave me a few useful options with examples.
Anyway, I’m digressing. When typing commands you can move around with your left and right arrow to move the cursor around.
Some systems also let you use the mouse to go to a specific place in the line. For example on macOS I can use option-click to position the cursor anywhere I want.
Pressing the up arrow will show the command you last typed. It’s nice when you make a typo and you don’t need to re-type all the thing.
If you type a command not found, the shell will tell you:
I made a few tutorials on using shells:
- How to use the macOS terminal
- The Bash shell
- Unix Shells Tutorial
- Introduction to Bash Shell Scripting
There’s a lot to read if you want!