Alpine Linux常用命令

目录


回到顶部

一:Alpine Linux开启SSH远程登陆

1.简介:

最重要的一个服务了,远程登陆需要用它,文件传输需要用它,必备功能。不管你是在实体机上跑,虚拟机上跑,docker里面跑,这个都是必须的。

2.配置

配置文件位置:/etc/ssh/sshd_config

配置文件选项:#PermitRootLogin prohibit-password

修改为:PermitRootLogin yes

3.配置命令

看不懂上面的,直接用下面这句。

sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config

4.重启服务

改了配置不会直接生效,需要重启服务器或者服务。

重启服务器:reboot

重启服务:rc-service sshd restart

回到顶部

二:Alpine Linux源管理

1.简介

源这个概念在linux早就存在了,其实就是类似于软件市场的存在,apple在iphone上发扬光大了,并且自己管理安全的软件,使得iphone上软件兼容性等等问题得到改善,用户体验比较好,android基于linux核心开发,也有了软件市场,最著名的就是google市场,因为被墙,所以国内各个大软件厂商也都有了自己的市场。

每个市场(源)都有自己的服务器,linux默认的都是外国的服务器,我们访问比较慢,所以就有了镜像服务器放在国内,让我们访问快一些。管理源,就是增加镜像服务器。

而且,linux因为是大众维护更新代码,所以还区分了稳定版,测试版……各种版本的市场,这些都需要进行源管理。

2.国内源简介:

这几个都有alpine的源

清华大学:https://mirror.tuna.tsinghua.edu.cn/alpine/

阿里云:https://mirrors.aliyun.com/alpine/

中科大:http://mirrors.ustc.edu.cn/alpine/

还有一些没有alpine的

网易:http://mirrors.163.com/

3.配置:

直接抄中科大的帮助http://mirrors.ustc.edu.cn/help/alpine.html

一般情况下,将 /etc/apk/repositories 文件中 Alpine 默认的源地址 http://dl-cdn.alpinelinux.org/ 替换为 http://mirrors.ustc.edu.cn/ 即可。

可以使用如下命令:

sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

也可以直接编辑 /etc/apk/repositories 文件。以下是 v3.5 版本的参考配置:

  1.  
    https://mirrors.ustc.edu.cn/alpine/v3.5/main
  2.  
    https://mirrors.ustc.edu.cn/alpine/v3.5/community

也可以使用 latest-stable 指向最新的稳定版本:

  1.  
    https://mirrors.ustc.edu.cn/alpine/latest-stable/main
  2.  
    https://mirrors.ustc.edu.cn/alpine/latest-stable/community

更改完 /etc/apk/repositories 文件后请运行 apk update 更新索引以生效。

3.我的配置:

打开/etc/apk/repositories后发现,中科大的sed命令无效,因为默认的源不是dl-cdn

自己改一下吧

原:

  1.  
    #/media/cdrom/apks
  2.  
    http://ftp.halifax.rwth-aachen.de/alpine/v3.7/main
  3.  
    #http://ftp.halifax.rwth-aachen.de/alpine/v3.7/community
  4.  
    #http://ftp.halifax.rwth-aachen.de/alpine/edge/main
  5.  
    #http://ftp.halifax.rwth-aachen.de/alpine/edge/community
  6.  
    #http://ftp.halifax.rwth-aachen.de/alpine/edge/testing
  7.  
     
  8.  
    http://mirror.yandex.ru/mirrors/alpine/v3.7/main
  9.  
    #http://mirror.yandex.ru/mirrors/alpine/v3.7/community
  10.  
    #http://mirror.yandex.ru/mirrors/alpine/edge/main
  11.  
    #http://mirror.yandex.ru/mirrors/alpine/edge/community
  12.  
    #http://mirror.yandex.ru/mirrors/alpine/edge/testing

