Ubuntu18.04安装完后的一些配置(不定期更新)

禁用休眠

sudo vim /etc/systemd/logind.conf
#修改 
#HandleLidSwitch=suspend
# 改为
HandleLidSwitch=ignore
#保存退出
# 重启服务
sudo service systemd-logind restart

安装ssh

apt install ssh

普通用户获取权限

安装完Ubuntu后每次都要使用sudo并且还要输密码很烦
#执行完就能像超管一样使用(其他命令不用加sudo)了
sudo su

更换源(中科大)

参考http://mirrors.ustc.edu.cn/help/ubuntu.html
# 首先备份
cd /etc/apt/
cp sources.list sources.list.bak
# 将 /etc/apt/sources.list 文件中 Ubuntu 默认的源地址 http://archive.ubuntu.com/ 替换为 http://mirrors.ustc.edu.cn
sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
# 更新
sudo apt-get update

如果apt update失败

访问https://mirrors.ustc.edu.cn/repogen/
生成一个配置文件(以下为18.04):

vim /etc/apt/sources.list

全部删除保存以下

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

## Not recommended
# deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 再次更新
apt-get update