🖥️watch
➡️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 watch command with important options and switches using examples.
4 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗ ██╗ █████╗ ████████╗ ██████╗██╗ ██╗
# ██║ ██║██╔══██╗╚══██╔══╝██╔════╝██║ ██║
# ██║ █╗ ██║███████║ ██║ ██║ ███████║
# ██║███╗██║██╔══██║ ██║ ██║ ██╔══██║
# ╚███╔███╔╝██║ ██║ ██║ ╚██████╗██║ ██║
# ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
watch -n 0.5 "ps uf -C process1,process2"
# Continually watch processes with names
watch -t -n1 "date +%T|figlet"
# show animated digital clock in the terminal.
watch -n1 cat /proc/net/wireless
# Monitor your wireless card signal strength on the screen.
watch -n1 'echo $(( 1500000000 - $( date +%s )))'
# Waiting for epoch second 1.5 x 10^9
watch -n 5 "ls -la | grep something"
# Execute a linux command at regular intervals - Use Linux watch to execute a running command at certain time. Note the usage of double quotes to include a complex command, eg ls -la AND grep result
# Options:
# -n 5: exec every 5s
watch -d -n 1 "netstat -an | grep :8080"
# Use it all the time to watch for incoming connections on a certain port.
watch -n 1 curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
# Monitor ElasticSearch cluster health - Useful for keeping an eye on ES when rebalancing takes place
# Watch how many tcp connections there are per state every two seconds. - slighty shorter
watch -c "netstat -nt | awk 'FNR > 3 {print \$6}' | sort | uniq -c"
# Watch how many tcp connections there are per state every two seconds.
watch -c "netstat -natp 2>/dev/null | tail -n +3 | awk '{print \$6}' | sort | uniq -c"
# Monitor cpu in realtime.
watch grep \"cpu MHz\" /proc/cpuinfo
# Show dd status every so often
watch --interval 5 killall -USR1 dd
# Explanation: The dd command has no progress indicator. While copying large files it may seem like nothing is happening, as dd prints nothing until completed. However, when the dd process receives USR1 signal, it prints I/O statistics to standard error and resumes copying. Here we use killall to send the signal, and we call it with watch to repeat this every 5 seconds, effectively giving a progress indicator to good old dd.
# Start in one window the watch:
watch --interval 5 killall -USR1 dd
# Start copying in another:
# dd if=/dev/random of=junk bs=1000 count=1000
# dd: warning: partial read (13 bytes); suggest iflag=fullblock
# 0+2 records in
# 0+2 records out
# 21 bytes (21 B) copied, 3.01687 s, 0.0 kB/s
# 0+3 records in
# 0+3 records out
# 29 bytes (29 B) copied, 8.02736 s, 0.0 kB/s
# Beobachte alle localen Netzwerkverbindungen
watch -n2 "sed -n 's%.* src=\(192.168.[0-9.]*\).*%\1%p' /proc/net/ip_conntrack | sort | uniq -c | sort -gr"
# Execute a linux command at regular intervals - Use Linux watch to execute a running command at certain time. Note the usage of double quotes to include a complex command, eg ls -la AND grep result
watch -n 5 "ls -la | grep something"
# Options:
# -n 5: exec every 5s
# Watch TCP, UDP open ports in real time with socket summary.
watch ss -stplu
# Show top 50 running processes ordered by highest memory/cpu usage refreshing every 1s - http://alvinalexander.com/linux/unix-linux-process-memory-sort-ps-command-cpu for an overview of --sort available values
watch -n1 "ps aux --sort=-%mem,-%cpu | head -n 50"
# Perform Real-time Process Monitoring Using Watch Utility
watch -n 1 'ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head'
# Real-time monitoring monitoring of MySQL queries
watch -n 1 mysqladmin processlist
# The -n 1 specifies that mysqladmin executes every second. Depending on your set-up, you may need to specify a mysql user and password:
watch -n 1 mysqladmin --user=<user> --password=<password> processlist
#==============================##==============================#
# CMD WATCH
#==============================##==============================#
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 watch in a clear format. This allows users to quickly access the needed information for watch without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for watch 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.