Upgrade the system:
1 |
pacman -Syyu |
1 |
pacman -S majaro-keyring archlinux-keyring |
1 |
pacman -Syyuu |
[embedyt]https://www.youtube.com/watch?v=DcbHylIXevs[/embedyt]
1. REFRESH PACMAN PACKAGE LIST.
Before installing or upgrading system, you need to refresh package list. (Packages Database). Run following command to refresh package list.
1 |
# pacman -Syy |
To install package from repository, run the following command,
1 2 |
# pacman -S <package-name> //Single Package # pacman -S <package-name-1> <package-name-2> <package-name-n> //For Multiple Packages |
Suppose I want to install openssh package, run following command
1 |
# pacman -S openssh |
3. UPDATE/UPGRADE PACKAGES:
To update one package, run following command,
1 |
# pacman -Sy <package-name> |
Arch Linux keeps it’s repository up-to-date. You can update your whole system by running following command in terminal,
1 |
# pacman -Syyu |
4. DELETE PACKAGES:
If you want to delete single package use following command in terminal,
1 |
# pacman -R <package-name> |
To, remove package and it’s depedancy, run following command,
1 |
# pacman -Rs <package-name> |
Now, I want to remove openssh package and It’s dependency, (Refer following screenshot)
Following command is used to remove package but without removing the dependent package,
1 |
# pacman -Rdd <package-name> |
5. SEARCH FOR A SPECIFIC PACKAGE FROM LOCAL DATABASE:
To search the package from local database using -Q flag (Query), run following command to search already installed package,
1 |
$ pacman -Qs <package name> |
6. SEARCH FOR A SPECIFIC PACKAGE FROM SYNC DATABASES
To search the package from local database using -S flag, run following command to search package from sync database,
1 |
$ pacman -Ss <package-name> |
Sample Output,
1 2 3 4 5 6 7 8 9 10 |
[nuxhack@ewikitech:~]$ pacman -Ss vlc extra/phonon-qt4-vlc 0.8.2-2 [installed] Phonon VLC backend for Qt4 extra/phonon-qt5-vlc 0.8.2-2 [installed] Phonon VLC backend for Qt5 extra/vlc 2.2.1-6 [installed] A multi-platform MPEG, VCD/DVD, and DivX player community/npapi-vlc 2.2.1-1 The modern VLC Mozilla (NPAPI) plugin [nuxhack@ewikitech:~]$ |
7. CHECK PACKAGE INFORMATION
To check extensive package information used -i flag,
1 2 |
$ pacman -Qi <package-name> //For Locale Database $ pacman – Si <package-name> //For Sync Databases |
8. PACKAGES BACKUP FILE AND MODIFICATION STATE:
To check packages backup files and It’s modification state, insert two -i flag, used following command,
1 |
$ pacman -Qii <package-name> |
9. LIST OF ALL ORPHAN PACKAGES
To check all packages no longer required as dependencies, use -dt flag. Run following command,
1 |
$ pacman -Qdt <package-name> |
10. CLEANE PACKAGE CACHE
After downloading pacman store the package in /var/cache/pacman/pkg/, to remove all the cached packages, use following command,
1 |
# pacman -Sc |
That’s It.
How To Use Arch Linux Package Management
Getting Started
Arch Linux provides package management facilities similar to those found in other modern Linux distributions. This is a guide to common package management operations.
Before proceeding further, make sure your package databases are up to date with:
1 2 |
sudo pacman -Sy |
Searching
Favoring brevity over intuitiveness, most package management operations in Arch Linux appear in the format:
1 2 |
pacman -<a-z><a-z>. |
For example, the normal command for searching pacman repositories is
1 2 |
pacman -Ss <package> |
Like most pacman commands, it is not particularly obvious. pacman also ships with a pacsearch utility. It works similarly, but it has some enhancements over pacman -Ss:
- color highlighting
- installed packages category (‘local’)
Here is how you would list all standard packages with the keyword ‘linux.’
1 2 |
pacsearch linux |
Sometimes there will be a lot of packages matching your search criteria. This is especially true when using an AUR helper like yaourt. Regular expressions can help narrow down the list. For example, let’s say you are trying to find anything related to the “ack” tool. A regular search for ack will inevitably return a lot of results to sift through, due to words like “package,” “hack,” or “playback.”
1 2 |
pacsearch ack |
However, not many words begin with ack. Adding a ^ to the search word will only include results that start with those letters. This works with at least pacsearch, pacman, and yaourt.
1 2 |
pacsearch ^ack |
To guarantee a regular expression works as intended, surround it with quotes.
1 2 |
pacsearch 'c\+\+' |
If you want to get a list of installed packages matching a search, pipe the results to “grep local.” The “-A 1” option tells grep to include one line after each match (the package description, in this case).
1 2 |
pacsearch linux | grep local -A 1 |
Alternatively, you can use pacman -Qs with the downside of no color highlighting.
1 2 |
pacman -Qs linux |
If you want color highlighting with pacman -Ss, you can uncomment Color from /etc/pacman.conf. It highlights different things than pacsearch, though, so you might want to try both and see which one you like better.
1 2 3 4 5 6 7 8 9 10 11 |
sudo vi /etc/pacman.conf ... # Misc options #UseSyslog Color #TotalDownload CheckSpace #VerbosePkgLists ... |
Getting Information
pacman -Qi displays basic information about an installed package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
pacman -Qi linux Name : linux Version : 3.8.4-1 Description : The linux kernel and modules Architecture : x86_64 URL : http://www.kernel.org/ Licenses : GPL2 Groups : base Provides : kernel26=3.8.4 Depends On : coreutils linux-firmware kmod mkinitcpio>=0.7 Optional Deps : crda: to set the correct wireless channels of your country Required By : None Optional For : None Conflicts With : kernel26 Replaces : kernel26 Installed Size : 64728.00 KiB Packager : Tobias Powalowski <tpowa@archlinux.org> Build Date : Wed Mar 20 21:16:17 2013 Install Date : Fri Mar 29 01:02:14 2013 Install Reason : Explicitly installed Install Script : Yes Validated By : Unknown |
If pacman -Qi is passed no arguments, it returns all packages in the system. You can search this output to get specialized information about installed packages.
For example, if you wanted to get each package and its size:
1 2 3 4 5 6 7 8 |
pacman -Qi | grep -e "Name" -e "Installed Size" Name : a52dec Installed Size : 244.00 KiB Name : aalib Installed Size : 768.00 KiB ... |
While pacman -Qi provides information about installed packages, pacman -Si queries the database for the most recently retrieved information about a package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
pacman -Si linux Repository : core Name : linux Version : 3.11.6-1 Description : The Linux kernel and modules Architecture : x86_64 URL : http://www.kernel.org/ Licenses : GPL2 Groups : base Provides : kernel26=3.11.6 Depends On : coreutils linux-firmware kmod mkinitcpio>=0.7 Optional Deps : crda: to set the correct wireless channels of your country Conflicts With : kernel26 Replaces : kernel26 Download Size : 47855.98 KiB Installed Size : 64493.00 KiB Packager : Thomas Bächler <thomas@archlinux.org> Build Date : Fri 18 Oct 2013 05:25:12 PM EDT Validated By : MD5 Sum SHA256 Sum Signature |
pacman -Ql lists all files associated with a package.
1 2 3 4 5 6 7 8 9 10 |
pacman -Ql vi vi /usr/ vi /usr/bin/ vi /usr/bin/edit vi /usr/bin/ex vi /usr/bin/vedit vi /usr/bin/vi ... |
The package name on each line can make the output more difficult to use in a script. pacman -Qlq (i.e. “pacman query list, quiet”) will not print the package name.
1 2 3 4 5 6 7 8 9 10 |
pacman -Qlq vi /usr/ /usr/bin/ /usr/bin/edit /usr/bin/ex /usr/bin/vedit /usr/bin/vi ... |
You can use pacman -Qlq | grep bin to find all files in that package that are in a bin folder (and thus are likely executable files). This is handy when the command associated with a package is different from the package name.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
pacman -Qql pacman | grep bin /usr/bin/ /usr/bin/bacman /usr/bin/checkupdates /usr/bin/cleanupdelta /usr/bin/makepkg /usr/bin/paccache /usr/bin/pacdiff /usr/bin/paclist /usr/bin/paclog-pkglist /usr/bin/pacman /usr/bin/pacman-db-upgrade /usr/bin/pacman-key /usr/bin/pacman-optimize /usr/bin/pacscripts /usr/bin/pacsearch /usr/bin/pacsort /usr/bin/pacsysclean /usr/bin/pactree /usr/bin/pkgdelta /usr/bin/rankmirrors /usr/bin/repo-add /usr/bin/repo-elephant /usr/bin/repo-remove /usr/bin/testdb /usr/bin/testpkg /usr/bin/updpkgsums /usr/bin/vercmp |
Storage Consumption
The simplest way to see which packages are taking up the most space on your system is pacsysclean which ships with pacman.
1 2 |
pacsysclean |
If you want something a little more complicated, the pacgraph utility can produce a dependency word cloud of the largest packages in SVG and PNG format.
pacgraph is found in the community repository.
1 2 |
sudo pacman -S pacgraph |
pacgraph -c will output to the console like pacsysclean. If there are a lot of packages, pacgraph’s output can get unwieldy since it is sorted from largest to smallest, unlike pacsysclean. You can pipe it to head to just see biggest packages.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
pacgraph -c | head Autodetected Arch. Loading package info Total size: 730MB 114MB linux 103MB libtool 84MB pacgraph 40MB imagemagick 25784kB ppl 22264kB nmap 17295kB pkgfile |
In the Arch Linux droplet I tested, some errors were produced before this output. To remove the errors, you will need to correct the locale settings from the default “C”.
1 2 |
export LANG=en_US.UTF-8 |
Run without any arguments, pacgraph produces an SVG and, if possible, a PNG file. If you don’t have a file sharing system set up with your virtual server, the simplest way to access the images generated by pacgraph is to use Secure Copy.
1 2 |
scp <user>@<addr>:<remote_path> <local_path> |
Note: Although pacgraph will claim to render a PNG file after imagemagick and libpng are installed, at the time of this writing it will not actually generate a PNG without inkscape, which has quite a few dependencies.
Downloads / Installation
The typical way to install or upgrade a standard package is pacman -S.
1 2 |
sudo pacman -S <package> |
Packages often have a similar pattern in their names. Brackets can be used as a shortcut.
1 2 |
sudo pacman -S lua-{sec,socket,zlib} |
Sometimes you might want to just download a package for archival purposes without installing it. pacman -Sw will download a package to the cache folder.
1 2 |
sudo pacman -Sw <package> |
If a package has been downloaded, or if you know the url, you can install it directly.
1 2 |
sudo pacman -U <package_path> |
Upgrades
Since pacman revolves around the idea of “syncing” a package with the remote repository, pacman -S will upgrade a package if it is already installed.
Pacman can list packages that are out of date.
1 2 |
pacman -Qu |
Unfortunately, it doesn’t display the version of the package in the repository, so you won’t be able to tell how out of date each package is. If this is important to you, you might want to look into 3rd party package managers or write a script that ties together the package version obtained from pacman -Qi and pacman -Si.
You can get the version from pacman -Qi or pacman -Si using a regular expression.
1 2 3 4 |
pacman -Qi linux | grep "Version" | sed 's/^Version\s*:\s//' 3.8.4-1 |
And then write a script that shows the versions side by side.
1 2 3 4 5 6 7 |
for i in $(pacman -Qqu) do printf "$i: " printf "$(pacman -Qi "$i" | grep 'Version' | sed 's/^Version\s*:\s//') " echo "$(pacman -Si "$i" | grep 'Version' | sed 's/^Version\s*:\s//')" done |
Pacman provides a way to upgrade all of your packages at once, but it is not recommended because Arch is a rolling release distribution. If problems arise, it can take time to determine what the causes are.
1 2 |
sudo pacman -Syu |
Downgrades
Arch Linux does not officially maintain deprecated packages. Instead, you will need to rely on your package cache and places like the Arch Rollback Machine.
Cache
Every package downloaded with pacman is stored in /var/cache/pacman/pkg.
1 2 3 4 5 6 |
ls /var/cache/pacman/pkg | grep linux linux-3.11.6-1-x86_64.pkg.tar.xz linux-3.9.7-1-x86_64.pkg.tar.xz ... |
If you would like to revert to a package in your cache, just install it directly.
1 2 |
pacman -U <path_to_cached_file> |
Arch Rollback Machine
The Arch Rollback Machine is a collection of snapshots of the official Arch Linux mirror. As of this writing, it goes back four months. The ARM is currently hosted at http://seblu.net/a/arm, though this could change in the future.
ARM packages can be installed remotely using pacman -U .
1 2 |
pacman -U http://seblu.net/a/arm/2013/08/31/extra/os/x86_64/apache-2.2.25-1-x86_64.pkg.tar.xz |
It isn’t exactly convenient to browse the ARM for older packages. Fortunately, there are tools that make this easier:
They search for older versions in the cache and the ARM. Their usage is what you would expect.
1 2 3 |
downgrade <package> downgrader <package> |
Both tools are in the AUR, so the easiest way to install them will be with a helper like yaourt.
Note: The ARM is an unofficial project and has been closed in the past, so it might be a good idea to avoid clearing your cache in case the ARM goes down or changes locations again. If you would like to roll your own ARM, there appears to be a NodeJS project on github.
Removal
Remove a package, provided nothing is depending on it. Leave its dependencies installed.
1 2 |
sudo pacman -R <package> |
Remove a package, provided nothing is depending on it. Remove its dependencies that aren’t required by anything else.
1 2 |
sudo pacman -Rs <package> |
Force removal of a package. This is the command you will reach for to just wipe the package from your system and reinstall when reinstalling alone isn’t enough.
1 2 |
sudo pacman -Rdd <package> |
Unofficial Packages
The vast majority of Arch Linux packages are located in the Arch User Repository. The best way to search for and download packages from the AUR is to use a helper tool.
There is already a Digital Ocean article on the AUR and the yaourt tool.