Back to notes

Shell (bash / zsh)

28.02.2023
•
updated at 12.03.2026
•

Searching

Search phrase inside PDF files

Search for <phrase> in all PDF files (case insensitive, e.g.: .pdf, .PDF) in the current directory (.).
sh
find . -iname "*.pdf" -exec pdfgrep "<phrase>" {} +

Check open port on given IP address

Check if on IP 145.23.12.30 there is open port 8080
sh
nmap -p 8080 145.23.12.30

Listing

Show all directories and their real sizes (with sort)

sh
du -sh */ | sort -hr

Copying

Copy all files of a given type to specific directory

Take all mp4 files from current directory (.) and paste into ~/Music.
bash
find . -name '*.mp4' -type f | xargs -I '{}' mv '{}' ~/Music

Updating

TBD

Testing

Benchmark server effectiveness

Spawn 12 threads with 400 simultaneous connections for 10s to http://127.0.0.1:9000
bash
wrk -t12 -c400 -d10s http://127.0.0.1:9000

Generating

Random passwords

Secure password file for users