How to Install Things on Linux

Linux, a robust and versatile operating system, offers a myriad of ways to install software and applications. Whether you’re a seasoned Linux administrator or a newcomer exploring its depths, understanding these installation methods is fundamental to leveraging the full power of your system. This guide will delve into the primary installation avenues, focusing on the most common and effective techniques.

Package Managers: The Cornerstone of Linux Software Installation

Package managers are the lifeblood of software distribution on Linux. They automate the process of installing, upgrading, configuring, and removing software packages, ensuring that dependencies are met and that the system remains stable. The specific package manager you’ll use depends on your Linux distribution.

APT (Debian, Ubuntu, Linux Mint)

Advanced Package Tool (APT) is the de facto standard for Debian-based distributions. It’s renowned for its user-friendliness and comprehensive capabilities.

Installing Packages with apt

The primary command for installing software is apt install. You’ll typically need root privileges, which are obtained using sudo.

sudo apt install <package_name>

For example, to install the popular text editor nano, you would run:

sudo apt install nano

You can install multiple packages simultaneously by listing them separated by spaces:

sudo apt install nano git vim

Updating Package Lists

Before installing new software or upgrading existing packages, it’s crucial to update your local package list to ensure you’re fetching the latest available versions and that your system knows about all available software.

sudo apt update

Upgrading Installed Packages

Once your package lists are updated, you can upgrade all installed packages to their latest versions.

sudo apt upgrade

This command will upgrade all packages that have newer versions available. For a more comprehensive upgrade that can also remove obsolete packages and install new dependencies for upgraded packages, you can use apt full-upgrade:

sudo apt full-upgrade

Removing Packages

To uninstall a package, use the apt remove command.

sudo apt remove <package_name>

This command removes the package but may leave behind configuration files. To remove the package and its configuration files, use apt purge:

sudo apt purge <package_name>

Searching for Packages

If you’re unsure of the exact package name, you can search for it using apt search.

apt search <search_term>

YUM/DNF (Fedora, CentOS, RHEL)

Yellowdog Updater, Modified (YUM), and its successor, DNF (Dandified YUM), are the package managers for Red Hat-based distributions. DNF is the modern, more efficient replacement for YUM.

Installing Packages with dnf (or yum)

The command to install a package is straightforward.

sudo dnf install <package_name>

or on older systems:

sudo yum install <package_name>

To install multiple packages:

sudo dnf install <package_name_1> <package_name_2>

Updating Package Lists and Upgrading Packages

Unlike APT, YUM/DNF often perform an update of the metadata when you attempt to install or upgrade, so a separate update step is less frequently needed for basic operations. However, to explicitly update the repository metadata:

sudo dnf check-update

To upgrade all installed packages:

sudo dnf upgrade

or on older systems:

sudo yum update

Removing Packages

To uninstall a package:

sudo dnf remove <package_name>

or on older systems:

sudo yum remove <package_name>

Searching for Packages

Similar to APT, you can search for packages.

dnf search <search_term>

or on older systems:

yum search <search_term>

Pacman (Arch Linux, Manjaro)

Pacman is the package manager for Arch Linux and its derivatives. It’s known for its simplicity and speed.

Installing Packages with pacman

The command to install a package is:

sudo pacman -S <package_name>

To install multiple packages:

sudo pacman -S <package_name_1> <package_name_2>

Synchronizing and Upgrading Packages

Before installing or upgrading, it’s essential to synchronize your local package database with the remote repositories and then upgrade all installed packages.

sudo pacman -Syu

This command updates the package database (y) and then upgrades all out-of-date packages (u).

Removing Packages

To uninstall a package:

sudo pacman -R <package_name>

To remove a package and its dependencies that are no longer required by any other package:

sudo pacman -Rs <package_name>

Searching for Packages

Pacman’s search functionality is typically done using the -Ss option:

pacman -Ss <search_term>

Compiling from Source: Ultimate Control and Customization

