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 版本的参考配置:

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

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

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

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

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

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

3.我的配置:

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

原:

#/media/cdrom/apks
http://ftp.halifax.rwth-aachen.de/alpine/v3.7/main
#http://ftp.halifax.rwth-aachen.de/alpine/v3.7/community
#http://ftp.halifax.rwth-aachen.de/alpine/edge/main
#http://ftp.halifax.rwth-aachen.de/alpine/edge/community
#http://ftp.halifax.rwth-aachen.de/alpine/edge/testing
http://mirror.yandex.r+u/mirrors/alpine/v3.7/main
#http://mirror.yandex.r+u/mirrors/alpine/v3.7/community
#http://mirror.yandex.r+u/mirrors/alpine/edge/main
#http://mirror.yandex.r+u/mirrors/alpine/edge/community
#http://mirror.yandex.r+u/mirrors/alpine/edge/testing
(敏感词汇,去掉上面.r+u/中的加号)

改为:

http://mirrors.ustc.edu.cn/alpine/v3.7/main
http://mirrors.ustc.edu.cn/alpine/v3.7/community
http://mirrors.ustc.edu.cn/alpine/edge/main
http://mirrors.ustc.edu.cn/alpine/edge/community
http://mirrors.ustc.edu.cn/alpine/edge/testing

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

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

或者

echo ‘http://mirrors.ustc.edu.cn/alpine/v3.7/main
http://mirrors.ustc.edu.cn/alpine/v3.7/community
http://mirrors.ustc.edu.cn/alpine/edge/main
http://mirrors.ustc.edu.cn/alpine/edge/community
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主要用于不同运行级增加或者删除服务。

alpine:~# rc-update --help
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)

3.rc-status

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

alpine:~# rc-status --help
Usage: rc-status [options] <runlevel>...
   or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]

Options: [ aclmrsuChqVv ]
  -a, --all                         Show services from all run levels
  -c, --crashed                     Show crashed services
  -l, --list                        Show list of run levels
  -m, --manual                      Show manually started services
  -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)

4.rc-service

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

alpine:~# rc-service --help
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: [ ce:ilr:INChqVv ]
  -e, --exists <arg>                tests if the service exists or not
  -c, --ifcrashed                   if the service is crashed then run the command
  -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)

5.openrc

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

alpine:~# openrc --help
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)

6.我常用的RC系列命令

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

rc-update add docker boot

b.重启网络服务

rc-service networking restart

c.列出所有服务

rc-status -a

五:关机重启

$ reboot #重启系统
$ poweroff #关机

原文地址:https://www.cnblogs.com/alusss/p/12610764.html

时间: 2024-08-30 00:43:32

Alpine Linux 常用命令的相关文章

Linux常用命令(echo、date、ls、cd、history、cat)

一.linux常用命令有很多今天我们来总结一下常用的入门命令: 1.linux下关机命令:poweroff.init 0.halt.shutdown -h now 2.linux下重启命令:reboot.init 6.shutdown -r now 3.shutdown命令: 格式:shutdown  options TIME 其中options有以下几个: -r:执行重启 -c:取消shutdown命令 -h:执行关机 其中TIME有以下几个: now:表示现在 +m:相对时间表示法,从命令提

linux常用命令详解

linux常用命令 cut命令 例如:cut -d\| -f1,4 xx.txt -d 表示字段分隔符 -f 表示要显示的字段域,如果域之间,(逗号)隔开表示显示对应的单个域,如果用-隔开表示显示连续的域 sort命令 例如:sort -t\| -k2 xx.txt -n 按数值排序 -r 降序 -t 字段分隔符 -k 以哪个字段为关键字进行排序 -u 去重 -f 排序时不区分大小写 uniq命令 注意:使用uniq命令时,一定要先进行排序 -c 显示文件中行重复的次数 -d 只显示重复的行 -

Linux常用命令大全

系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验

(转)linux常用命令

原地址:http://www.cnblogs.com/svage/p/3700122.html 1.删除目录及子目录下的 .svn目录 find . -type d -name ".svn" | xargs rm -rf 2./tmp 目录的权限 drwxrwxrwt rwt的意思是:对目录有执行权限,但不能删除,即sticky bit rwx : 可读可写可执行 4+2+1 3.改变群组.用户.权限 chgrp   群组名   改变的目录 groupadd -g gid gname

Linux 常用命令之文件和目录

1. cd 命令格式:cd  [dirName](cd和目录之间使用空格隔开) 作用:切换当前目录至dirName. 实例: cd /home 切换当前目录到/home (查看当前目录命令为pwd) cd .. 返回上一级目录 cd ../.. 返回上两级目录 cd ~ 进入个人的主目录 2. ls 命令格式:ls [选项] [目录名] (目录名为空时表示当前目录) 作用: 查看目录中的文件 常用选项: -a, –all 列出目录下的所有文件,包括以 . 开头的隐含文件. -l 除了文件名之外,

Linux 常用命令汇总

Linux 常用命令汇总 1. 显示日期与时间:date 可修改显示日期格式,如:date +%Y/%m/%d %H:%M à2016/12/25 17:05(%Y:年:%m:月:%d:日:%H:24小时制:%M:分) date –d 参数后可加:today/yesterday/tomorrow 来显示今天.昨天.明天日期 2. 显示日历:cal(默认显示本月月历) cal 2001 可显示2001年整年日历:cal 10 2001 可具体显示某月月历 3.  计算器:bc 4. Tab键:用在

第一章,Linux常用命令

20161124 Linux常用命令 1.find find /etc/ -size +50k -ls find /etc/ -size +50k -ls 2> /dev/null 查看目录下大于50K的文件并用ls列表显示出来, 理解2> /dev/null含义,把没权限的都隐藏起来了 2.pwd ,ls  ,ls -a   ,ls -al ,,ls -alh,touch   ,make, 常用ls -alh 3.标准输入和输出管道 cat >  packages1.txt   之后输

linux常用命令总结

linux常用命令: (1) ls(list,列表) 作用:使用列表把当前文件夹下所有文件显示出来 ls -a 显示所有文件,包括隐藏文件 ls -l 以详细信息显示 ls -a -l ls -l -a ls -la ls -al 四种方式都是可以的 (2) cd(change directory,更改目录) 作用:用来切换目录 涉及到相对路径和绝对路径 cd .. ..代表上一层目录 .代表当前目录 (3) pwd(print work directory,打印工作目录) 作用:打印出当前的绝

Linux常用命令介绍

Linux常用命令示例: 在使用Linux操作系统的过程中,我们经常要用到一些特殊的命令,不仅显示了技术的高超,而且在效率方面当然要比图像化界面高很多,下面我总结了一些常见的Linux命令,供以后学习使用,使用命令时,在命令后面加参数"--help"或者用"man 命令"可以取得命令的详细用法. (*)小常识:在Linux中使用命令操作文件时,可以仅输入文件名的前几个字符,然后按键盘的"Tab"键补全文件名的后面部分,若输入的字符是多个文件名的起