Misc commands to get system information from a Linux box.

Posted: December 18, 2015. At: 7:30 PM. This was 2 years ago. Post ID: 8582
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

List all network interfaces on your Linux machine that are up.

[jason@localhost ~]$ ip addr | grep UP
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN

List all MAC addresses for your network interfaces.

[jason@localhost ~]$ ipmaddr
1:      lo
        inet  224.0.0.1
        inet6 ff02::1
        inet6 ff01::1
2:      eno16777736
        link  01:00:5e:00:00:01
        link  33:33:00:00:00:01
        inet  224.0.0.1
        inet6 ff02::1
        inet6 ff01::1
3:      virbr0
        link  01:00:5e:00:00:01
        link  01:00:5e:00:00:fb
        inet  224.0.0.251
        inet  224.0.0.1
        inet6 ff02::1
        inet6 ff01::1
4:      virbr0-nic
        inet6 ff02::1
        inet6 ff01::1

Get the time from the BIOS hardware clock.

[jason@localhost ~]$ sudo hwclock 
[sudo] password for jason: 
Sat 19 Dec 2015 01:39:47 AM AEDT  -0.694616 seconds

How to view the system hostname on Linux.

[jason@localhost ~]$ hostname
localhost.localdomain

View the last 5 commands executed on a Linux shell.

[email protected]:~$ fc -ln -5
	 fc -ln -3
	 fc -ln -5
	 clear
	 fc -ln -5
	 ls

Display a ranked list of your most used Linux shell commands.

[email protected]:~$ history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head
     63 sudo
     17 gcc
     17 ./a.out
     11 sed
      9 tr
      8 nc
      8 cat
      7 ps
      7 ls
      6 mc

This function will print a table that shows the colors that your terminal emulator can display.

function colortest()
{
    f=3
    b=4
 
    for j in f b; do
        for i in {0..7}; do
            printf -v $j$i %b "\033[${!j}${i}m"
        done
    done
 
    bld=$'\033[1m'
    rst=$'\033[0m'
    inv=$'\033[7m'
 
cat << EOF
 
$f0█ $bld█$rst $f1█ $bld█$rst $f2█ $bld█$rst $f3█ $bld█$rst $f4█ $bld█$rst $f5█ $bld█$rst $f6█ $bld█$rst $f7█ $bld█$rst 
$f0█ $bld█$rst $f1█ $bld█$rst $f2█ $bld█$rst $f3█ $bld█$rst $f4█ $bld█$rst $f5█ $bld█$rst $f6█ $bld█$rst $f7█ $bld█$rst 
$f0▓ $bld█$rst $f1▓ $bld█$rst $f2▓ $bld█$rst $f3▓ $bld█$rst $f4▓ $bld█$rst $f5▓ $bld█$rst $f6▓ $bld█$rst $f7▓ $bld█$rst 
$f0▒ $bld█$rst $f1▒ $bld█$rst $f2▒ $bld█$rst $f3▒ $bld█$rst $f4▒ $bld█$rst $f5▒ $bld█$rst $f6▒ $bld█$rst $f7▒ $bld█$rst 
$f0░ $bld█$rst $f1░ $bld█$rst $f2░ $bld█$rst $f3░ $bld█$rst $f4░ $bld█$rst $f5░ $bld█$rst $f6░ $bld█$rst $f7░ $bld█$rst 
$rst
EOF
}

No comments have been made. Use this form to start the conversation :)

Leave a Reply