Skip to content

Instantly share code, notes, and snippets.

@kozmonaut
Last active January 15, 2021 16:28
Show Gist options
  • Save kozmonaut/b912ceef681c197a3e41 to your computer and use it in GitHub Desktop.
Save kozmonaut/b912ceef681c197a3e41 to your computer and use it in GitHub Desktop.
Extract Linux system data using command line
Time: /bin/date
Login: users | awk '{print $1}'
Architecture: uname -m
Kernel version: uname -v -r
Processor: cat /proc/cpuinfo | grep \"name\" | cut -d : -f2 | uniq
Operating system: cat /etc/*-release | grep \"PRETTY_NAME\" | cut -d \"=\" -f2 | uniq
Interfaces: ip link show | grep 'eth\|wlan' | awk '{print $1,$2}'
IP addresses: ip a | grep 'eth\|wlan' | awk '{print $1,$2}'
Transmitted: /sbin/ifconfig eth0 | grep 'TX bytes' | awk '{print $7,$8}'
Recieved: /sbin/ifconfig eth0 | grep 'RX bytes' | awk '{print $3,$4}'
Ping: ping -c 5 google.com | head -n 6 | awk '{print $3,$4,$8,$9,$10}'
Uptime: /usr/bin/cut -d. -f1 /proc/uptime
Processes: ps -ef | wc -l
Memory used: free -m | awk 'NR==2{print $3}'
Ping (google.com): ping -c 1 google.com | tail -1| awk '{print $4}' | cut -d '=' -f 3
Disk space(GB): df -BG | head -n 5 | awk '{print $1,$3,$4}'
Memory total: free -m | awk 'NR==2{print $2}'
Memory used: free -m | awk 'NR==2{print $3}'
Memory free: free -m | awk 'NR==2{print $4}'
Process Usage: ps aux | awk '{print $2, $3, $4, $11}' | head -1 && ps axu | awk '{print $2, $3, $4, $11}' | sort -k3 -nr | head -5
Last Logged In: last | awk '{print $1,$4,$5,$6,$7}' | head -n 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment