This post will guide you how to update OpenSUSE packages to keep your system up to date from the command line. How do I upgrade your packages and Linux kernel to the latest version from the command line interface on your OpenSUSE Linux. How to install package with zypper comand in OpenSUSE Linux.
Updating OpenSUSE System
If you want to update all pacakges to the latest version on your current OpenSUSE system, you need to refresh All OpenSUSE repositories to download metadata of packages from the medium, storing it in local cache. And the repository metadata are checked for chagnes before actually doing the refresh. A change is detected by downloading one or two metadata index files and comparing the checksums of the cached ones and the remote ones. If the files differ, the repository is out of date and will be refreshed.
Before refreshing repositories, you can check which repos are enabled in your system, type:
>zypper repos
outputs:
devops@linux-hxqn:~> zypper repos
Repository priorities are without effect. All enabled repositories share the same priority.
# | Alias | Name | Enabled | GPG Check | Refresh
---+---------------------------+------------------------------------+---------+-----------+--------
1 | openSUSE-Leap-15.1-1 | openSUSE-Leap-15.1-1 | No | ---- | ----
2 | repo-debug | Debug Repository | No | ---- | ----
3 | repo-debug-non-oss | Debug Repository (Non-OSS) | No | ---- | ----
4 | repo-debug-update | Update Repository (Debug) | No | ---- | ----
5 | repo-debug-update-non-oss | Update Repository (Debug, Non-OSS) | No | ---- | ----
6 | repo-non-oss | Non-OSS Repository | Yes | (r ) Yes | Yes
7 | repo-oss | Main Repository | Yes | (r ) Yes | Yes
8 | repo-source | Source Repository | No | ---- | ----
9 | repo-source-non-oss | Source Repository (Non-OSS) | No | ---- | ----
10 | repo-update | Main Update Repository | Yes | (r ) Yes | Yes
11 | repo-update-non-oss | Update Repository (Non-Oss) | Yes | (r ) Yes | Yes
Type the following zypper command to refresh all repositories on your OpenSUSE system:
> sudo zypper refresh
or
> sudo zypper ref
Outputs:
devops@linux-hxqn:~> sudo zypper refresh
Repository 'Non-OSS Repository' is up to date.
Repository 'Main Repository' is up to date.
Repository 'Main Update Repository' is up to date.
Repository 'Update Repository (Non-Oss)' is up to date.
All repositories have been refreshed.
Once repos are refreshed, and you can upgrade all packages of your OpenSUSE system to the latest version, type:
> sudo zypper update
Outputs:
devops@linux-hxqn:~> sudo zypper update
Loading repository data...
Reading installed packages...
The following 4 NEW packages are going to be installed:
kernel-default-4.12.14-lp151.28.13.1 libmediacheck5 virtualbox-guest-kmp-default virtualbox-kmp-default
The following 214 packages are going to be upgraded:
aaa_base aaa_base-extras apparmor-abstractions apparmor-docs apparmor
......
The following 3 packages require a system reboot:
dbus-1 kernel-default-4.12.14-lp151.28.13.1 kernel-firmware
214 packages to upgrade, 4 new.
Overall download size: 255.4 MiB. Already cached: 0 B. After the operation, additional 335.6 MiB will be used.
Note: System reboot required.
Continue? [y/n/v/...? shows all options] (y):
Retrieving package apparmor-docs-2.12.3-lp151.4.3.1.noarch (1/218), 286.1 KiB (355.5 KiB unpacked)
Retrieving delta: ./noarch/apparmor-docs-2.12.2_2.12.3-lp151.3.2_lp151.4.3.1.noarch.drpm, 26.6 KiB
Retrieving: apparmor-docs-2.12.2_2.12.3-lp151.3.2_lp151.4.3.1.noarch.drpm ........................................................................[done (14.7 KiB/s)]
Applying delta: ./apparmor-docs-2.12.2_2.12.3-lp151.3.2_lp151.4.3.1.noarch.drpm ...............................................................................[done]
Retrieving package apparmor-parser-2.12.3-lp151.4.3.1.x86_64
......
Executing %posttrans scripts ..................................................................................................................................[done]
There are some running programs that might use files deleted by recent upgrade. You may wish to check and restart some of them. Run 'zypper ps -s' to list these programs.
Core libraries or services have been updated.
Reboot is required to ensure that your system benefits from these updates.
devops@linux-hxqn:~>
From the above outputs, you would notice that if you want to list all running programs that use files deleted by upgrade operation. just type the following command:
> zypper ps -s
outputs:
devops@linux-hxqn:~> zypper ps -s
The following running processes use deleted files:
PID | PPID | UID | User | Command | Service
-----+------+------+--------+---------+--------
1739 | 1 | 1000 | devops | systemd |
You may wish to restart these processes.
See 'man zypper' for information about the meaning of values in the above table.
Core libraries or services have been updated.
Reboot is required to ensure that your system benefits from these updates.
Note: if you want to list all available updates for your current OpenSUSE system, and you can pass the “list-updates” option to the zypper command, type:
> sudo zypper list-updates
Outputs:
devops@linux-hxqn:~> sudo zypper list-updates
Loading repository data...
Reading installed packages...
S | Repository | Name | Current Version | Available Version | Arch
--+------------------------+---------------------------------+-------------------------------------+---------------------------------------+-------
v | Main Update Repository | PackageKit | 1.1.10-lp151.7.2 | 1.1.10-lp151.8.3.1 | x86_64
v | Main Update Repository | PackageKit-backend-zypp | 1.1.10-lp151.7.2 | 1.1.10-lp151.8.3.1 | x86_64
v | Main Update Repository | PackageKit-gstreamer-plugin | 1.1.10-lp151.7.2 | 1.1.10-lp151.8.3.1 | x86_64
v | Main Update Repository | PackageKit-gtk3-module | 1.1.10-lp151.7.2 | 1.1.10-lp151.8.3.1 | x86_64
......
Installing a Package on OpenSUSE
If you want to install a Firefox browser in your OpenSUSE system, and you can use zypper command to install it, type:
> sudo zypper install MozillaFirefox
Outputs:
devops@linux-hxqn:~> sudo zypper install MozillaFirefox
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 16 NEW packages are going to be installed:
desktop-file-utils libcanberra0 libcanberra-gtk0 libcanberra-gtk2-module libcanberra-gtk3-0 libcanberra-gtk3-module libcanberra-gtk-module-common libFLAC8
libpulse0 libsndfile1 libspeex1 libstartup-notification-1-0 libvorbisfile3 libxcb-util1 MozillaFirefox MozillaFirefox-branding-openSUSE
The following 2 recommended packages were automatically selected:
libcanberra0 libpulse0
16 new packages to install.
Overall download size: 39.6 MiB. Already cached: 0 B. After the operation, additional 143.9 MiB will be used.
Continue? [y/n/v/...? shows all options] (y):y
(16/16) Installing: MozillaFirefox-60.8.0-lp151.2.10.1.x86_64 .................................................................................................[done]
Updating Individual Packages on OpenSUSE
If you only want to update individual pacakges on OpenSUSE system with zypper command , and you need to specify one or more package names in zypper update command. You can use the * and ? wildcard characters in the package names to specify multiple packages matching the pattern.:
$ sudo zypper update packageName $ sudo zypper update packageName*
Conclusion
You should know that how to update/upgrade packages to the latest version with zypper command from the command line in your OpenSUSE Linux.