改为:

  1.  
    http://mirrors.ustc.edu.cn/alpine/v3.7/main
  2.  
    http://mirrors.ustc.edu.cn/alpine/v3.7/community
  3.  
    http://mirrors.ustc.edu.cn/alpine/edge/main
  4.  
    http://mirrors.ustc.edu.cn/alpine/edge/community
  5.  
    http://mirrors.ustc.edu.cn/alpine/edge/testing

也可以复制下面这组命令,一次执行

  1.  
    echo http://mirrors.ustc.edu.cn/alpine/v3.7/main >/etc/apk/repositories
  2.  
    echo http://mirrors.ustc.edu.cn/alpine/v3.7/community >>/etc/apk/repositories
  3.  
    echo http://mirrors.ustc.edu.cn/alpine/edge/main >>/etc/apk/repositories
  4.  
    echo http://mirrors.ustc.edu.cn/alpine/edge/community >>/etc/apk/repositories
  5.  
    echo http://mirrors.ustc.edu.cn/alpine/edge/testing >>/etc/apk/repositories

或者

  1.  
    echo 'http://mirrors.ustc.edu.cn/alpine/v3.7/main
  2.  
    http://mirrors.ustc.edu.cn/alpine/v3.7/community
  3.  
    http://mirrors.ustc.edu.cn/alpine/edge/main
  4.  
    http://mirrors.ustc.edu.cn/alpine/edge/community
  5.  
    http://mirrors.ustc.edu.cn/alpine/edge/testing' >/etc/apk/repositories

回到顶部

三:Alpine Linux 包管理

1.简介

Alpine使用apk进行包管理,下面介绍常用命令

2.apk update

$ apk update #更新最新镜像源列表

3.apk search

$ apk search #查找所以可用软件包
$ apk search -v #查找所以可用软件包及其描述内容
$ apk search -v 'acf*' #通过软件包名称查找软件包
$ apk search -v -d 'docker' #通过描述文件查找特定的软件包

4.apk add

$ apk add openssh #安装一个软件
$ apk add openssh openntp vim   #安装多个软件
$ apk add --no-cache mysql-client  #不使用本地镜像源缓存,相当于先执行update,再执行add

5.apk info

$ apk info #列出所有已安装的软件包
$ apk info -a zlib #显示完整的软件包信息
$ apk info --who-owns /sbin/lbu #显示指定文件属于的包

6.apk upgrade

$ apk upgrade #升级所有软件
$ apk upgrade openssh #升级指定软件
$ apk upgrade openssh openntp vim   #升级多个软件
$ apk add --upgrade busybox #指定升级部分软件包

7.apk del

$ apk del openssh  #删除一个软件

回到顶部

四:Alpine Linux服务管理

1.简介

alpine没有使用fedora的systemctl来进行服务管理,使用的是RC系列命令

2.rc-update

rc-update主要用于不同运行级增加或者删除服务。

  1.  
    alpine:~# rc-update --help
  2.  
    Usage: rc-update [options] add <service> [<runlevel>...]
  3.  
    or: rc-update [options] del <service> [<runlevel>...]
  4.  
    or: rc-update [options] [show [<runlevel>...]]
  5.  
     
  6.  
    Options: [ asuChqVv ]
  7.  
    -a, --all Process all runlevels
  8.  
    -s, --stack Stack a runlevel instead of a service
  9.  
    -u, --update Force an update of the dependency tree
  10.  
    -h, --help Display this help output
  11.  
    -C, --nocolor Disable color output
  12.  
    -V, --version Display software version
  13.  
    -v, --verbose Run verbosely
  14.  
    -q, --quiet Run quietly (repeat to suppress errors)

3.rc-status

