This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# render template via ansible module | |
$ ansible all -i "localhost," \ | |
-c local \ | |
-m template \ | |
-a "src=test.txt.j2 dest=./test.txt" \ | |
--extra-vars='{"users": ["Mike", "Smith", "Klara", "Alex"]}' | |
# render template via playbook | |
- hosts: 127.0.0.1 | |
tasks: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create virtual env | |
pyenv virtualenv <py version> <env name> | |
pyenv activate <env name> | |
pyenv deactivate | |
# list virtual env | |
pyenv virtualenvs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# compress file into gzip | |
tar --create --gzip --verbose --file <output file path> <input file path> | |
tar -czvf <output file path> <input file path> | |
# extract | |
tar -xzvf <file path> | |
# gzip option can be changed to use different compression algo | |
# https://www.howtogeek.com/248780/how-to-compress-and-extract-files-using-the-tar-command-on-linux/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<file glob> { | |
} | |
# run logrotate | |
logrotate --verbose --debug --force <logroate file | logrotate.d/> | |
# logrotate status | |
# check for past logrotate actions | |
/var/lib/logrotate.status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encrypt | |
openssl aes-256-cbc -in <file> -out <file> -md sha1 -base64 | |
# decrypt | |
openssl aes-256-cbc -d -in <file> -out <file> -md sha1 -base64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-keygen -E md5 -lf id_rsa.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# self-signed certificates only provide cryptographic security to HTTPS request | |
# they do not verify the identity of the server | |
sudo openssl req -x509 -nodes -newkey rsa:4096 \ | |
-keyout /etc/ssl/<name>.key \ | |
-out /etc/ssl/<name>.crt \ | |
-days <NUMBER_OF_DAYS> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
StartLimitIntervalSec=60 #length of limit interval | |
StartLimitBurst=6 #start limit within interval | |
# i.e. can start 6 times in a span of 60 sec | |
ConditionPathExists=/etc/foo/foo.conf # only start if this file exists | |
# see other Condition* directives | |
[Service] | |
RestartSec=10 # restart every 10 if restart conditions are met |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo du -Sh | sort -r -h | head -n 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mac | |
sed 's/<target>/<replacement>/g' <inputfile> > <outputfile> | |
# inplace | |
sed -i '.bck' 's/<target>/<replacement>/g' <inputfile> | |
# only if FOO appears in the line | |
sed 'FOO/s/<target>/<replacement>/g' <inputfile> | |
# multiple command |