I use Oracle VirtualBox to test and explore various Linux distributions. The other day I wanted to test different desktop environments, such as Deepin, MATE, LXDE, XFCE etc., on my Arch Linux. 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.
In 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 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)
- 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
- 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.
$ sudo pacman -Rsunc $(pacman -Qtdq)
Please make sure that you have mentioned all packages that you don't want to remove by pacman command.
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
And, that's all for now. Hope this helps. More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Reddit | Facebook | Twitter | LinkedIn | RSS feeds
Have a Good day!!
So this will leave everything in your home directory untouched, correct? It only removes the packages?
Yes, it will only delete the packages. However, it is recommended to backup important data just in case.
After this, how to install package again? Like Network Manager and sudo?
It doesn’t remove pacman. So just the packages using pacman as usual.
My laptop using wifi connection, and what happen? I reinstall arch linux.. hmm, this tutorial really doesn’t remove pacman or this is my mistake? Tomorrow i try pacman -Syu and this say : command not found..
How are packages installed by yay or others treated through this?
I deleted the Arch Linux setup, so I can’t confirm this at the moment. As stated in the article, it will keep only the base. Everything else will be treated as orphaned packages and deleted. Test this guide in a VM and verify yourself.