Installing Packages
APT Package Manager (Debian/Ubuntu)
APT (Advanced Package Tool) is the default package manager for Debian and Ubuntu-based distributions.
- Updating Package Lists: Before installing packages, it's a good practice to update the package lists:
sudo apt update
- Installing Packages:
To install a package, use the
apt install
command:
sudo apt install package-name
DPKG & APT
dpkg
is the low-level package manager for Debian-based distributions like Debian and Ubuntu. It directly handles package installation and management.
Installing Packages
- Downloading a Package:
Download the
.deb
package file from the official repository or a trusted source. - Installing a Package:
Use the
dpkg
command to install the downloaded package:
sudo dpkg -i package-file.deb
Replace package-file.deb
with the actual filename of the package you downloaded.
- Handling Dependencies: If there are missing dependencies, you might see an error message. To resolve this, use the following command to fix and install missing dependencies:
sudo apt install -f
Uninstalling Packages
- Uninstalling a Package:
To uninstall a package, use the
dpkg
command with ther
flag:
sudo dpkg -r package-name
- Removing a Package (with Configuration Files):
To remove a package along with its configuration files, use the
dpkg
command with the-purge
flag:
sudo dpkg --purge package-name
Listing Installed Packages
- Listing Installed Packages:
To list all installed packages, use the
dpkg
command with thel
flag:
dpkg -l
- Searching for a Specific Package:
To search for a specific package, use
dpkg
with thel
flag and pipe the output togrep
:
dpkg -l | grep package-name
Summary
- Installing a Package:
- Download the
.deb
package file. - Install with:
sudo dpkg -i package-file.deb
- Handling Dependencies:
- If needed, fix missing dependencies with:
sudo apt install -f
- Uninstalling a Package:
- Uninstall a package:
sudo dpkg -r package-name
- Remove with configuration files:
sudo dpkg --purge package-name
- Listing Installed Packages:
- List all installed packages:
dpkg -l
- Search for a specific package:
dpkg -l | grep package-name
Remember, dpkg
doesn't handle dependencies automatically like higher-level package managers. For efficient package management, consider using apt
along with dpkg
to ensure that dependencies are managed correctly.
YUM Package Manager (RHEL/CentOS)
YUM (Yellowdog Updater Modified) is the package manager for RHEL, CentOS, and Fedora-based distributions.
- Updating Package Lists: Update the package metadata before installing packages:
sudo yum update
- Installing Packages:
To install a package, use the
yum install
command:
sudo yum install package-name
Pacman Package Manager (Arch Linux)
Pacman is the package manager for Arch Linux and Arch-based distributions.
- Updating Package Lists: Update the package database before installing packages:
sudo pacman -Syu
- Installing Packages:
To install a package, use the
pacman -S
command:
sudo pacman -S package-name
Summary
- APT (Debian/Ubuntu):
- Update package lists:
sudo apt update
- Install packages:
sudo apt install package-name
- YUM (RHEL/CentOS):
- Update package lists:
sudo yum update
- Install packages:
sudo yum install package-name
- Pacman (Arch Linux):
- Update package lists:
sudo pacman -Syu
- Install packages:
sudo pacman -S package-name
Remember that you need administrative privileges (sudo) to install packages system-wide. Replace package-name
with the name of the package you want to install.
These commands will fetch and install packages from the respective distribution's repositories. Linux package managers handle dependencies automatically, ensuring that all required libraries and components are also installed.
Keep in mind that while the package managers are specific to these distributions, the general idea of updating and installing packages is quite similar across most Linux distributions. Always refer to your distribution's official documentation for detailed instructions and specific package names.