Alpine linux update upgrade

13 Apk Commands for Alpine Linux Package Management

Alpine Linux is an independent, free, and open-source Linux distribution based on BusyBox and musl. It is a lightweight and security-oriented Linux distribution that comes in a small footprint (about 160 MB).

For this reason, it’s widely used in creating containers that are lightweight and standalone units that provide an isolated environment to deploy and run applications.

Alpine Linux targets users who desire simplicity, security, and efficient resource utilization. It is designed for x86, x86-64. AArch64 and ARM architectures.

Like any other Linux distribution, Alpine Linux comes with its own package manager known as apk (Alpine Package Keeper) and comes pre-installed on all Alpine Linux distributions.

Apk handles all the package management operations including searching, installing, upgrading, listing, and removing software packages just to mention a few. In this guide, we showcase commonly used Apk command examples in Alpine Linux.

Alpine Linux Packages and Repositories

Before we look at the various apk commands that you can leverage to manage your packages, let us touch on Alpine Linux repositories.

Читайте также:  Найти файл через командную строку linux

Alpine Linux has two repositories enabled by default: the main and community repositories.

  1. The main repository comprises packages that are rigorously tested and approved to be officially hosted by the Alpine Linux core development team.
  2. The community repository, on the other hand, comprises community-supported packages which are ported from the edge or testing repositories.

On your local Alpine Linux system, you can find the repositories in the /etc/apk/repositories file, you can use the cat command to view them as follows.

Alpine Linux Repositories

Having looked at the repositories, let us straight away jump into managing packages using the apk package manager.

1. Update Alpine Linux

To update the repositories and package lists on Alpine Linux, run the command

Alpine Linux Update

2. Search for an Availability of Packages

Before installing packages, it’s worthwhile to check if the packages have been officially been hosted in the repositories. To do so, use the syntax:

For example, to search for a nano package in the repositories, run the command:

Search Package in Alpine Linux

3. Get a Description of an Installed Package

To get a description of a package in the repositories, about the package pass the -v and -d flags as shown. The option -d is short for description whilst the -v option prints out verbose output.

Get Package Description in Alpine Linux

4. Install Packages in Alpine Linux

To install packages on Alpine Linux, use the syntax:

For example, to install the nano text editor, run the command:

Install Packages in Alpine Linux

Additionally, you can install multiple packages in a single command using the syntax:

$ apk add package1 package2

For example, the command below installs neofetch and vim editor at a go.

Читайте также:  Настройка linux через ssh

Install Multiple Packages in Alpine Linux

You can confirm if you installed neofetch by running the command:

This populates information about the operating system such as OS type, kernel, uptime, and underlying hardware such as CPU and memory.

Neofetch Show Linux Information

To confirm that vim editor is installed, simply run the vim command without any arguments and this will display information about vim.

Vim Editor Info

The -i option prompts for user interaction when installing packages. It causes apk to ask you whether to continue with the installation of the package or abort.

Install Package Confirmation

5. Check Installed Package in Alpine Linux

To probe if a certain package is already installed, use the syntax:

In this example, we are checking if Nano is installed.

In addition, you can check if multiple packages exist by listing them in the same line. For this example, we are verifying if both nano and vim are installed.

Check Package in Alpine Linux

To list additional information such as the version and size of the installed package simply run:

Check Package Information in Alpine Linux

6. List Files Associated with a Package

The -L flag allows you to list the files associated with a package, which includes the binary and configuration files and other files.

List Installed Package Files in Alpine Linux

7. List Dependencies of a Package

With the -R option, you can list the packages that the package depends on. In the following example, we are listing the dependencies that vim depends on.

List Package Dependencies in Alpine Linux

8. Find the Installed Size of a Package

To view the installed size of a package, use the -s option (lowercase) as follows:

Find Installed Package Size in Alpine Linux

9. List All Installed Packages

To list all installed packages on Alpine Linux, run the command:

Читайте также:  Все дистрибутивы linux iso

List All Installed Packages in Alpine Linux

10. Upgrade Alpine Linux

To upgrade all the packages on Alpine Linux to their latest versions, run the command

Upgrade Alpine Linux

To perform a dry run of the upgrade, pass the -s option. This merely runs a simulation and shows the versions that the packages will be upgraded to. It does not upgrade the packages.

Dry Run Alpine Linux Upgrade

11. Hold a Package Upgrade

There are instances where you may want to keep a few packages back from an upgrade. For instance to keep nano in its current version – nano-5.9-r0 – run the command.

Hold Package Upgrade in Alpine Linux

This will exempt the nano package from the upgrade as other packages are upgraded to their latest versions.

To later release the package for the upgrade, run:

12. Remove a Package in Alpine Linux

If you no longer require a package, you can remove it using the syntax:

For example, to delete vim, run the command.

Remove Packages in Alpine Linux

13. Getting Help with Apk Command

For additional apk commands, you can browse the apk help catalog as shown

Apk Command Help

In this guide, we focussed on Alpine apk command examples. We hope that this will help you as you get started installing and managing packages on Alpine Linux.

Источник

Оцените статью
Adblock
detector