Ubutu1804 系统的基本配置
安装好 Ubuntu 系统后, 可使用下面的配置优化系统
1. 修改 root 用户的密码
sudo passwd root
输入密码
再次输入密码
2. 修改配置, 使 root 用户可以远程登录和开机可以使用 root 登录
- sudo sed -i '[email protected] n || [email protected] -s && mesg n || [email protected]' /root/.profile
- sudo sed -i '[email protected] n || [email protected] -s && mesg n || [email protected]' /root/.profile
验证:
查看 / root/.profile 文件是下面的样子就行
- [email protected]:~# cat /root/.profile
- # ~/.profile: executed by Bourne-compatible login shells.
- if [ "$BASH" ]; then
- if [ -f ~/.bashrc ]; then
- . ~/.bashrc
- fi
- fi
- tty -s tty -s mesg n || true
- [email protected]:~#
以上配置生效, 需重启系统
3. 修改 Ubuntu 的 apt 源
1. 打开阿里云的 Ubuntu 源
https://opsx.alibaba.com/mirror
2. 找到 Ubuntu 那一行, 点击后面的 "帮助"
3. 根据上面的提示, 打开 "/etc/apt/sources.list" 文件
把文件里默认的配置都清除
vi /etc/apt/sources.list
4. 选择 Ubuntu 的版本, 然后复制 apt 源的配置, 如 Ubuntu 18.04(bionic) 配置如下:
- 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-proposed main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed 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
5. 更新 apt 源
apt-get update
6. 更新 apt 源后, 就可以用 apt-get 安装软件了
示例: 安装 haproxy 和 keepalived 软件
apt-get install haproxy keepalived
输入 "y", 确认安装
4. 修改主机名
1. 修改主机名
vi /etc/hostname
主机名
2. 使主机名生效
reboot
5. 修改默认 Ubuntu 的网卡名称为 "eth" 格式
1. 修改配置文件 vi /etc/default/grub
2. 在 GRUB_CMDLINE_LINUX 添加内容
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
3. 生效新的 grub.cfg 文件
grub-mkconfig -o /boot/grub/grub.cfg
4. 修改网卡配置文件的名称
把原来的 "ensxx" 改为 "ethxx"
5. 重启系统生效
来源: http://www.bubuko.com/infodetail-3097746.html