DEV Community

Anish Pallati
Anish Pallati

Posted on • Updated on

Essential Safety Tools for New Linux Users

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 installation to provide safety in modifying my system.

1. 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:

curl https://raw.githubusercontent.com/binpash/try/main/try >> ANY_DIR_ON_PATH
Enter fullscreen mode Exit fullscreen mode

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:

yay -S try
Enter fullscreen mode Exit fullscreen mode

2. 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:

eval $(thefuck --alias oops)
Enter fullscreen mode Exit fullscreen mode

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:

eval $(thefuck --alias oops --enable-experimental-instant-mode)
Enter fullscreen mode Exit fullscreen mode

thefuck is also configurable beyond its alias. You can easily create your own rules using Python, for example. It's available on Homebrew, Arch Linux, FreeBSD, chromebrew, and PyPI. See the full installation instructions here.

3. timeshift

This is just a backup and system restoration tool. What makes it special? Timeshift is actively updated and maintained by the Linux Mint 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 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.

Like other backup applications, snapshots can be taken using rsync. If you use btrfs, 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

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 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 and the GitHub CLI, respectively. This saves you from having to specify the context in your prompt.

Disclaimer: This tool is a part of GitHub Next, which means you need to join a waitlist to get access to it.

Top comments (0)