Linux

tags: linux Linux 學習紀錄

影片

進度

shell 部分

Jserv

現在正在看的總綱

現在正在看的影片

筆記

聊天室

YT

Jserv 筆記

  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • 源碼閱讀順序推薦
    1. documentation : 門檻高,要先知道一些關鍵字會比較好 ex: networking, spinlock
    2. include : 123

交大開放課程

作業系統設計與實作

指令

sed

tar 壓縮相關

  • 壓縮
    • tar -zcvf RESULTFILE.tar.gz file1.exe file2.txt dir1/ dir2/
  • 解壓縮
    • tar -zxvf WANTUNZIPFILE.tar.gz -C /DESTINATION
  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • 影片

vim


# 第二個以後的參數
${@:2}

# 參數個數
$#

# 最後一個參數
${!#}

grep

awk

wc

pkill

pkill -kill -t pts/0

fail2ban

手動 ban 特定 IP

fail2ban-client set sshd banip 195.226.194.242

取得 fail2ban ban 掉的不重複 IP 數量

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

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
  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

命令列主機資訊查詢cpu、ram及disk

尚未知曉的指令紀錄

  • 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 sstoptstatusarestartrreloadtforce-reload

  • 這個沒開的話 crontab 設定的動作也不會執行

crontab -e

  • 設定要做甚麼動作

Ubuntu 查詢全部環境變數

  • declare 指令可以用來宣告變數
  • 也可以用來依不同的選項來顯示指定類型的環境變數
  • 如果不給任何的選項給 declare 指令的話,效果就和直接執行 set 指令相同
  • 而只想看環境變數,不想看到函式的話,那就用下面這一行的指令來查就可以了。
declare -p | more

開源專案相關

開頭被建議要讀的手冊

github

國立清華大學開放式課程

周志遠作業系統

中正大學作業系統

快速起一個 laravel 專案的 shell

千鋒 linux shell 入門

linux 介面顏色修改

講解 linux 如何入門的文章