Linux Essentials: The Singular Six
Tags: beginners, linux, discuss, illustrated
Published: 2020-03-07 17:04:31

---
title: Linux Essentials: The Singular Six
published: true
description: If you had to choose the most essential Linux commands to troubleshoot servers, those you really can't live without, what would that list look like to you?
tags: beginners, Linux, discuss, illustrated
---

If you had to choose the most essential Linux commands to troubleshoot servers, those you really can't live without, what would that list look like to you?

I came down to **six** essentials that are super important to locate and identify issues within Linux servers (not considering text editors or network commands). Meet the **Singular Six**!

![Linux's Singular Six](https://dev-to-uploads.s3.amazonaws.com/i/1rfsmuk0qfny1vjzixqt.jpg)

My list includes:

- `ls`
- `ps`
- `cat`
- `tail`
- `kill`
- `rm`

These are like the basic toolchain for dealing with Linux servers, and I can't think of anything more essential than these six commands. Let's have a quick recap of each one of them, just in case.

## LS

This one just had to be on the *list* (pun intended). The `ls` command is used to list files from a location. If you don't provide a directory to list, it will list the files from your current directory.

### Usage Examples for the `ls` Command

Lists all files from the current directory, including hidden files:

```bash
ls -la
```

Lists all files from a directory:

```bash
ls /var/log
```

## PS

The `ps` command is used to list processes that are currently running on the system.

### Usage Examples for the `ps` Command

Shows current active processes initiated by the logged user:

```bash
ps ux
```

Shows current active processes from all users:

```bash
ps aux
```

## CAT

The `cat` command is used to output the full contents of a file. Many people don't know that you can also use `cat` as an *improptu* editor to create or update text files.

### Usage Examples for the `cat` Command

Outputs content from a file  named `file.txt` in the current directory:

```bash
cat file.txt
```

Redirects content from the standard input to a file, until an `EOF` is entered:

```bash
cat > test.txt << EOF
heredoc> line1
heredoc> line2
heredoc> line3
heredoc> EOF
```

If you run a `cat test.txt` now, you'll get the following output:

```
line1
line2
line3
```

## TAIL

The `tail` command is used to output only the final portion of a file, which makes it great for checking system logs. By default, it will output the last 10 lines of a file.

### Usage Examples for the `tail` Command

Show the lasts 10 lines of a file:

```bash
tail /var/log/nginx/error.log
```

Shows the last 40 lines of a file:

```bash
tail -n 40 /var/log/nginx/error.log
```

Outputs new log lines in real time (blocks terminal - hit `CTRL+C` to exit):

```bash
tail -f /var/log/nginx/error.log
```

## KILL

The `kill` command is used to terminate processes that are currently running on the server.

### Usage Examples for the `kill` Command

Kills a process using a PID (process ID can be obtained with `ps`):

```bash
kill -9 1234
```

Kills all processes with a certain name:

```bash
killall -9 name
```

## RM 

The `rm` command is used to permanently delete files on a server.

### Usage Examples for the `rm` Command

**R**ecursively removes all files from a certain location (includes directories):
 
```bash
rm -r location/
```

Recursively removes files from a location, but asks for confirmation (**i**nteractive) before removing:

```bash
rm -ri location/
```

Recursively removes all files from a location, won't ask for confirmation (**f**orce) and shows files being removed (**v**erbose):

```bash
rm -rfv location/
```

Be careful with this one, because it won't give you a second chance to avoid removing important files (just make sure you're passing in the correct directory to be removed).

## It's Your Turn

Now, I want to know: what is in *your* top six?