Essential Safety Tools for New Linux Users
Tags: linux, beginners, tutorial
Published: 2023-06-30 10:39:46

If you're migrating to Linux from Windows or macOS, you'll immediately notice all the additional freedoms you have with regard to modifying your system. Making such changes can be enticing, especially for people who felt restricted by the configurability of their previous operating systems.

What they may not expect, however, is that Linux does not hold your hand when it comes to modifying your system. Copying the wrong command from the internet or making a few incorrect keystrokes in the terminal is enough to cause catastrophic, irreversible damage. Unfortunately, this is enough to require a complete reinstallation of your OS. For some users, it may be enough of a reason to move back to their old OS.

In this post, I'd like to list a few tools that I personally use in my [Arch Linux](https://archlinux.org/) installation to provide safety in modifying my system.

## 1. [try](https://github.com/binpash/try)

`try` allows you to safely run a command without having it make changes to your system. It allows you to "commit" those changes after inspecting them. You're also able to save those changes in another directory, so you can inspect/commit them at any point in the future.

`try` is just a shell script, so all you have to do to install it is  copy the file to your preferred `bin` directory:

```bash
curl https://raw.githubusercontent.com/binpash/try/main/try >> ANY_DIR_ON_PATH
```

Make sure to `chmod +x try` so you can execute it. Alternatively, if you're using Arch Linux like me, `try` is available in the [AUR](https://aur.archlinux.org/):

```bash
yay -S try
```

## 2. [thefuck](https://github.com/nvbn/thefuck)

`thefuck` is a small command-line tool that catches errors and common mistakes in the commands you write. You can easily accept suggested changes using the `fuck` command. Of course, this behavior is configurable:

```bash
eval $(thefuck --alias oops)
```

The above example in your `.bashrc` or `.zshrc` replaces the default response command with something SFW. It also supports "instant mode," which automatically runs the suggested change:

```bash
eval $(thefuck --alias oops --enable-experimental-instant-mode)
```

`thefuck` is also configurable beyond its alias. You can easily [create your own rules](https://github.com/nvbn/thefuck#creating-your-own-rules) using Python, for example. It's available on Homebrew, Arch Linux, FreeBSD, chromebrew, and PyPI. See the full installation instructions [here](https://github.com/nvbn/thefuck).

## 3. [timeshift](https://github.com/linuxmint/timeshift)

This is just a backup and system restoration tool. What makes it special? Timeshift is actively updated and maintained by the [Linux Mint](https://linuxmint.com/) team—users can request support in the official repository in addition to online guides. 

Furthermore, Timeshift has a GUI client, which makes it friendly towards new users. Configuring X applications to work under [XWayland](https://wayland.freedesktop.org/xserver.html) can already be a pain point for new users, but Timeshift's GUI client is built to work across multiple display environments.

It also has features to automatically create backups on boot, hourly/daily/weekly/etc., as well as on-demand, eliminating the need for new, inexperienced users to hassle with [`cron`](https://en.wikipedia.org/wiki/Cron).

Like other backup applications, snapshots can be taken using [rsync](https://rsync.samba.org/). If you use [btrfs](https://www.kernel.org/doc/html/latest/filesystems/btrfs.html), Timeshift supports btrfs snapshots. I personally use btrfs on my Arch Linux installation, so this was enough for me to opt to use Timeshift.

What makes Timeshift unique as a backup tool is that it specifically targets system files and settings. When you execute a potentially destructive command on your system, you can rest assured that you can revert the change with a backup without also reverting your personal documents and files in your home directory. Those files aren't backed up by design, which also saves you storage and time.

## 4. [Copilot for CLI](https://githubnext.com/projects/copilot-cli/)

This final tool is more universal—although it can be used as a safety tool, it has also made me far more productive in the terminal. You can set up the `??`, `git?`, and `gh?` shorthands in order to ask [GitHub Copilot](https://github.com/features/copilot) to write (or fix) your shell commands.

For example, using `?? how to display two videos side-by-side using ffmpeg` will generate the appropriate command, along with the necessary flags, to perform the prompt. It will give you the option to edit the result, modify your prompt, or execute the provided command.

The `git?` and `gh?` commands offer the same behavior, but within the context of [git](https://git-scm.com/) and the [GitHub CLI](https://cli.github.com/), respectively. This saves you from having to specify the context in your prompt.

_Disclaimer: This tool is a part of [GitHub Next](https://githubnext.com/), which means you need to join a waitlist to get access to it._