rc-status 主要用于运行级的状态管理。

  1.  
    alpine:~# rc-status --help
  2.  
    Usage: rc-status [options] <runlevel>...
  3.  
    or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]
  4.  
     
  5.  
    Options: [ aclmrsuChqVv ]
  6.  
    -a, --all Show services from all run levels
  7.  
    -c, --crashed Show crashed services
  8.  
    -l, --list Show list of run levels
  9.  
    -m, --manual Show manually started services
  10.  
    -r, --runlevel Show the name of the current runlevel
  11.  
    -s, --servicelist Show service list
  12.  
    -u, --unused Show services not assigned to any runlevel
  13.  
    -h, --help Display this help output
  14.  
    -C, --nocolor Disable color output
  15.  
    -V, --version Display software version
  16.  
    -v, --verbose Run verbosely
  17.  
    -q, --quiet Run quietly (repeat to suppress errors)

4.rc-service

rc-service主用于管理服务的状态

  1.  
    alpine:~# rc-service --help
  2.  
    Usage: rc-service [options] [-i] <service> <cmd>...
  3.  
    or: rc-service [options] -e <service>
  4.  
    or: rc-service [options] -l
  5.  
    or: rc-service [options] -r <service>
  6.  
     
  7.  
    Options: [ ce:ilr:INChqVv ]
  8.  
    -e, --exists <arg> tests if the service exists or not
  9.  
    -c, --ifcrashed if the service is crashed then run the command
  10.  
    -i, --ifexists if the service exists then run the command
  11.  
    -I, --ifinactive if the service is inactive then run the command
  12.  
    -N, --ifnotstarted if the service is not started then run the command
  13.  
    -l, --list list all available services
  14.  
    -r, --resolve <arg> resolve the service name to an init script
  15.  
    -h, --help Display this help output
  16.  
    -C, --nocolor Disable color output
  17.  
    -V, --version Display software version
  18.  
    -v, --verbose Run verbosely
  19.  
    -q, --quiet Run quietly (repeat to suppress errors)

5.openrc

openrc主要用于管理不同的运行级。

  1.  
    alpine:~# openrc --help
  2.  
    Usage: openrc [options] [<runlevel>]
  3.  
     
  4.  
    Options: [ a:no:s:SChqVv ]
  5.  
    -n, --no-stop do not stop any services
  6.  
    -o, --override <arg> override the next runlevel to change into
  7.  
    when leaving single user or boot runlevels
  8.  
    -s, --service <arg> runs the service specified with the rest
  9.  
    of the arguments
  10.  
    -S, --sys output the RC system type, if any
  11.  
    -h, --help Display this help output
  12.  
    -C, --nocolor Disable color output
  13.  
    -V, --version Display software version
  14.  
    -v, --verbose Run verbosely
  15.  
    -q, --quiet Run quietly (repeat to suppress errors)

6.我常用的RC系列命令

1.增加服务到系统启动时运行,下例为docker

rc-update add docker boot

2.重启网络服务

rc-service networking restart

3.列出所有服务

rc-status -a

