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

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

文章目录

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

虚拟机网络配置

安装net-tools工具

在新ubantu22.04中使用ifconfig工具

c 复制代码
sudo apt update
sudo apt install net-tools
c 复制代码
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),那么这些工具可能不适用。

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

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

c 复制代码
/usr/bin/vmware-user

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

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

c 复制代码
vi /usr/share/gnome/autostart/vmware-user.desktop

添加:

c 复制代码
Exec=/usr/bin/vmware-user

文件互通

两种方案:

方案一

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

方案二:使用FileZilla 工具

需要安装ssh服务:

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

安装ssh服务

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

c 复制代码
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"查看当前系统语言设置;

c 复制代码
locale

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

c 复制代码
sudo apt-get install language-pack-zh-hans

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

c 复制代码
sudo update-locale LANG=zh_CN.UTF-8

4.重启系统

中文输入法支持

1.安装fcitx-googlepinyin

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

c 复制代码
sudo apt-get install fcitx-googlepinyin -y

2.配置language support

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

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

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

3.输入法配置

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

快捷键配置:

apt更新源

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

备份现有镜像源列表

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

c 复制代码
etc/apt/sources.list
c 复制代码
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文件:

c 复制代码
sudo vi /etc/apt/sources.list

清华源

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

c 复制代码
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)

c 复制代码
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)

c 复制代码
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)

c 复制代码
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)

c 复制代码
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文件后,执行以下命令更新软件包列表:

c 复制代码
sudo apt update

等待更新完成即可。

常见问题及解决方法

更新失败或速度较慢:

  1. 尝试更换其他镜像源,如中科大或清华大学的镜像源。

    检查网络连接是否正常。

    权限问题:

  2. 确保使用sudo命令进行操作。

    检查/etc/apt/sources.list文件的权限是否正确。

    通过上述步骤,您可以在不同版本的Ubuntu中轻松更换为国内的镜像源,从而提升软件更新和安装的速度。

相关推荐
特立独行的猫a6 分钟前
redis客户端库redis++在嵌入式Linux下的交叉编译及使用
linux·数据库·c++·redis·redis客户端库
程序猿零零漆27 分钟前
【金仓数据库征文】金仓数据库:国产化浪潮下的技术突破与行业实践
数据库·金仓数据库 2025 征文·数据库平替用金仓
无敌小茶31 分钟前
Linux学习笔记之环境变量
linux·笔记
浩浩测试一下39 分钟前
SQL注入高级绕过手法汇总 重点
数据库·sql·安全·web安全·网络安全·oracle·安全架构
Harbor Lau1 小时前
Linux常用中间件命令大全
linux·运维·中间件
漫谈网络1 小时前
基于 Netmiko 的网络设备自动化操作
运维·自动化·netdevops·netmiko
Pasregret1 小时前
缓存与数据库一致性深度解析与解决方案
数据库·缓存·wpf
skywalk81631 小时前
Graph Database Self-Managed Neo4j 知识图谱存储实践2:通过官方新手例子入门(未完成)
数据库·知识图谱·neo4j
Lucky GGBond1 小时前
MySQL 报错解析:SQLSyntaxErrorException caused by extra comma before FROM
数据库·mysql
꧁坚持很酷꧂1 小时前
Linux Ubuntu18.04下安装Qt Craeator 5.12.9(图文详解)
linux·运维·qt