【Linux操作系统】重装系统配置文件一条龙

【Linux操作系统】重装系统配置文件一条龙


下面一切案例均在ubantu22.04下进行操作。

虚拟机网络配置

image-20240803162224981

image-20240803164458593

安装net-tools工具

在新ubantu22.04中使用ifconfig工具

sudo apt update
sudo apt install net-tools
apt-get install open-vm-tools
apt-get install open-vm-tools-desktop

解决屏幕自适应问题

apt-get install 是 Debian 及其衍生系统(如 Ubuntu)的包管理器 apt 的一部分,用于安装软件包。在你提供的命令中,open-vm-toolsopen-vm-tools-desktop 是两个不同的软件包,它们与 VMware 虚拟机的集成和增强功能有关。

  1. open-vm-tools

    • 这个包提供 VMware Tools 的开源版本,它是一个服务和一组模块,用于增强 VMware 虚拟机的功能性和性能。这些工具包括时钟同步、心脏跳动检测、网络配置等。
    • open-vm-tools 包通常用于服务器或不需要桌面集成的环境。
  2. open-vm-tools-desktop

    • 这个包提供了额外的桌面集成功能,比如支持 3D 图形加速、自动调整窗口大小、无缝窗口模式等,使得在虚拟机中运行桌面应用程序的体验更加接近本地桌面。
    • open-vm-tools-desktop 包适用于需要桌面环境支持的虚拟机。

安装这些包可以提高虚拟机的性能和用户体验,尤其是在使用 VMware 作为虚拟化平台时。如果你正在运行一个 VMware 虚拟机,并且希望获得更好的集成体验,安装这些工具是推荐的。不过,请注意,如果你的虚拟机使用的是其他虚拟化技术(如 KVM 或 Xen),那么这些工具可能不适用。

解决虚拟机与主机复制粘贴问题

执行此命令,会有一个警告,但是已经可以复制粘贴了。

/usr/bin/vmware-user

以下部分如果重启之后还是不能复制粘贴再看,一般情况不需要。

但是重启之后需要再次配置,每次开机都要配置,我们要把这个设置为开机自启动

vi /usr/share/gnome/autostart/vmware-user.desktop

添加:

Exec=/usr/bin/vmware-user

文件互通

两种方案:

方案一

共享文件夹 linux固定在 /mnt/hgfs 目录下,数据可以同步

方案二:使用FileZilla 工具

需要安装ssh服务:

  1. 查看ssh服务状态
sudo service sshd status
  1. 安装ssh命令
sudo apt-get install ssh
sudo apt-get install openssh-server

image-20240803172359699

安装ssh服务

不按照ssh服务是用不了远程主机的

sudo apt install update
//安装SSH
sudo apt install openssh-server -y
//查看服务状态
systemctl status ssh
    //将SSH服务加入系统启动服务中
    systemctl enable ssh

vscode远程写代码

  1. vscode下载扩展 Remote-SSH

  2. Linux环境下载ssh服务

  3. windows创建公钥钥私钥

  4. 把公钥拷贝到Linux的 vim ~/.ssh/authorized_keys (不用每次再输密码)

与香橙派操作一样

改中文

修改系统语言
1.打开终端,输入命令"locale"查看当前系统语言设置;

locale

2.如果当前系统语言不是中文,可以使用下面命令安装中文语言包

sudo apt-get install language-pack-zh-hans

3.安装完成后,使用下面命令将系统语言修改为中文。

sudo update-locale LANG=zh_CN.UTF-8

4.重启系统

中文输入法支持

1.安装fcitx-googlepinyin

Ctrl+Alt+T打开终端,输入

sudo apt-get install fcitx-googlepinyin -y

2.配置language support

安装完成后打开菜单栏(按键盘上ctrl和alt之间的那个键,就是windows里的win键,在ubuntu里叫super),键盘输入language support并打开。

image-20240803173550023

第一次打开会显示语言支持没有完全安装,点击安装并输入密码开始安装

image-20240803173620045

安装好后就能进入语言支持界面,最下面一行Keyboard input method system(键盘输入法系统),默认是iBus,点击下拉单切换到fcitx(系统初始没有fctix,安装fcitx-googlepinyin的时候会装好fcitx)。然后重启电脑。

image-20240803174005446

3.输入法配置

重启之后在右上角状态栏点击键盘图标,在下拉单里选择倒数第三个Configure进入配置界面。

image-20240803174532894

快捷键配置:

image-20240803174553293

apt更新源

在不同版本的Ubuntu中更换为国内镜像源,以提高软件更新和安装速度。以下示例将涵盖Ubuntu 16.04、18.04、20.04、22.04、24.04五个版本。

备份现有镜像源列表

在更改镜像源之前,建议先备份当前的镜像源列表文件/etc/apt/sources.list

etc/apt/sources.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list 

修改镜像源列表

使用文本编辑器打开/etc/apt/sources.list文件:

sudo vi /etc/apt/sources.list

清华源

# 默认注释了源码仓库,如有需要可自行取消注释
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

将文件内容替换为所需的镜像源列表。以下提供了常用的国内镜像源对应不同版本的配置。

Ubuntu 16.04 (代号:xenial)

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

## 预发布源,不建议启用
# deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse

Ubuntu 18.04 (代号:bionic)

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports 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

Ubuntu 20.04 (代号:focal)

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

## 预发布源,不建议启用
# deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

Ubuntu 22.04 (代号:jammy)

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports 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

Ubuntu 24.04 (代号:lunar)

deb http://mirrors.aliyun.com/ubuntu/ lunar main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ lunar-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ lunar-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ lunar-backports main restricted universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/ lunar main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-security main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-updates main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-backports main restricted universe multiverse

## 预发布源,不建议启用
# deb http://mirrors.aliyun.com/ubuntu/ lunar-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-proposed main restricted universe multiverse

更新软件包列表

保存并关闭/etc/apt/sources.list文件后,执行以下命令更新软件包列表:

sudo apt update

等待更新完成即可。

常见问题及解决方法
更新失败或速度较慢:

  1. 尝试更换其他镜像源,如中科大或清华大学的镜像源。
    检查网络连接是否正常。
    权限问题:

  2. 确保使用sudo命令进行操作。
    检查/etc/apt/sources.list文件的权限是否正确。
    通过上述步骤,您可以在不同版本的Ubuntu中轻松更换为国内的镜像源,从而提升软件更新和安装的速度。

  • 37
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

橘猫.exe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值