Open source command line tools to gather information on your unix like operating system

Having information on your local hardware as well as the core software which powers the various functionalities of your own operating system, is always a good idea to have. Fortunately for us, there are many open source tools available completely for free; and what's most important, highly customizable.

Neofetch

Written completely in Bash scripting language, neofetch is very useful when it comes to system information. Fast and easy to run, this command line tool offers the following system information by default:
  • OS
  • Host
  • Kernel
  • Uptime
  • Packages
  • Shell
  • Resolution
  • Terminal
  • Terminal Font
  • CPU
  • GPU
  • Memory
Being highly customizable through its configuration file, neofetch can be tweaked to meet your specific needs. Available for anyone to give it a try, neofetch can be easily cloned with the help of the command shown below.
git clone https://github.com/dylanaraps/neofetch.git
Once you have managed to download the project's directory structure on your local system, navigate to it with the help of the command shown below.
cd neofetch
Make the bash script executable with the help of the command shown below.
chmod +x neofetch
Then execute the script by running the following command on your local console.
./neofetch
The image shared above, perfectly illustrates the output of the command's execution on my OS X machine. Although by default neofetch displays system information in a colorful output, the --stdout flag can be used to normally print to standard output.
./neofetch --stdout
Once I managed to execute the above command on my local console, I got the following output.
OS: OS X El Capitan 10.11.4 15E65 x86_64
Host: MacBookAir7,2
Kernel: 15.4.0
Uptime: 1 day, 4 hours, 2 mins
Packages: 35 (brew)
Shell: bash 3.2.57
Resolution: 1440x900
DE: Aqua
WM: Quartz Compositor
WM Theme: Blue (Light)
Terminal: Apple_Terminal
Terminal Font: Menlo-Regular
CPU: Intel i5-5250U (4) É 1.60GHz
GPU: Intel HD Graphics 6000
Memory: 4686MiB / 8192MiB 
The above command is very useful when piping is required. There are many other various flags present in neofetch; each one of them serves a well defined purpose.

A practical and handy flag, is the --shell_path. According to the official documentation, it is off by default. Anytime you want to receive the absolute path of the current shell running on your operating system, the --shell_path flag can be used.
./neofetch --stdout --shell_path on
The execution of the above command, produced the output shown below on my local console.
OS: OS X El Capitan 10.11.4 15E65 x86_64
Host: MacBookAir7,2
Kernel: 15.4.0
Uptime: 1 day, 16 hours, 7 mins
Packages: 35 (brew)
Shell: /bin/bash 3.2.57
Resolution: 1440x900
DE: Aqua
WM: Quartz Compositor
WM Theme: Blue (Light)
Terminal: Apple_Terminal
Terminal Font: Menlo-Regular
CPU: Intel i5-5250U (4) @ 1.60GHz
GPU: Intel HD Graphics 6000
Memory: 3246MiB / 8192MiB 
It does not take a genius to distinguish the role of the --shell_path flag; which when turned on gives the user the absolute path of their current shell.

Neofetch can also be used to gather only very specific information on the system. Such task can be accomplished with the help of the following functions:

  • model
  • distro
  • kernel
  • uptime
  • packages
  • shell
  • resolution
  • de
  • wm
  • wm_theme
  • theme
  • icons
  • term
  • term_font
  • cpu
  • gpu
  • memory
  • disk
  • cpu_usage
  • battery
  • users
  • local_ip
  • public_ip

With the main purpose of illustrating the usage of functions for extracting specific information on the system, let's run the following example on the local console.
./neofetch memory
Once the above command got executed on my system, the following output came on my console.
memory: 2878MiB / 8192MiB 
Based on my experience with neofetch, it is also possible to have multiple functions listed on the command line.
./neofetch memory battery cpu_usage
The execution of the above command produces specific output, according to the functions specified as options in the command line.
memory: 2881MiB / 8192MiB
battery: 92%
cpu_usage: 39%
Now that you have a basic understanding of neofetch, enough to gather system information on your machine, let's make the changes permanent. First, let's install the neofetch tool on the machine with the help of the following command.
sudo make install 
If everything went like it is supposed, now you should be able to run neofetch directly from your console, without having to navigate to the project's directory structure. Launch a new console and try to run neofetch with the help of the following command.
neofetch
Time for some customization. According to the official documentation shared on the Github platform, we can easily adapt neofetch to fit our custom needs by making changes to its configuration file. Before making any changes, it is required that we locate the neofetch's configuration file.

Being an OS X user, the absolute path shared below helps me locate the configuration file of my local neofetch tool.
$HOME/.config/neofetch/config.conf
Once you have managed to locate the neofetch's configuration file, you can easily customize the tool to your own specific needs by commenting, uncommenting lines of code and also turning flags on and off.

