env
Ubuntu 20.04.1 LTS
- 主机名
tee >/etc/hostname <<EOF
igo_223
EOF
hostnamectl set-hostname igo_223
- 网络
u18及以前版本
cp /etc/network/interfaces{,.$(date +%Y%m%d)bak}
tee >/etc/network/interfaces <<EOF
auto ens32
iface ens32 inet static
address 10.10.2.223
netmask 255.255.255.0
gateway 10.10.2.2
dns-nameserver 223.5.5.5
EOF
netplan apply
u20及以后版本
u20 /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
version: 2
ethernets:
ens32:
dhcp4: false
addresses: [10.10.2.223/24]
gateway4: 10.10.2.2
nameservers:
addresses: [114.114.114.114,223.5.5.5]
netplan apply
https://igozhang.cn/network_config
#启用bbr模块
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf && \
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf && \
sysctl -p && lsmod | grep bbr
- apt_src
cp /etc/apt/sources.list{,.$(date +%Y%m%d)bak}
替换archive.ubuntu.com为mirrors.aliyun.com
#添加阿里源
cat << EOF > /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
EOF
apt-get update
- 初始软件包
apt -y install vim mlocate htop curl git unzip wget supervisor net-tools - 初始目录
mkdir /data - 开启root登录
sed -i 's/^.PermitRootLogin .*/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/^.PasswordAuthentication .*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
- 添加swap
dd if=/dev/zero of=/var/swap bs=1024 count=2048000 && \
chmod 600 /var/swap && \
mkswap /var/swap && \
swapon /var/swap && \
echo "/var/swap swap swap defaults 0 0" >> /etc/fstab && \
free -m
如需删除
swapoff /var/swap && rm /var/swap
# /etc/fstab
- 时区
timedatectl set-timezone Asia/Shanghai - 更新
更新软件包列表
apt update
软件更新并自动删除不使用的软件包
apt upgrade -y && apt autoremove -y - 启用crontab 日志
vim /etc/rsyslog.d/50-default.conf
取消注释#cron.* /var/log/cron.log,保存并退出
service rsyslog restart - 清空history
history -c && cat /dev/null > ~/.bash_history