Installing and Managing Packages
Full-Access Members Only
Sorry, this lesson is only available to Server Academy Full-Access members. Become a Full-Access member now and get instant access to this and many more premium courses. Click the button below and get instant access now.
Instructions
Q&A (0)
Notes (0)
Resources (0)
Saving Progress...
Resources
There are no resources for this lesson.
Notes can be saved and accessed anywhere in the course. They also double as bookmarks so you can quickly review important lesson material.
In this lesson, you'll learn about package management in Linux, focusing on the apt
package manager. By the end of this lesson, you'll understand how to search for, install, update, and remove packages using apt
. Additionally, we'll briefly compare apt
with other popular package managers, highlighting their similarities and differences.
Understanding Package Managers in Linux
Package managers are tools that automate the process of managing software on your Linux system. They handle the installation, updating, configuration, and removal of software packages. Each Linux distribution tends to favor a specific package manager, though they generally perform similar functions. The most common package managers include:
- APT (Advanced Package Tool): Used in Debian and Debian-based distributions like Ubuntu.
- YUM (Yellowdog Updater, Modified): Utilized in Red Hat and Red Hat-based distributions like CentOS.
- Zypper: The package manager for openSUSE.
- Pacman: Designed for Arch Linux.
These package managers differ mainly in their commands and package repositories but share the common goal of simplifying software management.
Working with apt
in Ubuntu and Debian
Searching for Packages
To search for a package in the apt
repository, use the command:
apt search package_name
Replace package_name
with the name or description of the software you're looking for. Search for the package named cowsay
.
Installing Packages
To install a package, the command is:
sudo apt install package_name
In this example, we will install the package cowsay
:
sudo apt install cowsay
Also install the package named fortune
, then you can pipe fortune to cowsay and get output like the following:
paulh@ubuntu-server:~$ fortune | cowsay
_______________________________________
/ As flies to wanton boys are we to the \
| gods; they kill us for their sport. |
| |
\ -- Shakespeare, "King Lear" /
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
List installed packages
You can list all install packages by using the command below:
apt list --installed
Updating Package Lists
Before installing new software or updating existing packages, it's a good practice to update the list of available packages:
sudo apt update
Upgrading a specific package
There may be times when you only want to upgrade one specific package instead of all of your packages. You can accomplish this with the command below:
sudo apt install --only-upgrade package_name
Upgrading Installed Packages
To upgrade all your installed packages to their latest available versions, use:
sudo apt upgrade
Removing Packages
To remove an installed package:
sudo apt remove package_name
To remove a package along with its configuration files:
sudo apt purge package_name
Comparison of Package Managers
Feature / Package Manager | APT | YUM | Zypper | Pacman |
---|---|---|---|---|
Base Distribution | Debian-based | Red Hat-based | openSUSE | Arch Linux |
Search Command | apt search | yum search | zypper search | pacman -Ss |
Install Command | apt install | yum install | zypper install | pacman -S |
Update Package List | apt update | yum check-update | zypper refresh | pacman -Sy |
Upgrade Packages | apt upgrade | yum update | zypper update | pacman -Su |
Remove Package | apt remove | yum remove | zypper remove | pacman -R |
Verifying Your Actions
After performing any package management operation, you can verify it by checking the status of the package. For instance, to verify installation:
apt list --installed | grep package_name
That is all we need to cover in this lesson.. See you in the next one!
Server Academy Members Only
Sorry, this lesson is only available to Server Academy Full Access members. Become a Full-Access Member now and you’ll get instant access to all of our courses.