While package managers are convenient, sometimes you need to install software that isn’t available in your distribution’s repositories, or you require a specific version or configuration. In such cases, compiling from source is the answer. This process involves downloading the software’s source code, configuring it for your system, compiling it into executable binaries, and then installing it.

The standard procedure for compiling from source typically follows these steps:

1. Download the Source Code

Source code is usually distributed as compressed archives (e.g., .tar.gz, .tar.bz2). You’ll download these archives, often from the software’s official website or a code repository.

2. Extract the Archive

Once downloaded, you need to extract the contents of the archive.

tar -xvf <archive_name.tar.gz>

This will create a new directory containing the source code. Navigate into this directory:

cd <source_code_directory>

3. Configure the Build

Most source code distributions include a configure script. This script checks your system for necessary libraries and tools, and prepares the build environment. You can often pass various options to configure to customize the installation.

./configure

Common options include --prefix=/path/to/install to specify the installation directory. For example:

./configure --prefix=/usr/local

4. Compile the Source Code

After configuration, you compile the source code using a build tool, most commonly make.

make

This step can take a significant amount of time, depending on the size of the software and your system’s performance.

5. Install the Software

Once compilation is complete, you can install the software to its designated location. This step typically requires root privileges.

sudo make install

Important Considerations for Compiling from Source:

  • Dependencies: You must ensure all necessary development libraries and tools are installed on your system before attempting to compile. The configure script will usually inform you if dependencies are missing.
  • Build Tools: You’ll need a C/C++ compiler (like GCC) and make installed. Package managers usually provide packages for these, often grouped as “build-essential” or “devel” packages.
  • Uninstallation: Uninstalling software installed from source can be more challenging than using a package manager. Some Makefiles provide an uninstall target (e.g., sudo make uninstall), but this is not always the case. You may need to manually remove files.

Installing Binaries Directly

In some scenarios, software is distributed as pre-compiled binaries, often in a single executable file or a compressed archive containing executables.

Executable Files

If you download a single executable file, you often need to make it executable and then place it in a directory that’s in your system’s PATH.

chmod +x <executable_file>

Then, you can move it to a suitable location, such as /usr/local/bin:

sudo mv <executable_file> /usr/local/bin/

AppImages and Flatpaks

More modern approaches to distributing binaries include AppImages and Flatpaks.

AppImages

AppImages are self-contained applications that run on most Linux distributions without needing to be installed in the traditional sense. You download an .AppImage file, make it executable, and then run it.

chmod +x <application.AppImage>
./<application.AppImage>

Flatpaks

Flatpaks are a universal package management system for Linux. They are designed to run in a sandbox, which enhances security and allows applications to be distributed independently of the underlying distribution. You typically use the flatpak command-line tool.

To install a Flatpak application (you’ll usually need to add a remote first, like Flathub):

flatpak install flathub <application_id>

To run a Flatpak application:

flatpak run <application_id>

Software Centers and Graphical Installers

For users who prefer a graphical interface, most modern Linux distributions offer “Software Centers” or application stores. These tools provide a user-friendly way to browse, search for, and install applications, often utilizing the underlying package manager or Flatpak/Snap technologies.

These graphical interfaces abstract away the command-line complexities, making the installation process accessible to a wider audience. You can search for applications by category or name, read descriptions, view screenshots, and click an “Install” button. Updates are also typically managed through these centers.

Understanding the various methods for installing software on Linux empowers you to manage your system effectively, whether you prioritize convenience, control, or the latest software versions. Each method has its strengths, and choosing the right one depends on your specific needs and the software you intend to install.

Leave a Comment

Your email address will not be published. Required fields are marked *

FlyingMachineArena.org is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. Amazon, the Amazon logo, AmazonSupply, and the AmazonSupply logo are trademarks of Amazon.com, Inc. or its affiliates. As an Amazon Associate we earn affiliate commissions from qualifying purchases.
Scroll to Top