Ubuntu Server 21.04 Install

Posted CIAS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu Server 21.04 Install相关的知识,希望对你有一定的参考价值。

前言

Ubuntu——公共云、数据中心和边缘上最受欢迎的 Linux 发行版。自成立以来,Ubuntu 一直在获得市场份额,截至今天已接近 50%

Ubuntu  Server 下载

Ubuntu 21.04 下载Ubuntu 软件源PXEdocker安装mysql 安装ansible安装Samba安装

MobaXterm 远程连接工具

64-bit ARM (ARMv8/AArch64) server install image参考参考参考参考参考参考download
PowerPC64 Little-Endian server install image
IBM System z server install image
64-bit PC (AMD64) server install image
Ubuntu 21.10 下载
64-bit ARM (ARMv8/AArch64) server install image
PowerPC64 Little-Endian server install image
IBM System z server install image
64-bit PC (AMD64) server install image

 Ubuntu Server 21.04安装

选择你的语言,继续下一步

 不更新,需要更新的更新安装

 键盘布局设置

 配置网卡,手动配置或者自动获取

  • 手动配置网络

  • Subnet 设置
  • IP设置
  • 网关设置
  • DNS设置

根据需要设置代理服务器URL。如果不需要,可以继续使用empty

 输入镜像服务器URL来获取包。通常,它是通过检测你的位置自动配置最接近的一个

磁盘分区设置

  • 手动分区

  • /  (1TB)
  • /boot (2G)
  • /swap  (8G)
  • /boot/efi (512MB)

  • /boot分区 2GB xfs分区模式

  • swap 分区 8GB

  •  根分区配置/ 使用所有容量

 

  • /boot/efi分区设置

  •  分区配置完成

  • 格式化磁盘

 设置管理用户帐户。输入任何你喜欢的用户名和密码

选择安装或不安装SSH服务器在此安装

 选择在服务器使用中经常使用的应用程序或软件环境。如果您没有特定的要求,可以不检查任何项目继续进行

安装过程完成后,选择[立即重新启动]重新启动计算机

重新启动计算机后,使用安装过程中设置的用户和密码登录。如果正常登录,您的Ubuntu服务器安装成功完成

 启用root

在安装过程中添加的用户帐户使用Sudo设置了一个管理帐户,所以很容易获得root帐户的shell
sudo -s

可以使用标准的su命令切换到root帐户来设置root帐户的密码
sudo passwd root

su -

对于[su]命令限制
vi /etc/pam.d/su

# line 15 : uncomment and add a group which is allow to run [su] command
auth       required   pam_wheel.so  group=adm
  •  root方式登陆

远程SSH 连接配置

cat >>/etc/ssh/sshd_config<<EOF
# add 18
PermitRootLogin yes
EOF
  • 重启ssh
systemctl restart ssh
  • 远程测试连接 

IP更改设置

cat << EOF > /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens160:
      addresses:
      - 192.168.15.42/24
      gateway4: 192.168.15.1
      nameservers:
        addresses:
        - 8.8.8.8
        search: []
  version: 2    
EOF
  • 应用更改
netplan apply

安装常规软件测试

apt install gcc unzip -y

国内源更换 

  • 备份默认源
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
cat >>/etc/apt/source.list<<EOF

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
EOF

添加DNS,用于解析无法下载的问题

cat >>/etc/resolv.conf<<EOF
nameserver 61.134.1.5
nameserver 8.8.8.8
EOF

更新在线源

sudo apt-get update

切换sh为bash 

dpkg-reconfigure dash

  •  输入NO

  • 查看切换结果,结果/bin/sh -> bash切换成功

ls -al /bin/sh

以上是关于Ubuntu Server 21.04 Install的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu Server 21.04 Install ansible

Ubuntu Server 21.04 Install ansible

Ubuntu Server 21.04 Install ansible

Ubuntu Server 21.04 Install one key Generic mysql 8.0.26

Ubuntu Server 21.04 Install Cockpit

Ubuntu Server 21.04 Install Cockpit