Package Management

Tarih: 2026-06-15 | Kategori: Linux

Etiketler: Linux

In the daily use and system administration of Linux operating systems, managing software packages is critically important. Linux distributions provide various package managers to facilitate tasks such as software installation, updating, and removal. These package managers allow you to manage software in package formats, along with their dependencies.

Each Linux distribution uses specific package management systems and package formats. In this section, we will explore package management tools commonly used in Debian-based Linux distributions and their basic usages.

Key Features of Package Managers

Linux package managers offer various features for managing software packages:

  • Package Downloading: Automatically download software packages and dependencies from the internet.
  • Dependency Resolution: Identify and automatically install the dependencies required by a package.
  • Package Installation and Removal: Install software packages to the system and remove them when necessary.
  • Updates and Upgrades: Check for new versions of installed packages and update them.
  • Configuration Files and Directories: Provide standards for the configuration files and directories of software packages.
  • Advanced Package Tool (APT)

    APT (Advanced Package Tool) is a powerful tool used to manage software packages in Debian-based Linux distributions such as Ubuntu. This tool allows users to easily install new software, update existing software, remove unnecessary ones, and automatically resolve dependencies between software packages. With simple command-line commands, users can keep their systems up-to-date and secure, while also quickly accessing the software they need. The convenience and efficiency offered by APT make it a popular choice among Linux users.

    Updating Package Lists

    APT keeps package lists in a database on your local system. It doesn't connect to servers each time you search, thus providing faster results, but the results might not be up-to-date. To get the most current results, you need to update your lists.

    To update your package list with `apt`, use the `update` command.

    user@hackerbox:~$ sudo apt update
    

    Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    All packages are up to date.
    

    Searching in Package Lists

    Now that we have updated the package lists in the database, we can search within those lists. For example, to search for a package with the name `htop`, you can perform the following search.

    user@hackerbox:~$ sudo apt search htop
    

    aha - ANSI color to HTML converter
    htop - interactive interactive processes viewer
    libauthen-oath-perl - Perl module for OATH One Time Passwords
    

    As you can see in the results, in addition to the `htop` package, there are other unrelated packages. This is because the `apt search` command also searches within the package descriptions. For example, if we look at the description of the `aha` package, we can see where `htop` is mentioned.

    The `apt search` command supports regular expressions. For example, to search for packages starting with `htop`, you could do:

    user@hackerbox:~$ sudo apt search ^htop
    

    Or, you could search for packages whose names contain the term `htop`.

    user@hackerbox:~$ sudo apt search --names-only htop
    

    Installing and Updating Packages

    To install a package found, use the `apt` command.

    user@hackerbox:~$ sudo apt install htop
    

    The following NEW packages will be installed:
      htop
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 80.0 kB of archives.
    After this operation, 201 kB of additional disk space will be used.
    

    This command also updates an existing installed package to the latest version if it's already installed. To update all packages on your system, you can use the `upgrade` command.

    user@hackerbox:~$ sudo apt upgrade
    

    This method will not install any new packages or remove any old ones. If this isn't a concern, you can use the `dist-upgrade` command.

    user@hackerbox:~$ sudo apt dist-upgrade
    

    Removing Packages

    To remove a package, use the `remove` command.

    user@hackerbox:~$ sudo apt remove htop
    

    The following packages will be REMOVED:
      htop
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 201 kB disk space will be freed.
    

    The output above shows that the `htop` package has been successfully removed from the system, freeing up 201 kB of disk space.

    The `remove` command does not delete the configuration files and deb files for `htop`. To remove those as well, you would use the `purge` command.

    user@hackerbox:~$ sudo apt purge htop
    

    Purging configuration files for htop (2.1.0-3) ...