Ubuntu 22.04LTS 基础配置

官网镜像下载:[点击这里]

设置root用户密码

1
2
3
4
5
6
7
8
9
10
11
# 登录系统 shell 命令行设置 root 用户密码
demo@demo-virtual-machine:~/Desktop$ sudo passwd
[sudo] password for demo: # 输入 demo 用户密码 123456
New password: # 设置 root 用户密码 123456
Retype new password:
passwd: password updated successfully
# 切换 root 用户登录系统
demo@demo-virtual-machine:~/Desktop$ su root
Password:
root@demo-virtual-machine:/home/demo/Desktop# cd
root@demo-virtual-machine:~#

配置阿里系统安装源

配置系统安装源(自选一个)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#清华
sudo mv /etc/apt/sources.list{,.bak}
sudo bash -c "cat >> /etc/apt/sources.list << EOF
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
EOF"

sudo apt-get update
#阿里
sudo mv /etc/apt/sources.list{,.bak}
sudo bash -c cat >> /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF
sudo apt-get update

安装小工具

安装Networkmanager,openssh-server,vim,inetutils-ping,net-tools服务

1
sudo apt-get install network-manager openssh-server vim inetutils-ping net-tools -y

开启 root 远程连接服务

修改 sshd_config 文件

1
2
3
sudo  vim /etc/ssh/sshd_config
# 配置文件末尾处添加如下
PermitRootLogin yes

重启 SSH 服务

1
sudo service ssh restart

设置静态ip

进入配置文件夹

1
2
3
4
root@demo-virtual-machine:~#  cd /etc/netplan
root@demo-virtual-machine:~# ll
-rw-r--r-- 1 root root 104 8月 9 2022 01-network-manager-all.yaml
##很显然我这里有一个01....

备份旧配置文件

1
root@demo-virtual-machine:~# sudo cp 01-network-manager-all.yaml{,.bak}

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
root@demo-virtual-machine:~# sudo vim 01-network-manager-all.yaml
#直接复制
network:
ethernets:
ens33:
dhcp4: false
addresses:
- 192.168.48.10/24
routes:
- to: default
via: 192.168.48.2
nameservers:
addresses: [192.168.48.2,114.114.114.114]
version: 2

:wq

sudo netplan apply
特别声明
千屹博客旗下的所有文章,是通过本人课堂学习和课外自学所精心整理的知识巨著
难免会有出错的地方
如果细心的你发现了小失误,可以在下方评论区告诉我,或者私信我!
非常感谢大家的热烈支持!