工具准备
VMware® Workstation 16 Player
ubuntu-20.04.4-desktop-amd64.iso
更新镜像源
ubuntu 20.04 更换系统镜像为清华镜像源或者其他镜像源
1.将系统自带的源文件做个备份:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
2.打开文件
sudo gedit /etc/apt/sources.list
拷贝粘贴下面的内容
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
上述内容可从下面链接获取:
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
更新源: sudo apt-get update
更新软件: sudo apt-get upgrade
参考链接:https://blog.csdn.net/ifreewolf_csdn/article/details/83185505
安装 samba,与 windows 系统实现文件共享
1.安装 samba
sudo apt-get install samba
2.创建一个共享文件并设置权限
mkdir ~/share
sudo chmod -R 777 ~/share
3.添加用户(添加到 samba 中的用户必须是系统用户中的一个,不能胡来)
$ sudo smbpasswd -a mary 1 ↵
[sudo] password for mary:
New SMB password:
Retype new SMB password:
Added user mary.
4.修改 samba 配置文件(/etc/samba/smb.conf)
在配置文件的最后添加如下:
[share]
comment = share folder
browseable = yes
path = /home/mary/share
create mask = 0700
directory mask = 0700
valid users = mary
public = yes
available = yes
writable = yes
5.重启 samba
sudo service smbd restart
6.windows 访问共享文件夹
输入 \\+ubuntu的ip地址
连接到虚拟机,输入账户和密码登录即可。建议保存密码。
参考链接:
https://blog.csdn.net/qq_44078824/article/details/119847027
更改默认 python 版本
新安装的 ubuntu 20.04,python 版本查询如下:
$ python3 --version
Python 3.8.10
$ python --version
zsh: command not found: python
$ sudo update-alternatives --list python
update-alternatives: error: no alternatives for python
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python (python) in auto mode
$ sudo update-alternatives --list python
/usr/bin/python3.8
$ python --version
Python 3.8.10
$ sudo update-alternatives --config python
There is only one alternative in link group python (providing /usr/bin/python): /usr/bin/python3.8
Nothing to configure.
修改 Python pip 源
为了加快 Python 包的下载速度,可将 pip 源切换到国内,例如切换为国内阿里的源。
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
pip config set global.trusted-host mirrors.aliyun.com
$ pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
Writing to /home/mary/.config/pip/pip.conf
$ pip config set global.trusted-host mirrors.aliyun.com
Writing to /home/mary/.config/pip/pip.conf
$ cat /home/mary/.config/pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com
其他问题
1.ubuntu 下执行 ifconfig 失败如何解决?
原因:
在 Ubuntu 系统中默认没有安装工具包,所以无法显示 ifconfig 命令。
解决方法:提前获取超级权限安装 net-tools,完成后再调用 ifconfig 命令即可调用出相关信息。
sudo apt install net-tools
$ ifconfig
ens33: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.121.130 netmask 255.255.255.0 broadcast 192.168.121.255
inet6 fe80::d9a5:fd3f:c4ca:2676 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:01:6b:26 txqueuelen 1000 (Ethernet)
RX packets 26356 bytes 31157090 (31.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4053 bytes 432988 (432.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 1867 bytes 165808 (165.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1867 bytes 165808 (165.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- VS Code 窗口全部字体大小缩放设置 - 快捷键
// 同时按住键盘 "ctrl" 和 "+" 按钮,即:
Ctrl + // 放大效果
Ctrl - // 缩小效果