Manjaro Difference between revisions of "Pacman Overview"

Difference between revisions of "Pacman Overview"

From Manjaro
imported>Excalibur1234
(improved formatting)
(extended warning)
 
(36 intermediate revisions by 13 users not shown)
Line 1: Line 1:
<languages/>
__TOC__
__TOC__


<translate>
=Overview= <!--T:1-->


<!--T:2-->
Manjaro's package manager, [[Special:MyLanguage/Pamac|Pamac]] ships with most Manjaro editions.  All Manjaro editions include [https://www.archlinux.org/pacman/ pacman], the package manager from upstream Arch Linux.  Pacman includes some advanced features not found in Pamac.


= Overview =
<!--T:3-->
Key points to know:


Pacman is a <u>'''pac'''</u>kage <u>'''man'''</u>ager used in Manjaro Linux, mainly developed by the Arch Linux developers. It is used to install, upgrade, configure and remove software (i.e. to manage software packages). Pacman is used through typing commands terminal; all the commands listed below to undertake various tasks assume that you have your terminal open.
<!--T:4-->
* 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 [[Special:MyLanguage/Pamac|Pamac]] or [[Special:MyLanguage/Octopi|Octopi]]
* Pacman can only use the official Manjaro [[Special:MyLanguage/Repositories_and_Servers|repository]]. There are separate articles available for accessing the [[Special:MyLanguage/Arch_User_Repository|Arch User Repository(AUR)]], using [[Special:MyLanguage/Flatpak|flatpaks]] and using [[Special:MyLanguage/Snaps|snaps]]




= Updating the System =
=Installing Updates= <!--T:5-->


{{tip| This should be the first thing you do after installing Manjaro!}}
<!--T:6-->
Update the package database and update all packages on the system
{{UserCmd|command=sudo pacman -Syu}}


To update your system, enter the following command in the terminal:
<!--T:8-->
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.</translate>
{{UserCmd|command=sudo pacman -Syuu}}


sudo pacman -Syu
<translate>


=Searching for Packages= <!--T:9-->


= Synchronising with the Manjaro Repositories =
<!--T:10-->
To search the Manjaro repositories for available packages you can use the command {{ic|pacman -Ss keyword}}. 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:</translate>
{{UserCmd|command=pacman -Ss smplayer}}


Your Manjaro system has a database of all the software packages (e.g. system updates and applications) that are available from the official repositories. This is used to help pacman locate and download these packages for installation. When updating your system, its database will automatically be refreshed as well. However, using this command is more thorough, as rather than just refreshing or updating the database, it will actually rebuild it completely. To synchronise your database with the Manjaro repositories, enter the following command in the terminal:
<translate><!--T:11--> You can search your installed packages in the same manner using {{ic|-Qs}} instead of {{ic|-Ss}}. To search your installed packages for smplayer:</translate>
{{UserCmd|command=pacman -Qs smplayer}}


sudo pacman -Syy


<translate><!--T:12--> Once you have found a package you can use {{ic|pacman -Qi}} to get more information about an installed packages or {{ic|pacman -Si}} for packages in the repos.  Following the example above you could use</translate>
{{UserCmd|command=pacman -Si smplayer}}


To simultaneously synchronise with the repositories '''and''' update your system, enter the command:


sudo pacman -Syyu
<translate><!--T:13--> Finally, for a list of all installed packages on your system, enter the following command:</translate>
{{UserCmd|command=pacman -Ql}}




= Searching for Software Packages =
<translate>
=Installing Packages= <!--T:14-->


It is also possible to use pacman to search for software packages, both available for download from the Manjaro repositories, as well as those already installed on your system.
<!--T:15-->
{{BoxWarning|Never install a package without updating the system first| On a rolling release this can lead to an unbootable system}}


<!--T:16-->
To install a software package, the basic syntax is {{ic|pacman -S packagename}}.  However, installing a package without updating the system will lead to a partial upgrade situation so all the examples here will use {{ic|pacman -Syu packagename}} which will install the package and ensure the system is up to date.  For example, to install smplayer the command is:</translate>
{{UserCmd|command=sudo pacman -Syu smplayer}}


== Searching the Manjaro Repositories==
<translate>
<!--T:17-->
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.


Manjaro's software repositories for any desired software, provided you know the name of what you want. The ''sudo'' prefix is not required for this. To search for a software package in the Official Manjaro repositories, the basic syntax is:
<!--T:18-->
Pacman can also directly install packages from the local system or a location on the internet. The format of that command is {{ic|pacman -U packagelocation}}. For example, to install a copy of your package cache you could do something like:</translate>
{{UserCmd|command=sudo pacman -U /var/cache/pacman/pkg/smplayer-19.5.0-1-x86_64.pkg.tar.xz}}


