跳转至

安装与使用 Linux

作为 Day 1,今天的内容还是比较放松的。只需基本的计算机操作水平和一点 C 语言基础即可。

本节内容:

  • 在虚拟机上安装 Linux
  • Shell 的使用

有用的参考资料:

安装 Linux

当然,我们不会在这里介绍每一个虚拟机软件,这方面的选取当然看你自己。这里列出一些主流的虚拟机软件:

  • Parallels Desktop(推荐 macOS 使用)
  • VMware
  • Oracle VirtualBox

下载 Linux 镜像

本课程中推荐使用 Debian Linux。当然,如果你对 Linux 已经有了初步的了解,完全可以按自己习惯的发行版来,不影响后续课程。

GNOME 登录界面

Apple Silicon Specials

很好,你我都是敢于用 M 系列芯片的敢死队。

目前绝大部分电脑都是 x86_64 指令集架构,这也意味着我们这些 arm64 或称 aarch64 架构的用户注定要走他们不用走的弯路。虽然没有 arm64 版本的 Live CD 环境,但所幸 Debian 足够好,可以在安装时就选择想要使用的桌面环境。至于 Ubuntu 用户,祝他们在 Canonical 的领导下一切顺利。

选择桌面环境

配置 APT 源

现在打开终端,溜点传统的 apt update。但是,它可能会报这样的错误:

user@debian:~$ sudo apt update
[sudo] user 的密码:
Ign:1 cdrom://[Debian GNU/Linux 12.4.0 _Bookworm_ - Official arm64 DVD Binary-1 with firmware 20231210-17:57] bookworm InRelease
Err:2 cdrom://[Debian GNU/Linux 12.4.0 _Bookworm_ - Official arm64 DVD Binary-1 with firmware 20231210-17:57] bookworm Release
  Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs
Hit:3 http://mirrors.tuna.tsinghua.edu.cn/debian bookworm InRelease
Hit:4 http://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates InRelease
Hit:5 http://security.debian.org/debian-security bookworm-security InRelease
Reading package lists... Done
E: The repository 'cdrom://[Debian GNU/Linux 12.4.0 _Bookworm_ - Official arm64 DVD Binary-1 with firmware 20231210-17:57] bookworm Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

这是因为,在安装 Debian 的时候 APT 源被设为我们选择的 ISO 镜像,但现在 ISO 镜像没有被连接到虚拟机。当然,如果已经进行到这一步,那它本就不应该还是 ISO 镜像。请参考镜像站使用帮助(ZJU MirrorTUNA)来手动设置 APT 源。

切换主目录为英文(可选)

如果安装时选择了中文,那么用户主目录下面的几个目录会是中文。当然,这没什么不好,但一般而言中文路径是应当避免的。但是,不要手动更改。我们需要在终端中设置 LANG 环境变量后运行 xdg-user-dirs-update。这可以在一行内完成。

Bash Session
1
2
3
4
5
6
7
8
9
user@debian:~$ LANG=C xdg-user-dirs-update --force
Moving DESKTOP directory from 桌面 to Desktop
Moving DOWNLOAD directory from 下载 to Downloads
Moving TEMPLATES directory from 模板 to Templates
Moving PUBLICSHARE directory from 公共 to Public
Moving DOCUMENTS directory from 文档 to Documents
Moving MUSIC directory from 音乐 to Music
Moving PICTURES directory from 图片 to Pictures
Moving VIDEOS directory from 视频 to Videos

如果重启后弹窗询问是否要将目录切换为中文,勾选“不再提示”并选择否。

英文主目录

使用 Linux

至此,我们的安装过程就算完成了!现在我们会留出一些时间让大家体验体验。开一局 2048 或者俄罗斯方块,体验一把 Linux Gaming(✕


怎么样,打完了?很好,那么我们继续。

(TODO)

Homework

编程题,限定语言为 Bash。

评论