Alpine linux apk команды

Working with the Alpine Package Keeper ( apk )

apk is the Alpine Package Keeper — the distribution’s package manager. It is used to manage the packages (software and otherwise) of the system. It is the primary method for installing additional software, and is available in the apk-tools package.

Normal Usage

Repositories and Mirrors

apk fetches information about available packages, as well as the packages themselves from various mirrors, which contain various repositories. Sometimes, those terms are used interchangeably. Here is a summary of relevant definitions:

A website that hosts repositories.

A collection of snapshots of various repositories.

A category of packages, tied together by some attribute.

Currently, three repositories exist:

Officially supported packages that are reasonable to expect to be in a basic system. Support cycles are 2 years long.

Packages from testing that have been tested. Support cycles are 6 months long.

New, broken, or outdated packages that need testing. No support for this repository is implied. It is not present in release snapshots.

Releases are versioned using a versioning scheme somewhat reminiscent of semantic versioning. However, one special release exists called «edge» — this is a «rolling» release. «Edge» is not officially supported — if you choose to run it, you are on your own. «Edge» is also the only release that contains the «testing» repository.

Repositories are configurable in the /etc/apk/repositories file. Each line corresponds to a repository. The format is as follows:

123
In this case, http:// is the protocol, dl-cdn.alpinelinux.org/alpine is the path, edge is the release and main is the repository.
In this case, @testing is the tag. More on this in Installing Packages.
In this case, the repository is a personal one, available on the filesystem of the machine.
This example uses the http:// protocol. ftp:// and https:// protocols are also supported.
This file should already have been been partially populated when you installed alpine.

Searching for Packages

In order to know what package to install, one must be able to find packages. Alpine has a specialized web interface dedicated to looking through various available packages. However, apk also provides a built-in searching mechanism. You invoke it by using the apk search subcommand. You can potentially search for anything in the package index, which, among other things, includes provided binaries and libraries). Further, globbing is supported. As such, here are a few examples of searching:

1234
You can search for partial library names.
You can also search for binary names.
You can exclude partial matches using -e .
You can specify that what you’re searching for is a library using the so: prefix (or the cmd: prefix for commands, and pc: prefix for pkg-config files) — it will work with -e (in fact, the prefix is required for this use-case if -e is used).

Installing Packages

Once you know what package you want to install, you must know how to do that. Apk’s add command is more strict than the search command — wildcards are not available, for instance. However, the cmd: , so: and pc: prefixes are still available.

While the so: prefix is still available for apk add , it is recommended that you avoid using it. This is because the provided library SONAME version can increase (for example, libmpack.so.0 may get updated, and become libmpack.so.1 ), in which case this will not update libmpack next time you run apk upgrade , and will instead fail. This is because so:libmpack.so.0 directly refers to that specific version of the library, and is typically used by packages, rather than users directly.

While the cmd: and pc: prefix is still available for apk add , you should know that it does not guarantee getting you the exact package you are looking for. Multiple packages can contain the same executable command or pkg-config definition, but only one will be selected — not necessarily the one you want.

Here are a few examples of adding packages:

12345
You must specify the exact package name.
You may add multiple packages at once.
This should be equivalent to the previous example, but specifies the command you are interested in.
It is possible, but discouraged, to specify specific desired libraries.
Finally, it is possible to specify pkg-config dependencies.
If apk add finds multiple matching packages (for example multiple cmd: matches), it will select the one with the highest version number.

Upgrading Packages

Updating the system using apk is very simple. One need only run apk upgrade . Technically, this is two steps: apk update , followed by apk upgrade proper. The first step will download an updated package index from the repositories, while the second step will update all packages in World, as well as their dependencies.

apk will avoid overwriting files you may have changed. These will usually be in the /etc directory. Whenever apk wants to install a file, but realizes a potentially edited one is already present, it will write its file to that filename with .apk-new appended. You may handle these by hand, but a utility called update-conf exists. Simply invoking it normally with present you with the difference between the two files, and offer various choices for dealing with the conflicts.

Читайте также:  Exporting private key windows
apk update is only ran once your cache is invalidated, which by default happens every 4 hours.

