若使用命令sudo apt-get update报错:apt-get:找不到命令,八成是源配置文件/etc/apt/sources.list不存在。但是一般来说不会不存在,若真的不小心删除的话,我们也可以进行恢复。

首先创建/etc/apt/sources.list文件,然后vim编辑内容,原内容可以访问https://developer.aliyun.com/mirror/ubuntu进行查看,如ubuntu16.04的sources.list如下:

deb https://mirrors.aliyun.com/ubuntu/ xenial maindeb-src https://mirrors.aliyun.com/ubuntu/ xenial maindeb https://mirrors.aliyun.com/ubuntu/ xenial-updates maindeb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates maindeb https://mirrors.aliyun.com/ubuntu/ xenial universedeb-src https://mirrors.aliyun.com/ubuntu/ xenial universedeb https://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb https://mirrors.aliyun.com/ubuntu/ xenial-security maindeb-src https://mirrors.aliyun.com/ubuntu/ xenial-security maindeb https://mirrors.aliyun.com/ubuntu/ xenial-security universedeb-src https://mirrors.aliyun.com/ubuntu/ xenial-security universe