Description

Displays quick system stats on a Linux machine, such as distro information, kernel, uptime, memory, swap, chip architecture, processor information, the date, user information, group info, current working directory, user’s home directory, the system’s hostname, all ip addresses, default gateway, and name servers. Helpful when you want a quick snapshot of system information.

Source Code

#!/bin/bash

SYSINFO=`head -n 1 /etc/issue`
IFS=$'\n'
UPTIME=`uptime`
D_UP=${UPTIME:1}
MYGROUPS=`groups`
DATE=`date`
KERNEL=`uname -a`
CPWD=`pwd`
ME=`whoami`
CPU=`arch`

printf "<=== SYSTEM ===>\n"
echo "  Distro info:	"$SYSINFO""
printf "  Kernel:\t"$KERNEL"\n"
printf "  Uptime:\t"$D_UP"\n"
free -mot | awk '
/Mem/{print "  Memory:\tTotal: " $2 "Mb\tUsed: " $3 "Mb\tFree: " $4 "Mb"}
/Swap/{print "  Swap:\t\tTotal: " $2 "Mb\tUsed: " $3 "Mb\tFree: " $4 "Mb"}'
printf "  Architecture:\t"$CPU"\n"
cat /proc/cpuinfo | grep "model name\|processor" | awk '
/processor/{printf "  Processor:\t" $3 " : " }
/model\ name/{
i=4
while(i<=NF){
	printf $i
	if(i<NF){
		printf " "
	}
	i++
}
printf "\n"
}'
printf "  Date:\t\t"$DATE"\n"
printf "\n<=== USER ===>\n"
printf "  User:\t\t"$ME" (uid:"$UID")\n"
printf "  Groups:\t"$MYGROUPS"\n"
printf "  Working dir:\t"$CPWD"\n"
printf "  Home dir:\t"$HOME"\n"
printf "\n<=== NETWORK ===>\n"
printf "  Hostname:\t"$HOSTNAME"\n"
ip -o addr | awk '/inet /{print "  IP (" $2 "):\t" $4}'
/sbin/route -n | awk '/^0.0.0.0/{ printf "  Gateway:\t"$2"\n" }'
cat /etc/resolv.conf | awk '/^nameserver/{ printf "  Name Server:\t" $2 "\n"}'

Screenshots

5 Spice ups

Nice Script to understand the basic information of Linux PC thanks

Very useful, thanks. Enough for quick analyze of system without any additional app.

first information : 1.head -n 1 /etc/issue It’s depend on the content of this file, some OS the fist line is blank so make sure the line which contain OS information. I tried on my SUSE server and get the blank result. Anyway, this script really cool and useful.

Could you please explain the reason why you use the loop below : { i=4 while(i<=NF){ printf $i if(i

It threw an error on the free command: free: invalid option – ‘o’ I just removed that and it works great. That line now reads: free -mt | awk ’ This was on Ubuntu 16.04.1 LTS

Fully agree with Timb0slice - just remove the -o option for the free command at Ubuntu/Lubuntu linux to make the wonder happen. :-). As (disk-)size always matters, I added following lines (for my personal use): printf “\n<=== USED DISKSPACE IN PERCENT===>\n” df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 " " $1 }’ printf “\n<=== AVAILABLE DISKSPACE ===>\n” df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $4 " " $1 }’

Wouldn’t using inxi be a better solution instead of re-inventing the wheel…

@CyberOptiq, not necessarily, If you have a system or environment that has strict security policies in place you may no be able to install the inxi or there are certain packages that cannot updated for whatever reason. (inxi needs around 56 packages to installed). @smmorris script still working good on Ubuntu 18.04.3, after removing the ‘o’ like everyone has done.