Single Line Update Command(s)

I wonder if this command line is OK to update/upgrade and remove orphans and clean the system and cache.

sudo pacman -Syu && yay -Yc  && paccache -r && paccache -ruk0 && pacman -Rns $(pacman -Qdtq) > orphans && sudo pacman -Scc --noconfirm

I have to say thank you for @fbuddymechanic for his wonderful thread A Complete Idiot's Guide To Endeavour OS Maintenance / Update / Upgrade

I hope to hear from him and from you all, what do you think?

For me, it’s much easier to manage if each command is on a separate line in a script. For example, if one of the commands is failing, you can just comment it out while you troubleshoot; not as clean with a single-line solution.

1 Like

@ajgringo619 I appreciate your input as a “Dev ISO tester”
I am just trying to find a way to make it simple, just one command to update, upgrade, remove orphans, clear cache, uninstall unneeded software… etc to keep the system updated and clean.

I think -after we conclude something will work for sure, safe and does the job I may put it in a bash script and an alias perhaps.

You can setup a pacman hook to automatically clean up your pacman cache. Here’s what mine looks like.

[Trigger]
Operation = Remove
Operation = Install
Operation = Upgrade
Type = Package
Target = *

[Action]
Description = Keep the last cache and the currently installed.

Just place a file with that in it in /etc/pacman.d/hooks and adjust the options to your liking.
When = PostTransaction
Exec = /usr/bin/paccache -rvk3

1 Like

I don’t know if doing everything on only one line is a good idea. I don’t know y’all, but I personally want to do things one by one, just to make sure everything went all and I could more easily see what happens.

What is that?

You have 4 different commands that all remove things from the cache with different options. The last one removes everything. That is just pointless.

You also have two different orphan removals. One of which that is obviously better.

On top of that, you aren’t updating your AUR packages.

Don’t just take every command you find and put them together with &&

Doesn’t this much shorter line do the exact same thing:

sudo pacman -Syu && yay -Yc && sudo pacman -Scc --noconfirm

That being said, removing all the packages from cache is not advisable. That will make it much harder to recover from certain types of issues.

2 Likes

Thank you @dalto for your valuable input.

I repeat, I am no techie. I just got the commands from different posts here (while I am no techie so I do not know what each does “exactly” and what is the difference. Again I appreciate your patience and understanding that I am no techie)

Till now, I am trying not to use AUR.
Till now, I didn’t need anything from AUR.

So, what would you suggest? Should I remove clearing cache?

So, I will take the command you suggested.
I trust you, you know!

So, this:

sudo pacman -Syu && yay -Yc

Is enough and the best thing to do?

Claiming you aren’t a “techie” has nothing to do with it. It requires no technical skills to understand those commands. You simply need to read what they do. It takes effort, not skill or knowledge.

In that case, use this. It will clean your cache but not remove it.

sudo pacman -Syu && yay -Yc && sudo paccache -r
7 Likes

@limotux

One should avoid deleting from the cache all past versions of installed packages and all uninstalled packages unless one desperately needs to free some disk space. This will prevent downgrading or reinstalling packages without downloading them again.

https://wiki.archlinux.org/title/Pacman#Cleaning_the_package_cache

And as @dalto has said this will make it much harder to recover from certain types of issues.

2 Likes

I will add 2 cents, above and beyond what dalto has already written. I see no point in combining everything into one command or script. I see no reason to do each and every task you list every time you run an update. Stringing all these commands together also adds complexity and introduces potential for errors and inadvertent damage.

I run pacman -syu and pacman -Scc every day, and that is it. If I ever need to downgrade a package, I can retrieve it from the web. I have only trizen and downgrade from the AUR, so no need for me to concern myself with that since those two packages rarely update. If there is something I think I want, I research the alternatives and install it inside a VM to test the effectiveness of a new package, and if that works, I will install it on my system.

I sort of follow this also. Although i probably update a lot more times in a day than that. :wink:

1 Like

My final conclusion and decision
I will just update and use what is in the welcome app as I am currently doing.
Thanks everybody for your inputs.
I now learned something new I didn’t know before, that cache is important, it is not just cache.

A few clicks from the welcome app is much better and safer.

Just added sudo pacman -Syu && yay -Yc && sudo paccache -r to my .bash_history. Super convenient for when I do an update. Thanks for posing the question. :+1:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.