Welcome to bashoneliners.com, a curated collection of practical and well-explained Bash one-liners, snippets, tips and tricks. We aim to make each published one-liner to be of high quality: useful, easy to read, follows best practices, with clear, detailed, accurate explanation. These one-liners should help you automate tasks, troubleshoot problems, whether it be in system administration, file management, networking or programming.
for i in {1..65535}; do (< "/dev/tcp/127.0.0.1/$i") &>/dev/null && { echo; echo "[+] Open Port at: $i"; } || printf "."; done; echo
iw dev IFACE scan | egrep "SSID|signal" | awk -F ":" '{print $2}' | sed 'N;s/\n/:/' | sort
comm -23 <(seq "$FROM" "$TO") <(ss -tan | awk '{print $4}' | cut -d':' -f2 | grep "[0-9]\{1,5\}" | sort | uniq) | shuf | head -n "$HOWMANY"
echo "address=/ru/0.0.0.0" | sudo tee /etc/NetworkManager/dnsmasq.d/dnsmasq-ru-blackhole.conf && sudo systemctl restart network-manager
curl -Lw '%{http_code}' -s -o /dev/null -I SOME_URL
for i in {1..254}; do arp -d 192.168.0.$i; done
dig +short myip.opendns.com @resolver1.opendns.com
netstat -rn | awk '/default/ { print $NF }' | head -1 | xargs -I {} ifconfig {} | awk '/ether/ {print $2}'
date +"%Y-%m-%d_%H-%M-%Z" | xargs -I {} bash -c "sudo tcpdump -nq -s 0 -i eth0 -w ./dump-{}.pcap"
for j in $(seq 0 255); do for i in $(seq 0 255) ; do seq -f "10.$j.$i.%g" 0 255; done; done
ipadm create-addr -T static -a 192.168.1.10/24 eth0/staticaddr
ping some_host | while read LINE; do echo $(date): $LINE; done