diff --git a/doc/bash b/doc/bash.md similarity index 100% rename from doc/bash rename to doc/bash.md diff --git a/doc/cmd b/doc/cmd.md similarity index 100% rename from doc/cmd rename to doc/cmd.md diff --git a/doc/general b/doc/general.md similarity index 51% rename from doc/general rename to doc/general.md index 0b9b121..183e83a 100644 --- a/doc/general +++ b/doc/general.md @@ -150,11 +150,10 @@ Default configuration file: `/etc/xdg/picom.conf` ## xwallpaper `xwallpaper --zoom filename` -# PDF +## PDF application/pdf) pdftoppm -f 1 -l 1 \ -``` ## imagemagick Image viewer in terminal @@ -224,152 +223,6 @@ directory of Trash: `~/.local/share/Trash/` C headfer files located in `/usr/include/` -## (IP) Internel Protocol - -`sudo pacman -S net-tools bind` - -Private IP range: -10.0.0.0 to 10.255.255.255 -172.16.0.0 to 172.31.255.255 -192.168.0.0 to 192.168.255.255 - -port: 65535 ports in total (16 bits). -Restircted: 0 - 1023 - -Common ports: -22: secure shell -53: DNS -80: HTTP -179: border gateway protocol -443: HTTPS -8080: web server -3360: TCP/IP - - -## Check IP - -| Cmd | Remark | -|-----------------------------------------------|-------------------------------| -| `ip addr` | Private IP | -| `ifconfig` | Private IP | -| `host myip.opendns.com resolver1.opendns.com` | Public IP, shown at last line | - -IP of router (access point) that you are connected to -In windows: default gateway -In linux: `route -n` - -## Change IP - -| Cmd | Remark | -|----------------------------------------------|----------------| -| `sudo ip addr add [ip_addr] dev [interface]` | Add private IP | -| `sudo ip addr del [ip_addr] dev [interface]` | Del private IP | -| Not easy to change public ip | | - -## NIC - -To check NIC devices, ip and mac. - -| Cmd | -|----------------| -| `netstat -i` | -| `ip link` | -| `ifconfig` | - -mtu: max transfer unit - - -For example, I have three NICs -1. enp0s31f6, en. it means ethernet, bus number 0 (p0) and slot number 31 (s31) -and function nuber 6 (f6), This is ethernet interface. -2. lo, local. it means loopback device with ip addr 127.0.0.1. If you run a webserver on your machine -and browse it using browser with the same machine, it uses this device. -3. wlp2s0, wl. it means wlan(wireless local area network). bus nubmer 2 and slot nubmer 0 - -## LAN - -LAN usually spans a building or campus - -- LAN - - Wired: ethernet, using coaxial cable - - bus : popular last century - - switched: popular today - - Wireless: WLAN, wifi - -Check devices that are in the same LAN as you -1. `arp-scan --localnet` -2. `nmap `, e.g. `nmap 192.168.100.0-254` -3. use `ipscan` -4. use advanced ip scanner - -It's better to use several tools together to find info, as some results are incomplete. - -Common Ethernet interface type: RJ45. - -## IW - -manipulate wireless devices - -| CMD | Description | -|---------------------------|--------------------------------| -| `iw dev` | get name of wireless interface | -| `iw dev link` | show link status | -| `iw dev scan` | search access points | - - -## ip cmd - -| CMD | Description | -|------------------------------|------------------------------------| -| `ip link show` | similar to ifconfig | -| `ip link show ` | show status of a certain interface | -| `sudo ip link set up/down` | activate/deactiviate interface | - - -## Geth - -geth default port: 8545 -simulation mode - -| CMD | Comment | -|------------------------------------------------------------------------------------------------|---------------------------------------| -| `geth --datadir account new` | create new account, key in ./keystore | -| `geth --datadir account new` | create another one | -| `geth --datadir --dev --password ./secret.txt` | | -| On anther terminal `geth attach ` | ipc_addr show according to above cmd | -| in console, `eth` | show relevant functions | -| `eth.accounts` | display accounts | -| `eth.coinbase` | | -| `eth.getBalance(eth.accounts[0])` | show balance | -| `eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:web3.toWei(1.5,"Ether")})` | transfer,node will show tx hash | - -Test to sepolia network - -`curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh` - -| CMD | Comment | -|---------------------------------------------------------------------------|----------------------| -| `geth --datadir --sepolia --http -http.api eth,net,web,admin` | | -| `eth.syncing` | check if syncing | -| `eth.blockNumber` | lastest block number | -| `curl http://localhost:3500/eth/v1/node/syncing` | check beacon node sync status | - -JSON-RPC -``` -curl -X POST -H "Content-Type: application/json" - 127.0.0.1:8545 --data \ - '{"jsonrpc":"2.0", \ - "method":eth_accounts}, \ - "params": [], \ - "id": 1 }' \ -``` - -curl -H "Content-Type: application/json" -X POST localhost:8545 --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0x2059dd53ecac9827faad14d364f9e04b1d5fe5b506e3acc886eff7a6f88a696a"],"id":1}' - -curl -H "Content-Type: application/json" -X POST localhost:8545 --data '{"jsonrpc":"2.0","method":"debug_traceBlockByNumber","params":["0x11fce84",{"disableStorage":false,"enableMemory":true,"enableReturnData":true}],"id":1}' - - - ## lspci | CMD | Comment | diff --git a/doc/knowledge b/doc/knowledge.md similarity index 100% rename from doc/knowledge rename to doc/knowledge.md diff --git a/doc/makefile b/doc/makefile.md similarity index 100% rename from doc/makefile rename to doc/makefile.md diff --git a/doc/network.md b/doc/network.md new file mode 100644 index 0000000..3985398 --- /dev/null +++ b/doc/network.md @@ -0,0 +1,169 @@ +# Network + + +## Topology + +### Application Layer + +HTTP, cookies, proxy server, DNS + +### Transport Layer + +### Network Layer +device: router +routing +IP address + +### Link Layer +device: switch +MAC address +ARP (address resolution protocol) +LAN + - Wired: Ethernet + - Wireless: WLAN + +### Physical Layer + +## (IP) Internel Protocol + +`sudo pacman -S net-tools bind` + +Private IP range: +10.0.0.0 to 10.255.255.255 +172.16.0.0 to 172.31.255.255 +192.168.0.0 to 192.168.255.255 + +port: 65535 ports in total (16 bits). +Restircted: 0 - 1023 + +Common ports: +22: secure shell +53: DNS +80: HTTP +179: border gateway protocol +443: HTTPS +8080: web server +3360: TCP/IP + + +## Check IP + +| Cmd | Remark | +|-----------------------------------------------|-------------------------------| +| `ip addr` | Private IP | +| `ifconfig` | Private IP | +| `host myip.opendns.com resolver1.opendns.com` | Public IP, shown at last line | + +IP of router (access point) that you are connected to +In windows: default gateway +In linux: `route -n` + +## Change IP + +| Cmd | Remark | +|----------------------------------------------|----------------| +| `sudo ip addr add [ip_addr] dev [interface]` | Add private IP | +| `sudo ip addr del [ip_addr] dev [interface]` | Del private IP | +| Not easy to change public ip | | + +## NIC + +To check NIC devices, ip and mac. + +| Cmd | +|----------------| +| `netstat -i` | +| `ip link` | +| `ifconfig` | + +mtu: max transfer unit + + +For example, I have three NICs +1. enp0s31f6, en. it means ethernet, bus number 0 (p0) and slot number 31 (s31) +and function nuber 6 (f6), This is ethernet interface. +2. lo, local. it means loopback device with ip addr 127.0.0.1. If you run a webserver on your machine +and browse it using browser with the same machine, it uses this device. +3. wlp2s0, wl. it means wlan(wireless local area network). bus nubmer 2 and slot nubmer 0 + +## LAN + +LAN usually spans a building or campus + +- LAN + - Wired: ethernet, using coaxial cable + - bus : popular last century + - switched: popular today + - Wireless: WLAN, wifi + +Check devices that are in the same LAN as you +1. `arp-scan --localnet` +2. `nmap `, e.g. `nmap 192.168.100.0-254` +3. use `ipscan` +4. use advanced ip scanner + +It's better to use several tools together to find info, as some results are incomplete. + +Common Ethernet interface type: RJ45. + +## IW + +manipulate wireless devices + +| CMD | Description | +|---------------------------|--------------------------------| +| `iw dev` | get name of wireless interface | +| `iw dev link` | show link status | +| `iw dev scan` | search access points | + + +## ip cmd + +| CMD | Description | +|------------------------------|------------------------------------| +| `ip link show` | similar to ifconfig | +| `ip link show ` | show status of a certain interface | +| `sudo ip link set up/down` | activate/deactiviate interface | + + +## Geth + +geth default port: 8545 +simulation mode + +| CMD | Comment | +|------------------------------------------------------------------------------------------------|---------------------------------------| +| `geth --datadir account new` | create new account, key in ./keystore | +| `geth --datadir account new` | create another one | +| `geth --datadir --dev --password ./secret.txt` | | +| On anther terminal `geth attach ` | ipc_addr show according to above cmd | +| in console, `eth` | show relevant functions | +| `eth.accounts` | display accounts | +| `eth.coinbase` | | +| `eth.getBalance(eth.accounts[0])` | show balance | +| `eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:web3.toWei(1.5,"Ether")})` | transfer,node will show tx hash | + +Test to sepolia network + +`curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh` + +| CMD | Comment | +|---------------------------------------------------------------------------|----------------------| +| `geth --datadir --sepolia --http -http.api eth,net,web,admin` | | +| `eth.syncing` | check if syncing | +| `eth.blockNumber` | lastest block number | +| `curl http://localhost:3500/eth/v1/node/syncing` | check beacon node sync status | + +JSON-RPC +``` +curl -X POST -H "Content-Type: application/json" + 127.0.0.1:8545 --data \ + '{"jsonrpc":"2.0", \ + "method":eth_accounts}, \ + "params": [], \ + "id": 1 }' \ +``` + +curl -H "Content-Type: application/json" -X POST localhost:8545 --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0x2059dd53ecac9827faad14d364f9e04b1d5fe5b506e3acc886eff7a6f88a696a"],"id":1}' + +curl -H "Content-Type: application/json" -X POST localhost:8545 --data '{"jsonrpc":"2.0","method":"debug_traceBlockByNumber","params":["0x11fce84",{"disableStorage":false,"enableMemory":true,"enableReturnData":true}],"id":1}' diff --git a/doc/software b/doc/software.md similarity index 99% rename from doc/software rename to doc/software.md index f8355a5..60c562a 100644 --- a/doc/software +++ b/doc/software.md @@ -131,7 +131,6 @@ Placeholder | Description #### PDF Preview Uncomment the following part in "scope.sh" -``` ### Onedrive onedrive on linux: insync with aur. Works but slow diff --git a/open_doc b/open_doc index bff65ed..cf06316 100755 --- a/open_doc +++ b/open_doc @@ -2,30 +2,33 @@ usage() { - echo "Arguments: [ge]neral [cm]d [kn]owledge [ba]sh [so]ftware [ma]kefile" + echo "Arguments: [ge]neral [cm]d [kn]owledge [ba]sh [so]ftware [ma]kefile [ne]twork" } open() { path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" case "$1" in ge|general) - nvim ${path}/doc/general + nvim ${path}/doc/general.md ;; cm|cmd) - nvim ${path}/doc/cmd + nvim ${path}/doc/cmd.md ;; kn|knowledge) - nvim ${path}/doc/knowledge + nvim ${path}/doc/knowledge.md ;; ba|bash) - nvim ${path}/doc/bash + nvim ${path}/doc/bash.md ;; so|software) - nvim ${path}/doc/software + nvim ${path}/doc/software.md ;; ma|makefile) - nvim ${path}/doc/makefile + nvim ${path}/doc/makefile.md ;; + ne|net|network) + nvim ${path}/doc/network.md + ;; *) usage ;;