Ubuntu Server版本安装
选择安装语言
安装界⾯传递内核参数
选择安装过程语⾔
地区设置
键盘选择
不进⾏探测,⼿动设置
选择键盘
键盘确认
配置主机名
创建新的普通系统⽤⼾
设置用户密码
确认用户密码
确认使用密码
自动分区
选择磁盘
确认写⼊磁盘
是否使⽤代理
系统安装过程
是否自动更新
选择安装组件
写⼊grub引导
确认重启服务器
系统安装完成
Ubuntu Server系统基础配置
更改主机名
root@xiaomao3:~# cat /etc/hostname
xiaomao3
更改网卡名称为eth*
root@xiaomao3:~# vim /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=2
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
# 更新内核参数
root@xiaomao3:~# sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-55-generic
Found initrd image: /boot/initrd.img-4.15.0-55-generic
done
root@xiaomao3:~# sudo reboot
配置静态ip地址
root@xiaomao3:~# cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses: [192.168.146.133/24]
gateway4: 192.168.146.2
nameservers:
addresses: [223.6.6.6]
#重启网卡生效
root@xiaomao3:~# set paste
#查看地址是否生效
root@xiaomao3:~# ip add
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:89:22:2b brd ff:ff:ff:ff:ff:ff
inet 192.168.146.133/24 brd 192.168.146.255 scope global eth0
配置root远程登录
root@xiaomao3:~# vim /etc/ssh/sshd_config
32 #PermitRootLogin prohibit-password #默认为禁⽌登录
33 PermitRootLogin yes #改为允许登录
57 #PasswordAuthentication yes
# 打开密码认证,其实默认就是允许通过密码认证登录
58 PasswordAuthentication yes
~$ sudo su - root #切换到root⽤⼾环境
~# passwd #设置密码
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
~# systemctl restart sshd #重启ssh服务并测试root⽤⼾远程ssh连接
Ubuntu软件包管理
修改软件仓库
root@xiaomao3:~# vim /etc/apt/sources.list
root@xiaomao3:~# cat !$
cat /etc/apt/sources.list
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
#更新软件仓库
root@xiaomao3:~# apt update
apt/apt-get
# apt list #apt列出仓库软件包,等于yum list
# apt search NAME #搜索安装包
# apt show apache2 #查看某个安装包的详细信息
# apt install apache2 #在线安装软件包
# apt remove apache2 #卸载单个软件包但是保留配置⽂件
# apt autoremove apache2 #删除安装包并解决依赖关系
# apt update #更新本地软件包列表索引,修改了apt仓库后必须执⾏
# apt purge apache2 #卸载单个软件包删除配置⽂件
# apt upgrade #升级所有已安装且可升级到新版本的软件包
# apt full-upgrade #升级整个系统,必要时可以移除旧软件包。
# apt edit-sources #编辑source源⽂件
# apt-cache madison nginx #查看仓库中软件包有哪些版本可以安装
# apt install nginx=1.14.0-0ubuntu1.6 #安装软件包的时候指定安装具体的版本
安装系统常用命令
root@xiaomao3:~# apt purge ufw lxd lxd-client lxcfs lxc-common
root@xiaomao3:~# apt install iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute gcc openssh-server lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip