File/Folder
touch filename
mdkir foldername
Move
cd - : go to previous directory
cd / cd ~ : go to home directory
Type
C-u: delete all lineC-w: delete word
Search 搜尋
- ctrl + r
type keyword to search history command !! <Enter>
grep -r "keyword" .
# brew install ripgrep
rg <word>
# 在多層目錄中找到filename.txt的路徑
find . -name {filename.txt}
Kill process running port
lsof -i:3000
kill <PID>
目錄大小
du -sh <path>
ssh
ssh {url} -l {login_name} -p {port}
wget
wget {url} 把檔案抓下來
netcat
TCP/IP 瑞士刀 (Swiss Army Knife)
nc <host> <port>
nc example.com 12345
import socket
s = socket.socket()
s.connect(("example.com", 12345))
while True:
data = input("> ")
s.send(data.encode())
response = s.recv(4096)
print(response.decode())
strings
把binary file -> string
strings -a -t x file
-a : all
-t x : 十六進位顯示
讀檔
open('dictionary.txt', 'rb').read()
open('dictionary.txt', 'r').read().splitlines()
open('dictionary.txt', 'rb').read().decode('utf-8')
更改權限
chmod +x filename
# read r 4
# write w 2
# execute x 1