apk 包管理命令
基本句法
apk [options] command
apk [options] command pkgName
apk [options] command pkgName1 pkgName2
升级包列表, enter:
# apk update
搜索包
# apk search pkgName
例如:
# apk search htop
输出:
htop-doc-2.0.2-r0
htop-2.0.2-r0
搜索并显示描述:
# apk search -v -d ‘htop‘
htop-doc-2.0.2-r0 - An interactive process viewer (documentation)
htop-2.0.2-r0 - An interactive process viewer
显示结果:
htop-doc-2.0.2-r0 - An interactive process viewer (documentation)
htop-2.0.2-r0 - An interactive process viewer
列出所有包:
# apk search -v
用通配符搜索包:
# apk search -v ‘php7*‘
用包名安装包:
句法:
# apk add pkgName
apk add pkgName1 pkgName2
# apk add htop
输出结果:
(1/1) Installing htop (2.0.2-r0)
Executing busybox-1.25.1-r0.trigger
OK: 39 MiB in 28 packages
安装Apache2以及PHP7和模块:
apk add apache2 php7-apache2 php7-gd php7-mysqli
安装本地.apk 文件包:
# apk add --allow-untrusted /path/to/foo.apk
用名字移除包句法:
# apk del pkgName
# apk del pkgName1 pkgName2
删除htop包:
# apk del htop
(1/1) Purging htop (2.0.2-r0)
Executing busybox-1.25.1-r0.trigger
OK: 39 MiB in 27 packages
升级alpine linux:
# apk update && apk upgrade
可以在?/ .bashrc中创建一个bash shell别名:
# echo "alias update=‘apk update && apk upgrade‘" >> /.bashrc
# update
升级选中包:
# apk update
# apk add -u htop
列出安装包样例:
# apk info
# apk info -vv | grep ‘foo‘
# apk info -vv | sort
找出文件属于那个包:
# apk info --who-owns /etc/passwd
/etc/passwd is owned by alpine-baselayout-3.0.4-r0
# apk info --who-owns /sbin/apk
/sbin/apk is owned by apk-tools-2.6.8-r2
列出包的内容:
# apk -L info pkgName
# apk -L info htop
htop-2.0.2-r0 contains:
usr/bin/htop
usr/share/applications/htop.desktop
usr/share/pixmaps/htop.png
检测包安装:
# apk -e info pkgName
#############################################
### find out if atop PACKAGE is installed ###
#############################################
# apk -e info atop
列出包的依赖:
# apk -R info atop
atop-2.2_p3-r0 depends on:
so:libc.musl-x86_64.so.1
so:libncursesw.so.6
so:libz.so.1
列出所有包的依赖:
# apk info -r pkgName
# apk info -r bash
bash-completion-2.4-r0
显示包大小:
# apk info -s pkgName
# apk info -s atop
atop-2.2_p3-r0 installed size:
520192
打印包的描述:
# apk info -d pkgName
# apk info -d bash
bash-4.3.46-r5 description:
The GNU Bourne Again shell
打印包的信息:
# apk info -a pkgName
# apk info -a bash
apk info -a bash
bash-4.3.46-r5 description:
The GNU Bourne Again shell
bash-4.3.46-r5 webpage:
http://www.gnu.org/software/bash/bash.html
bash-4.3.46-r5 installed size:
700416
bash-4.3.46-r5 depends on:
busybox
so:libc.musl-x86_64.so.1
so:libncursesw.so.6
so:libreadline.so.6
bash-4.3.46-r5 provides:
bash-4.3.46-r5 is required by:
bash-completion-2.4-r0
bash-4.3.46-r5 contains:
bin/bashbug
bin/bash
bash-4.3.46-r5 triggers:
bash-4.3.46-r5 has auto-install rule:
bash-4.3.46-r5 affects auto-installation of:
bash-doc-4.3.46-r5
bash-4.3.46-r5 replaces:
bash-4.3.46-r5 license:
GPL3+
统计安装仓库:
# apk stats
installed:
packages: 28
dirs: 163
files: 7097
bytes: 41205760
triggers: 1
available:
names: 11710
packages: 7961
atoms:
num: 5934
bash-4.3#
bash-4.3# apk stats
installed:
packages: 28
dirs: 163
files: 7097
bytes: 41205760
triggers: 1
available:
names: 11710
packages: 7961
atoms:
num: 5934
apk 命令选项和样例
Command Usage xample
apk update Update the package list apk update
apk upgrade Upgrade the system apk update
apt ugrade
apk add pkg Add a package apk add apache
apk del pkg Delete a package apk del nginx
apk search -v Search for packages apk search -v
apk search -v -d ‘nginx*’
apk search -v ‘apache*’
apk info List all installed pacakges apk info
apk fix Repair package or upgrade it without modifying main
dependencies apk fix
apk policy pkg Show repository policy for packages apk policy bash
apk stats Show statistics about repositories and installations apk stats
原文地址:https://www.cnblogs.com/alpine-enterprise/p/10898312.html