Querying Package Information

In some cases, it may be useful to inspect packages or files to see various details. For this use, the info subcommand exists. It may be used on any package, installed or not, though the information on the latter will be more limited. It may also be used with specific flags on files. By default, info will list the package description, webpage and installed size. For more details (such as a list of flags the subcommand supports), you can use the apk info -h output’s «Info options» section or see the manual page.

Removing Packages

Often, it is desirable to remove a package. This can be done using the del subcommand, with a base syntax that is identical to the add subcommand.

If you added a package using the cmd: , so: or pc: virtual, you must specify the same virtual to remove them. NOTE: Removing a package will automatically remove all of its dependencies that are otherwise not used.

The del subcommand also supports the -r flag, which will remove all packages that depend on the package being removed as well, rather than error out due to the package being needed.

Cleanup

Many package managers have specific features to «clean up». A common one is apt , which has an autoremove subcommand. Apk does this by default when removing packages.

It is also possible to clear out the apk cache, assuming it is enabled. You can do this using apk cache clean .

Advanced Usage

World

The packages you want to have explicitly installed are listed in the «world file», available in /etc/apk/world . It is safe to edit it by hand. If you’ve edited it by hand, you may run apk add with no arguments to bring the package selection to a consistent state.

Virtuals like cmd: , so: and pc: will appear as such in your world file — this is why using so: is discouraged — the soname might get bumped!

Virtuals

While cmd: , so: and pc: packages are automatically created virtuals, you can create your own as well. These allow for quick removal of purpose-specific packages. See the following examples for details:

123
This will add the packages «a», «b» and «c» as the dependencies of a virtual package «abc».
This will remove «abc» and all of its components («a», «b» and «c»), unless they are required elsewhere.
This is equivalent to the first example.

Swapping Repositories

When alpine has a new release, the repository path will change. Assuming you are going forward in time (e.g from 3.12 to 3.13 ), you can simply edit /etc/apk/repositories and run apk upgrade —available .

Downgrading packages/versions is currently not supported. While it is technically possible, you are on your own.

This is why it is not recommended to use edge repositories, unless you know what you’re doing, or are tagging all those packages.

Copyright © 2019 Alpine Linux Development Team. All rights reserved.

Источник

Alpine newbie apk packages

Contents

As explained in Alpine Linux:Overview, the system will always be minimalist. If you expected behavior like other fancy windows-type linux, that’s not the case here!

Packages provide the basic components of an operating system, along with shared libraries, applications, services, and documentation.

This document will guide new users through basic needs about:

  1. installing packages (software to install) and ..
  2. minimal setups (configurations to the system).

If more information is needed, see the Alpine package management behavior section in this document page.

New users: hostname and network wired connection

After installing Alpine Linux, you might need to configure your system to properly work for your use case, since Alpine’s main utilities are busybox -based.

Setting the hostname

A hostname is a unique name created to identify a machine on a network, configured in /etc/hostname. To change the computer’s hostname edit the /etc/hostname file or execute the following command (make sure to replace myhostname with your desired hostname):

You should add the hostname to your hosts file ( /etc/hosts ):

Network configuration

There are three types of internet connections: wired (Ethernet), wireless (WiFi) and PPTP (modems). This section will focus only on wired connections, for wireless configuration see the Connecting to a wireless access point article.

This section will help you update and configure your network interfaces. Connect your network cable, then at the console, run the DNS and interfaces configuration scripts.

Default root configuration

The root user is the god of the Linux Alpine system and must not be used as normal user for common tasks. For non-root users, the last section of this document will show you what you need to know.

When Alpine Linux is first installed, by default the user root has no password set. So the first step after booting into a fresh Alpine install is set a password for the user root. If during install, setup-alpine was run to change the root password, it will already be set and can be changed with the setup steps described here. More info is in the Setting users wiki page.

Читайте также:  Philips 242v8a драйвер windows 10

Change «secret_new_root_password» to your password.

New users: installing needed packages

