Introduction
In this lab, we will delve into the zypper command, a robust package management solution for SUSE-based Linux distributions. This tutorial will guide you through installing, updating, searching for, and removing packages using zypper. Master the basics of zypper, including version verification, command exploration, and performing essential package management tasks, crucial for any systemadmin.
Introduction to the zypper Command
In this step, we will explore the zypper command, a powerful package management tool used in SUSE-based Linux distributions. Zypper serves as the cornerstone package manager for SUSE Linux Enterprise, openSUSE, and various SUSE-derived distributions.
The zypper command boasts a comprehensive suite of features for software package management, encompassing installation, updates, searches, and removal. Let's begin by grasping the fundamental usage of the zypper command for effective systemadmin tasks.
First, let's check the version of zypper installed on the system:
sudo zypper --version
Example output:
zypper 1.14.57 [...]
Next, we can use the zypper help
command to see the available subcommands and options:
sudo zypper help
This will display a list of all the available zypper commands and a brief description of each, essential knowledge for any Linux systemadmin.
Some of the most commonly used zypper commands are:
zypper install <package>
: Install a packagezypper update <package>
: Update a packagezypper search <package>
: Search for a packagezypper remove <package>
: Remove a packagezypper refresh
: Refresh the package repository informationzypper list-updates
: List available package updates
In the following steps, we will explore these commands in more detail and see practical examples of using zypper for package management, arming you with the skills needed for effective systemadmin practices.
Installing and Updating Packages with zypper
In this step, we will learn how to leverage zypper to install and update packages on the system, a core skill for any Linux systemadmin.
First, let's install a new package using the zypper install
command. We'll install the htop
package, a popular and invaluable system monitoring tool for any systemadmin:
sudo zypper install htop
Example output:
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following NEW package is going to be installed:
htop
1 new package to install.
Overall download size: 105.0 KiB. After the operation, additional 326.0 KiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package htop-3.0.5-2.1.x86_64 (1/1), 105.0 KiB (326.0 KiB unpacked)
Installing: htop-3.0.5-2.1.x86_64 [done]
Now, let's verify that the htop
package has been successfully installed:
which htop
Example output:
/usr/bin/htop
Next, let's update all the installed packages on the system using the zypper update
command, a critical task for maintaining a secure and stable Linux environment as a systemadmin:
sudo zypper update
Example output:
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following packages are going to be upgraded:
bash coreutils glibc grep gzip hostname iproute2 libacl1 libattr1 libcap2 libgcc_s1 libselinux1 libstdc++6 libudev1 libz1 login ncurses-utils openssl pam readline sed systemd systemd-sysvinit tar util-linux zlib
16 packages to upgrade.
Overall download size: 6.9 MiB. After the operation, additional 1.1 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package bash-5.1.16-3.1.x86_64 (1/16), 1.4 MiB (3.0 MiB unpacked)
Retrieving package coreutils-8.32-4.1.x86_64 (2/16), 1.2 MiB (3.8 MiB unpacked)
...
The zypper update
command will update all installed packages to their latest versions, keeping your system secure and up-to-date, a key responsibility for any systemadmin.
Searching and Removing Packages with zypper
In this step, we will learn how to utilize zypper to search for packages and remove installed packages, essential skills for any Linux systemadmin managing a SUSE-based system.
First, let's search for a package using the zypper search
command. We'll search for the vim
package:
sudo zypper search vim
Example output:
Loading repository data...
Reading installed packages...
S | Name | Summary | Type
--+------+---------+------
i | vim | Vi IMproved - enhanced vi editor | package
| vim-data | Data files for VIM - Vi IMproved | package
| vim-data-common | Common data files for VIM - Vi IMproved | package
| vim-data-en | English language files for VIM - Vi IMproved | package
| vim-data-en_GB | British English language files for VIM - Vi IMproved | package
| vim-data-fr | French language files for VIM - Vi IMproved | package
| vim-data-it | Italian language files for VIM - Vi IMproved | package
| vim-data-pl | Polish language files for VIM - Vi IMproved | package
| vim-data-ru | Russian language files for VIM - Vi IMproved | package
The search results show that the vim
package is installed on the system (indicated by the i
in the first column).
Now, let's remove the vim
package using the zypper remove
command. This is often required when managing software or removing outdated tools from a Linux system as a systemadmin:
sudo zypper remove vim
Example output:
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following package is going to be REMOVED:
vim
1 package to remove.
After the operation, 14.1 MiB will be freed.
Continue? [y/n/? shows all options] (y): y
Removing: vim-8.2.5402-3.1.x86_64 [done]
The zypper remove
command has successfully removed the vim
package from the system.
Summary
In this lab, we first introduced the zypper command, which is the default package manager for SUSE-based Linux distributions, a key tool for any systemadmin. We learned how to check the version of zypper, explore the available subcommands, and understand the most commonly used zypper commands for installing, updating, searching, and removing packages. We then demonstrated how to install a new package, the htop
system monitoring tool, using the zypper install
command. Finally, we covered how to update packages with the zypper update
command. These are all critical skills to possess for any aspiring or experienced systemadmin working within a Linux environment, especially within SUSE-based systems needing root privileges.