Skip to content

Instantly share code, notes, and snippets.

@rumansaleem
Created May 28, 2019 08:51
Show Gist options
  • Save rumansaleem/083187292632f5a7cbb4beee82fa5031 to your computer and use it in GitHub Desktop.
Save rumansaleem/083187292632f5a7cbb4beee82fa5031 to your computer and use it in GitHub Desktop.
Instructions to clean up Arch Linux (Manjaro)

Contents

  • Clean pkg cache
  • Remove unused packages (orphans)
  • Clean cache in /home
  • remove old config files
  • Find and Remove
    • duplicates
    • empty files
    • empty directories
    • broken symlinks
  • Find Large files

1 Clean pkg cache

List packages

ls /var/cache/pacman/pkg/ | less 

Remove all pkg except those installed

sudo pacman -Sc 

Remove all files

sudo pacman -Scc

Download manually from archive.

Automatically remove

sudo pacman -S pacman-contrib

Remove

paccache -r

Systemd timer create file in /etc/systemd/system/paccache.timer with the following contents

[Unit]
Description=Clean-up old pacman pkg cache

[Timer]
OnCalendar=monthly
Persistent=true

[Install]
WantedBy=multi-user.target

Enable by sudo systemctl start paccache.timer

Pacman post-transaction hook

2 remove unused packages

List unused

sudo pacman -Qtdq

Remove unused

sudo pacman -R $(pacman -Qtdq)

3 Clean home cache

cache is located in ~/.cache

4 Config Files

stored in ~/.config/

5 Find and remove

install rmlint package sudo pacman -S rm lint.

@3llena
Copy link

3llena commented Apr 14, 2022

use sudo pacman -Rs $(pacman -Qtdq) instead of sudo pacman -R $(pacman -Qtdq) otherwise you would have to run it multiple times in a row

-Rcns

@muxina-credo
Copy link

Awesome! Thanks.

@yusufalvian16
Copy link

thank you.

@mrcodekiddie
Copy link

🥺 Thanks everyone

@mnzsss
Copy link

mnzsss commented Nov 10, 2022

thanks!

@Ser4ph4
Copy link

Ser4ph4 commented Nov 12, 2022

thanks

@lypeInvictvs
Copy link

Very useful... Thank u, bro

@viniciusgonmelo
Copy link

Does sudo pacman -R $(pacman -Qtdq) also remove config files, something like apt autoremove --purge for Debian based distros?

@Bryan2333
Copy link

Does sudo pacman -R $(pacman -Qtdq) also remove config files, something like apt autoremove --purge for Debian based distros?

Nope, see Removing packages

@venkatrahul-software-development

Thanks, very useful in maintaining arch-manjaro system clean

@rabichawila
Copy link

Thanks, Bookmarking this Gold

@FromSi
Copy link

FromSi commented Feb 21, 2024

thanks

@aragon999
Copy link

use sudo pacman -Rs $(pacman -Qtdq)
instead of sudo pacman -R $(pacman -Qtdq) otherwise you would have to run it multiple times in a row

This won't work as -s is for --search
https://archlinux.org/pacman/pacman.8.html

That is only true for sync (-S) or query (-Q) operations. For remove (-R) operations -s is for recursive. See "Remove Options" on the pacman man page.

@fastoch
Copy link

fastoch commented Apr 17, 2024

use sudo pacman -Rs $(pacman -Qtdq)
instead of sudo pacman -R $(pacman -Qtdq) otherwise you would have to run it multiple times in a row

This won't work as -s is for --search
https://archlinux.org/pacman/pacman.8.html

That is only true for sync (-S) or query (-Q) operations. For remove (-R) operations -s is for recursive. See "Remove Options" on the pacman man page.

You're right, I've removed my comment.

@PthDE
Copy link

PthDE commented May 31, 2024

Immensely informative and practical.
Thank you so much!

@progeroffline
Copy link

Thanks!

@Agusioma
Copy link

Agusioma commented Jul 3, 2024

🍾🍾🍾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment