Alpine linux包管理
本文最后更新于631 天前,其中的信息可能已经过时,如有错误请发送邮件到84581927@qq.com

配置源的方法:

localhost:cd /etc/apk

localhost:/etc/apk# vim repositories  //阿里云源
http://mirrors.aliyun.com/alpine/v3.15/main
http://mirrors.aliyun.com/alpine/v3.15/community
apk update  # 更新最新镜像源列表
apk search                 # 查找所有可用软件包
apk search -v              # 查找所用可用软件包及其描述内容
apk search -v ‘包名’        # 通过软件包名称查找软件包
apk search -v -d ‘docker’  # 通过描述文件查找特定的软件包
apk add openssh                       # 安装一个软件
apk add openssh  vim  bash nginx      # 安装多个软件
apk add --no-cache mysql-client       # 不使用本地镜像源缓存,相当于先执行update,再执行add
apk info           # 列出所有已安装的软件包
apk info -a zlib   # 显示完整的软件包信息
apk info --who-owns /usr/sbin/nginx # 显示指定文件属于的包
apk upgrade            # 升级所有软件
apk upgrade openssh    # 升级指定软件
apk upgrade openssh  vim  bash nginx # 升级多个软件
apk add --upgrade busybox  # 指定升级部分软件包
apk del openssh      # 删除一个软件
apk del nginx mysql  # 删除多个软件

Alpine Linux服务管理

rc-update    # 主要用于不同运行级增加或者删除服务。
rc-status    # 主要用于运行级的状态管理。
rc-service   # 主用于管理服务的状态
openrc       # 主要用于管理不同的运行级。

# 重启网络服务: rc-service networking restart
# 列出所有服务: rc-status -a

Alpine常用命令

# 安装vim命令 apk add vim  
(1/3) Installing xxd (8.2.3650-r0)
(2/3) Installing lua5.3-libs (5.3.6-r1)
(3/3) Installing vim (8.2.3650-r0)
Executing busybox-1.34.1-r3.trigger
OK: 885 MiB in 156 packages

apk add --no-cache openssh     # 不使用本地镜像源缓存,相当于先执行update,再执行add

localhost:~# apk del openssh   # 卸载软件包
WARNING: Ignoring https://mirrors.aliyun.com/alpine/: No such file or directory
(1/8) Purging openssh (8.8_p1-r1)
(2/8) Purging openssh-sftp-server (8.8_p1-r1)
(3/8) Purging openssh-server (8.8_p1-r1)
(4/8) Purging openssh-server-common (8.8_p1-r1)
(5/8) Purging openssh-client-default (8.8_p1-r1)
(6/8) Purging openssh-client-common (8.8_p1-r1)
(7/8) Purging openssh-keygen (8.8_p1-r1)
(8/8) Purging libedit (20210910.3.1-r0)
Executing busybox-1.34.1-r3.trigger
OK: 881 MiB in 150 packages

localhost:~# apk search -v 'gcc'  # 通过软件包名称查找软件包
WARNING: Ignoring https://mirrors.aliyun.com/alpine/: No such file or directory
gcc-zsh-completion-5.6.2-r0 - Zsh completions for gcc
gcc-8.3.0-r0 - The GNU Compiler Collection
gcc-objc-8.3.0-r0 - GNU Objective-C
gcc-gnat-8.3.0-r0 - Ada support for GCC
libgc++-7.6.4-r2 - A garbage collector for C and C++
gcc-doc-8.3.0-r0 - The GNU Compiler Collection (documentation)
libgcc-8.3.0-r0 - GNU C compiler runtime libraries

localhost:~# apk info gcc       # 列出安装已安装软件包的信息
WARNING: Ignoring https://mirrors.aliyun.com/alpine/: No such file or directory
gcc-8.3.0-r0 description:
The GNU Compiler Collection

gcc-8.3.0-r0 webpage:
http://gcc.gnu.org

gcc-8.3.0-r0 installed size:
72 MiB

localhost:~# apk upgrade gcc  # 升级指定的软件
fetch https://mirrors.aliyun.com/alpine/x86_64/APKINDEX.tar.gz
ERROR: https://mirrors.aliyun.com/alpine/: No such file or directory
WARNING: Ignoring https://mirrors.aliyun.com/alpine/: No such file or directory
OK: 881 MiB in 150 packages

localhost:~# rc-service apache2 restart  # 重启apache服务
 * Starting apache2 ...
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message

localhost:~# rc-update add apache2 boot  # 将apache服务设置开机自启
 * service apache2 added to runlevel boot

# 创建用户
localhost:~# addgroup -g 10001 -S admin  # 先指定一个GID组

# 指定一个UID的用户,指定shell,让其属于指定的用户组
localhost:~# adduser admin -u 20001 -D -S -s /bin/bash -G admin  

localhost:~# deluser admin  # 删除用户

Alpine常用软件安装

# 系统软件
apk add --no-cache vim openssh util-linux bash bash-doc  bash-completion curl net-tools

Apline网卡配置

vi /etc/network/interfaces  #打开配置文件
auto lo
iface lo inet loopback

auto eth0 
iface eth0 inet dhcp  #配置DHCP
auto lo   
iface lo inet loopback  #配置DHCP

auto eth0   #配置静态IP
iface eth0 inet static
address 10.1.3.200
netmask 255.255.255.0
gateway 10.1.3.3
dns1 114.114.114.114
dns2 8.8.8.8   #配置静态IP

双网卡配置默认路由

假如有多个网卡,在路由表中会出现多个名为default的默认路由,会导致我们期望的网络访问失败。可以通过命令查看所有路由配置:

ip route show

需要外网访问的网卡我们常设置为默认路由。这里先删除所有默认路由:

ip route del default

再添加默认路由,比如默认路由网关是10.0.0.2

ip route add default via 10.0.0.2
文末附加内容
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