最小化安装centos和ubuntu之后的配置

最小化安装后的设置。

更换国内源

参考配置清华源

CentOS

增加sudo权限

su - root
usermod -aG wheel username
su - username

安装epel

sudo yum install epel-release
# 更换清华源
sudo sed -e 's!^metalink=!#metalink=!g' \
    -e 's!^#baseurl=!baseurl=!g' \
    -e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
    -e 's!http://mirrors\.tuna!https://mirrors.tuna!g' \
    -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
sudo yum makecache

更新软件

yum check-update
sudo yum upgrade

设置时区和NTP

timedatectl set-timezone Asia/Shanghai
sudo yum install chrony
sudo systemctl enable --now chronyd
timedatectl status

自动补全

sudo yum install bash-completion
source ~/.bashrc

安装vim

sudo yum -y install vim

安装wget

sudo yum -y install wget

其他有用的记录

# 找程序所属的包
yum whatprovides netstat

Ubuntu

增加sudo权限

su - root
usermod -aG sudo username
su - username

更新软件

sudo apt update
sudo apt upgrade

安装vim

sudo apt install vim

安装ufw

sudo apt install ufw
sudo ufw enable
sudo ufw allow ssh
sudo ufw status

通用

配置开机进入命令行模式

sudo systemctl set-default multi-user.target
sudo reboot

配置vim

sudo vim /etc/vim/vimrc.local
# 粘贴下面的内容进去
set showcmd
set showmatch
set ignorecase
set smartcase
set incsearch
set autowrite
set hidden
set nocompatible
set number
set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set autoread
set wildmenu
set expandtab
if has("vms")
set nobackup
else
set backup
endif
filetype indent on
filetype on

保存后,执行source /etc/vim/vimrc


参考链接:
Centos和Ubuntu系统最小化安装基础命令
Ubuntu 20.04 Server Installation
写给工程师的 Ubuntu 20.04 最佳配置指南