Created
September 14, 2025 08:26
-
-
Save Sherlockboy/c5937ef5a1f8e4b63f245c5087d379d8 to your computer and use it in GitHub Desktop.
Ubuntu System Info One-Liner - Display CPU, RAM, and Storage with usage percentages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Ubuntu System Info One-Liner | |
| # Displays CPU cores, RAM size, and storage info with usage percentages | |
| printf "CPU: %d cores, " $(nproc) && printf "%.1f%% used, %.1f%% available\n" $(awk '{u=$2+$4; t=$2+$4+$5; if (NR==3) printf "%.1f %.1f", u*100/t, (100-u*100/t)}' /proc/stat) && printf "RAM: %s total, " $(free -h | awk 'NR==2{print $2}') && printf "%s used (%.1f%%), %s available (%.1f%%)\n" $(free -h | awk 'NR==2{printf "%s %.1f %s %.1f", $3, ($3/$2)*100, $7, ($7/$2)*100}') && printf "Storage: " && df -h / | awk 'NR==2{printf "%s total, %s used (%s), %s available\n", $2, $3, $5, $4}' | |
| # Sample Output | |
| # CPU: 4 cores, 2.5% used, 97.5% available | |
| # RAM: 7.6Gi total, 1.0Gi used (13.2%), 6.6Gi available (86.8%) | |
| # Storage: 75G total, 60G used (83%), 13G available |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment