# Linux
###### tags: `linux` `Linux` `學習紀錄`
[TOC]
## 影片
### [進度](https://youtu.be/lwbMWIxUluY?list=PLmOn9nNkQxJEEfgfPo0IMwu8ac5DIWYd3)
### [shell 部分](https://youtu.be/d99uNVMkDio?list=PLmOn9nNkQxJEEfgfPo0IMwu8ac5DIWYd3)
## Jserv
### [現在正在看的總綱](https://hackmd.io/@sysprog/linux-kernel-internal)
### [現在正在看的影片](https://youtu.be/nUXxdgszJAQ?t=3215)
### [筆記](https://hackmd.io/@sysprog/linux-kernel-internal)
### [聊天室](https://gitter.im/embedded2015/guts-general)
### [YT](https://www.youtube.com/c/GUTS4tech/videos)
### Jserv 筆記
* 
* 源碼閱讀順序推薦
1. documentation : 門檻高,要先知道一些關鍵字會比較好 ex: networking, spinlock...
2. include : 123
## 交大開放課程
### [作業系統設計與實作](https://youtu.be/VXwFoa2QhaI?list=PLj6E8qlqmkFvCxHVYYVYtnPuQb3NeOlUb&t=2472)
## 指令
### sed
* [sed 參考網站](https://www.hy-star.com.tw/tech/linux/sed/sed.html)
### tar 壓縮相關
* 壓縮
* tar -zcvf RESULTFILE.tar.gz file1.exe file2.txt dir1/ dir2/ ...
* 解壓縮
* tar -zxvf WANTUNZIPFILE.tar.gz -C /DESTINATION...
* 
* [影片](https://youtu.be/7CrF8eyOmlM?list=PLmOn9nNkQxJEEfgfPo0IMwu8ac5DIWYd3)
### vim
* [VI 魔鬼的編輯器](https://www.hy-star.com.tw/tech/linux/vi/vi.html)
* [指令介紹多的網站](https://vim.rtorr.com/lang/zh_tw)
* [指令敘述不錯的網站](http://www.study-area.org/tips/vim/Vim-3.html)
* [Windows Terminal 默认配置 ctrl v 与 vim 快捷键冲突](https://www.sunzhongwei.com/windows-terminal-default-configuration-conflict-with-vim-shortcut-ctrl-v)
* 
* [給程式設計師的Vim入門圖解說明](https://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/)
* [pdf 圖示](https://blog.vgod.tw/wp-content/uploads/2014/08/vgod-vim-cheat-sheet-full.pdf)
* [指令表 github 介紹頁面](https://github.com/chloneda/vim-cheatsheet)
```shell
# 第二個以後的參數
${@:2}
# 參數個數
$#
# 最後一個參數
${!#}
```
### grep
* [grep 簡介](https://ithelp.ithome.com.tw/articles/10265120)
* [Linux grep 命令](https://www.runoob.com/linux/linux-comm-grep.html)
* [Linux 匹配文字 grep 指令用法教學與範例](https://blog.gtwang.org/linux/linux-grep-command-tutorial-examples/)
### awk
* [awk 文字記錄的資料處理](https://www.hy-star.com.tw/tech/linux/awk/awk.html)
### wc
* [Linux 使用 wc 指令計算字數、行數教學與範例](https://blog.gtwang.org/linux/linux-wc-command-tutorial-examples/)
### pkill
* [Linux系统下强制踢掉登录用户](https://blog.csdn.net/qq_16542775/article/details/62046699)
* 
```shell
pkill -kill -t pts/0
```
### fail2ban
#### 手動 ban 特定 IP
```shell
fail2ban-client set sshd banip 195.226.194.242
```
#### 取得 fail2ban ban 掉的不重複 IP 數量
```shell
cat /var/log/fail2ban.log | grep "NOTICE \[sshd\] Ban" | grep "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" -o | sort | uniq | grep ".*" -c
```
* grep -o "regex" : 只列出匹配的結果
* 排序
* 去重 : 只會去相鄰的
### 綜合使用
#### 取得出現次數前 10 的 IP
```shell
grep -i -o -E "([0-9]{1,3}\.){3}[0-9]{1,3}" /var/log/fail2ban.log | sort -n | uniq -c | sort -nr | head -10
```
* 
### [命令列主機資訊查詢cpu、ram及disk](https://www.ccc.tc/article/cli-check-cpu-ram-disk-on-linux?page=4)
### 尚未知曉的指令紀錄
* ping -c1 8.8.8.8
* ping 一次 8.8.8.8
* ping -c1 8.8.8.8 &>/dev/null
* ping 一次 8.8.8.8 且將動作返回的訊息丟棄
* ping -c1 8.8.8.8 && echo "up" || echo "down"
* ping 一次 8.8.8.8 並對動作結果的成功與否做判斷
* 做完一個動作之後會由 $? 來判斷成功與否
* 當 $? == 0 ,代表動作成功,會執行 && 後的動作
* 當 $? != 0 ,代表動作失敗,會執行 || 後的動作
### cron & crontab
#### sudo cron {start|stop|status|restart|reload|force-reload}
* 這個沒開的話 crontab 設定的動作也不會執行
#### crontab -e
* 設定要做甚麼動作
### [Ubuntu 查詢全部環境變數](https://www.arthurtoday.com/2015/02/ubuntu-lists-all-variables-in-shell.html)
* declare 指令可以用來宣告變數
* 也可以用來依不同的選項來顯示指定類型的環境變數
* 如果不給任何的選項給 declare 指令的話,效果就和直接執行 set 指令相同
* 而只想看環境變數,不想看到函式的話,那就用下面這一行的指令來查就可以了。
```shell
declare -p | more
```
## 開源專案相關
### [開頭被建議要讀的手冊](https://www.kernel.org/doc/html/latest/admin-guide/index.html)
### [github](https://github.com/torvalds/linux)
## 國立清華大學開放式課程
* [影片](https://www.youtube.com/watch?v=3PfL2WIS22o&list=PLS0SUwlYe8czigQPzgJTH2rJtwm0LXvDX&ab_channel=NTHUOCW)
## 周志遠作業系統
* [影片](https://www.youtube.com/watch?v=7EOttqasc5U&list=PL9jciz8qz_zyO55qECi2PD3k6lgxluYEV&index=1)
## 中正大學作業系統
* [影片](https://www.youtube.com/watch?v=hD8nCwwbvqg&list=PLMWkAn-aOA0bRR7n_A86Hs51B2WrAQA9i&ab_channel=ShiwuLo)
## 快速起一個 laravel 專案的 shell
* [github](https://github.com/kawagami/laravel-with-laradock-in-one-command)
## 千鋒 linux shell 入門
* [影片](https://youtu.be/Qxlsj1xVcnw?list=PLwDQt7s1o9J4FMviSY4p5rhC43kBPvJvO&t=95)
## linux 介面顏色修改
* [參考](https://it001.pixnet.net/blog/post/357658754)
# 講解 linux 如何入門的文章
* [連結](https://www.readfog.com/a/1713713362858250240)