Linux 教程
Linux 是什么、为什么后端必须会,以及一台新机器上手先做哪几件事。
Key PointsLinux 是服务器上的默认操作系统;后端要会的是:看进程、看日志、看磁盘、改配置、管权限。
Linux 是什么
Strictly, Linux is only the kernel. What you install is a distribution — kernel plus GNU tools, a package manager and an init system: Ubuntu, Debian, Rocky, Alpine. Commands are largely the same; the differences are packaging and defaults.
为什么后端必须会
| Task | What you need |
|---|---|
| Service is slow | top, iostat, ss, strace |
| Disk full | df, du, lsof |
| Can't connect | ss -lntp, curl -v, tcpdump |
| Deploy a service | systemctl, journalctl, 权限, 环境变量 |
| Read logs | tail -f, grep, awk, less |
新机器上手五件事
Bash
uname -a # 内核与架构
cat /etc/os-release # 发行版与版本
df -h # 磁盘剩余
free -h # 内存
systemctl status ssh # SSH 是否在跑学习路线
- 安装与登录 —— 本地装、云主机、WSL
- 目录与文件 —— 结构、权限、增删改查
- 用户与磁盘 —— 账号、组、挂载
- 编辑器与包管理 —— vim、yum/apt
- Shell 脚本 —— 变量、判断、循环、函数、重定向
Do not memorise commands. Remember the problem, then read
man or --help. Only twenty-odd commands really matter.Linux 是什么
严格说 Linux 只是内核。我们日常说的「装了个 Linux」,指的是内核 + GNU 工具 + 包管理器 + 服务管理组成的发行版,比如 Ubuntu、Debian、Rocky、Alpine。它们命令大同小异,差别主要在包管理和默认配置。
为什么后端必须会
| 场景 | 要用的东西 |
|---|---|
| 服务变慢 | top、iostat、ss、strace |
| 磁盘满了 | df、du、lsof |
| 连不上 | ss -lntp、curl -v、tcpdump |
| 部署服务 | systemctl、journalctl、权限、环境变量 |
| 看日志 | tail -f、grep、awk、less |
新机器上手五件事
Bash
uname -a # 内核与架构
cat /etc/os-release # 发行版与版本
df -h # 磁盘剩余
free -h # 内存
systemctl status ssh # SSH 是否在跑学习路线
- 安装与登录 —— 本地装、云主机、WSL
- 目录与文件 —— 结构、权限、增删改查
- 用户与磁盘 —— 账号、组、挂载
- 编辑器与包管理 —— vim、yum/apt
- Shell 脚本 —— 变量、判断、循环、函数、重定向
不要背命令。记住「要解决什么问题」,然后
man xxx 或 xxx --help。真正高频的只有二三十个命令。