Manjaro Difference between revisions of "Pacman Overview"

Difference between revisions of "Pacman Overview"

From Manjaro
imported>Cscs
imported>Dalto
(Revamp and merge content from Pacman Tips and Progress Bar as Pacman Eating Powerpills)
Line 1: Line 1:
__TOC__
__TOC__


= Overview =


Pacman is Manjaro's default <u>'''pac'''</u>kage <u>'''man'''</u>ager used to install, upgrade, configure and remove software (i.e. to manage software packages).  Key points to know:
=Overview=


* Pacman is already installed in Manjaro Linux by default.
Manjaro's package manager, [[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.
* Pacman is mainly developed/maintained by Arch Linux developers.
* Pacman uses terminal commands.
* A [https://en.wikipedia.org/wiki/Graphical_user_interface GUI] alternative to pacman is [[Octopi]].
* Pacman can only use the official Manjaro [[Repositories_and_Servers|repository]].    See [[AUR]] for use and info (and warnings) on the [[AUR|Arch User Repository]].


= Synchronizing and updating your system =
Key points to know:


{{tip| This should be the first thing you do after installing Manjaro!}}
* Pacman is already installed in Manjaro Linux by default
{{tip| Check the article about [[System Maintenance]]}}
* 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 [[Repositories_and_Servers|repository]]. There are seperate articles available for accessing the [[Arch_User_Repository|Arch User Repository(AUR)]], using [[Flatpak|flatpaks]] and using [[Snaps|snaps]]


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 and update your system, enter the following command in the terminal:


sudo pacman -Syyu
=Installing Updates=


= Searching for Software Packages =
To update the package database and update all packages on the system
sudo pacman -Syu


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.
== Searching the Manjaro Repositories==
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:
pacman -Ss [software package name]


To force a full refresh of the package database and update all packages on the system. You must do this when [[Switching_Branches|switching branches]] or [[Pacman-mirrors|switching mirrors]].
sudo pacman -Syyu


For example, to search the repositories to see if a text editor called Leafpad is available, the following command would be entered:


  pacman -Ss leafpad
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.
sudo pacman -Syyuu




==Searching Your System==
=Searching for Packages=


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:
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:
pacman -Ss smplayer


pacman -Qs [software package name]


You can search your installed packages in the same manner using {{ic|-Qs}} instead of {{ic|-Ss}}.  To search your installed packages for smplayer:
pacman -Qs smplayer


Otherwise, to gain far more comprehensive about an installed package, enter the following command:


pacman -Qi [software package name]
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
 
  pacman -Si smplayer
 
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:
 
  pacman -Qii [software package name]




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


{{warning|Where using the above command, expect to see a lot of text flying through the terminal for a while!}}


=Installing Packages=


=Dependencies=
{{warning|Never install a package without updating the system first.  On a rolling release this can lead to an unbootable system}}


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:


  pactree [software package name]
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 sinatll smplayer the command is:
sudo pacman -Syu smplayer




= Orphans=
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.


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:


  pacman -Qdt
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:
sudo pacman -U /var/cache/pacman/pkg/smplayer-19.5.0-1-x86_64.pkg.tar.xz


Alternatively, you could get it directly from one of Manjaro's mirrors:
sudo pacman -U https://mirror.alpix.eu/manjaro/stable/community/x86_64/smplayer-19.5.0-1-x86_64.pkg.tar.xz


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


sudo pacman -Rs $(pacman -Qdtq)
{{warning|When using pacman -U it is up to you to ensure that the package you are installing is fully compatible with your system.}}


See '''[[Orphan Package Removal]]''' for a more detailed exposition of this topic.


=Removing Packages=


= Downloading and Installing Software Packages =
{{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.}}


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!'''


To remove a software package, the basic syntax is {{ic|sudo pacman -R packagename}}.  We could remove the smplayer package we installed above with:
sudo pacman -R smplayer


==Packages from the Manjaro Repositories==


To install a software package, the basic syntax is:
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:
sudo pacman -Rsu smplayer


sudo pacman -Syu [software package name]


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.
sudo pacman -Rc smplayer


For example, to download and install leafpad, the following command would be entered:


sudo pacman -Syu leafpad
The most nuclear option is {{ic|pacman -Rcs packagename}}.  This will remove everything that depends on packagename and continue to do so on it's 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.


{{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.}}


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:
sudo pacman -Rn smplayer
sudo pacman -Rsun smplayer
sudo pacman -Rcn smplayer


It is also possible to download software packages without actually installing them by entering the following command:


sudo pacman -Syuw [software package name]
=Viewing and Removing Orphans=


==Packages from the AUR (Arch User Repository)==
To list all ''orphans'', installed packages that are not used by anything else and should no longer be needed:
pacman -Qdt


To install a package from the AUR using a ''wrapper for pacman'' like '''yay'''-


  yay -S [software package name]
To remove all the orphans:
  sudo pacman -Rs $(pacman -Qdtq)


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==
=Downloading Packages without Installing=


To install a package already downloaded onto your system (the file name should end in '''pkg.tar.xz'''), the basic syntax is:
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:
sudo pacman -Sw smplayer


sudo pacman -U [/package_path/][software package name.pkg.tar.xz]


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


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]
=Determining which Package Owns a File=


 
It is often 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:
To install a package via a URL (i.e. located elsewhere on the internet), the basic syntax is:
  pacman -Qo /usr/bin/smplayer
 
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=
=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).
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 it's automated pacman cache cleaning functions.  It is also possible to clean them manually using pacman.


To clear the cache of downloads that have already been installed, enter the following command:
To clear the cache of downloads that have already been installed, enter the following command:
  sudo pacman -Sc
  sudo pacman -Sc




Otherwise, to clear the cache completely, enter the following command (and use with care):
Otherwise, to clear the cache completely, enter the following command (and use with care):
  sudo pacman -Scc
  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]]'''.


A safer way to remove old package cache files is to remove all packages except for the latest three package versions using {{ic|paccache}}:
paccache -rvk3


=Holding Back Packages from being Upgraded=


Courtesy the [https://wiki.archlinux.org/index.php/Pacman#Skip_package_from_being_upgraded Arch Wiki]
=The Configuration File, pacman.conf=


Pacman's settings are located in {{ic|/etc/pacman.conf}}.  This file is owned by root, please see [[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.


Pacman's settings are located in  /etc/pacman.conf


{{note|pacman.conf settings are case sensitive}}


'''To hold back a specific package from being updgraded'''


IgnorePkg=package-name
==Enabling Color Output==


For multiple packages use a space-separated list, or use additional IgnorePkg lines.
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 ort adding the following line to the file
Color




''Skipping a whole package group is also possible''
==Showing PacMan Eating Power Pills==


  IgnoreGroup=gnome
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




= Learning pacman's options =
=Troubleshooting=


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:
A separate page for pacman troubleshooting is available '''[[pacman troubleshooting|here]]'''.


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=


= See Also =
* [[System Maintenance]]
* [[Pacman-mirrors]]
* [[Pacman troubleshooting]]
* [[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]


* '''[[System Maintenance]]'''
* '''[http://repo.manjaro.org: Mirror Service]'''
* '''[[Manjaro_Mirrors|Manjaro Mirrors]]'''
* '''[[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]]
[[Category:Contents Page]]
[[Category:Software Management]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.