How to Manage Packages on SUSE Linux

SUSE Linux Logoyum is for CentOS and Redhat. apt-get is for Debian and Ubuntu. In the same way, zypper is for SUSE Linux.

Zypper is a command line tool for package management in OpenSUSE and SUSE Enterprise Linux platforms.

On a high-level, you can manage two different things using zypper command:

  1. Manage Repositories: Zypper also has the ability to work with repositories. You can add, remove, enable or disable repositories from command line. It also has the ability to prioritize your repositories during installation process.
  2. Manage Packages: Zypper is used to install, remove, update and query the software packages of local or remote media.

I. Manage Packages using Zypper

1. Install a Package using zypper

To install a package using zypper command, use the following syntax:

zypper install

For example, to install the Mozilla firefox and all its dependencies, execute the following:

# zypper install MozillaFirefoxLoading repository data...Reading installed packages...Resolving package dependencies...The following NEW packages are going to be installed:  MozillaFirefox MozillaFirefox-branding-SLEDThe following packages are not supported by their vendor:  MozillaFirefox MozillaFirefox-branding-SLED2 new packages to install.Overall download size: 964.0 KiB. After the operation, additional 3.4 MiB will be used.Continue? [y/n/?] (y): yRetrieving package MozillaFirefox-3.6.16-0.2.1.x86_64 (1/2), 949.0 KiB (3.4 MiB unpacked)Retrieving: MozillaFirefox-3.6.16-0.2.1.x86_64.rpm [done]Installing: MozillaFirefox-3.6.16-0.2.1 [done]Retrieving package MozillaFirefox-branding-SLED-3.5-1.1.5.x86_64 (2/2), 15.0 KiB (34.0 KiB unpacked)Retrieving: MozillaFirefox-branding-SLED-3.5-1.1.5.x86_64.rpm [done]Installing: MozillaFirefox-branding-SLED-3.5-1.1.5 [done]

2. Install Source Package

To install source package in a repository, use the source-install option as shown below.

# zypper source-install apache2-mod_nssReading installed packages...Loading repository data...Resolving package dependencies...Retrieving package mozilla-nss-devel-3.12.8-1.2.1.x86_64 (2/3), 473.0 KiB (2.6 MiB unpacked)Retrieving: mozilla-nss-devel-3.12.8-1.2.1.x86_64.rpm [done]Installing: mozilla-nss-devel-3.12.8-1.2.1 [done]Retrieving: apache2-mod_nss-1.0.8-17.5.src.rpm [done]

3. System Wide Full Distribution Upgrade

To perform a full distribution upgrade on the system, use the dup option along with zypper as shown below:

# zypper dupWarning: You are about to do a distribution upgrade with all enabled repositories. Make sure these repositories are compatible before you continue. See 'man zypper' for more information about this command.Loading repository data...Reading installed packages...Computing distribution upgrade...The following NEW packages are going to be installed:  drbd-xen libsoftokn3-32bit mozilla-nspr-32bit mozilla-nss-32bit mozilla-nss-certs-32bit suseRegister xen yast2-registration  yast2-registration-branding-SLEThe following packages are going to be upgraded:  libfreebl3-32bit libnsssharedhelper0 libnsssharedhelper0-32bitThe following packages are going to change vendor:  libfreebl3-32bit           SUSE LINUX Products GmbH, Nuernberg, Germany -> openSUSE Build Service  libnsssharedhelper0        SUSE LINUX Products GmbH, Nuernberg, Germany -> openSUSE Build Service  libnsssharedhelper0-32bit  SUSE LINUX Products GmbH, Nuernberg, Germany -> openSUSE Build Service

4. Delete a Package

To remove a package, use the remove option as shown below. This will also remove all the depedencies.

