Bash tips
kill procces by port
sudo kill $(sudo lsof -ti:port)
create symlink
ln -sf /path/to/file /path/to/symlink
install psql
sudo apt install postgresql postgresql-contrib
open url from bash
xdg-open http://google.com
# bash loop
for (;;); do command; command-2; done
# output timestamps
ts # timestamp
ts -i # each output duration
ts -s # time taken from start
# async threads with status control
set -m # to enable job control in .sh scripts
echo > job-status # file contr# kill procces by port
ol
command || echo false > job-status & # command with file control
while [[ $(jobs) ]]; do fg; done # jobs wait
[[ $(cat job-status) != "false" ]] # check jobs status
# find & replace in all files in folder & subfolders
sudo kill $(sudo lsof -ti:port)
ack -l 'pattern' | xargs perl
-pi -E 's/pattern/replacement/g'
# check postgres certificates
curl https://raw.githubusercontent.com/thusoy/postgres-mitm/master/postgres_get_server_cert.py | python3 - host:port | openssl x509 -noout -dates
# postgres
# drop connections for dbname
# create symlink
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'dbname' AND pid <> pg_backend_pid();
# create full duplicate of dbname named dbname_copy with db_user owner
create database dbname_copln -sf /path/to/file /path/to/symlink
y WITH TEMPLAT
E dbname OWNER owner;
# visualize git repo development
gource --stop-at-end --hide filenames,usernames,dirnames -1920x1080 -s 0.5 -o - | ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -threads 0 -bf 0 gource.mp4 -crf 0
# list opened ports and its process names
netstat -nlpt
# install psql
sudo apt install postgresql postgresql-contrib
# open url from bash
xdg-open http://google.com
# bash loop
for (;;); do command; command-2; done
# output timestamps
ts # timestamp
ts -i # each output duration
ts -s # time taken from start
# async threads with status control
set -m # to enable job control in .sh scripts
echo > job-status # file control
command || echo false > job-status & # command with file control
while [[ $(jobs) ]]; do fg; done # jobs wait
[[ $(cat job-status) != "false" ]] # check jobs status
# find & replace in all files in folder & subfolders
ack -l 'pattern' | xargs perl -pi -E 's/pattern/replacement/g'
# check postgres certificates
curl https://raw.githubusercontent.com/thusoy/postgres-mitm/master/postgres_get_server_cert.py | python3 - host:port | openssl x509 -noout -dates
# postgres
# drop connections for dbname
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'dbname' AND pid <> pg_backend_pid();
# create full duplicate of dbname named dbname_copy with db_user owner
create database dbname_copy WITH TEMPLATE dbname OWNER owner;
# visualize git repo development
gource --stop-at-end --hide filenames,usernames,dirnames -1920x1080 -s 0.5 -o - | ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -threads 0 -bf 0 gource.mp4 -crf 0
# list opened ports and its process names
netstat -nlpt