centos8
一、YUM/DNF换源(阿里云)
1.备份源
cd /etc/yum.repos.d/
mv /etc/yum.repos.d/CentOS-AppStream.repo /etc/yum.repos.d/CentOS-AppStream.repo.bak
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
mv /etc/yum.repos.d/CentOS-centosplus.repo /etc/yum.repos.d/CentOS-centosplus.repo.bak
mv /etc/yum.repos.d/CentOS-Extras.repo /etc/yum.repos.d/CentOS-Extras.repo.bak
mv /etc/yum.repos.d/CentOS-PowerTools.repo /etc/yum.repos.d/CentOS-PowerTools.repo.bak
2.下载repo文件,因为centos8纯净安装并没有wget,所以需要使用curl做出命令,如果你的机子有wget,也可以使用第二条命令
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
3.查询是否安装成功,执行命令
ls -l /etc/yum.repos.d/
4.如果正常 则会看到以下内容
total76
-rw-r--r--.1rootroot731Aug142019CentOS-AppStream.repo.bak
-rw-r--r--.1rootroot712Aug142019CentOS-Base.repo.bak
-rw-r--r--1rootroot2595Feb2215:20CentOS-Base.repo.rpmsave
-rw-r--r--.1rootroot798Aug142019CentOS-centosplus.repo.bak
-rw-r--r--.1rootroot756Aug142019CentOS-Extras.repo.bak
-rw-r--r--1rootroot719Nov1008:32CentOS-Linux-AppStream.repo
-rw-r--r--1rootroot704Nov1008:32CentOS-Linux-BaseOS.repo
-rw-r--r--1rootroot1130Nov1008:32CentOS-Linux-ContinuousRelease.repo
-rw-r--r--1rootroot318Nov1008:32CentOS-Linux-Debuginfo.repo
-rw-r--r--1rootroot732Nov1008:32CentOS-Linux-Devel.repo
-rw-r--r--1rootroot704Nov1008:32CentOS-Linux-Extras.repo
-rw-r--r--1rootroot719Nov1008:32CentOS-Linux-FastTrack.repo
-rw-r--r--1rootroot740Nov1008:32CentOS-Linux-HighAvailability.repo
-rw-r--r--1rootroot693Nov1008:32CentOS-Linux-Media.repo
-rw-r--r--1rootroot706Nov1008:32CentOS-Linux-Plus.repo
-rw-r--r--1rootroot724Nov1008:32CentOS-Linux-PowerTools.repo
-rw-r--r--1rootroot898Nov1008:32CentOS-Linux-Sources.repo
-rw-r--r--.1rootroot736Aug142019CentOS-PowerTools.repo.bak
-rw-r--r--1rootroot1919Feb2215:12docker-ce.repo
5.执行cat命令查询源是否为阿里云(aliyun)
cat /etc/yum.repos.d/CentOS-Base.repo
6.生成缓存并升级软件包
yum clean all // 清空缓存
yum makecache // 生成缓存
yum -y update //更新包
二、安装docker
安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
1.下载docker-ce的repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.安装docker-ce
yum install docker-ce docker-ce-cli
输入此命令即可解决
yum install docker-ce docker-ce-cli --allowerasing
4.启动docker
systemctl start docker
5.验证安装
docker --version
6.开机自启
systemctl enable docker
三、设置镜像加速
1.在阿里云docker镜像仓库中获取镜像加速地址
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
2.执行命令
sudo systemctl daemon-reload
sudo systemctl restart docker
四、至此 ,centos8下docker安装完成!
1.拉取最新的 Nginx 镜像
docker pull nginx:latest
2.查看本地镜像
docker images
3.运行容器
docker run --name nginx-test -p 8080:80 -d nginx
Ubuntu
操作环境
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
一、换源(阿里云)
1.更新软件源为阿里源并用它更新软件
cp /etc/apt/sources.list /etc/apt/sources.list.bak_`date "+%y_%m_%d"`
sed -i 's/http:\/\/.*.ubuntu.com/https:\/\/mirrors.aliyun.com/g' /etc/apt/sources.list
apt update
apt upgrade
2.安装apt依赖包 用于通过HTTPS获取仓库
sudo apt-get install
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
4.添加 Docker 的官方 GPG秘钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
验证是否带有指纹密匙
sudo apt-key fingerprint 0EBFCD88
输出如下:
5.将 Docker APT 软件源添加到你的系统
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
输出如下
三、安装docker
sudo apt update // 更新软件列表
sudo apt install -y docker-ce docker-ce-cli containerd.io // 安装最新版本docker
*安装结束 一般会自动启动docker 使用下面这条命令查看运行*
sudo systemctl status docker
按ctrl + C 返回终端
2.开机自启
systemctl enable docker
四、设置镜像加速
1.在阿里云docker镜像仓库中获取镜像加速地址
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
2.执行命令
sudo systemctl daemon-reload
sudo systemctl restart docker
五、至此 ,Ubuntu下docker安装完成!
1.拉取最新的 Nginx 镜像
docker pull nginx:latest
2.查看本地镜像
docker images
3.运行容器
docker run --name nginx-test -p 8080:80 -d nginx
访问 ip:8080 看到欢迎页即为成功
Kali 2019-4
一、更换kali国内源( 中科大 )
vim /etc/apt/sources.list
注释掉里面的默认源,加上中科大的url
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
完成后保存推出
2.更新软件列表
apt-get update
[scode type="blue"]
如果报错,则是key过期
执行以下命令:
wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add
[/scode]
二、安装组件与docker
1.安装https
协议 CA证书
apt-get install -y apt-transport-https ca-certificates dirmngr
2.添加GPG密钥并添加更新源
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/ buster stable' | sudo tee /etc/apt/sources.list.d/docker.list
3.系统更新以及安装docker
apt-get update // 更新源
apt install docker-ce //安装docker
apt install docker-compose // 安装compose
reboot // 重启电脑
service docker start // 启动docker
4.验证安装
docker --version
三、开机自启
systemctl enable docker
四、设置镜像加速
1.在阿里云docker镜像仓库中获取镜像加速地址
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
2.执行命令
sudo systemctl daemon-reload
sudo systemctl restart docker
五、至此 ,Ubuntu下docker安装完成!
1.拉取最新的 Nginx 镜像
docker pull nginx:latest
2.查看本地镜像
docker images
3.运行容器
docker run --name nginx-test -p 8080:80 -d nginx
访问 ip:8080 看到欢迎页即为成功