配置网络服务
先测试本地lo网络是否通畅:
ping 127.0.0.0
手机USB网络共享网络
通过手机USB网络共享网络给服务器:
ifconfig # 终端中查看现有网络接口,或者使用ip addr,如果出现类似usb0的接口,说明手机已经连接上了
dhclient usb0 # 申请IP,或者直接dhclient
ping www.baidu.com # 测试网络是否通畅
查看硬件信息,使用lspci:
lspci -v # -v参数可以查看详细信息
在这里会显示有线网卡和无线网卡的信息,其中无线网卡的名字为wlan,有线网卡的名字为Ethernet。
命令行连接wifi
# 查看wifi接口
iwconfig
# or
nmcli dev wifi
# 连接wifi
nmcli dev wifi connect "wifi名" password "密码"
挂载U盘
手动挂载
# 查看U盘
df -h
# 挂载U盘
mount /dev/sdc1 /home
挂载路径不能是系统路径,否则会清空单前系统数据或者无法启动机器。如/root,/usr等。
通过UUID自动挂载
lsblk -f # 查看U盘UUID
vim /etc/fstab # 添加一行:UUID=xxx /home vfat/ext4 defaults 0 0
更新源
查看Ubuntu系统版本:
lsb_release -a
查看操作系统架构:
uname -a
uname -a命令的输出结果中,x86_64表示64位系统,i386表示32位系统。
或者:
dpkg --print-architecture
看看是amd64还是aarch64。
更换源:
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
以清华源为例,将以下内容复制到sources.list中:(1对应ubuntu;2对应ubuntu-ports)
- 对于32/64位x86架构处理器,22.04LTS:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src 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-src 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-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
- 对于 ARM(arm64, armhf)、PowerPC(ppc64el)、RISC-V(riscv64) 和 S390x 等架构的Ubuntu系统,22.04LTS:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
更新软件和源:
sudo apt-get update
sudo apt-get upgrade
update是更新源,upgrade是更新软件。