Skip to content

Instantly share code, notes, and snippets.

@g2g
Forked from rumansaleem/clean-up-arch-linux.md
Created March 19, 2025 15:09
Show Gist options
  • Save g2g/0a901218163edd4469d01d4678613854 to your computer and use it in GitHub Desktop.
Save g2g/0a901218163edd4469d01d4678613854 to your computer and use it in GitHub Desktop.

Revisions

  1. @rumansaleem rumansaleem created this gist May 28, 2019.
    73 changes: 73 additions & 0 deletions clean-up-arch-linux.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@
    ## 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
    ```bash
    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`.