Packages and programs on alpine are described on Alpine_newbie: Packages overall info. The /community repository of each Alpine release contains community supported packages that were accepted from the /testing repository. Only the /main repository of each released version of Alpine is supported for some Main Alpine Developers and Man Powers.

enable repository packages

Repositories are needed to retrieve packages as described on Alpine_newbie: Packages overall info, run:

This will enable the /community and /main repository branches on your instance of Alpine.

install basic tools

As explained in Alpine Linux:Overview, Alpine will always be minimalist. If you expected a behavior like other Linux distributions, the similarity to them will be minimal at best. Run:

manpages in alpine

In the previous section, we noted that some packages have a «xxx-doc» file. As explained in Alpine Linux:Overview, the system always will be minimalistic. If you want the manpages for a software package, install the «xxx-doc» package.

Take into consideration that in some earlier versions of alpine, some packages might not have a doc package available.

coreutils libc and utmps in alpine

Some programs like wall(1) depend on a libc feature named «utmp», that cannot be implemented in libc securely. For this reason, musl (the libc that Alpine uses) does not implement utmp. Instead, it provides stubs that do nothing.

That is why programs that use utmp — such as wall, who or w — output nothing but still exit successfully. This is expected, a feature, and cannot be fixed easily.

Some have a nice solution. For example, a utmps login monitor is only in the «edge» repositories. So let’s do that to learn how. We’ll activate the edge repository, temporarily install the software, then deactivate it later:

fonts and fonts configuration

Default internal fb fonts (tty console) or xorg fonts (desktops) are suitable for a default installation. If you can’t see your language, you need to install the font that has glyphs (little pictures) created for it. font-misc-misc is installed with X server, so fonts for most languages (Japanese, Korean, Latin, Cyrillic) are already covered. Exceptions are Arabic, Persian, Thai, Tamil, etc. according to the Wikipedia Page on languages for article translation. For complete info about fonts in Alpine see Fonts configurations and settings in Alpine. That section should cover the needs of most users:

These selections will cover most languages and are a good fit for most setups:

These selections add special support for cyrillic languages like Russian and Serbian, etc.:

These selections cover special Asiatic languages like Japanese, etc.:

The following will add some partially supported Chinese fonts:

These selection will cover, in general Arabic, Thai, Ethiopic, Hebrew, Romanian, Persian, Korean Hangul, Greek, Persian, Russian/Slavic Cyrillic, Macedonian/Serbian, Armenian, Georgian, Lao, Devanagari, Urdu (Hindustani as in Northern India and Pakistan), Cherokee, Thaana languages support for desktop setups:

The system font directory is located at /usr/share/fonts . User font location is at

/.font for security reasons. Configurations are by X server, using the

Per-user Configuration is made in

/.fonts.conf but it’s hard to configure. An easier method is to use the

The following will set up for all users, a minimal resource usage for fonts. No antialiasing. No hint, etc. :

apk packages for sound base

Currently, alsa is the basic package for Alpine Linux sound. For desktop systems there’s gstreamer, phonon and pulseaudio but that will be merged into the desktop wiki pages:

Alsa service is not started on install, you need to start it and to add it to rc.

New users: management of users and logins

When Alpine Linux is first installed, by default, the user root has no password. So the first step after booting into a feash Alpine installation is to set the root password. If during install, setup-alpine was run to change root password, it will already be assigned and may be changed with the setup steps described here. More info is on the Setting users wiki page.

Users creation and defaults

Only root can manage users. Creating an account enables that account to have it’s own $HOME directory and enables you to limit access to the configuration of the operating system for security reasons. The following commands will first set up the root environment login then assign a new password:

By default, SSH security prevents remote management directly with the root account. You’ll need to setup a remote connection account and use the «su» command once you’re connected.

An example of one method is to have a user named «remote» and a non-privileged user named «general.» We’ll set up a hardened limited environment and create those two users:

Note: those users are created with minimal settings. Replace «secret_new_remote_user_password» and «secret_new_general_user_password» with secure passwords.
The two passwords should NOT be the same!

Users management and system access

This user will not have enough privileges for general operating purposes. Alpine comes with high security so the administrator (the root account owner) must manage that user.
Take care, for a server, there’s no similar procedure!

