DevOps Shack _ Managing Packages and Processes in Linux
DevOps Shack _ Managing Packages and Processes in Linux
DevOps Shack
Table of Contents
1. Introduction to Package Management in Linux
o Overview of package management systems
o Importance of packages in Linux environments
2. Popular Package Managers
o apt (Debian/Ubuntu)
o yum / dnf (RHEL/CentOS/Fedora)
o zypper, pacman, snap, flatpak
3. Installing, Updating, and Removing Packages
o Command examples for install, update, and uninstall
o Handling dependencies and broken packages
4. Searching and Querying Packages
o Finding packages using command-line tools
o Viewing package details and files
5. Managing Software Repositories
o Adding/removing repositories
o Updating package lists and security
6. Introduction to Process Management
o Definition of processes and their types
o Foreground vs. background processes
7. Monitoring and Controlling Processes
o Tools: ps, top, htop, pidof, pgrep
2
o Killing/stopping/resuming processes (kill, nice, renice)
8. Automating and Managing Startup Services
o Using systemd, service, and init.d
o Enabling/disabling services on boot
3
1. Introduction
1.1 What is Package Management?
Package management refers to a system of tools and processes that simplify
the installation, upgrade, configuration, and removal of software applications
and libraries in Linux systems. It ensures software components are correctly
installed, updated, and maintained with minimal user intervention.
1.2 What is a Package?
A package is an archive file containing:
Compiled software or binaries
Metadata (name, version, description, dependencies)
Configuration files
Scripts (for installation or removal)
Packages usually have extensions like .deb (Debian-based), .rpm (Red Hat-
based), or are delivered in universal formats like Snap, Flatpak, or AppImage.
1.3 Key Roles of Package Managers
Package managers help users:
Search for available software
Install and remove software cleanly
Automatically resolve and install dependencies
Upgrade packages to newer versions
Maintain consistency and reduce software conflicts
1.4 Types of Package Management Systems
Linux distributions typically use one of the following two types of package
managers:
a) Binary Package Managers
These handle precompiled binaries (ready-to-install software):
apt (Advanced Package Tool) – Ubuntu/Debian
4
yum / dnf – Red Hat, CentOS, Fedora
zypper – openSUSE
pacman – Arch Linux
b) Source-based Package Managers
These compile packages from source:
portage (Gentoo)
pkgsrc (NetBSD)
1.5 Centralized vs. Decentralized Systems
Centralized: Packages come from official repositories (e.g., Ubuntu's
main repo)
Decentralized: Packages are installed from multiple sources (e.g.,
Snapcraft, Flatpak, PPAs)
1.6 Benefits of Package Management
Efficiency: Avoids manual compilation and installation
Security: Signed packages and regular updates
Scalability: Easily scriptable for enterprise-wide deployments
Dependency Handling: Automatically installs required libraries and tools
1.7 Components of a Package Management System
Package manager tool: e.g., apt, yum, pacman
Repositories: Server locations that store and serve packages
Package database: Keeps track of installed packages on a system
1.8 Summary
Understanding package management is foundational for working efficiently in
Linux. Whether you’re deploying a simple tool or managing hundreds of
servers, knowing how to handle packages ensures a stable and maintainable
environment.
5
2. Popular Package Managers
Linux distributions rely on different package managers depending on their
family (Debian-based, Red Hat-based, etc.). Each package manager offers
commands and syntax to handle software efficiently.
7
Allows installing from AUR (Arch User Repository) via helpers like yay
9
3. Installing, Updating, and Removing Packages in Linux
One of the most routine and vital tasks for Linux users and administrators is
managing software packages—installing new software, updating existing ones,
and removing unused applications. The commands and processes vary slightly
depending on the package manager and Linux distribution.
10
Using Flatpak
flatpak install flathub <app-id>
# Example:
flatpak install flathub org.gimp.GIMP
11
Pacman
sudo pacman -R <package-name> # Remove package only
sudo pacman -Rs <package-name> # Remove with unused dependencies
Zypper
sudo zypper remove <package-name>
Snap
sudo snap remove <package-name>
Flatpak
flatpak uninstall <app-id>
12
DNF automatically resolves conflicts, but logs and dnf history can help identify
issues:
sudo dnf history rollback <ID> # Roll back to a previous state
dnf pacman -
Cleanup apt autoremove -
autoremove Rns
13
4. Searching and Querying Packages
Efficient package management requires the ability to find, inspect, and verify
packages—both before installation and after they're on the system. Each
package manager provides a set of commands to help search repositories, view
details, and list package contents or dependencies.
14
# Example:
snap find vlc
Flatpak
flatpak search <package-name>
# Example:
flatpak search gimp
16
rpm -ql <package-name>
pacman - snap
View details apt show dnf info flatpak info
Si info
List installed dpkg -l dnf list pacman - snap list flatpak list
17
Task APT DNF/YUM Pacman Snap Flatpak
packages installed Q
pacman -
List package files dpkg -L rpm -ql - -
Ql
Check apt
dnf deplist pactree - -
dependencies depends
18
DNF/YUM
dnf repolist
yum repolist
Pacman
cat /etc/pacman.conf
Zypper
zypper repos
21
sudo sed -i 's|http://archive.ubuntu.com|http://mirror.provider.com|'
/etc/apt/sources.list
Pacman
sudo pacman-mirrors --fasttrack
Zypper
zypper modifyrepo --priority 90 repo-name
cat
View repos cat sources.list dnf repolist zypper repos
pacman.conf
priority=X in
Set priority apt pinning Manual order --priority flag
repo file
22
In Linux, a process is an instance of a running program. Every time a command
or program is executed, the system creates a new process. Understanding and
managing these processes is vital for maintaining system stability, performance,
and responsiveness.
23
top
Interactive, real-time process monitor.
top
Keys:
P – Sort by CPU
M – Sort by memory
k – Kill a process
q – Quit
htop (Enhanced top, needs installation)
htop
Features:
Colorful display
Easy sorting and filtering
Mouse support
pidof
Get PID of a running program.
pidof apache2
pgrep
Find processes by name.
pgrep firefox
24
fg %1 # Bring job 1 to foreground
bg %1 # Resume job 1 in background
18 SIGCONT Continue
19 SIGSTOP Pause/Stop
Use kill -l to list all signals.
26
7. Monitoring and Controlling Processes
Monitoring and controlling processes in Linux ensures efficient system
performance, prevents resource hogging, and helps with debugging and system
27
troubleshooting. This involves real-time observation, resource usage tracking,
and reactive control techniques.
29
gdb -p <PID>
30
7.7 GUI Tools for Monitoring (Optional)
System Monitor (GNOME/KDE)
KSysGuard
Xfce Task Manager
Install via your desktop environment’s package manager.
31
user or production environments. This section outlines best practices to help
you stay in control and minimize risks.
# CentOS/RHEL
sudo dnf update -y
Use Package Signing and Verification
Ensure packages are signed with trusted GPG keys.
Example: apt-key, rpm --checksig, or dnf check-update.
Avoid Manual Binary Installations
Installing software by downloading and extracting .tar.gz files or
precompiled binaries may bypass dependency and update management.
Remove Unused Packages
Clear out unnecessary packages to free up space and reduce attack
surface.
32
sudo apt autoremove
sudo dnf autoremove
33
Monitor logs using tools like logrotate, journalctl, or fail2ban.
Packages Use official repos, verify signatures, keep updated, clean unused
34
Area Best Practices
✅ Conclusion
Understanding and mastering package and process management in Linux is
fundamental for any system administrator, DevOps engineer, or advanced user.
Following best practices ensures you have:
A secure and stable system
Efficient performance
Controlled and accountable resource usage
Automated, documented, and reproducible setups
35