Below are a bunch of easy one-liner commands that give information about various aspects of your Linux machine.
Memory Used/Total
free -h | awk '/^Mem:/ {print $3 "/" $2}'
Show CPU temperature
sensors | awk '/^Core*/ {print $1$2, $3}'
Most Memory Intensive processes
ps axch -o cmd:15,%mem --sort=-%mem | head
Most CPU Intensive processes
ps axch -o cmd:15,%cpu --sort=-%cpu | head
I wrote a small shell script to get (almost) realtime update of your system.
#!/usr/bin/env bash
# Realtime system info
#
# Use: watch -ct -n0 sys.sh
#
# TODO:
# 1. Netspeed
# 2. Open ports ?
# color definitions
RESET=$'\e[0m'
BOLD_GREEN_FG=$'\e[1;32m'
BOLD_WHITE_FG=$'\e[1m'
## RAM Usage
ram=$(free -h | awk '/^Mem:/ {print $3 "/" $2}')
## Show CPU temperature
temperature=$(sensors | awk '/^Core*/ {print $1$2, $3}')
## Most Memory Intensive processes
mem_intensive=$(ps axch -o cmd:15,%mem --sort=-%mem | head)
## Most CPU Intensive processes
cpu_intensive=$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)
pc_uptime=$(uptime -p | awk '{for (i=2; i<NF; i++) printf $i " "; if (NF >= 1) print $NF; }')
printf "%70s\n\n" "${BOLD_WHITE_FG}System Monitor${RESET}"
printf "\n%s\n" "${BOLD_GREEN_FG}RAM :${RESET} $ram"
printf "\n%s\n\n" "${BOLD_GREEN_FG}CPU Temperature 🌡 : ${RESET}"
printf "%s\n" "$temperature"
printf "\n%s\n\n" "${BOLD_GREEN_FG}Most Memory Intensive Processes${RESET}"
printf "%s" "$mem_intensive"
printf "\n\n%s\n\n" "${BOLD_GREEN_FG}Most CPU Intensive Processes${RESET}"
printf "%s\n\n" "$cpu_intensive"
Here is a quick demo of how this looks like
The watch
command handles the "realtime" aspect, it can be used to perform operations like running a certain command periodically.
The -c
flag enables the watch to render ANSI colors.
The default interval for the watch
command is 2 seconds but can be configured using the -n
option.
Save the above script and use it like this:
watch -ct -n0 sys.sh
If you have any other ideas, drop them below 👇
Seems interesting?, Subscribe 🚀 to receive more such cool stuff or just connect with me on twitter.
Top comments (4)
The default interval for
watch
is 2 seconds. 0.1 seconds is the minimum granularity it'll let you aim for.Ah yes 😬.
Thanks for correcting 👍🏽
nice article
Thanks ✌🏽