Linux : Easily get any system details


Sometimes, when writing scripts or when troubleshooting a problem on a Linux platform you are struggling to remember how to get the number of cores, the current IP address, the kernel version, available space, ... All those settings are present somewhere in the system. Remember, with Linux, everything is file based. There is a way to easily get those details with one single command. Please continue reading !

Let's meet "facter"

Funny enough, I'm in the Linux business for the last 20 years and I just discovered yesterday the command facter ! We are learning everyday right ? But I don't know how I can pass over this for so long. Amazing & powerful it gives you immediate access to so many variables that I cannot name them all here. Here is a sample of the facter output on my test system :

# facter
architecture => x86_64
bios_release_date => 04/01/2014
bios_vendor => SeaBIOS
bios_version => 1.9.1-5.el6
blockdevice_sda_model => VDISK
blockdevice_sda_size => 32212254720
blockdevice_sda_vendor => NUTANIX
blockdevice_sdb_model => VDISK
blockdevice_sdb_size => 107374182400
blockdevice_sdb_vendor => NUTANIX
blockdevice_sr0_model => QEMU DVD-ROM
blockdevice_sr0_size => 1073741312
blockdevice_sr0_vendor => QEMU
blockdevices => sda,sdb,sr0
dhcp_servers => {"system"=>"", "eth0"=>""}
facterversion => 2.4.1
filesystems => xfs
fqdn => facter
gid => root
hardwareisa => x86_64
hardwaremodel => x86_64
hostname => facter
id => root
interfaces => eth0,lo
ipaddress =>

There a lot more than just the above, actually there are 88 variables on my platform that can be used for anything.

You can use the command by simply pointing out the relevant parameter. As matter of example, getting the ip address of the machine by simply entering :

# facter ipaddress

I really encourage you to use it in your scripts. Initially this script has been created for puppet and is now available standalone. This is not default on Linux platform you need to install it via the EPEL repository.

Install facter

Facter is available via the EPEL repository, so, first, you need to add EPEL to your system.

# rpm -ivh

# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
repo id            repo name                            status
base/7/x86_64      CentOS-7 - Base                      9,911
epel/x86_64        Extra Packages for Enterprise Linux 7 - x86_64                                                               12,577
extras/7/x86_64    CentOS-7 - Extras                    305
updates/7/x86_64   CentOS-7 - Updates                   632
repolist: 23,425

Repolist above confirms your EPEL repo has been added and enabled into your system.

Now, just install facter as usual with yum :

# yum install facter -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package facter.x86_64 0:2.4.1-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                     Arch                        Version                            Repository                 Size
 facter                      x86_64                      2.4.1-1.el7                        epel                      101 k

Transaction Summary
Install  1 Package

Total download size: 101 k
Installed size: 271 k
Downloading packages:
facter-2.4.1-1.el7.x86_64.rpm                                                                        | 101 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : facter-2.4.1-1.el7.x86_64                                                                                1/1 
  Verifying  : facter-2.4.1-1.el7.x86_64                                                                                1/1 

  facter.x86_64 0:2.4.1-1.el7                                                                                               


Enjoy !


What's hot ?

My journey with Nutanix Community Edition