Introduction
ethod โ and when to use it โ is essential for any Linux user or system administrator.
Package Managers (Recommended)
Package managers are the easiest and safest way to install software. They handle dependencies, updates, and removal automatically.
apt (Debian, Ubuntu, Mint)
# Update package list
sudo apt update
# Install a package
sudo apt install nginx
# Install multiple packages
sudo apt install git curl wget vim
# Search for a package
apt search nginx
# Show package info
nx
# Remove a package
sudo apt remove nginx
# Remove package and config files
sudo apt purge nginx
# Remove unused dependencies
sudo apt autoremove
# Upgrade all packages
sudo apt upgrade
# Full system upgrade
l-upgrade
dnf / yum (RHEL, CentOS, Fedora)
tem from source ruby
Install a version
asdf install nodejs 20.0.0 asdf install python 3.12.0
Set global version
asdf global nodejs 20.0.0
Set local version (per project)
asdf local python 3.12.0
## Resources
- [apt Documentation](https://manpages.debian.org/apt)
- [dnf Documentation](https://dnf.readthedocs.io/)
- [GNU Autoconf (./configure)](https://www.gnu.org/software/autoconf/)
- [asdf Version Manager](https://asdf-vm.com/)
- [Linux From Scratch](https://www.linuxfromscratch.org/) โ build a complete Linux sysges
apt-mark showhold
Verify Installation
# Check if a command is available
which nginx
command -v nginx
# Check version
nginx -v
python3 --version
# Check if a service is running
systemctl status nginx
# Find where a package installed files
dpkg -L nginx
rpm -ql nginx
Managing Multiple Versions
asdf (Universal version manager)
# Install asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
# Add a plugin
asdf plugin add nodejs
asdf plugin add python
asdf plugin addcies
```bash
# Error: "configure: error: OpenSSL not found"
sudo apt install libssl-dev # Debian/Ubuntu
sudo dnf install openssl-devel # RHEL/Fedora
# Error: "cannot find -lz" (zlib missing)
sudo apt install zlib1g-dev
# Find which package provides a file
apt-file search libssl.so
dpkg -S /usr/lib/libssl.so
Version Conflicts
# Install a specific version
sudo apt install nginx=1.18.0-0ubuntu1
# Hold a package at current version (prevent upgrades)
sudo apt-mark hold nginx
# Check held packa
# Install from package.json
npm install
# Update packages
npm update
# Uninstall
npm uninstall express
Ruby (gem/bundler)
# Install a gem
gem install rails
# Install from Gemfile
bundle install
# Update gems
bundle update
# List installed gems
gem list
Go
# Install a package (Go modules)
go get github.com/gin-gonic/gin
# Install a CLI tool
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
Troubleshooting Common Issues
Missing Dependenuests==2.28.0
Install from requirements file
pip install -r requirements.txt
Install in virtual environment (recommended)
python3 -m venv .venv source .venv/bin/activate pip install requests
Upgrade a package
pip install –upgrade requests
List installed packages
pip list
Uninstall
pip uninstall requests
### Node.js (npm/yarn)
```bash
# Install globally
npm install -g typescript
# Install locally (project dependency)
npm install express
# Install dev dependency
npm install --save-dev jest
g
Common Build Dependencies
# Install essential build tools (Debian/Ubuntu)
sudo apt install build-essential
# Install essential build tools (RHEL/CentOS)
sudo dnf groupinstall "Development Tools"
# Common dependencies
sudo apt install \
gcc g++ make cmake \
libssl-dev \
zlib1g-dev \
libreadline-dev \
libffi-dev \
pkg-config
Installing Language-Specific Packages
Python (pip)
# Install a package
pip install requests
# Install specific version
pip install req
```bash
# Install to a custom directory (avoids conflicts with package manager)
./configure --prefix=/opt/myapp
# See all available options
./configure --help
# Common options
./configure \
--prefix=/usr/local \
--enable-ssl \
--disable-debug \
--with-openssl=/usr/local/ssl
Checking for Errors
# Check if the last command succeeded (0 = success)
echo $?
# Run configure and check
./configure --prefix=/usr/local
echo "Configure exit code: $?"
# Capture errors
make 2>&1 | tee build.loource (Compile)
When a package isn't available in your distro's repositories, or you need a specific version, compile from source.
### The Three-Step Process
```bash
# 1. Download and extract
wget https://example.com/software-1.0.tar.gz
tar -zxvf software-1.0.tar.gz
cd software-1.0/
# For .tar.bz2 files
tar -jxvf software-1.0.tar.bz2
# For .tar.xz files
tar -Jxvf software-1.0.tar.xz
# 2. Configure
./configure --prefix=/usr/local
# 3. Compile and install
make
sudo make install
Configure Options
Remove
flatpak uninstall org.gimp.GIMP
## Installing from a Downloaded Package
### .deb files (Debian/Ubuntu)
```bash
# Download
wget https://example.com/package.deb
# Install
sudo dpkg -i package.deb
# Fix missing dependencies
sudo apt install -f
# Or use apt directly (handles dependencies)
sudo apt install ./package.deb
.rpm files (RHEL/CentOS/Fedora)
# Install
sudo rpm -ivh package.rpm
# Or with dnf (handles dependencies)
sudo dnf install ./package.rpm
Installing from Ss
sudo pacman -Syu
List installed
pacman -Q
### snap (Universal, cross-distro)
```bash
# Install
sudo snap install code --classic
# List installed snaps
snap list
# Update all snaps
sudo snap refresh
# Remove
sudo snap remove code
flatpak (Universal, sandboxed)
# Add Flathub repository
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Install
flatpak install flathub org.gimp.GIMP
# Run
flatpak run org.gimp.GIMP
# Update all
flatpak update
```bash
# Install
sudo dnf install nginx
# Search
dnf search nginx
# Show info
dnf info nginx
# Remove
sudo dnf remove nginx
# Update all
sudo dnf upgrade
# List installed packages
dnf list installed
# Check for updates
dnf check-update
pacman (Arch Linux, Manjaro)
# Sync and install
sudo pacman -S nginx
# Search
pacman -Ss nginx
# Remove
sudo pacman -R nginx
# Remove with dependencies
sudo pacman -Rs nginx
# Update all package
Comments