ENPT-BRsign insign up

This course is still under construction. You're free to read the parts that are done already but please sign up to receive an email when it's fully finished!

Sign Up

Already have an account? Sign in

How to use terminals

By Vilson Vieira ·

Tags: coding

Introduction

Everytime someone says "open your terminal and run these commands" you freeze, a drop of sweat rolls down your face, the fear grows in you only by remembering the dark background with green letters, the blinking prompt, cold, demanding your command, while the only thing you wanted was to install a simple .deb package :D

That sounds like the plot for a horror movie, but I get it, it took some time to me to leave the piece of graphical user interfaces and embrace the dark background terminal. I actually had to, because when I started using Linux I was not able to even setup my monitor well to work with graphics, so I stayed in the terminal for months. I read emails, talked with friends and even navigated in the Web using only the terminal. And I use it until this day. Don't get me wrong, I like a beautiful and well designed GUI, but I still spend 90% of time in the terminal.

Why, you ask. Well, that's what we're going to discover together in this short course. But what I can say right now is that it gives you lots of power. It's a hackable environment, where you can easily plug program together and use the whole Operational System as your tool.

Why to use terminals?

Installing a terminal in your machine

There are pretty great terminals these days. Let me start by listing the ones I know exists and then I'll guide you on how to install the one I use daily:

I use Ghostty as my default terminal. It's an opensource project from the same guy that created Vagrant and Terraform, so he know one thing or two about good opensource software design ;-) It's also modern: rendering is GPU-based, supports new features like images, etc.

No matter which terminal you install, it's important to install a good font. We do that because terminals are text-based and terminals those days support pretty beautiful things like UTF-8, emojis, icons, ligatures, etc. I recommend you installing the 0xProto font family:

After that, the font should be available to be selected in any application of your operational system, including your terminal.

Good, so like I said, you can install any one of those terminals I listed, but if you end up installing Ghostty in MacOS, I recommend you opening the config file (click in Ghostty -> Settings... menu, that will open the file) and pasting those configs:

# This is the configuration file for Ghostty.
font-family = "0xProto Nerd"
font-size = 11
macos-titlebar-style = tabs

After that you should have a terminal that looks like this:

What is this blinking thing?!

What you see blinking (or maybe not even blinking) is a shell prompt. See, the shell is also a program. It reads your input and run your commands. Those commands are generally other programs.

So everything you type there is expected to be a valid program, if the command doesn't exist, it will show a command not found message.

First commands

OK so the most important question now is: what commands/programs I can type here?! Short answer: every program in your computer. And tons more that you didn't even know that existed!

Let's start with moving around. You'll soon learn that files are really, really important in terminals. So it's pretty important to navigate through folder and files. You can do that using:

Everything is a file

Terminals are a pretty old thing, but their design is really beautiful, so well done that holds up until these days! Almost all terminals follow the POSIX standard and thanks to the Unix tradition, everything is a file.

Permissions

Unix-based systems are multiuser, so they allow you to control exactly who can access what and how.

Connecting to other machines

ssh user@host

`mosh user@host

Useful commands for...

File exploring

Process management

Coding

Interpreters:

Compilers:

Linkers:

Network

Devices