🖥️ping
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ping command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██╗███╗ ██╗ ██████╗
# ██╔══██╗██║████╗ ██║██╔════╝
# ██████╔╝██║██╔██╗ ██║██║ ███╗
# ██╔═══╝ ██║██║╚██╗██║██║ ██║
# ██║ ██║██║ ╚████║╚██████╔╝
# ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
# ping a host with a total count of 15 packets overall.
ping -c 15 www.example.com
# ping a host with a total count of 15 packets overall, one every .5 seconds (faster ping).
ping -c 15 -i .5 www.example.com
# test if a packet size of 1500 bytes is supported (to check the MTU for example)
ping -s 1500 -c 10 -M do www.example.com
#==============================#
# CMD PING
#==============================##==============================#
ping -n -c1 -Mdo -s 1472 172.17.1.2
ping -i 60 -a www.google.com
# Give an audible sound as soon as the server comes live.
ping -c100 4.2.2.2 | sponge | pee head tail
# The pee command can run head and tail on same input. sponge waits for all the data first.
# Assuming my network is 10.10.0.0/24, if i run a ping on the broadcast address like
ping -c 5 -b 10.10.0.255 | grep 'bytes from' | awk '{ print $4 }' | sort | uniq
# Also using the "ping the broadcast address" method pointed out by chburd, this pipe should do the trick for you:
ping -c 5 -b 10.11.255.255 | sed -n 's/.* \([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p' | sort | uniq
# Generating list of IP addresses and ping
for ip in 192.168.1.{1..10}; do ping -c 1 -t 1 $ip > /dev/null && echo "${ip} is up"; done
oder
for i in {1..254} ;do (ping 192.168.1.$i -c 1 -w 5 >/dev/null && echo "192.168.1.$i" &) ;done
# Ping mit echo
ping -c 1 -t 1 192.168.1.1 && echo "192.168.1.1 is up!"
# oder ping mit exit code der variablen $?
ping -c 1 -t 1 192.168.1.1;
if [ $? -eq 0 ]; then
echo "192.168.1.1 is up";
else
echo "ip is down";
fi
# Hiding ping output
ping -c 1 -t 1 192.168.1.1 > /dev/null && echo "IP is up"
IP is up
# Add timestamp to the output of ping
ping some_host | while read LINE; do echo $(date): $LINE; done
# Explanation: The while loop reads the output of ping line by line, and echoes it back with $(date) prepended.
mtr google.com
# Most of us are familiar with ping and traceroute. How about combining the functionality of both the command into one with mtr command.
mping(){ ping $@|awk -F[=\ ] '/time=/{t=$(NF-1);f=2000-14*log(t^18);c="play -q -n synth 1 pl "f"&";print $0;system(c)}';}
# mping yahoo\.com or mping any other number of IPs that have various ping times. Try mping 127.0.0.1 vs. mping your gateway IP.
arping 10.0.8.5
# Like ping, but it uses an ARP request to check, which gets around host firewalls blocking ICMP. Only works on same subnet
#==============================##==============================#
# CMD PING
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command ping in a clear format. This allows users to quickly access the needed information for ping without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for ping are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.