pacman -Ss [software package name]
<translate><!--T:19--> Alternatively, you could get it directly from one of Manjaro's mirrors:</translate>
{{UserCmd|command=sudo pacman -U <nowiki>https://mirror.alpix.eu/manjaro/stable/community/x86_64/smplayer-19.5.0-1-x86_64.pkg.tar.xz</nowiki>}}


<translate>
<!--T:20-->
{{BoxWarning|Warning|When using pacman -U it is up to you to ensure that the package you are installing is fully compatible with your system.}}


For example, to search the repositories to see if a text editor called Leafpad is available, the following command would be entered:
=Removing Packages= <!--T:21-->


pacman -Ss leafpad
<!--T:22-->
{{BoxWarning|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.}}




==Searching Your System==
<!--T:23-->
To remove a software package, the basic syntax is {{ic|sudo pacman -R packagename}}.  We could remove the smplayer package we installed above with:</translate>
{{UserCmd|command=sudo pacman -R smplayer}}


In addition, it is also possible to search for packages that have already been installed on your system. For basic information, enter the following command:


  pacman -Qs [software package name]
<translate><!--T:24--> This will remove the package, but will leave all the dependencies behind. If you also want to remove the unneeded dependencies you could use {{ic|pacman -Rsu packagename}} as seen in this example:</translate>
{{UserCmd|command=sudo pacman -Rsu smplayer}}




Otherwise, to gain far more comprehensive about an installed package, enter the following command:
<translate><!--T:25--> 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 {{ic|pacman -Rc packagename}} to remove a package and everything that depends on it.  Be careful to heed the above warning when using this option.</translate>
{{UserCmd|command=sudo pacman -Rc smplayer}}


pacman -Qi [software package name]


<translate><!--T:26-->
The most nuclear option is {{ic|pacman -Rcs packagename}}.
{{BoxDanger|Use this with extreme caution, or don’t use it at all|
-Rcs will remove every package that depends on packagename regardless of whether a package is needed for something else. This could render Manjaro unusable. }}


It is also possible to gain even more information, including related backup files as well as the date that the package was last altered by entering the command:
<!--T:27-->
Pacman usually also creates backup configuration files when deleting packages. To remove those, you can add {{ic|n}} to any of the examples above.  For example:</translate>
{{UserCmd|command=sudo pacman -Rn smplayer}}
{{UserCmd|command=sudo pacman -Rsun smplayer}}
{{UserCmd|command=sudo pacman -Rcn smplayer}}


pacman -Qii [software package name]
<translate>


=Viewing and Removing Orphans= <!--T:28-->


Finally, for a list of all installed packages on your system, enter the following command:
<!--T:29-->
To list all ''orphans'', installed packages that are not used by anything else and should no longer be needed:
{{UserCmd|command=pacman -Qdt}}


pacman -Ql


{{warning|Where using the above command, expect to see a lot of text flying through the terminal for a while!}}
<!--T:30-->
To remove all the orphans:</translate>
{{UserCmd|command=sudo pacman -Rs $(pacman -Qdtq)}}




=Dependencies=
<translate>
=Downloading Packages without Installing= <!--T:31-->


To list all dependencies of a particular software package (i.e. other software that requires the specified software package in order to work), enter the following command:
<!--T:32-->
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 {{ic|pacman -Sw packagename}}.  For example:</translate>
{{UserCmd|command=sudo pacman -Sw smplayer}}


pactree [software package name]


<translate>
<!--T:33-->
The package and any rerquired dependencies will be downloaded to your pacman cache at {{ic|/var/cache/pacman/pkg}}


= Orphans=


To list all ''orphans'' - that is, installed packages that are not used by anything else and that consequently serve no purpose - enter the following command:
=Determining which Package Owns a File= <!--T:34-->


  pacman -Qdt
<!--T:35-->
It is often useful to understand which package installed a file on your system.  This is easy to do with pacman using {{ic|pacman -Qo /path/to/filename}}. For example:</translate>
{{UserCmd|command=pacman -Qo /usr/bin/smplayer}}




'''It is highly recommended to remove orphans from your system, as although harmless, they still serve no purpose other than to take up room and resources. Rather than having to remove them one-by-one, the following command will search for and remove them for you:
<translate>
=Cleaning the Cache= <!--T:36-->


  sudo pacman -Rs $(pacman -Qdtq)
<!--T:37-->
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 [[Special:MyLanguage/Pamac|Pamac]] will already have access to its automated pacman cache cleaning functions. It is also possible to clean them manually using pacman.


See '''[[Orphan Package Removal]]''' for a more detailed exposition of this topic.
<!--T:38-->
To clear the cache of packages that are no longer installed, enter the following command:</translate>
{{UserCmd|command=sudo pacman -Sc}}




= Downloading and Installing Software Packages =
<translate><!--T:39--> Otherwise, to clear the cache completely, enter the following command (and use with care):</translate>
{{UserCmd|command=sudo pacman -Scc}}


Software packages may be downloaded and installed from a range of sources, and not just from the official Manjaro repositories. '''However, please note that where installing packages from unofficial sources, you do so entirely at your own risk!'''


<translate><!--T:40--> A safer way to remove old package cache files is to remove all packages except for the latest three package versions using {{ic|paccache}}:</translate>
{{UserCmd|command=paccache -rvk3}}


==Packages from the Manjaro Repositories==


To install a software package, the basic syntax is:
<translate>
=The Configuration File, pacman.conf= <!--T:41-->


  sudo pacman -S [software package name]
<!--T:42-->
Pacman's settings are located in {{ic|/etc/pacman.conf}}. This file is owned by root, please see [[Special:MyLanguage/Viewing_and_editing_configuration_files|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.


<!--T:43-->
{{BoxSuccess|Note|pacman.conf settings are case sensitive}}


For example, to download and install leafpad, the following command would be entered:
==Enabling Color Output== <!--T:44-->


  sudo pacman -S leafpad
<!--T:45-->
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</translate>
  Color


{{tip| many software packages (especially complex applications) will require other software packages - known as ''dependencies'' - to also be downloaded and installed in order to work. Fortunately, pacman will automatically detect and install these for you.}}
<translate>
==Showing PacMan Eating Power Pills== <!--T:46-->


<!--T:47-->
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:</translate>
ILoveCandy


It is also possible to download software packages without actually installing them by entering the following command:
<translate>
=Troubleshooting= <!--T:48-->
A separate page for pacman troubleshooting is available '''[[Special:MyLanguage/pacman troubleshooting|here]]'''.


sudo pacman -Sw [software package name]


=See Also= <!--T:49-->
* [[Special:MyLanguage/System Maintenance|System Maintenance]]
* [[Special:MyLanguage/Pacman-mirrors|Pacman-mirrors]]
* [[Special:MyLanguage/Pacman troubleshooting|Pacman troubleshooting]]
* [[Special:MyLanguage/Downgrading packages|Downgrading packages]]
* [https://wiki.archlinux.org/index.php/Pacman ArchWiki: pacman]
* [https://wiki.archlinux.org/index.php/Pacman_tips ArchWiki: pacman tips]
* [https://wiki.archlinux.org/index.php/Improve_pacman_performance ArchWiki: pacman performance]
</translate>


==Packages from the AUR (Arch User Repository)==


To install a package from the AUR using a ''wrapper for pacman'' like '''yaourt'''-
[[Category:Contents Page{{#translation:}}]]
 
yaourt -S [software package name]
 
See [http://wiki.manjaro.org/index.php?title=Arch_User_Repository The Arch User Repository] for more details.
 
 
==Packages Located Locally or From the Internet==
 
To install a package already downloaded onto your system (the file name should end in '''pkg.tar.xz'''), the basic syntax is:
 
sudo pacman -U [/package_path/][software package name.pkg.tar.xz]
 
 
For example, to install a package located in the ''Downloads'' folder, the following command would be entered:
 
sudo pacman -U ~/Downloads/[software package name.pkg.tar.xz]
 
 
To install a package via a URL (i.e. located elsewhere on the internet), the basic syntax is:
 
pacman -U http://www.examplepackage/repo/examplepkg.tar.xz
 
 
= Removing Applications and Software Packages =
 
To remove a software package, the basic syntax is:
 
sudo pacman -R [software package name]
 
 
For example, to remove the software application Leafpad, the following command would be entered:
 
sudo pacman -R leafpad
 
 
It is also possible to remove package and its dependencies, provided those dependencies are not being used by any other packages. Deleting dependencies exclusive to a certain package is wise, as once the main package is removed, they will become ''orphans'', serving no other purpose than to clutter up your system. To do so, enter the following command:
 
sudo pacman -Rs [software package name]
 
 
However, Pacman usually also creates backup configuration files when deleting packages. As such, for a more thorough (and cleaner) removal (ie. the package, its dependencies, and any configuration files usually generated by pacman) enter the following command:
 
sudo pacman -Rns
 
 
=Cleaning the Cache=
 
Your system cache is where downloaded software packages are stored for installation. Even after being installed, they may still remain in the cache. This is why on occasion it may be found that when re-installing a software package, it does not have to be downloaded again. However, it is possible to clear your cache to free up space on your system (and may be necessary in some rare instances to download and install new software packages).
 
To clear the cache of downloads that have already been installed, enter the following command:
 
sudo pacman -Sc
 
 
Otherwise, to clear the cache completely, enter the following command (and use with care):
 
sudo pacman -Scc
 
For tips on how to easily manage the '''/var/cache/pacman/pkg''' for your benefit see '''[[Maintaining /var/cache/pacman/pkg for System Safety]]'''.
 
 
=Holding Back Packages from being Upgraded=
 
Courtesy the [https://wiki.archlinux.org/index.php/Pacman#Skip_package_from_being_upgraded Arch Wiki]
 
 
Pacman's settings are located in  /etc/pacman.conf
 
 
'''To hold back a specific package from being updgraded'''
 
IgnorePkg=package-name
 
For multiple packages use a space-separated list, or use additional IgnorePkg lines.
 
 
''Skipping a whole package group is also possible''
 
IgnoreGroup=gnome
 
 
= Learning pacman's options =
 
It is a very good idea to become familiar with the varied and powerful uses of pacman. A comprehensive list of options that can be used with pacman can be found by entering the following command:
 
man pacman
 
To exit out of the list, simply press '''q'''.
 
 
= Troubleshooting =
 
A separate page for pacman troubleshooting is available '''[[pacman troubleshooting|here]]'''.
 
 
= See Also =
 
* '''[[Maintaining_/var/cache/pacman/pkg_for_System_Safety|Maintaining the cache for system safety]]'''
* '''[[Progress Bar as Pacman Eating Power Pills]]'''
* '''[[Pacman Tips|Pacman Tips]]
* '''[[Pacman troubleshooting]]
* '''[https://wiki.archlinux.org/index.php/Pacman ArchWiki: pacman]
* '''[https://wiki.archlinux.org/index.php/Pacman_tips ArchWiki: pacman tips]
* '''[https://wiki.archlinux.org/index.php/Improve_pacman_performance ArchWiki: pacman performance]
 
[[Category:Contents Page]]

Latest revision as of 09:23, 28 December 2023

Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎русский • ‎中文 • ‎中文(中国大陆)‎

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


Installing Updates

Update the package database and update all packages on the system

user $ sudo pacman -Syu COPY TO CLIPBOARD


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 -Syuu COPY TO CLIPBOARD



Searching for Packages

To search the Manjaro repositories for available packages you can use the command pacman -Ss keyword. 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 -Qs instead of -Ss. To search your installed packages for smplayer:

user $ pacman -Qs smplayer COPY TO CLIPBOARD



Once you have found a package you can use pacman -Qi to get more information about an installed packages or pacman -Si 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



Installing Packages

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 pacman -S packagename. However, installing a package without updating the system will lead to a partial upgrade situation so all the examples here will use pacman -Syu packagename 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 pacman -U packagelocation. For example, to install a copy of your package cache you could do something like:

user $ sudo pacman -U /var/cache/pacman/pkg/smplayer-19.5.0-1-x86_64.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/smplayer-19.5.0-1-x86_64.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.

Removing Packages

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 sudo pacman -R packagename. 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 pacman -Rsu packagename 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 pacman -Rc packagename 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 pacman -Rcs packagename.

Use this with extreme caution, or don’t use it at all
-Rcs will remove every package that depends on packagename regardless of whether a package is needed for something else. This could render Manjaro unusable.

Pacman usually also creates backup configuration files when deleting packages. To remove those, you can add n 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



Viewing and Removing Orphans

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



Downloading Packages without Installing

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 pacman -Sw packagename. For example:

user $ sudo pacman -Sw smplayer COPY TO CLIPBOARD



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


Determining which Package Owns a File

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

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



Cleaning the Cache

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 paccache:

user $ paccache -rvk3 COPY TO CLIPBOARD



The Configuration File, pacman.conf

Pacman's settings are located in /etc/pacman.conf. 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

Troubleshooting

A separate page for pacman troubleshooting is available here.


See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.