grimoire

personal wiki
git clone git://git.pyratebeard.net/grimoire.git
Log | Files | Refs

nubbins.md (790B)


      1 # nubbins
      2 
      3 ## compare contents of two directories
      4 ```
      5 for f in $(find dir1/ -type f | awk -F/ '{print $NF}') ; do
      6 	find dir2/ -type f -name "$f" -exec echo {} is in both \;
      7 done
      8 ```
      9 
     10 ## processes
     11 
     12 ### zombies
     13 check the number of [zombie processes][]
     14 ```
     15 ps aux | awk '$8 ~ /Z/ { print }' | wc -l
     16 ```
     17 
     18 ### sort by resource usage
     19 find [top processes][] sorted by mem or cpu usage
     20 ```
     21 ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
     22 ```
     23 
     24 ## tmux ssh
     25 use tmux window name to ssh (.bashrc function example)
     26 ```
     27 ssh() {
     28 	[ $# -eq 0 ] && \
     29 		/usr/bin/ssh $(tmux display-message -p '#W') || \
     30 		/usr/bin/ssh $*
     31 ```
     32 
     33 [zombie processes]: https://www.howtogeek.com/119815/htg-explains-what-is-a-zombie-process-on-linux/
     34 [top processes]: https://tecmint.com/find-linux-processes-memory-ram-cpu-usage