A User Command to Clean and Update System

First of all, please do not consider my post as an advice.
As the thread proceeded (and as I mentioned below in this OP) I said:

I am sure it is not perfect.

So please take this as nothing more than I am just thinking loud.
Just an attempt… no more.

So, the main reference for cleaning the system is A Complete Idiot's Guide To Endeavour OS Maintenance / Update / Upgrade and not this thread

As part of my commitment to the community I would like to share with you something I did to my laptop a few times and booted and me and my laptop are still alive.

I understand this is not windoze, but I read about orphaned packages, and caches of uninstalled apps… and anyway there are on official Arch websites instructions to clean a bit.

I read about cleaning the system, cached stuff, orphaned packages… etc. at:

I made a little script “clean.sh” (not perfect I know) but it works I believe, which I share with you:

echo "$1" | eos-rankmirrors
echo "$1" | yay -Syyu
echo "$1" | sudo pacman -Sc

journalctl --vacuum-time=4weeks
paccache -ruk0
echo "$1" | sudo pacman -Rns $(pacman -Qdtq)

( I am getting an error message “no targets specified”)

Then I added the line a line to ~/.bashrc

alias clean="bash /home/limo/Software/MyScripts/clean.sh"

to make it like a Linux command to run my clean.sh script.

I hope this helps!
I ran the command I just created( clean ) and booted repeatedly a few times before posting to be sure it does not hurt anybody.
I am sure it is not perfect. The first script I ever made was a few days ago “ocr”

I hope this helps!
This is my second contribution. I hope my first one How I changed Grub Screen would be of interest.

I hope to hear from the experts as I hope to learn more and more…


A few things here that you might want to consider/know.

  • I am fairly certain that paccache -ruk0 and pacman -Sc do the exact same thing. Remove packages you no longer have installed from the cache. There is no reason to call both of them.
  • Unless you are using a mirror that is severely broken(no out of date, but broken), there is no need to use -Syyu when switching mirrors. -Syu or in your case just yay is sufficient.
  • Please be sure you know what pacman -Rns actually does and aren’t just copy and pasting it from somewhere else.
  • You are ranking the EOS mirrors but not the Arch mirrors. Since 99% of the packages come from the Arch mirrors, you might want to add that.
  • Is there a reason you are using echo "$1" into all those commands?

Here comes my teacher again as usual.

So, I will edit and keep only pacman -Sc as it looks simple and “cute”

A few days ago, as I did “yay” to update I got lots of 404.
Anyway this command "clean " won’t be run daily… weekly or monthly perhaps.

The “Syyu” is on official Arch page, plus I saw it here a few times.

I believe I got it from somewhere here on the forums. (at my main reference at A Complete Idiot's Guide To Endeavour OS Maintenance / Update / Upgrade (first post, point 6). I understand it helps cleaning uninstalled/orphaned packages (should I remove it?)

My ignorance comes again here.
So, I am not sure what to put to rank Arch mirrors?

Well, some of them required root password, so I was trying to pass it once only.
I will modify the copy.sh accordingly later!

I really thank you for always being there to support, teach and help.

You should understand it, and then decide if you want to keep it or change it.

The whole command you are using pacman -Rns $(pacman -Qdtq) is a commonly used command to remove orphans. You should understand it and the implications of each part.

  • The $(pacman -Qdtq) part is what finds the orphans.
  • pacman -R says to remove the packages
  • The s remove the dependencies of a package unless those dependencies were explicitly installed or are a hard requirement of another package
    • There is an important side effect of using this that you should be aware of. It can remove the optional dependencies of other packages.
  • The n means to not create .pacsave files for things in the backup array. Some things to consider here:
    • Very few packages have anything in the backup array
    • What goes in the backup array is mostly important config files in /etc and only a subset of those
    • A .pacsave is only created if you have modified the file
    • This leads to the question, are you sure you don’t want those .pacsave files?

So nothing “wrong” with that command. Just make sure you understand the implications and that those are things you actually want to have happen.

You mean you are doing something like clean mypasswordhere? If so, you really shouldn’t do that. That will put your password in plain text in your history file. If you have been doing this, you should really change your password and the root password.

Install the package rate-mirrors and then add

rate-mirrors arch | sudo tee /etc/pacman.d/mirrorlist

paccache -ruk0 should remove all cached uninstealled packages. I believe pacman -Sc will remove the whole cache.

The post @limotux linked to in my maintenance thread - he skipped over the updating of the Arch mirrorlist. It didn’t matter to correct him so much in the thread, but now it’s actually relevant.

1 Like

I don’t feel OK to remove optional dependencies…
This is EOS, Linux… not windoze anyway!
Oooops… then better avoid.

No, better avoid… why take a chance… my point of view!

I apologize if I misunderstood something… I am a noob anyway!
I just thought of each command independently.

and "echo “$1” removed

So, better keep paccache -ruk0 only… right?

You didn’t misunderstand it. You missed it completely. And as I mentioned since no one really will look over that post compared to the first post, it wasn’t necessary to fix it. But now that you’re linking to it specifically here you may want to consider going in and making sure you get all of my steps in your post and why in it in case someone links to it from here. If they then say well I used The idiot’s guide . . . to find out they used your abreviated post instead… . it will be confusing.

Or you could just link to the first post of that thread instead so you’re not missing anything.

It’s your thread man. I spent a long time putting together my guide, I’m going to keep using that.

I don’t think so. pacman -Sc removes uninstalled and pacman -Scc removes all.

Oh… sorry… of course I did not mean to cause any trouble to you or to anybody.

I will edit my OP.

And there we go. You’re right, just uninstalled.

-c, --clean

Remove packages that are no longer installed from the cache as well as currently unused sync databases to free up disk space. When pacman downloads packages, it saves them in a cache directory. In addition, databases are saved for every sync DB you download from and are not deleted even if they are removed from the configuration file pacman.conf(5). Use one –clean switch to only remove packages that are no longer installed; use two to remove all files from the cache. In both cases, you will have a yes or no option to remove packages and/or unused downloaded databases.

1 Like

Yes I did! I just took each command as just a command, independently… I did not link it all together.
My bad I admit!

OMG… too complicated for me!
I would better forget about this command I am trying to do.
And I would better be just a user… browse internet, LibreOffice… read PDF… update system… and that’s it!

Is this ok?

rate-mirrors arch | sudo tee /etc/pacman.d/mirrorlist
yay -Syu
paccache -ruk0
journalctl --vacuum-time=4weeks

The point is that the two commands do the same thing so just pick one of them. It doesn’t matter which.

It’s straight out of the pacman manual. . .


1 Like

Thank you… I will read it… just out of curiosity.
And I will stick to what I am… just a normal home user!
Things are different now than some time ago, and Arch is really different from other RPM, DEB based… though better.

Most of us are normal home users. It is just that some of us like to explore, tinker with and read man/wiki pages. I have been using Linux for a far shorter time than you :smile: