Pacman remove orphans

Pacman remove orphans DEFAULT

How to clean Arch Linux

Every system becomes cluttered sooner or later and Arch Linux is not the exception. So, in this post, you will learn how to clean your Arch Linux system.

INTRODUCTION

Although Arch Linux takes little of disk space right after the installation, as the time passes it grows quite a lot. So, if you do not have any free space left on your computer or you just would like to keep your Arch Linux system clean, this post is all you need.

In this post, you will learn how to:

  1. Clean package cache
  2. Remove unused packages (orphans)
  3. Clean the cache in your /home directory
  4. Remove old config files
  5. Remove duplicates, empty files, empty directories and broken symlinks
  6. Find the largest files and directories
  7. Disk cleaning programs that can do most of the steps above automatically
  8. Clean Systemd journal

NOTE that I would like to warn you that you may damage your system if you do a mistake during these procedures. So, please back up all your files before doing anything to your system.

VIDEO

Steps to Clean Arch Linux

1. Clean package cache

Pacman, a package manager of Arch Linux, stores all downloaded packages in and it does not remove the old or uninstalled versions automatically. You might think this is a mistake, but this is done deliberately. This allows downgrading a package without the need to retrieve the previous version through the Arch Linux Archive. Or if you uninstall a program, you can easily reinstall it without a new download. If you have a slow internet connection, this may be useful. For example, you can simply install a package from this directory using the command below.

However, this folder can grow indefinitely in size.

Showing the size of downloaded packages in my Arch Linux

So, you need to clean it from time to time. There are two ways you can do that: manually and automatically.

Cleaning the cache manually

You can clean the cache manually. For example, I usually move these files to my old hard drive that I use only to store data. This way I can always access these files but they do not take valuable space on my system.

However, if you do not have extra space to store these packages, you can remove them without a backup. One option is to remove cached packages that are not currently installed:

The other option is to remove all the package from the cache, including those that are installed:

Delete the PKG cache to save space

And if you happen to need some of these packages after you removed them, you can go to Arch Package Archive and download them manually. This is not an optimal solution if you need to download many packages because downloading them manually will take quite some time, but it is still possible.

Cleaning the cache Automatically

Another way to clean the directory is to use a script that automatically deletes all cached versions of installed and uninstalled packages, except for the most recent 3 versions. The script is called . You can install it with the package.

For available, options check the help menu of .

Showing the Paccache help

For example, you can run it in the dry mode to see how many packages will be removed using the option. Then, you can run a real clean by using the option.

Running paccache

Run monthly

A very useful way to use this script is to have it run automatically once a month using the systemd timer. Basically, you need to create the file in , which will trigger .

So, you create a file with nano:

Then, to run this script monthly, paste the following content into this file:

After that, start the systemd service:

Finally, you can check the service status.

The paccache status in systemd is active

So, you should see the message that it is active. Now, will run every month and clean the cache of your old and uninstalled packages.

Run after

Alternatively to this timer, you can also run every time after you run . So, you need to create a Hook for that. Just create a file .

After that, add this content on the file.

Now, if I remove a package using , will also be executed.

Now paccache will run after pacman

Did not you know this way to clean up Arch Linux?

2. Remove unused packages (orphans)

When you install and remove packages in Arch Linux, some unused orphans packages may remain on your system. To find them you need to run this command:

Showing the orphan packages

As you can see, by executing the above command, you will be able to know which packages are orphans. To remove them, you need to modify the command with the remove action:

Removing the orphan packages

Now, you know how to clean Arch Linux system files by removing the pkg cache and removing the orphan packages. However, there are still more things to do in your home folder.

3. Clean the cache in your /home directory

In this step, I will show you how to clean Arch Linux by removing the cache files in your folder.

As we use our system, the cache will fill up and take up a lot of space. So, the first thing you probably would want to do is to clean cache in your user directory. If you want to check the size of your cache folder, you can do it with this command:

Show the cache folder size in the home directory

To clean it, you need to remove all files inside it:

And that is it.

4. Remove old config files

The configuration files of different programs are stored in . You can enter it from your file manager and check if there any config files left from the programs you uninstalled. Just select those folders and delete them. But before you remove any file, I would also remind you that it is better to have a backup of all your files before you remove anything.

The .config folder is where the configuration files are

Some old files may also be lying in . Check it too and delete some files and folders if necessary.

5. Remove duplicates, empty files, empty directories and broken symlinks

You can do even more cleaning by removing duplicated and empty files and directories. To keep some order in your system, I also recommend removing broken symlinks, e.i. links that lead to non-existing filer or folders. They do not take much space, but they clutter your system. To remove such things, you can use the program .

Install it:

If you check all its options with , you will see there are pretty many. I recommend to explore them.

rmlint has many options

However, using this application is quite simple, you can run it by specifying the directory you want to check for duplicated files. For example:

Using rmlint on the home folder

This program will list everything it finds and creates a shell script to remove this lint. The script can be found in the home folder. Open it using a text editor, scroll down and check what files it will remove.

rmlint generates a script file

You can remove some of these files manually, or if you agree with suggested remove action you can go back to the terminal and execute this script. Again, make sure you have a backup of all files before you run this script. This action will be irreversible.

Removing duplicates file using rmlint

Now, your system is cleaner. But it is not the end, there are still a few things you can do to clean it even further.

6. Find the largest files and directories

You can check what the largest files in your system are and maybe you do not need them. To accomplish this task, you can use some command line tools or graphical programs. For the command line tool, I use .

To install it, run this command:

Search for the largest directories and then go inside those directories and find the largest files and remove them if you do not need them.

Using ncdu to find the largest folder on the system

If you prefer a graphical program you can use for Plasma 5. It shows a graphical summary for all hard-drives and you can go inside and check the directories, then go inside the largest directories and so on until.

Using filelight

If you are using Gnome, you ca install . There are some other tools listed in Arch Wiki. Pick whatever you like.

Others disk usage display tools

7. Disk cleaning programs

There are also some disk cleaning programs that can do many of the tasked listed above automatically. Nevertheless, since you use Arch Linux, I do not recommend using these programs. It is not always obvious what exactly will be done and you do not have full control of your system. Besides, you can very easily delete some configuration files you did not want to delete.

But I still would like to share with you this option as some user may still prefer all-in-one package for system cleaning.

Disk cleaning tools available on Arch Linux

Among all automatic cleaning programs in Arch Linux, Bleachbit is probably the most popular. It has a nice graphical interface and it can do most of the things I have shown above. For example, you can clean your system cache. Just select it, and click on the clean button.

How to clean Arch Linux using Bleachbit

In the end, you will see something like this.

Cleaning the cache using Bleachbit

Which means your system cache has been cleaned.

Check out the other options of Bleachbit. I believe most of them are self-explanatory.

Update

Thanks to the comments on YouTube and below this post, I can improve this post by extending this list. Below, you will find a few more things you can do to clean your Arch Linux system.

8. Clean Systemd journal

Systemd stores its logs in and these logs can be very useful as I described in my post on 10 Things to do first after installing Arch Linux. However, these log files can take up to 10% of your system size by default. There are two solution to limit this size.

  1. You can clean these log files manually when you run out of space. You can keep only the latest logs by size limit (e.g. keep only 50Mb of the latest logs):

Or by time limit (e.g. last 4 weeks):

  1. You can also set such limit as permanent and never worry about cleaning the logs. Just edit the file by uncommenting and setting the size limit:

This is what I choose to do and that is why I missed this point when I originally wrote this article. I simply never experienced large journalctl files.

I would like to acknowledge Sebastian for pointing this out in the comments section.

CONCLUSION

Now that you know how to clean Arch Linux, so there are no excuses not to do it on your system :-) Remember that lack of free space may slow down your system, so in some sense, these things help to maintain a stable and fluid system.

However, I cannot know everything. If there is something you would add, please comment below.

You may also like my post about Install and configure Plasma 5 on Arch Linux.

Please consider supporting this project:


Become a patronBuy me a coffeeBuy me a coffee Shop on Amazon Buy Linux Laptop Build Linux PC BTC: 1CfCLTYCqqDfYbngcvQtEav3n7SMZihfSS

Average Linux User

Average Linux UserFollowI am the founder of the Average Linux User project, which is a hobby I work on at night. During the day I am a scientist who uses computers to analyze genetic data.

Sours: https://averagelinuxuser.com/clean-arch-linux/
Pacman it is, without a doubt, one of the best package managers. However, some of its associated managers (such as Yogurt o Packer) although they are very good, they leave a little to be desired. In particular, by staying truncate la installation de packages through AUR it is common for installed dependencies not to be removed properly after a compilation failure. This is especially true, the higher the number of dependencies to install.


The solution is very simple: we must delete the packages that were orphaned (that is, no other package needs them and we can delete them without causing problems).

I just opened a terminal and wrote:

sudo pacman -Rs $ (pacman -Qtdq)

What it does is delete all the packages and their dependencies (pacman -Rs) from a specific package list (which, in our case, are the orphaned packages, whose list is obtained with pacman -Qtdq).

For those who come from Ubuntu, this command is similar to sudo apt-get autoremove.


Sours: https://blog.desdelinux.net/en/como-quitar-paquetes-huerfanos-en-arch/
  1. Drum type crossword clue
  2. Schwinn adjustable rear rack
  3. Bauer hammer drill

pacman/Tips and tricks

Related articles

For general methods to improve the flexibility of the provided tips or pacman itself, see Core utilities and Bash.

Maintenance

Note: Instead of using comm (which requires sorted input with sort) in the sections below, you may also use or .

See also System maintenance.

Listing packages

With version

You may want to get the list of installed packages with their version, which is useful when reporting bugs or discussing installed packages.

  • List all explicitly installed packages: .
  • List all packages in the package group named :
  • List all foreign packages (typically manually downloaded and installed or packages removed from the repositories): .
  • List all native packages (installed from the sync database(s)): .
  • List all explicitly installed native packages (i.e. present in the sync database) that are not direct or optional dependencies: .
  • List packages by regex: .
  • List packages by regex with custom output format (needs expac): .

With size

Figuring out which packages are largest can be useful when trying to free space on your hard drive. There are two options here: get the size of individual packages, or get the size of packages and their dependencies.

Individual packages

The following command will list all installed packages and their individual sizes:

$ LC_ALL=C pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h
Packages and dependencies

To list package sizes with their dependencies,

  • Install expac and run .
  • Run pacgraph with the option.

To list the download size of several packages (leave blank to list all packages):

$ expac -S -H M '%k\t%n' packages

To list explicitly installed packages not in the meta packagebase nor package groupbase-devel with size and description:

$ expac -H M "%m\t%n\t%10d" $(comm <(pacman -Qqen | sort) <({ pacman -Qqg base-devel; expac -l '\n' '%E' base; } | sort | uniq)) | sort -n

To list the packages marked for upgrade with their download size

$ expac -S -H M '%k\t%n' $(pacman -Qqu) | sort -sh

By date

To list the 20 last installed packages with expac, run:

$ expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort | tail -n 20

or, with seconds since the epoch ( UTC):

$ expac --timefmt=%s '%l\t%n' | sort -n | tail -n 20

Not in a specified group, repository or meta package

Note: To get a list of packages installed as dependencies but no longer required by any installed package, see #Removing unused packages (orphans).

List explicitly installed packages not in the basemeta package:

$ comm <(pacman -Qqe | sort) <(expac -l '\n' '%E' base | sort)

List explicitly installed packages not in the base meta package or base-develpackage group:

$ comm <(pacman -Qqe | sort) <({ pacman -Qqg base-devel; expac -l '\n' '%E' base; } | sort -u)

List all installed packages unrequired by other packages, and which are not in the base meta package or base-devel package group:

$ comm <(pacman -Qqt | sort) <({ pacman -Qqg base-devel; expac -l '\n' '%E' base; } | sort -u)

As above, but with descriptions:

$ expac -H M '%n\t%10d' $(comm <(pacman -Qqt | sort) <({ pacman -Qqg base-devel; expac -l '\n' '%E' base; } | sort -u))

List all installed packages that are not in the specified repository repo_name

$ comm <(pacman -Qq | sort) <(pacman -Sql repo_name | sort)

List all installed packages that are in the repo_name repository:

$ comm <(pacman -Qq | sort) <(pacman -Sql repo_name | sort)

List all packages on the Arch Linux ISO that are not in the base meta package:

