Yahoo
Advertisement
Advertisement
Advertisement
Advertisement

Here's How I Batch Install All My Old Apps When Switching Linux Distros

Linux terminal open in the Ubuntu desktop on a laptop screen.
Hannah Stryker / How-To Geek

Whether the year of the Linux desktop is here or not, switching distros is still a pain. If you're planning to make a move to another Linux distribution, here's how I batch-install all my old applications I was using on the previous one.

You could of course just eyeball your application launcher and hand-write a list of apps you want to install, then manually search for and install all of them on your new system. I've done that before, and it's tedious work. You also won't see most command line tools that way. Batch-installing will save you a ton of time, and fortunately Linux command shells were built for such time-saving tasks.

Don't Fear the Terminal

If you're switching Linux distros, and you want to automate or semi-automate the installation of apps you like, you're going to need to be comfortable with the terminal. To my knowledge, none of the graphical software managers have a means of batch-installing applications.

Advertisement
Advertisement

If you haven't yet, consider reviewing Linux terminal guidelines for beginners . For this particular guide, you'll definitely want to be familiar with installing software from the Linux terminal . You might also benefit from checking out a few beginner Bash scripts .

Before Switching, Run These Commands

Before deleting my current Linux distro, I need to grab a list of manually installed packages. This will include every piece of software installed on my system that didn't come with it by default. Later, I'll batch-install everything on my new system using that list.

Of course, this isn't a foolproof method. Different distros—and even different versions of the same distro—can have different software installed by default. It's possible a few apps that were preinstalled on my current distro won't be present on the new one. The vast majority should be covered though.

If my current distro is Debian, Ubuntu, or one of their derivatives, I can use the apt-mark command to list all the packages I installed myself from the distro repository.

Linux terminal showing the output of several applications from the apt-mark showmanual command.

I also have several Flatpaks installed I want to use, so I ran this Flatpak command, which shows only the app name column from the list command, and pipes into the head command to cut the column heading:

Linux terminal showing the output of several applications from a flatpak list command.

If you have Snap packages you want to batch-install, the best method I'm aware of for getting all their names is actually to list the directories in this location using the ls command :

It's not very elegant, and there might be some folder names that aren't software names at all. To confirm, you can compare it against the output of this command:

Other Distro-Specific Package Managers

On Fedora and Arch systems, you can use these commands to see all installed packages:

You'll notice the output shows version numbers along with package names. If the distro you're moving to may have the same packages with different version numbers, even if it uses the same package manager.

Advertisement
Advertisement

To print the list with those version numbers stripped out using the awk command on Fedora, you can run this:

Or on Arch Linux, you can do the same with a simpler piping command:

Save the Output Somewhere Safe

Now I need to either copy and paste or, better yet, pipe the output of those commands directly into individual files. For example, I made a file called my-packages.txt with the output on my Ubuntu device using this command:

redirect","yLinkElement":"context_link","yModuleName":"content-canvas"}" href="/site/yahoo_759/default?url=https%3A%2F%2Ftech.yahoo.com%2Fgeneral%2Farticles%2Fpipe-redirect-pro-linux-command-161512462.html">The > redirect saves the output to the file. If you're using Fedora or Arch, you can just tack on that "> my-packages.txt" redirect exactly the same way.

I'm also going to do the same for my Flatpak applications:

Regardless of the distro, you can quickly confirm the redirect was successful with the cat command:

Linux terminal showing the output of cat commands on text files listing installed packages.

I highly recommend pruning from your lists any package names you aren't certain you want to bring over to the new machine. The first time I attempted this, I didn't bother pruning, and I ended up with weird graphical issues.

Advertisement
Advertisement

With all my application lists saved, it's time to transfer them to a thumb drive or to the cloud. Perhaps the most efficient method is to back up your Linux device , then when you restore your files from the backup, find your package lists there.

Run These Commands and Wait

Now it's time to actually do the batch installation. On my new Ubuntu computer where I copied over my pruned list of packages, I first tried running a simple APT install command with a variable. It may work for you if you're lucky.

However, it threw a series of errors for me and failed to install any packages only because APT couldn't identify some of the package names. If you run into that too, this is the next best command I'm aware of for getting the job done:

This is a Bash for loop that cycles through the entire list and attempts to install each one. If you're on Fedora or Arch, just type dnf installor pacman -Sin place of "apt install".

Advertisement
Advertisement

This took quite a while for me because I didn't do much pruning. Also, be aware that it will occasionally ask you to confirm you want to install software. If you want to skip those prompts and install everything no-questions-asked, run this tweaked version of the same loop, with a -y flag on the APT command which will automatically answer "yes" to all confirmation prompts.

Linux terminal showing the output of a series of packages being installed.

Once the main package manager script was done, it was time for my Flatpaks. I first had to install Flatpak support on Ubuntu, and then enable the Flathub repo:

I was able to install my Flatpaks using the simpler Bash command:

Linux terminal showing the output of a series of Flatpaks being installed.

If it hadn't worked, I would have simply worked it into the for loop.

Watch for Errors

Be sure to review all the output from the installation commands you run. It's possible you'll see error messages for specific packages you installed. If that's the case, try installing them individually to figure out what the issue is.

Advertisement
Advertisement

Expect to have several issues if the distro you're hopping to uses a different package manager or repositories than the one you're switching from. Packages names are often slightly different between repositories, and your package manager may not be able to resolve those installation requests. They also may come from special repositories you'll need to find elsewhere.


One common type of Linux software I didn't mention here is AppImages. I love using AppImages because they can be transported between devices, and in a distro-hopping operation their portability will save you some time.

Advertisement
Advertisement
Mobilize your Website
View Site in Mobile | Classic
Share by: