mariusv.com

Watch as I awkwardly stumble through life

A single command to kill a list of processes :

$ kill -9 `ps -ef | grep apache | grep -v grep | awk '{print $2}'`

Or as bash script :

#!/usr/bin/env bash
kill -9 `ps -ef | grep $1 | grep -v grep | awk '{print $2}'`

Delete an IPtable rules based on row number :

$ sudo iptables -L -vnx --line-numbers
$ sudo iptables -t nat -D <chain-name> <number>

Show header HTTP with tcpdump :

$ tcpdump -s 1024 -l -A src 10.0.12.23 or dst 10.0.12.54

Random passwords with openssl :

$ openssl rand -base64 12

Don’t log your last session in bash history :

$ kill -9 $$

nova list only the IPs of the servers :

$ nova list |awk '{print $12}' |grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

Flush DNS cache OSX :

$ dscacheutil -flushcache

Check MySQL top 50 tables by size descending :

SELECT * FROM
(SELECT TN TableName,LPAD(REPLACE(FORMAT(TS/POWER(1024,1),2),',',''),Z,' ') KB,
LPAD(REPLACE(FORMAT(TS/POWER(1024,2),2),',',''),Z,' ') MB,
LPAD(REPLACE(FORMAT(TS/POWER(1024,3),2),',',''),Z,' ') GB
FROM (SELECT CONCAT(table_schema,'.',table_name) TN,
(data_length+index_length) TS FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','mysql','performance_schema')
AND engine IS NOT NULL) A,(SELECT 13 Z) B ORDER BY TS DESC) MMM LIMIT 50;

Nicer format for git log :

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

See all packets hitting our wireless interface :

tcpdump -Ii en0

Usefull Bash alias to find your Public IP

alias ip="dig +short myip.opendns.com @resolver1.opendns.com"

Ansible inventory file from Consul

curl consul.domain:8500/v1/catalog/nodes | jq '.[]|.Address' | tr -d '"'