以下是为零基础学习者设计的Linux系统入门到精通的教程大纲,包含实用案例和渐进式学习路径:
第一阶段:Linux基础入门(1-2周)
1. Linux系统概述
- 什么是Linux?与Windows/Mac的区别
- 主流发行版介绍(Ubuntu/CentOS/Debian)
- 实验:通过VirtualBox安装Ubuntu虚拟机
2. 终端基础操作
终端打开方式与基本结构
20个必学命令:
1
2
3
4
5
6
7
8
9
10pwd # 显示当前路径
ls -l # 详细文件列表
cd ~/Documents # 切换目录
mkdir project # 创建目录
touch file.txt # 创建空文件
cp file.txt backup/ # 复制文件
rm -r old_dir # 删除目录
cat file.txt # 查看文件内容
grep "error" log.txt # 文本搜索
sudo apt update # 更新软件列表实例:创建
/home/user/project目录,在其中创建3个测试文件并备份
3. 文件权限管理
- 理解rwx权限
chmod 755 script.sh(设置可执行权限)chown user:group file(修改所有者)- 案例:创建共享目录,设置组用户可读写权限
第二阶段:系统管理实战(2-3周)
1. 用户与组管理
- 创建用户并设置密码:
1
2sudo adduser alice
sudo passwd alice - 用户组管理:
1
2sudo groupadd developers
sudo usermod -aG developers alice
2. 软件包管理
- APT/DNF实战:
1
2
3sudo apt install nginx # 安装Web服务器
sudo apt remove --purge nano # 完全卸载
sudo apt search python3 # 搜索软件包
3. 进程与系统监控
- 查看进程树:
pstree - 终止进程:
kill -9 1234 - 系统监控命令:
1
2
3top # 动态监控
free -h # 内存使用
df -Th # 磁盘空间
4. 定时任务(Cron)
- 编辑crontab:
crontab -e - 示例:每天凌晨备份
1
0 3 * * * tar -czf /backup/home_$(date +\%F).tar.gz /home
第三阶段:Shell脚本编程(2周)
1. 基础脚本开发
- 第一个脚本
hello.sh:1
2
echo "Hello, $USER! Today is $(date)" - 执行:
chmod +x hello.sh && ./hello.sh
2. 条件与循环
- 文件存在检查:
1
2
3
4
5if [ -f "lockfile" ]; then
echo "系统正在维护中..."
else
echo "系统正常运行"
fi - 批量重命名脚本:
1
2
3for file in *.log; do
mv "$file" "archive/$(date +%Y%m%d)_$file"
done
3. 实用脚本案例
- 自动备份脚本:
1
2
3
4
5
6
7
BACKUP_DIR="/backup"
SOURCE_DIR="/var/www"
FILENAME="backup_$(date +%Y%m%d).tar.gz"
tar -czf $BACKUP_DIR/$FILENAME $SOURCE_DIR
echo "备份完成于 $(date)" >> $BACKUP_DIR/backup.log
第四阶段:网络与安全管理(1周)
1. 网络配置
- 查看IP:
ip addr show - 设置静态IP(Ubuntu示例):
1
2
3
4
5
6
7
8
9
10# /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
2. 防火墙管理
- 开放SSH端口:
1
2sudo ufw allow 22/tcp
sudo ufw enable
3. SSH远程管理
- 密钥认证配置:
1
2ssh-keygen -t rsa
ssh-copy-id user@remote-server
第五阶段:开发环境搭建(1周)
1. Python环境配置
- 安装Python虚拟环境:
1
2
3sudo apt install python3-venv
python3 -m venv myenv
source myenv/bin/activate
2. Git版本控制
- 基础工作流:
1
2
3
4
5git clone https://github.com/user/repo.git
git checkout -b feature-branch
git add .
git commit -m "添加新功能"
git push origin feature-branch
第六阶段:高级实战(持续学习)
1. 容器技术入门
- Docker快速部署Nginx:
1
docker run -d -p 80:80 --name webserver nginx
2. 脚本调试技巧
- 调试模式运行:
1
bash -x script.sh
学习资源推荐
- 在线练习:https://overthewire.org/wargames/bandit/
- 交互教程:https://linuxjourney.com/
- 经典书籍:《鸟哥的Linux私房菜》《Linux命令行与Shell脚本编程大全》
- 社区支持:Stack Overflow、Linux中国论坛
通过这个系统化的学习路径,配合每天1-2小时的实践操作,零基础学习者可在2-3个月内掌握Linux系统的基础运维和自动化脚本编写能力。关键是多在真实环境中操作,遇到问题善用man手册和网络搜索。