This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
code:linux [2017/03/27 17:25] hansek |
code:linux [2023/11/11 00:39] (current) hansek [jq] |
||
|---|---|---|---|
| Line 145: | Line 145: | ||
| Pro více typů zopakovat celou konstrukci **! -name ' | Pro více typů zopakovat celou konstrukci **! -name ' | ||
| + | Na ČH, kde je pouze `find`: | ||
| + | <code bash> | ||
| + | # on remote server | ||
| + | find . -type f -printf " | ||
| + | |||
| + | # on localhost | ||
| + | |||
| + | scp remote: | ||
| + | |||
| + | cat last_changes.txt | ||
| + | |||
| + | # or with striping some lines | ||
| + | |||
| + | sed '/ | ||
| + | </ | ||
| ===== Výpis 20 největších souborů na FS v rámci adresáře ===== | ===== Výpis 20 největších souborů na FS v rámci adresáře ===== | ||
| Vynechání některých souborů viz předchozí. | Vynechání některých souborů viz předchozí. | ||
| Line 189: | Line 204: | ||
| - | ==== Grep DataDog logs from syslog ==== | + | ===== Grep DataDog logs from syslog |
| <code bash> | <code bash> | ||
| tailf / | tailf / | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Clean up old kernels | ||
| + | Source: https:// | ||
| + | |||
| + | Check current version and **DO NOT REMOVE THIS KERNEL!** | ||
| + | <code bash> | ||
| + | uname -r | ||
| + | </ | ||
| + | |||
| + | List all kernels | ||
| + | <code bash> | ||
| + | dpkg --list | grep linux-image | ||
| + | </ | ||
| + | |||
| + | Delete/ | ||
| + | <code bash> | ||
| + | sudo apt-get purge linux-image-x.x.x.x-generic | ||
| + | </ | ||
| + | |||
| + | * rc = Remove - only Configs | ||
| + | * ii = Install - Installed | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | ===== Disable / enable services from autostart ===== | ||
| + | Source: https:// | ||
| + | <code bash> | ||
| + | sudo update-rc.d mongodb disable | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Postgres restore ===== | ||
| + | |||
| + | * -F = '' | ||
| + | * -c = '' | ||
| + | * -O = '' | ||
| + | * -x = '' | ||
| + | * -j5 = use 5 parallel jobs | ||
| + | * -d = database name | ||
| + | |||
| + | <code bash> | ||
| + | pg_restore -Fc -Oxv -j5 -d < | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Journal logy ===== | ||
| + | |||
| + | Pročištění logů, odmaže starší záznamy. | ||
| + | |||
| + | <code bash> | ||
| + | sudo journalctl --vacuum-size=500M | ||
| + | </ | ||
| + | |||
| + | Nastavení limitu pro journal v '' | ||
| + | |||
| + | <code bash> | ||
| + | SystemMaxUse=500M | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Jaký proces využívá port ===== | ||
| + | |||
| + | <code bash> | ||
| + | lsof -i :80 | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Certbot / Certifikáty ===== | ||
| + | |||
| + | List of existing certificates on host | ||
| + | |||
| + | <code bash> | ||
| + | certbot certificates | ||
| + | </ | ||
| + | |||
| + | Certificate detailed info | ||
| + | |||
| + | <code bash> | ||
| + | openssl x509 -text -noout -in < | ||
| + | </ | ||
| + | |||
| + | nebo online | ||
| + | |||
| + | <code bash> | ||
| + | nmap -p 443 --script ssl-cert coex.cz | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== CPU iowait debug ===== | ||
| + | |||
| + | Source: https:// | ||
| + | |||
| + | <code bash> | ||
| + | atop # run it with -d option or press d to toggle the disk stats view. | ||
| + | iostat -xm 2 # try it with the -xm 2 options for extended statistics, in megabytes and in two-second intervals. | ||
| + | iotop -oPa # – top-like I/O monitor. Try it with the -oPa options to show the accumulated I/O of active processes only. | ||
| + | ps auxf # – use auxf, then under the “STAT” column “D” usually indicates disk iowait. | ||
| + | strace | ||
| + | lsof # – after you’ve identified the process responsible, | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== jq ===== | ||
| + | |||
| + | **Inplace transform Unix timestamp to Datetime inside json log** | ||
| + | |||
| + | <code bash> | ||
| + | docker events | TZ=Europe/ | ||
| + | </ | ||
| + | |||
| + | **Inplace decode all k8s secrets values** | ||
| + | |||
| + | <code bash> | ||
| + | kubectl get secrets postgres-secrets -o json | jq '.data | map_values(@base64d)' | ||
| </ | </ | ||