嵌入式技术
服务,即service,其本质上也是进程,但是运行在后台,通常都会监听某个端口,等待其他程序的请求,比如(mysqld, sshd, 防火墙等),因此又将其称为守护进程。
service指令所管理的服务可以直接在/etc/init.d/目录下查看。
service 服务名 [start | stop | restart | reload | status]
systemctl 指令管理的服务可在/usr/lib/systemd/system/目录下查看。
systemctl [start | stop | restart | status] 服务名
=================================================
# 设置服务的自启动状态
systemctl enable 服务名 # 设置服务开机自启
systemctl disable 服务名 # 关闭服务开机自启
systemctl is-enabled 服务名 # 检查某服务是否自启动
=================================================
每次操作完防火墙后都需要重新载入防火墙配置,命令firewall-cmd --reload
# 打开端口
firewall-cmd --permanent --add-port=端口号/协议
# 关闭端口
firewall-cmd --permanent --remove-port=端口号/协议
# 重新载入,让配置生效
firewall-cmd --reload
# 查询端口是否开放
firewall-cmd --query-port=端口/协议
测试某个端口是否开放,使用telnet
命令即可。
telnet 192.168.1.100 111 # 测试111端口是否开放
修改镜像源文件前记得备份一份原来文件,修改完成后执行sudo apt update
命令刷新本地apt缓存。
/etc/apt/sources.list
阿里云镜像源配置教程
域名说明
对于阿里云ECS用户,需要将配置文件中 https://mirrors.aliyun.com/ 替换成 http://mirrors.cloud.aliyuncs.com/ 进行使用
sed -i 's/https:\\/\\/mirrors.aliyun.com/http:\\/\\/mirrors.cloud.aliyuncs.com/g' /etc/apt/sources.list
图形界面配置
新手推荐使用图形界面配置: 系统设置 -> 软件和更新 选择下载服务器 -> "mirrors.aliyun.com"
手动更改
用你熟悉的编辑器打开:
/etc/apt/sources.list
替换默认的
http://archive.ubuntu.com/
为
mirrors.aliyun.com
以Ubuntu 14.04.5 LTS为例,最后的效果如下:
deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
## Not recommended
# deb https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
ubuntu 16.04 配置如下
deb https://mirrors.aliyun.com/ubuntu/ xenial main
deb-src https://mirrors.aliyun.com/ubuntu/ xenial main
deb https://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb https://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src https://mirrors.aliyun.com/ubuntu/ xenial universe
deb https://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb https://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src https://mirrors.aliyun.com/ubuntu/ xenial-security main
deb https://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src https://mirrors.aliyun.com/ubuntu/ xenial-security universe
ubuntu 18.04(bionic) 配置如下
deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
ubuntu 20.04(focal) 配置如下
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
全部0条评论
快来发表一下你的评论吧 !