Home Linux How To Remove Everything Except The Base System In Arch Linux

How To Remove Everything Except The Base System In Arch Linux

By sk
Published: Last Updated on 17.4K views

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)

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.

$ 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

Suggested read:


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:

Have a Good day!!

You May Also Like

7 comments

Matt May 16, 2020 - 11:40 am

So this will leave everything in your home directory untouched, correct? It only removes the packages?

Reply
sk May 16, 2020 - 11:47 am

Yes, it will only delete the packages. However, it is recommended to backup important data just in case.

Reply
erickmufath July 7, 2020 - 7:15 am

After this, how to install package again? Like Network Manager and sudo?

Reply
sk July 7, 2020 - 11:04 am

It doesn’t remove pacman. So just the packages using pacman as usual.

Reply
erickmufath July 8, 2020 - 3:52 pm

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

Reply
AstroCAR May 22, 2021 - 6:22 am

How are packages installed by yay or others treated through this?

Reply
sk May 22, 2021 - 12:06 pm

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.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

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

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More