- apk –help
- apk update
- apk upgrade #升级软件
- apk add openssh openntp vim
- apk add –no-cache mysql-client
- apk add docker –update-cache –repository http://mirrors.ustc.edu.cn/alpine/v3.8/main/ –allow-untrusted
- apk add asterisk=1.6.0.21-r0
- apk add ‘asterisk<1.6.1’
- apk add ‘asterisk>1.6.1’
- apk del openssh openntp vim
- apk add –upgrade busybox #指定升级部分软件包
- apk search #查找所以可用软件包
- apk search -v #查找所以可用软件包及其描述内容
- apk search -v ‘acf*’ #通过软件包名称查找软件包
- apk search -v -d ‘docker’ #通过描述文件查找特定的软件包
- apk info #列出所有已安装的软件包
- apk info -a zlib #显示完整的软件包信息
- apk info –who-owns /sbin/lbu #显示指定文件属于的包
-
官方镜像列表:http://dl-cdn.alpinelinux.org/alpine/MIRRORS.txt
MIRRORS.txt中是当前Alpine官方提供的镜像源(Alpine安装的时候系统自动选择最佳镜像源)
-
国内镜像源
清华TUNA镜像源:https://mirror.tuna.tsinghua.edu.cn/alpine/
中科大镜像源:http://mirrors.ustc.edu.cn/alpine/
阿里云镜像源:http://mirrors.aliyun.com/alpine/
-
如何配置软件源
以中科大源为例:在/etc/apk/repositories文件中加入对应源地址就行了,一行一个地址。
1
2
3
4
5
6
|
# /media/cdrom/apks`
http://mirrors.ustc.edu.cn/alpine/v3.5/main
http://mirrors.ustc.edu.cn/alpine/v3.5/community
|
-
rc-update
rc-update主要用于不同运行级增加或者删除服务。
rc-update语法格式:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
Usage: rc-update [options] add <service> [<runlevel>...]
or: rc-update [options] del <service> [<runlevel>...]
or: rc-update [options] [show [<runlevel>...]]
Options: [ asuChqVv ]
-a, --all Process all runlevels
-s, --stack Stack a runlevel instead of a service
-u, --update Force an update of the dependency tree
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
|
使用实例:
1
2
3
|
$ rc-update add docker boot #增加一个服务
$ rc-update del docker boot #删除一个服务
|
-
rc-status
rc-status 主要用于运行级的状态管理。
rc-status语法格式:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
Usage: rc-status [options] <runlevel>...
or: rc-status [options] [-a | -c | -l | -r | -s | -u]
Options: [ aclrsuChqVv ]
-a, --all Show services from all run levels
-c, --crashed Show crashed services
-l, --list Show list of run levels
-r, --runlevel Show the name of the current runlevel
-s, --servicelist Show service list
-u, --unused Show services not assigned to any runlevel
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
|
使用实例:
$ rc-status #检查默认运行级别的状态
$ rc-status -a #检查所有运行级别的状态
-
rc-service
rc-service主用于管理服务的状态
rc-service语法格式:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
Usage: rc-service [options] [-i] <service> <cmd>...
or: rc-service [options] -e <service>
or: rc-service [options] -l
or: rc-service [options] -r <service>
Options: [ e:ilr:INChqVv ]
-e, --exists <arg> tests if the service exists or not
-i, --ifexists if the service exists then run the command
-I, --ifinactive if the service is inactive then run the command
-N, --ifnotstarted if the service is not started then run the command
-l, --list list all available services
-r, --resolve <arg> resolve the service name to an init script
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
|
使用实例:
$ rc-service sshd start #启动一个服务。
$ rc-service sshd stop #停止一个服务。
$ rc-service sshd restart #重启一个服务。
-
openrc
openrc主要用于管理不同的运行级。
openrc语法格式:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
Usage: openrc [options] [<runlevel>]
Options: [ a:no:s:SChqVv ]
-n, --no-stop do not stop any services
-o, --override <arg> override the next runlevel to change into when leaving single user or boot runlevels
-s, --service <arg> runs the service specified with the rest of the arguments
-S, --sys output the RC system type, if any
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
|
Alpine Linux可用的运行级
-
default
-
sysinit
-
boot
-
single
-
reboot
-
shutdown
使用实例
$ openrc single #更改为single运行级
$ reboot #重启系统,类似于shutdown -r now。
$ halt #关机,类似于shutdown -h now。
$ poweroff #关机
1
2
3
4
|
apk add nginx
nginx -v
rc-update add nginx
/etc/init.d/nginx start
|