The functions at the top of the configuration file, give you total freedom on the kind of system information you want to be displayed by default once the neofetch program is executed on the local console.
  3 print_info() {
  4     info title
  5     info underline
  6
  7     info "OS" distro
  8     info "Host" model
  9     info "Kernel" kernel
 10     info "Uptime" uptime
 11     info "Packages" packages
 12     info "Shell" shell
 13     info "Resolution" resolution
 14     info "DE" de
 15     info "WM" wm
 16     info "WM Theme" wm_theme
 17     info "Theme" theme
 18     info "Icons" icons
 19     info "Terminal" term
 20     info "Terminal Font" term_font
 21     info "CPU" cpu
 22     info "GPU" gpu
 23     info "Memory" memory
 24
 25     # info "GPU Driver" gpu_driver  # Linux/macOS only
 26     # info "CPU Usage" cpu_usage
 27     # info "Disk" disk
 28     # info "Battery" battery
 29     # info "Font" font
 30     # info "Song" song
 31     # [[ "$player" ]] && prin "Music Player" "$player"
 32     # info "Local IP" local_ip
 33     # info "Public IP" public_ip
 34     # info "Users" users
 35     # info "Locale" locale  # This only works on glibc systems.
 36
 37     info cols
 38 }
As you may have already guessed, the lines that start with a # are deactivated functions. We can easily activate them by removing the #.

With the main purpose of customizing neofetch to my own needs, I am going to uncomment the following functions:
# info "GPU Driver" gpu_driver  # Linux/macOS only
# info "CPU Usage" cpu_usage
# info "Disk" disk
# info "Battery" battery
# info "Users" users
# info "Local IP" local_ip
Once you have managed to activate the functions you have selected, save the file and run the neofetch tool directly from your console with the help of the command shown below.
neofetch --stdout
The execution of the above command produces a longer output when compared to the previous ones, due to the activation of new functions.
OS: OS X El Capitan 10.11.4 15E65 x86_64
Host: MacBookAir7,2
Kernel: 15.4.0
Uptime: 2 days, 15 hours, 39 mins
Packages: 35 (brew)
Shell: bash 3.2.57
Resolution: 1440x900
DE: Aqua
WM: Quartz Compositor
WM Theme: Blue (Light)
Terminal: Apple_Terminal
Terminal Font: Menlo-Regular
CPU: Intel i5-5250U (4) É 1.60GHz
GPU: Intel HD Graphics 6000
Memory: 3307MiB / 8192MiB
GPU Driver: macOS Default Graphics Driver
CPU Usage: 12%
Disk (/): 79G / 86G (93%)
Battery: 72%
Local IP: 192.168.252.205
Users: oltjano
It is a truly good idea to include the neofetch in the .bash_profile file, so the program automatically runs each time a fresh terminal console is launched. Just make sure to include the following line inside the .bash_profile file.
neofetch

screenFetch

Same as neofetch, screenFetch is entirely written in the Bash scripting language. Currently at version 3.9.1, it supports many flavors of linux, as well as operating systems which have support for the Bash shell.

Although not as rich in features as neofetch, screenFetch accomplishes well what is designed for. It's setup is pretty straightforward for anyone who has a basic knowledge on the command line. With the main purpose of demonstrating screenFetch in action, clone the official project with the help of the following command.
git clone https://github.com/KittyKatt/screenFetch.git
Then navigate to the project's root directory with the help of the cd command.
cd screenFetch
Make the Bash script executable with the help of the command shown below.
chmod +x screenfetch-dev
Then run the screenFetch program by executing the command shown below.
./screenfetch-dev
Once I managed to execute the above command on my terminal console, I got the following output.
Many various options part of screenFetch can be used to customize system information according to your specific needs. For example, the -n option can be used to remove the ASCII distribution logo from being displayed.
./screenfetch-dev -n
The output of the above command's execution is shown below.
 oltjano@oltjanos-MacBook-Air
 OS: 64bit Mac OS X 10.11.4 15E65
 Kernel: x86_64 Darwin 15.4.0
 Uptime: 3d 14h 58m
 Packages: 101
 Shell: bash 3.2.57
 Resolution: 1440x900
 DE: Aqua
 WM: Quartz Compositor
 WM Theme: Blue
 Font: snameX$classesVNSFontXNSOb
 Disk: 86G / 92G (95%)
 CPU: Intel Core i5-5250U @ 1.60GHz
 GPU: Intel HD Graphics 6000
 RAM: 2601MiB / 8192MiB
You can also strip all the colors from output by making use of the -N option.
./screenfetch-dev -n -N
A useful option is the -s; it tells the script that you want to take a screenshot of the system information.
./screenfetch-dev -s

Final thoughts

System information tools are very useful when it comes to data gathering on the hardware of your machine. Being fully open source, the tools being shared through this article can be easily tweaked to fit your specific needs.

Post a Comment

0 Comments