Читайте также:  Windows вывод системных переменных

User management can be done with the default busybox, but there’s a few packages that make life easier for an administrator. We’ll use the libuser package from the testing repository:

Now we can change some defaults and add the user to the desired groups to access devices or perform connections. Here is a list of the recommended groups the user should be a member of:

  • disk:x:6:root,adm Only if need usage vith virtual machines and access to other partitions over new disks for
  • lp:x:7:lp IF will need to use printing services and printers management
  • floppy:x:11:root Backguard compatible group, use only if need access to external special devices
  • audio:x:18: Need for audio listening and management of sound volumes as normal user
  • cdrom:x:19: For access to disck writers and mounting DVD, BR or CD rom disk as normal user
  • dialout:x:20:root Need for dial private connections and use of modems as normal users
  • tape:x:26:root Need have into this if plan to use special devices for backup.. rarelly in no servers
  • video:x:27:root For usage of cameras, mor thant one GPU special features, as normal user
  • netdev:x:28: For network connections management as normal user
  • kvm:x:34:kvm Only if as normal user will manage graphically virtual machines.. rarelly on no servers
  • games:x:35: Need if you want to play games also specially need if will share score between users
  • cdrw:x:80: To write RW-DVD, RW-BR or RW-CD disk on a disk writing device
  • apache:x:81: Need if you will perfom development as normal user and want to publish locally on web server
  • usb:x:85: Need to access to special usb devices, deprecated group
  • users:x:100:games If you plan to used common files for all users, mandatory as desktop usage

Now that we have libuser, we can change the default shell:

  • If you want to change the current user’s shell, log in as that user, then inside a terminal session, execute::
  • If you want to change a different user’s shell, run as administrator or as root:

where «general» is a valid user name.

Continue to Desktop

Before you continue, you must perform the steps in the section described: New users: common needed package to install!

Previous required What’s next to read
Alpine newbie install manual Alpine newbie desktops

Alpine package management behavior

This section is not for new users. Please go to Alpine newbie desktops or Alpine Newbies: Xorg and Openbox if you only want to set up your system.

Programs, the software installed on Alpine, come from two places. A repository with the following structure: http:// /alpine/ /
(a URL that can be invoked with apk listed in the /etc/apk/repositories file) and original upstream sources (those compiled in the traditonal Unix-like way).

As a new user, you can read the Alpine newbie apk packages page, but please read the rest of this section too:

Alpine Software Packages

Alpine software repositories have main packages and user contributed packages. Each Alpine release has two repository braches. The /community repository of each Alpine release contains community supported packages that were accepted from the /testing repository. Only /main repository of each version of Alpine release is supported for some Main Alpine Developers and Man Powers.

  • Main: Main packages are the Alpine software that has direct support and updates from the Alpine core and main team. They also have official special documentation, are always available for all releases and will have substitutions if some are not continued from upstream. Commonly, those packages are selected due to their responsibility and stability with respect to upstream availability. When those in testing perform well or are mature, they go to the main branch.
  • User Contributed: User-contributed package repositories are those made by users in concert with the official developers and integrated into the Alpine packages. They are user supported. That support could end if the user ends support with respect to Alpine work. For example, could not include substitution in next release due to lack of support by the upstream author. They are in testing and when accepted, go to the community branch.
  • Testing: New packages come into testing repositories of the edge Alpine version and are those made by any contributor or man power on Alpine. The edge contains unstable current development content. This branch has no release linked or related to Alpine. They are in testing and when accepted, go to the community branch.
Alpine APK user resources

Alpine new users have two resources for package management. The https://pkgs.alpinelinux.org/packages page, a search-friendly way, and the Alpine newbie apk packages page that describes how to use the apk-tool .

Alpine APK quick infrastructure

Software packages for Alpine Linux are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. They have the extension .apk , and are often called «a-packs».

The apk command located at /sbin/apk manages package retreval. The apk configuration files are stored in /etc/apk/ . «a-packs» downloaded from repositories are stored in /etc/apk/cache before being unpacked and installed into the system.

Источник

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