ubuntu-server-22.04上手指南
ubuntu-server-22.04上手指南
一、更新并安装基础软件
#切换root用户
sudo su -
#更新
apt update
#升级
apt upgrade
#install vim
apt install vim
#install net-tools
apt install net-tools
二、安装ssh并设置开机自启动
#install ssh
apt install openssh-server
apt install openssh-client
#重启ssh服务
service ssh restart
vim /root/.bashrc
#文件末尾增加一条记录service ssh start
service ssh start
#将PermitRootLogin的值改为yes,/搜索即可,超级简单
vim /etc/ssh/sshd_config
PermitRootLogin yes
#放开22端口
ufw allow 22
三、设置ubuntu更新源为阿里源
#更换阿里源
vim /etc/apt/sources.list
#清除原有文件内容
:%d
#把下面的贴过去
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
#更新
apt update
#升级
apt upgrade
四、命令行设置静态IP地址
#进入网络管理目录
cd /etc/netplan
root@kelsen-ubuntu-desktop:/etc/netplan# ls
01-network-manager-all.yaml
vim 01-network-manager-all.yaml
# 设置600的文件权限,否则会报错Permissions for /etc/netplan/01-network-manager-all.yaml are too open. Netplan configuration should NOT be accessible by others.
chmod 600 /etc/netplan/01-network-manager-all.yaml
#解决虚拟机下网络报错的问题
apt-get install openvswitch-switch
#01-network-manager-all.yaml修改为
network:
version: 2
renderer: networkd
ethernets:
ens33: ##ens33可根据命令ifconfig -a 显示的网卡名
dhcp4: false
addresses: [192.168.1.105/24] # 将此处的IP地址替换为你想要设置的静态IP地址
routes:
- to: default
via: 192.168.31.1 # 将此处的网关地址替换为你家庭路由器的网关地址,家庭网络中就是路由器地址
nameservers:
addresses: [192.168.31.1,8.8.8.8,8.8.4.4] # 可根据需要修改为你常用的DNS服务器地址
#应用
netplan apply
原文地址:https://blog.csdn.net/JingLisen/article/details/143740641
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!