A User Command to Clean and Update System

But, honestly, Arch is completely different than other distros… much better in my humble experience.

Plus, I have been on EndeavourOS/Arch for less than 1 month! +2 months on another Arch based distro, (Previously I was on OpenSuse, most of the time then some DEB based…
So, I am an absolute noob…

It’s all terribly unnecessary and just adds more potential for something to go wrong.

Just run

yay

every couple of days. That’s really all you need to do normally. When something needs fixing, then you may need some of those other commands but in normal use, you really don’t.

You can’t possibly be that low on storage space to warrant cleaning your cache on every update (and if you are, it’s best to setup a soystemd timer to do it for you). Your mirrorlists cannot possibly be that terrible that you need to rank your mirrors on every update (and if you do, it’s better to handle that with a pacman hook)… “Vacuuming” your system log is also unnecessary, unless your root partition is getting low on space.

And you can’t possibly create that many orphan packages that you need to delete them on every update. Also, removing orphans after updating is just stupid, the time to do that is before the update, because the whole point of it is to make updating faster. But… it should never be done automatically: pacman -Rns $(pacman -Qdtq) may remove more than you want and create problems.

This whole clean.sh script is just another example of making your life more complicated than it needs to be. I’m positive it will just create more problems for you than it will solve.

4 Likes

You can run the whole script with sudo ie. sudo clean.sh or make the script detect if it is root and call sudo if necessary then rerun itself.
echo doesn’t look safe to me.

It is unsafe to run an AUR helper like yay as root.

clean.sh is to clean not to update.
I just created “clean.sh”:

  • I once ran into a lot of 404 upon updating with “yay”
  • It is just a script to run IFF needed not to update
    - mainly to practice and learn more
  • to just write down how to create an alias

I will modify accordingly. Thanks. Now I learned something new.

I will appreciate if you have a better suggestion.

I modified it and removed “echo” - previous post.

Just to learn more (and not to create another thread)

Since I started with Suse 7 in 2000, I knew Linux did not have that problem of windoze of leaving junk, orphans, and trash behind - that makes windoze more and more irresponsive as time passes (this was my understanding then)

So, what happened? Where/Why all this orphans/cache… in Arch (or Linux)?

Did I miss something or misunderstand something (as usual) way back in 2000? Or things in Linux have changed? or is it Arch specific?

Just to understand more, do cache, orphans,… etc (if not ever cleaned) affect:

  • EOS performance?
  • EOS update/upgrade time
  • do they really take disk space?

Is it okay to just never do any of the commands in “clean.sh”?

No, performance is not affected in any way by having many packages installed. Or having old packages in cache. The only time this can be a problem is if you completely run out of space, which you’ll probably notice before it happens and then act accordingly to prevent it.

Yes, because you are updating orphan packages as well.

Yes, they take up disk space like any other installed package.

An orphan package is just a package that was installed as a dependency for another package, and then stopped being needed (either because the dependant package was removed, or changed dependencies). Orphan packages are still fully functional packages installed on your system. They are not junk.

It’s just that they are no longer a dependency for something else, so in that sense they can be removed. But they can still be optional dependencies (which you may want to keep) or they can be useful to you on their own.

When removing orphan packages, you should understand what they do and know whether you want to remove them or not. You should manually go through the list of them and decide on each one whether to keep it or remove it.

I am confused. How come not needed and maybe needed?

  • To clean the package cache you could enable a service that does it periodically. Try paccache-service-manager for this.

  • To keep your system up to date, run yay periodically, e.g. once a day or once a week.

  • If mirrors start causing problems, re-rank the Arch mirrors (many alternatives, e.g. rate-mirrors, reflector, reflector-simple). Also re-ranking the EndeavousOS mirrors may be needed (eos-rankmirrors) in case they cause issues.

2 Likes

Yeah, I can see. It may be a bad idea to write automation scripts that remove an unknown number of packages while in a state of confusion. Just saying…

Like I said, an orphan package is a package that was installed as a dependency for another package but stopped being a dependency (so in the sense of that other packege needing it, it is not longer needed). But that doesn’t mean you don’t need it for something else.

1 Like

So, I better remove! I am not in position to “decide” when it comes to this!

Well, who is then? It’s your system, of course you’re in position to decide which packages to have installed and which to remove!

2 Likes

If you know apt from Deb distros well, you can compare it with pacman or yay which option is available:

https://wiki.archlinux.org/title/Pacman/Rosetta

This would be helpful for Pacman beginners.

Sure I understand!
But for a noob like me I do not have enough technical knowledge to decide!
So, my rule of thumb applies. That is “just don’t change anything, just go with the defaults” to be on the safe side.

You don’t need (a lot of) technical knowledge to decide whether you want a package or not.

pacman -Qi package_name

Look at the description, required by, optional for, replaces, install reason and other fields. This will tell you all you need to know to decide whether to keep the package or not.

Also, look at the package size. If you are unsure whether to keep it or remove it, and it’s a tiny package, just keep it. Do you really benefit from freeing half a megabyte of storage? I doubt it…

1 Like

You can add pacman shortcuts instead script.

For bash user
Edit $HOME/.bashrc
OR
For zsh user
Edit $HOME/.zshrc
OR
(For fish user)
(Edit $HOME/.config/fish/fish.config)

#Pacman Shortcuts
alias install="sudo pacman -S"
alias update="sudo pacman -Syyu"
alias search="sudo pacman -Ss"
alias search-local="sudo pacman -Qs"
alias pkg-info="sudo pacman -Qi"
alias local-install="sudo pacman -U"
alias clear-cache="sudo pacman -Scc"
alias unlock="sudo rm /var/lib/pacman/db.lck"
alias remove="sudo pacman -R"
alias autoremove="sudo pacman -Rns"
2 Likes

Note that some of those aliases should not have sudo in them…
Nice list.

1 Like

According to what I learned from all of you here, I would better make it:


#!/bin/bash
rate-mirrors arch | sudo tee /etc/pacman.d/mirrorlist
eos-rankmirrors
### paccache -ruk0
### journalctl --vacuum-time=4weeks

yay -Syu

I will rename it then to “update” or “mirrorcheck”…. Something like that!

This amazing :star_struck:
A wonderful list of aliases