转载Alpine Linux常用命令的更多相关文章

  1. 【转载】Linux常用命令

    Linux常用命令大全(非常全!!!) 转载出处:https://www.cnblogs.com/yjd_hycf_space/p/7730690.html 系统信息 arch 显示机器的处理器架构( ...

  2. 【转载】 Linux常用命令: zip、unzip 压缩和解压缩命令

    Linux常用命令: zip.unzip 压缩和解压缩命令   Linux常用命令: zip.unzip 压缩和解压缩命令 zip的用法 基本用法是: zip [参数] [打包后的文件名] [打包的目 ...

  3. Alpine Linux常用命令

    一:Alpine Linux开启SSH远程登陆 1.简介: 最重要的一个服务了,远程登陆需要用它,文件传输需要用它,必备功能.不管你是在实体机上跑,虚拟机上跑,docker里面跑,这个都是必须的. 2 ...

  4. Alpine Linux 常用命令

    一:Alpine Linux开启SSH远程登陆 1.简介: 最重要的一个服务了,远程登陆需要用它,文件传输需要用它,必备功能.不管你是在实体机上跑,虚拟机上跑,docker里面跑,这个都是必须的. 2 ...

  5. 【转载】Linux常用命令列表

    原文地址:http://www.cnblogs.com/Javame/p/3968343.html 1 目录与文件操作 1.1 ls(初级) 使用权限:所有人 功能 : 显示指定工作目录下之内容(列出 ...

  6. (转载)linux 常用命令

    出处:http://www.cnblogs.com/vamei $ 命令行提示符 粗体表示命令 斜体表示参数 filename, file1, file2 都是文件名.有时文件名有后缀,比如file. ...

  7. linux 常用命令 和 nginx(反响代理、负载均衡)安装和配置

    (1)linux常用命令 [1]在光标前输入内容:i [2]删除输入方式下所输入的文本:Ctrl+u  [3]文件保存退出:wq [4]文件不保存退出:q [5]文件强制退出:q! [6]常规删除文件 ...

  8. linux常用命令三

    linux常用命令三 系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 ...

  9. linux常用命令二

    linux常用命令一 常用指令 ls        显示文件或目录 -l           列出文件详细信息l(list) -a          列出当前目录下所有文件及目录,包括隐藏的a(all ...

随机推荐

  1. linux内存 free命令 buffer cache作用

    free命令用于查看linux内存使用情况 #free shared:用于进程之间相互共享数据. Used:已使用内存. total:内存总量. free:未使用的内存. available:开启一个 ...

  2. TPS和QPS 并发量区别;日活 访问量 活跃度

    一.系统承载吞度量 系统的吞度量(承压能力)与request对CPU的消耗.外部接口.IO等等紧密关联.单个reqeust 对CPU消耗越高,外部系统接口.IO影响速度越慢,系统吞吐能力越低,反之越高 ...

  3. 《尚学堂_史上最易懂的设计模式视频》--章节5 动态代理-JDK6自带的编译器

    所有的设计模式中最难的一个 ==组合和聚合是有很大区别的 组合和聚合是有很大区别的,这个区别不是在形式上,而是在本质上: 比如A类中包含B类的一个引用b,当A类的一个对象消亡时,b这个引用所指向的对象 ...

  4. 3D Slicer中文教程(二)—软件功能界面介绍

    1.界面介绍 2.菜单及工具栏介绍 (1)菜单 File-文件菜单 文件菜单包含用于加载MRML场景的选项,用于从互联网下载样本数据集或各种类型的各个数据集.此处还提供了保存场景和数据的选项. Edi ...

  5. 【MYSQL】MYSQL报错解决方法: Warning: (3719, "'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8M B4 in a future release."

    用python3.6.5创建mysql库时出现如下报错,虽然报错,但是数据库可以插入成功. D:\python3\lib\site-packages\pymysql\cursors.py:170: W ...

  6. [C][变量作用域]语句块

    概述 C语言作用域有点类似于链式结构,就是下层能访问上层声明的变量,但是上层则不能访问下层声明的变量: #include <stdio.h> #define TRUE 1 int main ...

  7. matplotlib 无法显示中文和负号的解决办法

    matplotlib无法显示中文和负号解决办法

  8. 树上背包O(n*m^2)|| 多叉树转二叉树 || o(n*m)???

    #. 选课 描述 提交 自定义测试 问题描述 在大学里每个学生,为了达到一定的学分,必须从很多课程里选择一些课程来学习,在课程里有些课程必须在某些课程之前学习,如高等数学总是在其它课程之前学习.现在有 ...

  9. Java+maven+httpcomponents封装post/get请求

    httpcore4.4.10, httpclient4.5.6 package com.test.http; import com.alibaba.fastjson.JSONArray; import ...

  10. Redis .NET操作

    Redis是一个支持数据结构更多的键值对数据库.它的值不仅可以是字符串等基本数据类型,也可以是类对象,更可以是Set.List.计数器等高级的数据结构. Memcached也可以保存类似于Set.Li ...