## 什么是 Ubuntu Ubuntu 是一个基于 Debian 的 Linux 发行版,Ubuntu有三个正式版本,包括桌面版、服务器版及用于物联网设备和机器人的Core版。 ## 查看 Ubuntu 版本 ```Shell $ lsb_release -a ``` ## 安装必备工具 ```Shell $ sudo apt update && sudo apt upgrade -y $ sudo apt install iputils net-tools htop iotop iftop dstat -y ``` ## 开启 ssh 和 root 登录 ```Shell # 安装ssh服务并启动 $ sudo apt install openssh-server -y $ sudo systemctl enable --now ssh $ sudo systemctl status ssh # 开启root登录 $ sudo passwd # 设置root密码 $ sudo vim /etc/ssh/sshd_config # >>> PermitRootLogin yes # 修改ssh端口 $ sudo vim /etc/ssh/sshd_config # >>> Port 5550 # 修改ssh连接间隔,解决闲置过久自动断开问题 $ sudo vim /etc/ssh/sshd_config # >>> ClientAliveInterval 60 和 ClientAliveCountMax 10 #重启ssh服务 $ sudo service sshd restart ``` ## SSH 登录 使用 SSH 登录建议使用密钥无密码方式,详细配置可以参考 [[Shell#SSH公钥认证登录]] ## 防火墙 阿里云服务器建议关闭系统防火墙,使用网络安全组策略。 ```Shell $ sudo ufw disable ``` 如果服务器没有其他安全策略,建议打开防火墙,详细配置可以参考 [[Shell#UFW]] ```shell $ sudo ufw enable ``` ## 修改 ip 地址 静态ip修改步骤如下,其他设置可参考文档 https://ubuntu.com/server/docs/network-configuration 1. 查看网卡信息 `ip a` 2. 修改配置文件 `vim /etc/netplan/00-installer-config.yaml` ```Shell # This is the network config written by 'subiquity' network: ethernets: ens3: addresses: - 172.16.0.8/24 routes: - to: default via: 172.16.0.1 nameservers: addresses: [114.114.114.114, 223.5.5.5, 8.8.8.8] version: 2 renderer: networkd ``` 3. 应用设置 `sudo netplan apply` ## 开启 bbr 1. 安装软件包 ```Shell $ sudo apt install wget apt-transport-https gnupg2 software-properties-common ``` 2. 检查是否开启 bbr ```Shell $ sysctl net.ipv4.tcp_congestion_control ``` 3. 如果没有开启 bbr 需要修改配置文件 ```Shell $ sudo vim /etc/sysctl.conf >>> net.core.default_qdisc=fq 和 net.ipv4.tcp_congestion_control=bbr $ sudo sysctl -p ``` ## 扩容磁盘 1. 查看磁盘容量 ```shell $ df -h $ sudo fdisk -l $ sudo lsblk ``` 2. 使用 `growpart` 扩容 ```shell $ sudo growpart /dev/sda 分区号 ``` 3. 更新逻辑卷大小 ``` $ sudo lvresize --extents +100%FREE --resizefs /dev/mapper/ubuntu--vg-ubuntu--lv ```