Linux cli snippets
From DevOps Notebook
Contents
- 1 Linux command line snippets
- 1.1 Get website SSL certificate details using CLI
- 1.2 Temporary stop bash history
- 1.3 Check ssl expiry date on file from cli
- 1.4 Start all vm's with autostart set with virsh
- 1.5 Sort files by size with ls
- 1.6 Change different permissions to files and folders in one run recursively
- 1.7 Search and replace string in all files recursively in given folder
Linux command line snippets
Get website SSL certificate details using CLI
$ echo | openssl s_client -showcerts -servername sendfileto.net -connect sendfileto.net:443 2>/dev/null | openssl x509 -inform pem -noout -text
Temporary stop bash history
Turn off:
$ set +o history
Turn on:
$ set -o history
Alternative is to add HISTCONTROL="ignorespace" into .bashrc file and all things written with space in front wont be recorded in history
Check ssl expiry date on file from cli
# openssl x509 -noout -dates -in /path/to/cert.crt
Start all vm's with autostart set with virsh
# for i in $(virsh list --name --autostart); do virsh start $i; done
Sort files by size with ls
# ls -l -S | sort -k 5 -n
Change different permissions to files and folders in one run recursively
# find /path/to/dir -type f -exec chmod 664 {} + -o -type d -exec chmod 775 {} +
Search and replace string in all files recursively in given folder
# find ./ -type f -exec sed -i -e 's/tomato/potato/g' {} \;