$ comm <(curl https://gitlab.archlinux.org/archlinux/archiso/-/raw/master/configs/releng/packages.x86_64) <(expac -l '\n' '%E' base | sort)

Tip: Alternatively, use (instead of ) from the moreutils package which has a syntax that is easier to remember. See combine(1).

Development packages

To list all development/unstable packages, run:

$ pacman -Qq | grep -Ee '-(bzr|cvs|darcs|git|hg|svn)$'

Browsing packages

To browse all installed packages with an instant preview of each package:

$ pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'

This uses fzf to present a two-pane view listing all packages with package info shown on the right.

Enter letters to filter the list of packages; use arrow keys (or /) to navigate; press to see package info under less.

To browse all packages currently known to pacman (both installed and not yet installed) in a similar way, using fzf, use:

$ pacman -Slq | fzf --preview 'pacman -Si {}' --layout=reverse

The navigational keybindings are the same, although Enter will not work in the same way.

Listing files owned by a package with size

This one might come in handy if you have found that a specific package uses a huge amount of space and you want to find out which files make up the most of that.

$ pacman -Qlq package | grep -v '/$' | xargs -r du -h | sort -h

Identify files not owned by any package

If your system has stray files not owned by any package (a common case if you do not use the package manager to install software), you may want to find such files in order to clean them up.

One method is to use as the root user from pacutils which will list unowned files among other details.

Another is to list all files of interest and check them against pacman:

# find /etc /usr /opt | LC_ALL=C pacman -Qqo - 2>&1 >&- >/dev/null | cut -d ' ' -f 5-

Tip: The lostfiles script performs similar steps, but also includes an extensive blacklist to remove common false positives from the output.

Tracking unowned files created by packages

Most systems will slowly collect several ghost files such as state files, logs, indexes, etc. through the course of usual operation.

from pacutils can be used to track these files and their associations via (see pacreport(1) §&#;FILES).

An example may look something like this (abridged):

/etc/pacreport.conf[Options] IgnoreUnowned = usr/share/applications/mimeinfo.cache [PkgIgnoreUnowned] alsa-utils = var/lib/alsa/asound.state bluez = var/lib/bluetooth ca-certificates = etc/ca-certificates/trust-source/* dbus = var/lib/dbus/machine-id glibc = etc/ld.so.cache grub = boot/grub/* linux = boot/initramfs-linux.img pacman = var/lib/pacman/local update-mime-database = usr/share/mime/magic

Then, when using as the root user, any unowned files will be listed if the associated package is no longer installed (or if any new files have been created).

Additionally, aconfmgr (aconfmgr-gitAUR) allows tracking modified and orphaned files using a configuration script.

Removing unused packages (orphans)

For recursively removing orphans and their configuration files:

# pacman -Qtdq | pacman -Rns -

If no orphans were found, the output is . This is expected as no arguments were passed to .

Note: The arguments list only true orphans. To include packages which are optionally required by another package, pass the flag twice (i.e., ).

Removing everything but essential packages

If it is ever necessary to remove all packages except the essentials packages, one method is to set the installation reason of the non-essential ones as dependency and then remove all unnecessary dependencies.

First, for all the packages installed "as explicitly", change their installation reason to "as dependency":

# pacman -D --asdeps $(pacman -Qqe)

Then, change the installation reason to "as explicitly" of only the essential packages, those you do not want to remove, in order to avoid targeting them:

# pacman -D --asexplicit base linux linux-firmware
Note:
  • Additional packages can be added to the above command in order to avoid being removed. See Installation guide#Install essential packages for more info on other packages that may be necessary for a fully functional base system.
  • This will also select the bootloader's package for removal. The system should still be bootable, but the boot parameters might not be changeable without it.

Finally, follow the instructions in #Removing unused packages (orphans) to remove all packages that have installation reason "as dependency".

Getting the dependencies list of several packages

Dependencies are alphabetically sorted and doubles are removed.

Note: To only show the tree of local installed packages, use .

$ LC_ALL=C pacman -Si packages | awk -F'[:<=>]' '/^Depends/ {print $2}' | xargs -n1 | sort -u

Alternatively, with expac:

$ expac -l '\n' %E -S packages | sort -u

Listing changed backup files

If you want to back up your system configuration files, you could copy all files in but usually you are only interested in the files that you have changed. Modified backup files can be viewed with the following command:

# pacman -Qii | awk '/^MODIFIED/ {print $2}'

Running this command with root permissions will ensure that files readable only by root (such as ) are included in the output.

Tip: See #Listing all changed files from packages to list all changed files pacman knows about, not only backup files.

Back up the pacman database

The following command can be used to back up the local pacman database:

$ tar -cjf pacman_database.tar.bz2 /var/lib/pacman/local

Store the backup pacman database file on one or more offline media, such as a USB stick, external hard drive, or CD-R.

The database can be restored by moving the file into the directory and executing the following command:

# tar -xjvf pacman_database.tar.bz2

Note: If the pacman database files are corrupted, and there is no backup file available, there exists some hope of rebuilding the pacman database. Consult #Restore pacman's local database.

Tip: The pakbak-gitAUR package provides a script and a systemd service to automate the task. Configuration is possible in .

Check changelogs easily

When maintainers update packages, commits are often commented in a useful fashion. Users can quickly check these from the command line by installing pacologAUR. This utility lists recent commit messages for packages from the official repositories or the AUR, by using .

Installation and recovery

Alternative ways of getting and restoring packages.

Installing packages from a CD/DVD or USB stick

To download packages, or groups of packages:

# cd ~/Packages # pacman -Syw --cachedir . base base-devel grub-bios xorg gimp # repo-add ./custom.db.tar.gz ./*

Pacman, which will reference the host installation by default, will not properly resolve and download existing dependencies. In cases where all packages and dependencies are wanted, it is recommended to create a temporary blank DB and reference it with :

# mkdir /tmp/blankdb # pacman -Syw --cachedir . --dbpath /tmp/blankdb base base-devel grub-bios xorg gimp # repo-add ./custom.db.tar.gz ./*

Then you can burn the "Packages" folder to a CD/DVD or transfer it to a USB stick, external HDD, etc.

To install:

1. Mount the media:

# mkdir /mnt/repo # mount /dev/sr0 /mnt/repo #For a CD/DVD. # mount /dev/sdxY /mnt/repo #For a USB stick.

2. Edit and add this repository before the other ones (e.g. extra, core, etc.). This is important. Do not just uncomment the one on the bottom. This way it ensures that the files from the CD/DVD/USB take precedence over those in the standard repositories:

/etc/pacman.conf[custom] SigLevel = PackageRequired Server = file:///mnt/repo/Packages

3. Finally, synchronize the pacman database to be able to use the new repository:

# pacman -Syu

Custom local repository

Use the repo-add script included with pacman to generate a database for a personal repository. Use for more details on its usage. A package database is a tar file, optionally compressed. Valid extensions are .db or .files followed by an archive extension of .tar, .tar.gz, .tar.bz2, .tar.xz, .tar.zst, or .tar.Z. The file does not need to exist, but all parent directories must exist.

To add a new package to the database, or to replace the old version of an existing package in the database, run:

$ repo-add /path/to/repo.db.tar.gz /path/to/packagex86_pkg.tar.xz

The database and the packages do not need to be in the same directory when using repo-add, but keep in mind that when using pacman with that database, they should be together. Storing all the built packages to be included in the repository in one directory also allows to use shell glob expansion to add or update multiple packages at once:

$ repo-add /path/to/repo.db.tar.gz /path/to/*.pkg.tar.xz

Warning:repo-add adds the entries into the database in the same order as passed on the command line. If multiple versions of the same package are involved, care must be taken to ensure that the correct version is added last. In particular, note that lexical order used by the shell depends on the locale and differs from the vercmp(8) ordering used by pacman.

If you are looking to support multiple architectures then precautions should be taken to prevent errors from occurring. Each architecture should have its own directory tree:

$ tree ~/customrepo/ | sed "s/$(uname -m)/<arch>/g"/home/archie/customrepo/ └── <arch> ├── customrepo.db -> customrepo.db.tar.xz ├── customrepo.db.tar.xz ├── customrepo.files -> customrepo.files.tar.xz ├── customrepo.files.tar.xz └── personal-website-git-b99cce<arch>.pkg.tar.xz 1 directory, 5 files

The repo-add executable checks if the package is appropriate. If this is not the case you will be running into error messages similar to this:

==> ERROR: '/home/archie/customrepo/<arch>/foo-<arch>.pkg.tar.xz' does not have a valid database archive extension.

repo-remove is used to remove packages from the package database, except that only package names are specified on the command line.

$ repo-remove /path/to/repo.db.tar.gz pkgname

Once the local repository database has been created, add the repository to for each system that is to use the repository. An example of a custom repository is in . The repository's name is the database filename with the file extension omitted. In the case of the example above the repository's name would simply be repo. Reference the repository's location using a url, or via FTP using ftp://localhost/path/to/directory.

If willing, add the custom repository to the list of unofficial user repositories, so that the community can benefit from it.

Network shared pacman cache

If you happen to run several Arch boxes on your LAN, you can share packages so that you can greatly decrease your download times. Keep in mind you should not share between different architectures (i.e. i and x86_64) or you will run into problems.

Read-only cache

Note: If pacman fails to download 3 packages from the server, it will use another mirror instead. See https://bbs.archlinux.org/viewtopic.php?id=

If you are looking for a quick solution, you can simply run a standalone webserver, e.g. darkhttpd, which other computers can use as a first mirror:

# ln -s /var/lib/pacman/sync/*.db /var/cache/pacman/pkg $ sudo -u http darkhttpd /var/cache/pacman/pkg --no-server-id

You could also run darkhttpd as a systemd service for convenience. Just add this server at the top of your in client machines with . Make sure to keep your mirror updated.

If you are already running a web server for some other purpose, you might wish to reuse that as your local repository server instead of darkhttpd. For example, if you already serve a site with nginx, you can add an nginx server block listening on port

/etc/nginx/nginx.confserver { listen ; root /var/cache/pacman/pkg; server_name myarchrepo.localdomain; try_files $uri $uri/; }

Remember to restart nginx after making this change.

Whichever web server you use, remember to open port to local traffic (and you probably want to deny anything not local). For example, if using iptables, add to your ruleset (adjust for your LAN subnet if necessary).

Overlay mount of read-only cache

It is possible to use one machine on a local network as a read-only package cache by overlay mounting its directory. Such a configuration is advantageous if this server has installed on it a reasonably comprehensive selection of up-to-date packages which are also used by other boxes. This is useful for maintaining a number of machines at the end of a low bandwidth upstream connection.

As an example, to use this method:

# mkdir /tmp/remote_pkg /mnt/workdir_pkg /tmp/pacman_pkg # sshfs <remote_username>@<remote_pkgcache_addr>:/var/cache/pacman/pkg /tmp/remote_pkg -C # mount -t overlay overlay -o lowerdir=/tmp/remote_pkg,upperdir=/var/cache/pacman/pkg,workdir=/mnt/workdir_pkg /tmp/pacman_pkg

Note concerning overlay: The working directory must be an empty directory on the same mounted device as the upper directory.

After this, run pacman using the option , e.g.:

# pacman -Syu --cachedir /tmp/pacman_pkg

Distributed read-only cache

There are Arch-specific tools for automatically discovering other computers on your network offering a package cache. Try pacredir, pacserve, pkgdistcacheAUR, or paclanAUR. pkgdistcache uses Avahi instead of plain UDP which may work better in certain home networks that route instead of bridge between WiFi and Ethernet.

Historically, there was PkgD and multipkg, but they are no longer maintained.

Read-write cache

In order to share packages between multiple computers, simply share using any network-based mount protocol. This section shows how to use shfs or SSHFS to share a package cache plus the related library-directories between multiple computers on the same local network. Keep in mind that a network shared cache can be slow depending on the file-system choice, among other factors.

First, install any network-supporting filesystem packages: shfs-utils, sshfs, curlftpfs, samba or nfs-utils.

Tip:
  • To use sshfs or shfs, consider reading Using SSH Keys.
  • By default, smbfs does not serve filenames that contain colons, which results in the client downloading the offending package afresh. To prevent this, use the mount option on the client.

Then, to share the actual packages, mount from the server to on every client machine.

Warning: Do not make or any of its ancestors (e.g., ) a symlink. Pacman expects these to be directories. When pacman re-installs or upgrades itself, it will remove the symlinks and create empty directories instead. However during the transaction pacman relies on some files residing there, hence breaking the update process. Refer to FS# for further details.

two-way with rsync

Another approach in a local environment is rsync. Choose a server for caching and enable the Rsync#rsync daemon. On clients synchronize two-way with this share via the rsync protocol. Filenames that contain colons are no problem for the rsync protocol.

Draft example for a client, using within the share name ensures an architecture-dependent sync:

# rsync rsync://server/share_$(uname -m)/ /var/cache/pacman/pkg/ # pacman # paccache # rsync /var/cache/pacman/pkg/ rsync://server/share_$(uname -m)/

Dynamic reverse proxy cache using nginx

nginx can be used to proxy package requests to official upstream mirrors and cache the results to the local disk. All subsequent requests for that package will be served directly from the local cache, minimizing the amount of internet traffic needed to update a large number of computers.

In this example, the cache server will run at and store the packages in .

Install nginx on the computer that is going to host the cache. Create the directory for the cache and adjust the permissions so nginx can write files to it:

# mkdir /srv/http/pacman-cache # chown http:http /srv/http/pacman-cache

Use the nginx pacman cache config as a starting point for . Check that the directive works for your needs. In the upstream server blocks, configure the directives with addresses of official mirrors, see examples in the config file about the expected format. Once you are satisfied with the configuration file start and enable nginx.

In order to use the cache each Arch Linux computer (including the one hosting the cache) must have the following line at the top of the file:

/etc/pacman.d/mirrorlistServer = http://cache.domain.example/$repo/os/$arch

Note: You will need to create a method to clear old packages, as the cache directory will continue to grow over time. (which is provided by pacman-contrib) can be used to automate this using retention criteria of your choosing. For example, will keep the last 2 versions of packages in your cache directory.

Pacoloco proxy cache server

Pacoloco is an easy-to-use proxy cache server for pacman repositories. It also allows automatic prefetching of the cached packages.

It can be installed as pacoloco. Open the configuration file and add pacman mirrors:

/etc/pacoloco.yamlport: repos: mycopy: urls: - http://mirror.lty.me/archlinux - http://mirrors.kernel.org/archlinux

Restart and the proxy repository will be available at .

Flexo proxy cache server

Flexo is yet another proxy cache server for pacman repositories. Flexo is available as flexo-gitAUR. Once installed, start the unit.

Flexo runs on port by default. Enter to the top of your so that pacman downloads packages via Flexo.

Synchronize pacman package cache using synchronization programs

Use Syncthing or Resilio Sync to synchronize the pacman cache folders (i.e. ).

Preventing unwanted cache purges

By default, removes package tarballs from the cache that correspond to packages that are not installed on the machine the command was issued on. Because pacman cannot predict what packages are installed on all machines that share the cache, it will end up deleting files that should not be.

To clean up the cache so that only outdated tarballs are deleted, add this entry in the section of :

CleanMethod = KeepCurrent

Recreate a package from the file system

To recreate a package from the file system, use fakepkgAUR. Files from the system are taken as they are, hence any modifications will be present in the assembled package. Distributing the recreated package is therefore discouraged; see ABS and Arch Linux Archive for alternatives.

List of installed packages

Keeping a list of all the explicitly installed packages can be useful, to backup a system for example or speed up installation on a new system:

$ pacman -Qqe > pkglist.txt
Note:
  • With option , the packages already required by other explicitly installed packages are not mentioned. If reinstalling from this list they will be installed but as dependencies only.
  • With option , foreign packages (e.g. from AUR) would be omitted from the list.
  • Use to also create a list of the installed optional dependencies which can be reinstalled with .
  • Use to create the list of AUR and other foreign packages that have been explicitly installed.

To keep an up-to-date list of explicitly installed packages (e.g. in combination with a versioned ), you can set up a hook. Example:

[Trigger] Operation = Install Operation = Remove Type = Package Target = * [Action] When = PostTransaction Exec = /bin/sh -c '/usr/bin/pacman -Qqe > /etc/pkglist.txt'

Install packages from a list

To install packages from a previously saved list of packages, while not reinstalling previously installed packages that are already up-to-date, run:

# pacman -S --needed - < pkglist.txt

However, it is likely foreign packages such as from the AUR or installed locally are present in the list. To filter out from the list the foreign packages, the previous command line can be enriched as follows:

# pacman -S --needed $(comm <(pacman -Slq | sort) <(sort pkglist.txt))

Eventually, to make sure the installed packages of your system match the list and remove all the packages that are not mentioned in it:

# pacman -Rsu $(comm <(pacman -Qq | sort) <(sort pkglist.txt))

Tip: These tasks can be automated. See bacpacAUR, packupAUR, pacmanityAUR, and pugAUR for examples.

Listing all changed files from packages

If you are suspecting file corruption (e.g. by software/hardware failure), but are unsure if files were corrupted, you might want to compare with the hash sums in the packages. This can be done with pacutils:

# paccheck --md5sum --quiet

For recovery of the database see #Restore pacman's local database. The files can also be extracted as from the respective package files.

Note: This should not be used as is when suspecting malicious changes! In this case security precautions such as using a live medium and an independent source for the hash sums are advised.

Reinstalling all packages

To reinstall all native packages, use:

# pacman -Qqn | pacman -S -

Foreign (AUR) packages must be reinstalled separately; you can list them with .

Pacman preserves the installation reason by default.

Warning: To force all packages to be overwritten, use , though this should be an absolute last resort. See System maintenance#Avoid certain pacman commands.

Restore pacman's local database

See pacman/Restore local database.

Recovering a USB key from existing install

If you have Arch installed on a USB key and manage to mess it up (e.g. removing it while it is still being written to), then it is possible to re-install all the packages and hopefully get it back up and working again (assuming USB key is mounted in )

# pacman -S $(pacman -Qq --dbpath /newarch/var/lib/pacman) --root /newarch --dbpath /newarch/var/lib/pacman

For example, if you want to see the contents of supplied within the systemd package:

$ bsdtar -xOf /var/cache/pacman/pkg/systemdx86_pkg.tar.xz etc/systemd/logind.conf

Or you can use vim to browse the archive:

$ vim /var/cache/pacman/pkg/systemdx86_pkg.tar.xz

Find applications that use libraries from older packages

Even if you installed a package the existing long-running programs (like daemons and servers) still keep using code from old package libraries. And it is a bad idea to let these programs running if the old library contains a security bug.

Here is a way how to find all the programs that use old packages code:

# lsof +c 0 | grep -w DEL | awk '1 { print $1 ": " $NF }' | sort -u

It will print running program name and old library that was removed or replaced with newer content.

Installing only content in required languages

Many packages attempt to install documentation and translations in several languages. Some programs are designed to remove such unnecessary files, such as localepurgeAUR, which runs after a package is installed to delete the unneeded locale files. A more direct approach is provided through the directive in , which prevent these files from ever being installed.

Warning: Some users noted that removing locales has resulted in unintended consequences, even under Xorg.

The example below installs English (US) files, or none at all:

/etc/pacman.confNoExtract = usr/share/help/* !usr/share/help/C/* NoExtract = usr/share/gtk-doc/html/* NoExtract = usr/share/locale/* usr/share/X11/locale/*/* usr/share/i18n/locales/* opt/google/chrome/locales/* !usr/share/X11/locale/C/* NoExtract =&#;!*locale*/en*/* !usr/share/*locale*/locale.* NoExtract = !usr/share/*locales/en_?? !usr/share/*locales/i18n* !usr/share/*locales/iso* NoExtract = usr/share/i18n/charmaps/* !usr/share/i18n/charmaps/UTFgz NoExtract = !usr/share/*locales/trans* NoExtract = usr/share/man/* !usr/share/man/man* NoExtract = usr/share/vim/vim*/lang/* NoExtract = usr/lib/libreoffice/help/en-US/* NoExtract = usr/share/kbd/locale/* NoExtract = usr/share/*/translations/*.qm usr/share/*/nls/*.qm usr/share/qt/translations/*.pak&#;!*/en-US.pak # Qt apps NoExtract = usr/share/*/locales/*.pak opt/*/locales/*.pak usr/lib/*/locales/*.pak&#;!*/en-US.pak # Electron apps NoExtract = opt/onlyoffice/desktopeditors/dictionaries/* !opt/onlyoffice/desktopeditors/dictionaries/en_US/* NoExtract = opt/onlyoffice/desktopeditors/editors/web-apps/apps/*/main/locale/*&#;!*/en.json NoExtract = opt/onlyoffice/desktopeditors/editors/web-apps/apps/*/main/resources/help/*&#;!*/help/en/* NoExtract = opt/onlyoffice/desktopeditors/converter/empty/*/* NoExtract = usr/share/ibus/dicts/emoji-*.dict !usr/share/ibus/dicts/emoji-en.dict

Performance

Download speeds

Note: If your download speeds have been reduced to a crawl, ensure you are using one of the many mirrors and not ftp.archlinux.org, which is throttled since March

When downloading packages pacman uses the mirrors in the order they are in . The mirror which is at the top of the list by default however may not be the fastest for you. To select a faster mirror, see Mirrors.

Pacman's speed in downloading packages can also be improved by using a different application to download packages, instead of pacman's built-in file downloader, or by enabling parallel downloads.

In all cases, make sure you have the latest pacman before doing any modifications.

# pacman -Syu

Powerpill

Powerpill is a pacman wrapper that uses parallel and segmented downloading to try to speed up downloads for pacman.

wget

This is also very handy if you need more powerful proxy settings than pacman's built-in capabilities.

To use , first install the wget package then modify by uncommenting the following line in the section:

XferCommand = /usr/bin/wget --passive-ftp --show-progress -c -q -N %u

Instead of uncommenting the parameters in , you can also modify the configuration file directly (the system-wide file is , per user files are ).

aria2

aria2 is a lightweight download utility with support for resumable and segmented HTTP/HTTPS and FTP downloads. aria2 allows for multiple and simultaneous HTTP/HTTPS and FTP connections to an Arch mirror, which should result in an increase in download speeds for both file and package retrieval.

Note: Using aria2c in pacman's XferCommand will not result in parallel downloads of multiple packages. Pacman invokes the XferCommand with a single package at a time and waits for it to complete before invoking the next. To download multiple packages in parallel, see Powerpill.

Install aria2, then edit by adding the following line to the section:

XferCommand = /usr/bin/aria2c --allow-overwrite=true --continue=true --file-allocation=none --log-level=error --max-tries=2 --max-connection-per-server=2 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --summary-interval=60 --timeout=5 --dir=/ --out %o %u

Tip:This alternative configuration for using pacman with aria2 tries to simplify configuration and adds more configuration options.

See aria2c(1) §&#;OPTIONS for used aria2c options.

  • : The directory to store the downloaded file(s) as specified by pacman.
  • : The output file name(s) of the downloaded file(s).
  • : Variable which represents the local filename(s) as specified by pacman.
  • : Variable which represents the download URL as specified by pacman.

Other applications

There are other downloading applications that you can use with pacman. Here they are, and their associated XferCommand settings:

  • :
  • :
  • :
  • : (please read the documentation on the Github project page for more info)
  • : (please read the documentation on the project page for more info)

Utilities

  • Lostfiles &#; Script that identifies files not owned by any package.
https://github.com/graysky2/lostfiles || lostfiles
  • Pacmatic &#; Pacman wrapper to check Arch News before upgrading, avoid partial upgrades, and warn about configuration file changes.
http://kmkeen.com/pacmatic || pacmatic
  • pacutils &#; Helper library for libalpm based programs.
https://github.com/andrewgregory/pacutils || pacutils
  • pkgfile &#; Tool that finds what package owns a file.
https://github.com/falconindy/pkgfile || pkgfile
  • pkgtools &#; Collection of scripts for Arch Linux packages.
https://github.com/Daenyth/pkgtools || pkgtoolsAUR
  • pkgtop &#; Interactive package manager and resource monitor designed for the GNU/Linux.
https://github.com/orhun/pkgtop || pkgtop-gitAUR
  • Powerpill &#; Uses parallel and segmented downloading through aria2 and Reflector to try to speed up downloads for pacman.
https://xyne.archlinux.ca/projects/powerpill/ || powerpillAUR
  • repoctl &#; Tool to help manage local repositories.
https://github.com/cassava/repoctl || repoctlAUR
  • repose &#; An Arch Linux repository building tool.
https://github.com/vodik/repose || repose
  • snap-pac &#; Make pacman automatically use snapper to create pre/post snapshots like openSUSE's YaST.
https://github.com/wesbarnett/snap-pac || snap-pac
  • vrms-arch &#; A virtual Richard M. Stallman to tell you which non-free packages are installed.
https://github.com/orospakr/vrms-arch || vrms-arch-gitAUR

Graphical

Warning: PackageKit opens up system permissions by default, and is otherwise not recommended for general usage. See FS# and FS#

  • Apper &#; Qt 5 application and package manager using PackageKit written in C++. Supports AppStream metadata.
https://userbase.kde.org/Apper || apper
  • Deepin App Store &#; Third party app store for DDE built with DTK, using PackageKit. Supports AppStream metadata.
https://github.com/dekzi/dde-store || deepin-store
https://userbase.kde.org/Discover || discover
  • GNOME PackageKit &#; GTK 3 package manager using PackageKit written in C.
https://freedesktop.org/software/PackageKit/ || gnome-packagekit
https://wiki.gnome.org/Apps/Software || gnome-software
  • pcurses &#; Curses TUI pacman wrapper written in C++.
https://github.com/schuay/pcurses || pcurses
  • tkPacman &#; Tk pacman wrapper written in Tcl.
https://sourceforge.net/projects/tkpacman || tkpacmanAUR
Sours: https://wiki.archlinux.org/title/Pacman/Tips_and_tricks

Pacman Overview

Manjaro's package manager, Pamac ships with most Manjaro editions. All Manjaro editions include pacman, the package manager from upstream Arch Linux. Pacman includes some advanced features not found in Pamac.

Key points to know:

  • Pacman is already installed in Manjaro Linux by default
  • Pacman is mainly developed/maintained by Arch Linux developers
  • Pacman can only be used from the command line, if you would prefer a graphical package manager please see Pamac or Octopi
  • Pacman can only use the official Manjaro repository. There are separate articles available for accessing the Arch User Repository(AUR), using flatpaks and using snaps

To update the package database and update all packages on the system

user $ sudo pacman -Syu COPY TO CLIPBOARD


To force a full refresh of the package database and update all packages on the system. You must do this when switching branches or switching mirrors.

user $ sudo pacman -Syyu COPY TO CLIPBOARD

To force a full refresh of the package database, update all packages on the system and allow packages to be downgraded. Downgrading should be only be needed when switching to an older branch. For example, switching from Testing to Stable.

user $ sudo pacman -Syyuu COPY TO CLIPBOARD

To search the Manjaro repositories for available packages you can use the command . It will search both the package name and the description for the keyword. For example, to search for packages containing the keyword smplayer you could use:

user $ pacman -Ss smplayer COPY TO CLIPBOARD

You can search your installed packages in the same manner using instead of . To search your installed packages for smplayer:

user $ pacman -Qs smplayer COPY TO CLIPBOARD


Once you have found a package you can use to get more information about an installed packages or for packages in the repos. Following the example above you could use

user $ pacman -Si smplayer COPY TO CLIPBOARD


Finally, for a list of all installed packages on your system, enter the following command:

user $ pacman -Ql COPY TO CLIPBOARD

Warning


Never install a package without updating the system first. On a rolling release this can lead to an unbootable system

To install a software package, the basic syntax is . However, installing a package without updating the system will lead to a partial upgrade situation so all the examples here will use which will install the package and ensure the system is up to date. For example, to install smplayer the command is:

user $ sudo pacman -Syu smplayer COPY TO CLIPBOARD

You will then be presented a list of software to install. You may notice this list has more packages than you requested. This is because many packages also have dependencies which are packages that must be installed in order for the software you selected to function properly.


Pacman can also directly install packages from the local system or a location on the internet. The format of that command is . For example, to install a copy of your package cache you could do something like:

user $ sudo pacman -U /var/cache/pacman/pkg/smplayerx86_pkg.tar.xz COPY TO CLIPBOARD

Alternatively, you could get it directly from one of Manjaro's mirrors:

user $ sudo pacman -U https://mirror.alpix.eu/manjaro/stable/community/x86_64/smplayerx86_pkg.tar.xz COPY TO CLIPBOARD

Warning


When using pacman -U it is up to you to ensure that the package you are installing is fully compatible with your system.

Warning


Always review the package list before confirming when removing packages. If you are not careful you can easily remove your entire desktop due to dependencies.


To remove a software package, the basic syntax is . We could remove the smplayer package we installed above with:

user $ sudo pacman -R smplayer COPY TO CLIPBOARD


This will remove the package, but will leave all the dependencies behind. If you also want to remove the unneeded dependencies you could use as seen in this example:

user $ sudo pacman -Rsu smplayer COPY TO CLIPBOARD


Sometimes when you try to remove a package you will not be able to because there are other packages which depend on it. You can use to remove a package and everything that depends on it. Be careful to heed the above warning when using this option.

user $ sudo pacman -Rc smplayer COPY TO CLIPBOARD


The most nuclear option is . This will remove everything that depends on packagename and continue to do so on its dependencies. This should really only be used in exceptional circumstances such as when removing an entire desktop environment and trying not to leave anything behind.


Pacman usually also creates backup configuration files when deleting packages. To remove those, you can add to any of the examples above. For example:

user $ sudo pacman -Rn smplayer COPY TO CLIPBOARD

user $ sudo pacman -Rsun smplayer COPY TO CLIPBOARD

user $ sudo pacman -Rcn smplayer COPY TO CLIPBOARD

To list all orphans, installed packages that are not used by anything else and should no longer be needed:

user $ pacman -Qdt COPY TO CLIPBOARD


To remove all the orphans:

user $ sudo pacman -Rs $(pacman -Qdtq) COPY TO CLIPBOARD

In some cases it may be useful to download a package without installing. For example, to install on a different system that is not connected to the internet. This can be done with . For example:

user $ sudo pacman -Sw smplayer COPY TO CLIPBOARD


The package and any rerquired dependencies will be downloaded to your pacman cache at

It is often useful to understand which package installed a file on your system. This is easy to do with pacman using . For example:

user $ pacman -Qo /usr/bin/smplayer COPY TO CLIPBOARD

When pacman installs packages, it keeps a copy of all the old packages you have downloaded. This cache can be very useful if you have to install older packages in an emergency. However, left unchecked, this cache will grow very large over time. Systems running Pamac will already have access to its automated pacman cache cleaning functions. It is also possible to clean them manually using pacman.

To clear the cache of packages that are no longer installed, enter the following command:

user $ sudo pacman -Sc COPY TO CLIPBOARD


Otherwise, to clear the cache completely, enter the following command (and use with care):

user $ sudo pacman -Scc COPY TO CLIPBOARD


A safer way to remove old package cache files is to remove all packages except for the latest three package versions using :

user $ paccache -rvk3 COPY TO CLIPBOARD

Pacman's settings are located in . This file is owned by root, please see this guide if you need more information on how to edit this file. A full reference to these options can be found in the Arch Wiki linked below. This sections features some settings that may be of particular interest to Manjaro users.

Note


pacman.conf settings are case sensitive

Enabling Color Output

By default, pacman's output is monochrome but enabling colored output can make the output easier to read if your terminal supports colors. This can be enabled by uncommenting or adding the following line to the file

Color

Showing PacMan Eating Power Pills

If you are bored of simply watching lines of hashes while downloading software packages in the terminal, why not change the progress bar to Pacman eating power pills instead? To enable this, simply add the line:

ILoveCandy

A separate page for pacman troubleshooting is available here.

Sours: https://wiki.manjaro.org/index.php?title=Pacman_Overview

Orphans pacman remove

Does it seem safe to remove all of the following orphans?

already had a reported bug in older versions, therefore I felt like swimming in the unknown. After somewhat unnecessary “panic-mode” steps in order to prevent any damage to my Manjaro system prior to my first orphan removal, I finally succeeded to clean my system by using the above command. Overall, I needed to review the list one-by-one and when I identified the packages I wanted to keep, I did the following (before removing the orphans) to mark them as :

Creating backups is important and this is the routine I relied on for this particular purpose before I removed anything:

BACKUP:

RESTORE:

After the command, I restarted Manjaro and used the aforementioned script that additionally cleared M of space.

I have freed approx. G of my disk space by removing those orphans and after some testings, the system seems stable. This was my very first experience in removing the orphans, so I apologize if I raised some eyebrows out there. :smile:

Thank you for all of your patience and support! :relaxed:

7 Likes

Sours: https://forum.manjaro.org/t/does-it-seem-safe-to-remove-all-of-the-following-orphans/
ArchLinux - Remove Orphan/Unwanted packages and save disk space!

How to Use Pacman to Manage Software on Arch Linux

Pacman is the default command line package management tool for Arch Linux and its derivatives. With it you can easily install, remove, update, and upgrade packages along with all required dependencies.

Pacman is a software package manager created by Arch Linux creator Judd Vinet. It is one of the main difference between Arch Linux and other major distributions like RedHat / Fedora / CentOS and Ubuntu / Debian.

Pacman, stands for Package Manager, combines a simple binary package format with an easy-to-use build system. The aim of Pacman is to easily manage software packages.

This guide applies to Arch Linux and all the other Arch-based Linux distros using Pacman as the package manager. So, let&#;s see how to use Pacman to install, remove, update, and querying packages in Arch Linux with simple examples.

Refresh Package Lists

Like in all Linux operating systems, before installing any packages, or updating the system, we must update the package lists.

Searching for Package

To search for a specific package, for example vlc, from a sync database (remote server), run:

Getting Information About Package

To display the detailed information of the given package from the sync database, run:

Installing a Package

Installing a package with is really easy. Just run the following command:

As a result, this process will automatically identify all the necessary dependencies and take care of it.

Installing a Local Package

Pacman stores all downloaded packages in /var/cache/pacman/pkg/ folder. In case, you want to install the locally downloaded package, for example vlc located into /var/cache/pacman/pkg/ directory, go to the folder where the package is located and enter the following command:

Update/Upgrade a Package

To update a single package, for example rsync, run:

To update all packages in your system, just run:

Sometimes you want to upgrade the packages but for one particular package, you want it to stay at an older version (because you know the newer version has removed a feature or is broken). So, if vlc was causing the problem, you could use the following command for this:

Remove a Package

In order to remove a package with all its dependencies, run the following command:

This command will completely remove vlc package and all dependencies. Pacman will keep the important configuration files with the extension: .pacsave while removing packages.

In addition, if you no longer want them and want to free up hard drive, you can remove the package along with all its configuration files with command:

Remove Orphaned (Unused) Packages

As you might know, there will still be some orphaned (unused) packages in your Arch Linux after removing a package. These orphaned packages are not required anymore, so we can get rid of them to free up some space. To remove these packages, run:

If no orphans were found, the output is:

Searching for Already Installed Packages

Sometimes you want to check for a specific package if it is installed locally. In this case you can do it using the command below:

You can view a list of all the packages installed on your system using the following command:

Find All Files Owned by a Package

You can find all the files that are installed by a specific package using the following command:

This returns the package name and the path to files that it owns.

Find the Package Owner of the File

If you want to check the location of the binary executable file owned by a package, use the flag.

Download a Package

Sometimes, you might want to just download a package and keep it in your cache without installing it. For example, you might plan to use the downloaded packages in future. To do so, run:

The above command will only download the vlc package, and keep it in the cache folder. Pacman stores all downloaded packages in /var/cache/pacman/pkg/ folder.

Clean Up Package Cache

All packages that we downloaded during the installation will be stored in the cache directory i.e /var/cache/pacman/pkg/. If you don&#;t remove them periodically, it will slowly eat up your hard drive space, and sooner or later you could end up with low disk space.

So it is good to remove the cache periodically. To remove all the cached packages that are not currently installed, and the unused sync database, execute:

In addition, if you want to remove all files from the cache, use the clean &#;c&#; switch twice. Of course, this is the most aggressive approach and will leave nothing in the cache folder:

Conclusion

Arch Linux is one of the most reputed and popular Linux distributions out there. This guide has covered most of the commands that you need to know when using Pacman. Hopefully it was helpful in your journey with Arch-based distros.

You can find detailed documentation about Pacman package manager in the official Arch Linux Wiki.

If this guide has helped you, please consider buying us a coffee. Buy me a coffee!Your support and encouragement are greatly appreciated!
Sours: https://linuxiac.com/how-to-use-pacman-to-manage-software-on-arch-linux/

You will also like:

And, he sold her his human soul in the distant future. She caressed him so tenderly as no earthly woman can caress. Talking to him constantly through the wild bestial demon groan, how lonely it is for all of them in Hell, sparkling with fire and flashes of red flickering flame in. Those demonic eyes, black like the darkness itself.



1933 1934 1935 1936 1937