I run these 5 commands on every fresh Linux install to save hours of work

Setting up a new Linux system and getting it ready for your job can sometimes be a tedious waste of time. That’s why I have this 5-step approach to make it as quick as possible.
Run a system update
You may have noticed that whenever you see instructions for installing something using a package manager, the documentation or tutorial includes a small update command like sudo apt update. Why then?
Sometimes when you run a command to install an application, an error may be returned. Something like “package not found” or “unable to recover”. If this happens, it does not necessarily mean that the target package does not exist in the package manager repositories. The package may fail to locate the package if the local package manager database is not in sync with the Linux servers.
Every time you run something like apt install vlcit does not immediately connect to the server to locate the package. It would be slow and finicky (depending on your connection). Instead, your operating system creates a local index of all available packages and runs the search against that database.
As new packages are added and old versions are updated in the official repositories, the local database becomes out of sync with the remote repository. It must be updated manually and synchronized with official providers. This is what sudo apt update does.
Once the local index is synced with the official repositories, you can run sudo apt upgrade to update all your packages to their latest versions. Upgrading packages seems like the opposite of saving time, but running these two commands regularly saves you a lot of time (and trouble) down the line.
Linux applications rely heavily on shared libraries and dependencies. If you don’t update them regularly, you’ll be stuck in what’s called “dependency hell,” where you’ll have to scramble to resolve dependency issues manually. If you installed the operating system from even a slightly older install image, you might find yourself spending hours playing wack-a-mole with broken packages. The solution is often as simple as running sudo apt update && sudo apt upgrade.
If you are on an Arch system, try this command.
sudo pacman -Syu
Fedora users can run sudo dnf update
Select the fastest mirrors
Linux packages are not hosted on a single centralized server. Instead, exact copies of software repositories are hosted on servers all over the world. These servers are called mirrors (because they are identical.) Not all of these servers are accessible at all times, nor do they all offer the same download speeds.
Beginner distributions usually have some sort of graphical utility for selecting the fastest mirror. For example, I’m using MX Linux here, and it has this MX Repo Manager tool that automatically selects the fastest mirror for your PC.
You can do the same thing in the terminal with nala.
sudo nala fetch
I’ve seen mirrors with poor connection speeds and downloading anything from these mirrors is excruciatingly slow. If you find that your downloads or updates are taking too long, 9 times out of 10 you just need to change mirrors.
Install packages quickly
When doing a fresh install, the first thing you’ll probably want to do is install your favorite apps. Normally you just type the package names as you remember them and then install them. Let me show you a faster way.
If you still have access to your previous Linux setup, try this. If you do not proceed to the next step.
Open the terminal on your old machine and enter this command. It creates a list of all the packages you have installed manually.
apt-mark showmanual > packages.txt
Transfer the packages.txt file to the PC with the new installation. Open a terminal and navigate to the folder where you kept the packages.txt file. Then run this command.
sudo xargs apt install -y
This command will install all packages in the list at once. You can also edit the text file to remove or add packages before running this command.
If you don’t have access to your old packages, you can also use Tuxmate. This site allows you to select packages and gives you a single installation command.
Pull my stitch files
I spent some time configuring my Kitty terminal, nvimand zsh shell, and I’m finally happy with my setup. However, if this machine crashes or I install Linux on another computer, I don’t want to recreate it manually. That’s what chezmoi is for. This tool allows you to transfer your dot files to a GitHub repository and quickly re-apply them with a single command.
Start by installing at my place.
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin
Next, open GitHub in your browser and create a blank repository for your dot files. I call mine “dotfiles” (so creative.) Next, open your terminal and run the following commands.
chezmoi init
chezmoi add ~/.zshrc
chezmoi add ~/.config/kitty/kitty.conf
I only need to backup my zsh and Kitty configurations. You can add any stitch files you want.
chezmoi cd
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/usr/dotfiles
You will need to enter your username and a repository authentication token here.
git push -u origin main
On my new OS I can simply run this command and it will automatically apply all my configurations.
chezmoi init --apply https://github.com/usr/dotfiles.git
Configure system-wide backups
I didn’t bother setting up system-wide backups until last year, when an update broke my CachyOS machine and I lost all my data. I spent days trying to recover the operating system to no avail. Since then, I’ve made it a strict rule for myself to maintain system-wide backups.
The good news is that most beginner distributions make creating and maintaining backups very easy. For example, Timeshift (built into many Debian-based distributions) creates system snapshots that you can revert to in the event of a crash.
Setting up a new Linux can sometimes be very frustrating. However, with the right tools and a “work smart, not hard” approach, it can be a breeze.




