How To Remove Everything Except The Base System In Arch Linux

Install MATE desktop environment in Arch Linux

Like everyone else, I do use Oracle VirtualBox to test and explore various Linux distributions. The other day, while playing with my Arch Linux VM, I wanted to test different desktop environments, such as Deepin, MATE, LXDE, XFCE etc. But the problem is some of the DEs are already installed and I don’t have enough space to install other DEs or any other applications. More importantly, I wanted a fresh Arch Linux system. I am bit lazy to reinstall the arch linux from scratch and also I find it pointless and time consuming process to reinstall the entire OS each time. While looking for an easy way out to solve this problem, I came to know that we can remove everything except the base system in Arch Linux.

By this way, we don’t have to reinstall the entire Arch Linux OS every time. We can quickly remove all packages except the base system and install other applications or desktop environments on top of the base system as many time as we want. Also, it reduces a lot of time, because we don’t need to install Arch Linux from beginning all the time. If you are wondering how to do it, you’re on the right track. Read on.

Remove Everything Except The Base System In Arch Linux

As usual, I strongly recommend you to take a backup of your important data and system configuration files in your Arch Linux system.

What we are going to do is to mark all packages as dependencies and mark the base system as explicitly installed packages and then finally remove the orphaned packages.

First, let us mark all packages as dependencies using command:

$ sudo pacman -D --asdeps $(pacman -Qe)

Here,

  • The asdeps option tells the pacman to install packages non-explicitly. In other words, we fake their install reason to be installed as a dependency.

Next, mark the base system as explicitly installed. Also, just mention anything else you don’t want to remove in the below command.

$ sudo pacman -S --asexplicit --needed base

Here,

  • The asexplicit option tells the pacman to install packages explicitly. In other words, we fake their install reason to be explicitly installed. This is useful if you want to mark a package as explicitly installed so it will not be removed by the –recursive remove operation.

Finally, remove the orphaned packages (dependencies) using the following command. Please make sure that you have mentioned all packages that you don’t want to remove by pacman command.

$ sudo pacman -Rsunc $(pacman -Qtdq)

Now, remove any unwanted configuration files and other files in your $HOME directory. You can also reset all customization and tweaks you made in your system, including the pinned applications in the Dock, desktop panel applets, desktop indicators, your system fonts, GTK themes, Icon themes, monitor resolution, keyboard shortcuts, window button placement, menu and launcher behaviour etc., as described in the following article.

Now, you have a fresh Arch Linux system. Go ahead and start installing any packages you want to test and explore.

For more details, refer pacman manual pages.

$ man pacman

Suggested read:


And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned!

Cheers!

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.