-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
在本课程中,我学习了 Linux 命令行操作和 Shell 脚本编写。这一学习过程使我对 Linux 的工作原理有了更深的理解,同时掌握了编写自动化脚本的基本能力。 | ||
|
||
## 1. Linux 命令行 | ||
|
||
### 1.1 文件与目录操作 | ||
|
||
- `ls`:列出目录内容,用于查看文件和目录。 | ||
- `cd`:切换目录。 | ||
- `pwd`:显示当前工作目录。 | ||
- `mkdir` 和 `rmdir`:创建和删除目录。 | ||
- `touch`:创建空文件。 | ||
- `cp`、`mv` 和 `rm`:复制、移动和删除文件。 | ||
|
||
### 1.2 文件内容查看与编辑 | ||
|
||
- `cat`、`more`、`less`:查看文件内容。 | ||
- `nano` 和 `vim`:在终端中编辑文件。 | ||
|
||
## 2. Linux 系统管理 | ||
|
||
### 2.1 进程管理 | ||
|
||
- `ps`:查看当前进程。 | ||
- `top` 和 `htop`:实时监控系统资源使用。 | ||
- `kill`:终止进程。 | ||
- `jobs` 和 `bg`/`fg`:管理后台任务。 | ||
|
||
## 3. Shell 脚本编写 | ||
|
||
### 3.1 基础语法 | ||
|
||
- **变量**:使用 `$` 来调用变量。 | ||
- **条件判断**:使用 `if-else` 判断语句。 | ||
- **循环结构**:包括 `for`、`while`、`until` 等循环。 | ||
- **函数**:将代码块封装成函数,提高代码复用性。 | ||
|
||
### 3.2 常用命令 | ||
|
||
- `awk` 和 `sed`:文本处理工具,用于格式化文本输出和批量替换。 | ||
- `grep`:用于文本搜索。 | ||
- `find`:查找文件。 | ||
- `cron`:定时任务管理。 | ||
|
||
## 4. 总结 | ||
|
||
学习该课程提高了我对 Linux 命令行操作的熟练度,还让我理解了自动化任务的重要性。通过学习 Shell 脚本,我能够将日常管理任务自动化,极大地提高了工作效率。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
## 问题 1: | ||
|
||
### 方法一: | ||
|
||
1. **命令**: | ||
```bash | ||
git reset --hard HEAD | ||
``` | ||
|
||
2. **截图**: | ||
- ![使用 git reset 回退所有修改](./截图-2024-10-26-16-28-18.png) | ||
|
||
### 方法二: | ||
|
||
1. **取消暂存区的更改**: | ||
```bash | ||
git restore --staged <file> | ||
``` | ||
|
||
2. **回退工作区的更改**: | ||
```bash | ||
git restore <file> | ||
``` | ||
|
||
3. **截图**: | ||
- ![取消暂存的更改和回退工作区的更改](./截图-2024-10-26-16-34-07.png) | ||
|
||
## 问题 2:回退已提交的版本 | ||
|
||
|
||
### 方法一: | ||
|
||
1. **命令**: | ||
```bash | ||
git revert <commit_hash> | ||
``` | ||
|
||
2. **截图**: | ||
- ![使用 git revert 创建新的提交](./截图-2024-10-26-16-41-53.png) | ||
|
||
### 方法二: | ||
|
||
1. **命令**: | ||
```bash | ||
git reset --hard <commit_hash> | ||
``` | ||
|
||
2. **截图**: | ||
- ![硬回退](./截图-2024-10-26-16-42-49.png) | ||
|
||
## 问题 3: | ||
|
||
### 方法一: | ||
|
||
1. **命令**: | ||
```bash | ||
git checkout feature-branch | ||
git rebase main | ||
``` | ||
|
||
2. **截图**: | ||
- ![使用 git rebase 合并分支](./截图-2024-10-26-16-45-07.png) | ||
|
||
### 方法二: | ||
|
||
1. **命令**: | ||
```bash | ||
git checkout main | ||
git cherry-pick <commit_hash> | ||
``` | ||
|
||
2. **截图**: | ||
- ![使用 git cherry-pick 选择性合并提交](./截图-2024-10-26-16-47-32.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.