Last active
May 25, 2022 14:20
Revisions
-
flc revised this gist
Nov 1, 2021 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -178,3 +178,6 @@ openssl s_client -connect example.com:443 -tls1_3 # list all the processes currently listening ss -ltup # delete files older than 180 days in the current directory tree find . -type f -mtime +180 | xargs rm -
flc revised this gist
Apr 22, 2021 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -175,3 +175,6 @@ openssl s_client -connect example.com:443 -tls1_1 openssl s_client -connect example.com:443 -tls1_2 # TLS1.3 openssl s_client -connect example.com:443 -tls1_3 # list all the processes currently listening ss -ltup -
flc revised this gist
Apr 21, 2021 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -166,4 +166,12 @@ sudo lsof -i -P -n | grep LISTEN # git | delete all local branches that are gone # will not delete branches that are not fully merged git branch -vv | grep gone | cut -d " " -f3 | xargs git branch -d # check TLS connections # TLS1.1 openssl s_client -connect example.com:443 -tls1_1 # TLS1.2 openssl s_client -connect example.com:443 -tls1_2 # TLS1.3 openssl s_client -connect example.com:443 -tls1_3 -
flc revised this gist
Apr 13, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -165,5 +165,5 @@ ssh-keygen -t rsa -b 4096 -C "<optional_comment>" sudo lsof -i -P -n | grep LISTEN # git | delete all local branches that are gone # will not delete branches that are not fully merged git branch -vv | grep gone | cut -d " " -f3 | xargs git branch -d -
flc revised this gist
Apr 12, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -100,6 +100,7 @@ tail -n +2 file.csv | awk -F "," '$2 >= <my threshold value>' | wc -l # pg_dump ssh tunnel ssh -o "Compression=no" mydbserver "pg_dump -Fc -Z9 -U postgres mydb" > mydb.dump ssh -i <private_key_path> -o "Compression=no" yourdomain.com "pg_dump --username=<username> --host=localhost --blobs --verbose --format=c --compress=9 <db_name>" > mydb.dump # generate random password # of course there are tons of ways to do this -
flc revised this gist
Apr 6, 2021 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -161,4 +161,8 @@ cat -A file ssh-keygen -t rsa -b 4096 -C "<optional_comment>" # check listening ports and applications sudo lsof -i -P -n | grep LISTEN # git | delete all local branches that are gone # will not delete branches that are nto fully merged git branch -vv | grep gone | cut -d " " -f3 | xargs git branch -d -
flc revised this gist
Jan 27, 2021 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -158,4 +158,7 @@ sed -e "s/\r//g" file > newfile cat -A file # generate ssh key ssh-keygen -t rsa -b 4096 -C "<optional_comment>" # check listening ports and applications sudo lsof -i -P -n | grep LISTEN -
flc revised this gist
Sep 4, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -125,7 +125,7 @@ openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 1000 -salt -in <file> -out <en openssl aes-256-cbc -d -md sha512 -pbkdf2 -iter 1000 -in <encrypted_file> -out <file> -k <passphrase> # generate your dhparam.pem file openssl dhparam -out /etc/nginx/ssl/dhparam.pem 4096 # search for pattern in codebase grep -inIEr --color=ALWAYS "<pattern_to_search>" . -
flc revised this gist
May 7, 2020 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -155,4 +155,7 @@ sed -i -e '$a\' file sed -e "s/\r//g" file > newfile # check for all visible characters cat -A file # generate ssh key ssh-keygen -t rsa -b 4096 -C "<optional_comment>" -
flc revised this gist
Sep 25, 2019 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,9 @@ tail -n +2 file > new_file # remove first line of the file (less efficient) sed 1d file > newfile # show from a specific line number <number> till the end of the file tail -n +<number> file # count how many lines of a file contain a pattern cat file | grep pattern | wc -l grep pattern -c file -
flc revised this gist
Jun 28, 2019 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,12 @@ tar -xzf archive.tar.gz # view an tar archive tar tvf archive.tar.gz # create uncompressed tar archive tar -cvf archive.tar dirname # extract uncompressed tar archive tar -xvf archive.tar dirname # extract tar.bz2 tar jxf filename.tar.bz2 -
flc revised this gist
Jun 14, 2019 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -140,4 +140,10 @@ rsync -avz -e "ssh -i <ssh_key_path> -o StrictHostKeyChecking=no -o UserKnownHos find . -type f | wc -l # adds newline at the end of the file if it doesn't already end with a newline sed -i -e '$a\' file # remove CTRL-M (^M) characters from a file sed -e "s/\r//g" file > newfile # check for all visible characters cat -A file -
flc revised this gist
May 29, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -121,7 +121,7 @@ openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 # search for pattern in codebase grep -inIEr --color=ALWAYS "<pattern_to_search>" . # search for pattern in files with specific extension (.py in the example) find . -iname '*.py' | xargs grep -inIE --color=ALWAYS "<pattern_to_search>" # copy directory tree recursively without overwrite -
flc revised this gist
May 29, 2019 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -121,6 +121,9 @@ openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 # search for pattern in codebase grep -inIEr --color=ALWAYS "<pattern_to_search>" . # searcg for pattern in files with specific extension (.py in the example) find . -iname '*.py' | xargs grep -inIE --color=ALWAYS "<pattern_to_search>" # copy directory tree recursively without overwrite rsync -a -v --ignore-existing <src_dir> <dst_dir> -
flc revised this gist
Apr 15, 2019 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -111,6 +111,10 @@ sudo reboot openssl aes-256-cbc -salt -in <file> -out <encrypted_file> -k <passphrase> openssl aes-256-cbc -d -in <encrypted_file> -out <file> -k <passphrase> # encrypt/decrypt file with openssl NEW openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 1000 -salt -in <file> -out <encrypted_file> -k <passphrase> openssl aes-256-cbc -d -md sha512 -pbkdf2 -iter 1000 -in <encrypted_file> -out <file> -k <passphrase> # generate your dhparam.pem file openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 -
flc revised this gist
Mar 20, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -104,6 +104,9 @@ sudo chage -d 0 <username> sudo shutdown -h now sudo poweroff # server restart / reboot sudo reboot # encrypt/decrypt file with openssl openssl aes-256-cbc -salt -in <file> -out <encrypted_file> -k <passphrase> openssl aes-256-cbc -d -in <encrypted_file> -out <file> -k <passphrase> -
flc revised this gist
Nov 16, 2017 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -127,4 +127,7 @@ lsof -Fpcn | nawk '/^p/ { pid=substr($0,2) } /^c/ { cmd=substr($0,2) } /^n/ { fd rsync -avz -e "ssh -i <ssh_key_path> -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress <file> <username>@<remote_ip>:<remote_dir> # count files in a directory recursively find . -type f | wc -l # adds newline at the end of the file if it doesn't already end with a newline sed -i -e '$a\' file -
flc revised this gist
Aug 30, 2017 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -124,4 +124,7 @@ ps -e -orss,%mem,cputime,%cpu,pid,args | sort -b -k1,1n | pr -TW$COLUMNS lsof -Fpcn | nawk '/^p/ { pid=substr($0,2) } /^c/ { cmd=substr($0,2) } /^n/ { fd[cmd"["pid"]"]++ } END { for (cc in fd) printf("%-30s %i\n",cc,fd[cc]) } ' | sort -n -k 2 | tail -30 # copy file with rsync over SSH rsync -avz -e "ssh -i <ssh_key_path> -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress <file> <username>@<remote_ip>:<remote_dir> # count files in a directory recursively find . -type f | wc -l -
flc revised this gist
Aug 25, 2017 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -122,3 +122,6 @@ ps -e -orss,%mem,cputime,%cpu,pid,args | sort -b -k1,1n | pr -TW$COLUMNS # find processes with maximum file descriptors lsof -Fpcn | nawk '/^p/ { pid=substr($0,2) } /^c/ { cmd=substr($0,2) } /^n/ { fd[cmd"["pid"]"]++ } END { for (cc in fd) printf("%-30s %i\n",cc,fd[cc]) } ' | sort -n -k 2 | tail -30 # copy file with rsync over SSH rsync -avz -e "ssh -i <ssh_key_path> -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress <file> <username>@<remote_ip>:<remote_dir> -
flc revised this gist
May 12, 2016 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -115,4 +115,10 @@ openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 grep -inIEr --color=ALWAYS "<pattern_to_search>" . # copy directory tree recursively without overwrite rsync -a -v --ignore-existing <src_dir> <dst_dir> # find processes with most memory usage ps -e -orss,%mem,cputime,%cpu,pid,args | sort -b -k1,1n | pr -TW$COLUMNS # find processes with maximum file descriptors lsof -Fpcn | nawk '/^p/ { pid=substr($0,2) } /^c/ { cmd=substr($0,2) } /^n/ { fd[cmd"["pid"]"]++ } END { for (cc in fd) printf("%-30s %i\n",cc,fd[cc]) } ' | sort -n -k 2 | tail -30 -
flc revised this gist
Dec 31, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -112,4 +112,7 @@ openssl aes-256-cbc -d -in <encrypted_file> -out <file> -k <passphrase> openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 # search for pattern in codebase grep -inIEr --color=ALWAYS "<pattern_to_search>" . # copy directory tree recursively without overwrite rsync -a -v --ignore-existing <src_dir> <dst_dir> -
flc revised this gist
Nov 11, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -109,4 +109,7 @@ openssl aes-256-cbc -salt -in <file> -out <encrypted_file> -k <passphrase> openssl aes-256-cbc -d -in <encrypted_file> -out <file> -k <passphrase> # generate your dhparam.pem file openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 # search for pattern in codebase grep -inIEr --color=ALWAYS "<pattern_to_search>" . -
flc revised this gist
Oct 12, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -107,3 +107,6 @@ sudo poweroff # encrypt/decrypt file with openssl openssl aes-256-cbc -salt -in <file> -out <encrypted_file> -k <passphrase> openssl aes-256-cbc -d -in <encrypted_file> -out <file> -k <passphrase> # generate your dhparam.pem file openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 -
flc revised this gist
Oct 2, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -102,4 +102,8 @@ sudo chage -d 0 <username> # server shutdown sudo shutdown -h now sudo poweroff # encrypt/decrypt file with openssl openssl aes-256-cbc -salt -in <file> -out <encrypted_file> -k <passphrase> openssl aes-256-cbc -d -in <encrypted_file> -out <file> -k <passphrase> -
flc revised this gist
May 18, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -98,4 +98,8 @@ ssh -o "Compression=no" mydbserver "pg_dump -Fc -Z9 -U postgres mydb" > mydb.dum < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; # force the user to change their password upon next login sudo chage -d 0 <username> # server shutdown sudo shutdown -h now sudo poweroff -
flc revised this gist
Jan 13, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -96,3 +96,6 @@ ssh -o "Compression=no" mydbserver "pg_dump -Fc -Z9 -U postgres mydb" > mydb.dum # of course there are tons of ways to do this # you can replace 32 with the desired password length < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; # force the user to change their password upon next login sudo chage -d 0 <username> -
flc revised this gist
Dec 18, 2014 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -90,4 +90,9 @@ sudo renice -n <niceness> -g <pid> tail -n +2 file.csv | awk -F "," '$2 >= <my threshold value>' | wc -l # pg_dump ssh tunnel ssh -o "Compression=no" mydbserver "pg_dump -Fc -Z9 -U postgres mydb" > mydb.dump # generate random password # of course there are tons of ways to do this # you can replace 32 with the desired password length < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; -
flc revised this gist
Dec 16, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,7 @@ sudo groupadd <groupname> # add existing user to group sudo usermod -a -G <groupname> <username> # add a user to multiple groups sudo usermod -a -G <groupname1>,<groupname2>,<groupname3> <username> # view user's group assignemnts -
flc revised this gist
Dec 16, 2014 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -62,6 +62,14 @@ sudo usermod -a -G <groupname1>,<groupname2>,<groupname3> <username> id <username> groups <username> # make a directory accessible for a group # change group of all files/directories recursively sudo chgrp -R <groupname> <directory> # add write permissions to group sudo chmod -R g+w <directory> # set "GID", so that all new files and directories created under <directory> are owned by the group sudo find <directory> -type d -exec chmod 2775 {} \; # randomize lines of a big file memory efficiently uuid -v 4 -n $(wc -l < lines.txt) | paste - lines.txt | sort | cut -f2 > lines_random.txt -
flc revised this gist
Dec 16, 2014 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -47,7 +47,20 @@ tar tvf archive.tar.gz tar jxf filename.tar.bz2 # add user sudo adduser <username> # add group sudo groupadd <groupname> # add existing user to group sudo usermod -a -G <groupname> <username> # ass a user to multiple groups sudo usermod -a -G <groupname1>,<groupname2>,<groupname3> <username> # view user's group assignemnts id <username> groups <username> # randomize lines of a big file memory efficiently uuid -v 4 -n $(wc -l < lines.txt) | paste - lines.txt | sort | cut -f2 > lines_random.txt
NewerOlder