# zypper remove MozillaFirefoxLoading repository data...Reading installed packages...Resolving package dependencies...The following packages are going to be REMOVED:  MozillaFirefox MozillaFirefox-branding-SLED2 packages to remove.After the operation, 3.4 MiB will be freed.Continue? [y/n/?] (y): yRemoving MozillaFirefox-branding-SLED-3.5-1.1.5 [done]Removing MozillaFirefox-3.6.16-0.2.1 [done]

5. Update a Package

Once a package is installed, you can upgrade it to a new version when it becomes available using the update command as shown below.

The following will upgrade only MozillaFirefox package.

zypper update MozillaFirefox

The following will upgrade all the packages on your system to the latest version.

zypper update

You can also view all the available updates using the list-updates option as shown below.

6. Search for a Specific Package

To search for a package from a repository use the following command. You can also use wild card in the keyword.

In this example, it will search for all packages that starts with the keyword “usb”.

# zypper search usb*Loading repository data...Reading installed packages...S | Name           | Summary                                                        | Type--+----------------+----------------------------------------------------------------+--------  | usb_modeswitch | A mode switching tool for controlling multiple-device USB gear | packagei | usbutils       | Tools and libraries for USB devices                            | package

7. View Details about a Package

To display information about a specific package, use the info option with zypper as shown below:

# zypper info usbutilsLoading repository data...Reading installed packages...Information for package usbutils:Repository: @SystemName: usbutilsVersion: 0.73-38.19Arch: x86_64Vendor: SUSE LINUX Products GmbH, Nuernberg, GermanySupport Level: unknownInstalled: YesStatus: up-to-dateInstalled Size: 461.0 KiBSummary: Tools and libraries for USB devicesDescription:This package contains a utility for inspecting devices connected to USBports.It requires kernel version 2.3.99-pre7 or newer, or the USB backportwhich was introduced in 2.2.18 (supporting the /proc/bus/usbinterface).

8. Install Patches using Zypper

You can also use zypper to install patches on your system.

First, view all available patches using patches option as shown below:

zypper patches

Next, you can install a specific patch from the above output using the patch option as shown below.

zypper patch

9. Lock a Specific Package

Package lock prevents the changes to the package on the system. Once this lock is set, you cannot remove, upgrade the package.

The following example shows how to setup the package locks and remove it when needed.

Add a package lock to ypbind package using “al” option. al stands for “Add Lock”

# zypper al ypbindSpecified lock has been successfully added.

To view all the packages that are locked, use the “ll” option. ll stands for “List Locks”. The following output indicates that “ypbind” package is currently locked, and you cannot remove or upgrade this package.

# zypper ll# | Name   | Type    | Repository--+--------+---------+-----------1 | ypbind | package | (any)

10. Remove Lock from a Package

Remove the package lock from ypbind package using “rl” option. rl stands for “Remove Lock”

# zypper rl ypbindLoading repository data...Reading installed packages...1 lock has been successfully removed.

As you see below, currently no packages are locked.

# zypper llThere are no package locks defined.

II. Manage Repositories using Zypper

11. Add a Repository using Zypper

The general syntax to add a repository using http URI is as follows:

zypper addrepo

For example, to add a repository using the URI do the following:

# zypper addrepo --check --refresh --name "Mozilla-repo" http://download.opensuse.org/repositories/mozilla/SLE_11/ "Mozillarepo"Adding repository 'Mozilla-repo' [done]Repository 'Mozilla-repo' successfully addedEnabled: YesAutorefresh: YesURI: http://download.opensuse.org/repositories/mozilla/SLE_11/

12. View Repositories

Your can view all the repositories using the following zypper command:

# zypper lr# | Alias                                            | Name                                             | Enabled | Refresh--+--------------------------------------------------+--------------------------------------------------+---------+--------1 | Mozillarepo                                      | Mozilla-repo                                     | Yes     | Yes2 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | Yes     | Yes

To display the complete URI for the repo, use the following:

