The power behind the Linux terminal
Tags: linux, terminal, bash, overthewire
Published: 2021-03-15 15:45:28

---
title: The power behind the Linux terminal
published: true
description: Let's talk about what the command line is and how you can deal with when you need to, in practice.
tags: linux,terminal,bash,overthewire
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e2ymn14orzpgtbny0wzt.png
---

- [🇧🇷 Brazilian Version](https://dev.to/andersonbosa/o-poder-por-tras-do-terminal-linux-2m63)

---

#### Table of contents

- [Introduction](#chapter-eng-1)
- [Basic commands](#chapter-eng-2)
- [Commands that help us help each other](#chapter-eng-3)
- [Have your own Snippets](#chapter-eng-4)
- [Practice!](#chapter-eng-5)

### Introduction <a id="chapter-eng-1"></a>

Search, differentiate, analyze, share, unzip, encrypt a file, access a cloud computer, convert a video to gif, etc. These are some of the possible things to do with the command line.

The terminal is a magic wand to interact with the computer's resources. Allowing interaction practically and flexibly, which makes it a very powerful tool.

Basically on all operating systems (e.g., Windows, Android, Mac and etc.), the command line is a text interface to communicate with the computer (or device).

![image](https://i.giphy.com/media/toXKzaJP3WIgM/giphy.webp "likeagod")

Also known as `shell`,` console`, `prompt`, and among other names, the terminal can be frightening and confusing at first contact. Like all new knowledge, in the beginning, there may be more difficulties. However, as we overcome these barriers, we are faced with our evolution.

Knowing how to use the terminal can be essential when trying to deal with the problems that pop up daily as an IT professional. I read a post the other day when the author said something that itched me:

> If you are a Linux user, Terminal is probably the most powerful tool you have ever had. But the problem with Terminal is that you need to learn how to use it if you want to benefit from it. - [Mauro Garcia][maurogarcia]

<p style="font-size:14px; color: #aaa; text-align: center;"> me: YYEESSSS </p>

![image](https://dev-to-uploads.s3.amazonaws.com/i/xkjs7elno05bdzdrn67i.png "YEEEEESSSSSSSSS")

It scratched me to want to share a little of what I learned out there with my colleagues. And then I brought it here too. Knowing some of these things makes a difference in my day-to-day life as a software developer.

I hope I can help you feel a little more comfortable the next time you need to open the terminal.

### But before we start ... a tip for non-native speakers of English:

> Thinking in English helps to assimilate the commands!

If you are like me, non-native English, I believe you will understand better what I mean.

Let's understand with an example, the command `pwd` is for `Print Working Directory`. What in my language (Brazilian\*) would be something like `edt` (`Write the Working Directory`).

I think this example helps to make it clear that thinking about what you want to do in English helps to assimilate what is being done. Helping to internalize what you want to do. As with `ls` (list) or `cd` (change directory).

### Basic commands <a id="chapter-eng-2"></a>

Here are some practical commands to know. I used a command to describe them, we'll see which one is ahead.

- **mv** - move (rename) files
- **cp** - copy files and directories
- **rm** - remove files or directories
- **ls** - list directory contents
- **pwd** - print name of current/working directory
- **mkdir** - make directories, create a directory
- **rmdir** - remove empty directories, delete a directory
- **cat** - concatenate files and print on the standard output
- **tac** - concatenate and print files in reverse
- **more** - file perusal filter for crt viewing
- **less** - opposite of more
- **chown** - change file owner and group, change ownership of a file
- **chmod** - change file mode bits, change permissions of a file
- **chattr** - change file attributes on a Linux file system
- **curl** - transfer a URL
- **wget** - The non-interactive network downloader.
- **tar** - an archiving utility
- **gzip** - compress or expand files, sort of Linux 'WinRar'
- **ping** - send ICMP ECHO_REQUEST to network hosts
- **sort** - sort lines of text files
- **filter** - cups file conversion filter interface
- **uniq** - report or omit repeated lines
- **history** - GNU History Library
- **top** - display Linux processes
- **ps** - report a snapshot of the current processes.
- **pkill** - look up or signal processes based on name and other attributes
- **ssh** - OpenSSH remote login client
- **git** - the stupid content tracker

All commands can be concatenated in the terminal, it is a matter of knowing how to do them. The power to concatenate commands gives us incredible power with the command line.

For example, let's say we want to find which commands are in the history, but there are a lot of repetitions and irrelevant information at the moment (like the parameters) ... We could do it by unifying 4 commands in the following order: `history | cut --delimiter=" " -f 4 | sort | uniq`.

Or maybe you want to use an image as an icon ... You could:

```bash
# 1) download the image and 2) encode it on the fly.
curl https://duckduckgo.com/i/bfc48a09.jpg --output - | base64 -
# is now ready to use in an HTML tag 😎
```

#### Here is precious witchcraft for the next time your virtual memory runs out:

- **xkill** - kill a client by its X resource. Basically when you proclaim this command the point of your mouse will become Alvo Dumbledore's wand. Wherever you (left) click, the thing where you clicked dies.

![image](https://media.giphy.com/media/AhjXalGPAfJg4/giphy.gif)

### Commands that help us help each other <a id="chapter-eng-3"></a>

- **whatis** - display one-line manual page descriptions. It helps to identify the purpose of any command in seconds. **This was the command I mentioned above.**
- **which** - locate a command.
- **whereis** - locate the binary, source, and manual page files for a command.
- **man** - the program manual. An interface to the system reference manuals.
  [This is the way][mandaloriancreed] to anything. The relevant information about the program will be in the manual.

```bash
# Try on your terminal
$ whatis whatis which whereis man
```

### Have your own Snippets <a id="chapter-eng-4"></a>

A snippet is a function designed to serve a purpose. In Bash / shellscript we have the famous "one-liners". I recommend having them for two reasons:

1. Fear: they obviously scare. A chain of interconnected commands to serve a purpose? I find it incredible and terrifying. ~~ Whenever I find myself running a I think that if it breaks in half it will delete my entire system 😅. ~~ With that you will be cautious with the terminal because even a hammer is bad if it is not used correctly.

2. And news: you will be exposed to new solutions and also to new ways of using what you already know.

> I will leave some references on the wheel, places where we can check out these "one-liners". 😆

<!-- propaganda
Confira também esta publicação que fiz com algumas referências
-->

### Practice! <a id="chapter-eng-5"></a>

The best way to learn and assimilate is by doing. So let's put into practice what we've seen so far through some exercises. For this we will use Capture The Flag [Bandit] [overthewirebandit] from [OverTheWire] [overthewiresite].

**Capture The Flag** is a style of competition that involves several skills to solve challenges related to `infosec`, to capture the flag (usually a code), and scoring. In **Bandit** the CTF levels take place on a remote machine, where we will connect via the terminal via [ssh] [sshwiki].

**Bandit** will help us to put into practice and polish our skills with the Terminal. From here on, it's up to you. Good luck!

- [#Start here!][overthewirebandit]


### Feedbacks 💙

- Was something missing, or was it wrong, or do you have any suggestions? Please let me know your opinions!


---


#### One-liners

- ⭐ https://linuxcommandlibrary.com/
- ⭐ http://www.bashoneliners.com/
- https://catonmat.net/top-ten-one-liners-from-commandlinefu-explained
- https://www.stefanjudis.com/notes/1025-shell-command-one-liners-on-one-page/
- https://rosettacode.org/wiki/Shell_one-liner

##### Credits, fonts and articles:

- https://dev.to/maurogarcia_19/linux-terminal-the-ultimate-cheat-sheet-2g5b
- https://ubuntu.com/tutorials/command-line-for-beginners#1-overview
- https://www.howtogeek.com/140679/beginner-geek-how-to-start-using-the-linux-terminal/
- https://ctf-br.org/sobre/
- https://wiki.archlinux.org/index.php/Dash
- https://wiki.archlinux.org/index.php/Bash
- https://wiki.archlinux.org/index.php/Command-line_shell
- https://en.wikipedia.org/wiki/Bourne_shell

<!-- links -->

[feedbackForm]: https://forms.gle/M3K8eaSun4oY4mjQ6
[maurogarcia]: https://dev.to/mauro_codes
[ultimatecheatsheet]: https://dev.to/maurogarcia_19/linux-terminal-the-ultimate-cheat-sheet-2g5b
[linuxcommandlibrary]: https://linuxcommandlibrary.com/
[felixfanoneliners]: https://felixfan.github.io/shell-script/
[sshwiki]: https://en.wikipedia.org/wiki/SSH_(Secure_Shell)
[overthewiresite]: https://overthewire.org/wargames
[overthewirebandit]: https://overthewire.org/wargames/bandit/
[mandaloriancreed]: https://youtu.be/uelA7KRLINA?t=8
[kalirevealed]: https://kali.training/downloads/Kali-Linux-Revealed-1st-edition.pdf
[bashoneliners]: http://www.bashoneliners.com/oneliners/popular/