Package management

From xotHostWiki
Jump to: navigation, search

This is a very concise guide for package management in various Linux distributions, and as well as FreeBSD. Package managers are very powerful tools and the guide below just scratches the surface of what you can do with your distro's package manager.
Here we show only the most basic package management features for various distros.

Contents

About Package Management

Package management in Linux and FreeBSD is very different than in other Operating Systems.
Here all the software packages are hosted in a repository that you can access from your machine via the package manager of your distro.
This includes package installation, update, upgrades, search, and system updates among other things.
Most distributions come with very good desktop tools for package management, but here we will focus only on command line tools, since the access to your server or VPS is mainly via SSH.
For more information check the manual pages for your package management tool you use.

Basic commands by distribution

ArchLinux - pacman

Managing software

  • Install a new package from a software repository
# pacman -S packagename
  • Install software from a file
# pacman -U filename
  • Update exisitng package
# pacman -S packagename
  • Remove package
# pacman -R packagename

Updating the system

  • Update package database
# pacman -Sy
  • Update system
# pacman -Su
  • One-step system update
# pacman -Syu

Package search

  • Search by package name
$ pacman -Ss packagename
  • Search by pattern
$ pacman -Ss pattern
  • Search by file name
# pacman -Qo filename
  • List installed packages
# pacman -Q

Managing software repositories

  • List repositories
# cat /etc/pacman.conf
  • Add repository

Edit the file /etc/pacman.conf

  • Remove repository

Edit the file /etc/pacman.conf

Debian / Ubuntu - apt (deb)

Ubuntu has the root user disabled by default and uses sudo for administrative tasks. When using Ubuntu, change the commands as follows:

# command

for

$ sudo command

Managing software

  • Install a new package from a software repository
# apt-get install packagename
  • Install software from a file
# dpkg -i packagename
  • Update exisitng package
# apt-get install packagename
  • Remove package
# apt-get remove packagename

Updating the system

  • Update package database
# apt-get update
  • Update system
# apt-get upgrade

Package search

  • Search by package name
# apt-cache search packagename
  • Search by pattern
# apt-cache search pattern
  • Search by file name
# apt-file search path
  • List installed packages

Managing software repositories

  • List repositories
# cat /etc/apt/sources.list
  • Add repository

Edit the file /etc/apt/sources.list

  • Remove repository

Edit the file /etc/apt/sources.list

CentOS / Fedora / Scientific Linux - yum(rpm)

Managing software

  • Install a new package from a software repository
# yum install packagename
  • Install software from a file
# yum localinstall packagename
  • Update exisitng package
# yum update packagename
  • Remove package
# yum erase packagename

Updating the system

  • Update package database
# yum check-update
  • Update system
# yum update

Package search

  • Search by package name
# yum list packagename
  • Search by pattern
# yum list pattern
  • Search by file name
# yum provides filename
  • List installed packages
# rpm -qa

Managing software repositories

  • List repositories
# yum repolist
  • Add repository

edit /etc/yum.repos.d

  • Remove repository

edit /etc/yum.repos.d

OpenSUSE - zypp (rpm)

Managing software

  • Install a new package from a software repository
# zypper install packagename
  • Install software from a file
# zypper install package
  • Update exisitng package
# zypper update -t package packagename
  • Remove package
# zypper remove packagename

Updating the system

  • Update package database
# zypper refresh
  • Update system
# zypper update

Package search

  • Search by package name
# zypper search packagename
  • Search by pattern
# zypper search -t pattern pattern
  • Search by file name
# zypper wp filename
  • List installed packages
# zypper search -is

Managing software repositories

  • List repositories
# zypper repos
  • Add repository
# zypper addrepo URL repo name
  • Remove repository
# zypper removerepo repo name

FreeBSD - binary and ports system

Managing software

  • Install a new package from a software repository (binary)
# pkg_add -r packagename
  • Install a new package from a software repository (ports)
# cd port_dir && make && make install
  • Install software from a file (binary)
# pkg_add path_to_package
  • Update exisitng package (binary)
# pkg_add path_to_package
  • Update exisitng package (ports)
# portupgrade -R pkg
  • Remove package (binary and ports)
# pkg_delete pkgname

Updating the system

  • Security Patches (binary)
# freebsd-update fetch install # freebsd-update install
  • Security Patches (ports)
# portsnap fetch install
  • Update package database (ports)
# csup -L 2 -h cvsup.FreeBSD.org path_to_supfile
# portsnap update
  • Update system (ports)
# portupgrade -a
# portmanager -u
# portmaster -a

Package search

  • Search by package name (ports)
# cd /usr/ports && make search packagename
  • Search by pattern (ports)
# cd /usr/ports && make search pattern
  • List installed packages (binary and ports)
# pkg_info

About this guide

This guide was based on several documentation from the distros, and from the very good Package Management Cheatsheet from Distrowatch.com


Back to Main Page
Go to xotHost.com

Personal tools
Namespaces

Variants
Actions
Navigation
Tools