# zypper lr --uri# | Alias                                            | Name                                             | Enabled | Refresh | URI--+--------------------------------------------------+--------------------------------------------------+---------+---------+----------------------------------------------------------1 | Mozillarepo                                      | Mozilla-repo                                     | Yes     | Yes     | http://download.opensuse.org/repositories/mozilla/SLE_11/2 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | Yes     | Yes     | http://19.106.65.64/FUSELinux/600RC0

13. Search Packages Inside Repository

To list all the packages from the specific repository, use the following command:

# zypper search --repo MozillarepoLoading repository data...Reading installed packages...S | Name                                 | Summary                                                                 | Type--+--------------------------------------+-------------------------------------------------------------------------+-----------i | MozillaFirefox                       | Mozilla Firefox Web Browser                                             | packagei | MozillaFirefox-branding-SLED         | SLED branding of MozillaFirefox                                         | package    | MozillaFirefox-branding-openSUSE     | openSUSE branding of MozillaFirefox                                     | package  | MozillaFirefox-branding-openSUSE     | openSUSE branding of MozillaFirefox                                     | srcpackage

14. Rename a Repository

To rename any repository, use the renamerepo option.

In this example, the repo name “mylocalrepo” has been renamed to “LOCALRPM-Repo”

# zypper renamerepo mylocalrepo LOCALRPM-RepoRepository 'mylocalrepo' renamed to 'LOCALRPM-Repo'.

15. Create a Local Repository

You can also create a local repository from a local directory on your server that has all the rpm files using the following syntax:

zypper addrepo

For example, to add a repository called myrepo with the local directory that has all the rpms use the below command:

# zypper addrepo /var/stormgt/dsminst mylocalrepoAdding repository 'mylocalrepo' [done]Repository 'mylocalrepo' successfully addedEnabled: YesAutorefresh: NoURI: dir:///var/stormgt/dsminst# zypper search --repo mylocalrepoLoading repository data...Reading installed packages...S | Name        | Summary                                 | Type--+-------------+-----------------------------------------+--------i | TIVsm-API   | the API                                 | packagei | TIVsm-API64 | the API                                 | packagei | TIVsm-BA    | the Backup Archive Client               | packagei | gskcrypt32  | IBM GSKit Cryptography Runtime          | packagei | gskcrypt64  | IBM GSKit Cryptography Runtime          | packagei | gskssl32    | IBM GSKit SSL Runtime With Acme Toolkit | packagei | gskssl64    | IBM GSKit SSL Runtime With Acme Toolkit | package

You can also add the NFS or FTP location to the repositories using the above command.

16. Delete a Repository

To delete a repository use the removerepo option as shown below.

# zypper removerepo LOCALRPM-RepoRemoving repository 'mylocalrepo' [done]Repository 'mylocalrepo' has been removed.

17. Backup a Repository

You can backup the repository file that contains the list of repositories using the export option as shown below. This will store the repository list in the backup.repo file.

# zypper lr --export /var/tmp/backup.repoRepositories have been successfully exported to /var/tmp/backup.repo.

18. Add Repositories from a Backup

If you have a previously exported repository file, you can use that to add new repositories using addrepo command as shown below.

zypper addrepo /var/tmp/backup.rep

19. Disable or Enable a Repository

To disable the repository use the modify repo option with -d flag as shown below. This will disable the Mozilla repository.

# zypper modifyrepo -d MozillarepoRepository 'Mozillarepo' has been successfully disabled.

To enable the repository that was previously disabled, use the -e flag along with modifyrepo option as shown below.

# zypper modifyrepo -e MozillarepoRepository 'Mozillarepo' has been successfully enabled.

20. Refresh a Repository

It is very important to refresh a repository, when it becomes out of date. You can either do a manual refresh as shown in the below example or set to refresh automatically when needed.

# zypper refresh MozillarepoRepository 'Mozilla-repo' is up to date.Specified repositories have been refreshed.

To set auto refresh option for a specific repository, please use the command as shown in below example:

# zypper modifyrepo --refresh mylocalrepoAutorefresh has been enabled for repository 'mylocalrepo'.

>

You may also like...