Ubuntu replaces the domestic apt source

Essential operations for ubuntu

1 Replace the apt mirror source

  1. backup image
cp /etc/apt/sources.list /etc/apt/sources.list.bak
  1. Check your ubuntu version
# 查看自己的codename
#查看自己的ubuntu版本[注意关注:DISTRIB_CODENAME,发行代号]
cat /etc/*release

# DISTRIB_CODENAME=cosmic
# 例如(下面是ubuntu的LTS长期支持版):
# Ubuntu20.04(focal)
# Ubuntu19.10(eoan)
# Ubuntu19.04(disco)
# Ubuntu18.04(bionic)
# Ubuntu16.04(xenial)
  1. Set domestic mirror source

My ubuntu version is 18.10, and there is no corresponding mirror image maintained in China, but the major versions are consistent (so I used bionic)

vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic  main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
  1. Update the software list and complete the source change
apt update
  1. Fix broken packages
apt-get install  -f
  1. update software
apt-get upgrade

2 Other commands

①Firewall related

# 查看防火墙状态
sudo ufw status
# 开启/关闭防火墙
sudo ufw enable/disable

Guess you like

Origin blog.csdn.net/weixin_45565886/article/details/132281977