How to Display System Information With Neofetch

Objective

Learn how to install, use, and customize Neofetch to display system information in the terminal.

Distributions

Neofetch is available for nearly Linux distributions.

Requirements

A Linux installation with access to root for package installations.

Difficulty

Easy

Conventions

  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Introduction

Neofetch is popular among Linux customization enthusiasts. It provides a convenient and customizable way to display critical information about your system in the terminal, and it looks so good that it’s easy to share.

Display System Info With Neofetch



Install Neofetch

Debian Jessie

# echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" >> /etc/apt/sources.list
$ curl -L "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" -o Release-neofetch.key
# apt-key add Release-neofetch.key
# apt update
# apt install neofetch

Ubuntu 16.10 Or Earlier

$ sudo add-apt-repository ppa:dawidd0811/neofetch
$ sudo apt update
$ sudo apt install neofetch

Debian Stretch/Ubuntu 17.04 Or Later

$ sudo apt install neofetch

Fedora

# dnf intall dnf-plugins-core
# dnf copr enable konimex/neofetch
# dnf install neofetch

Arch Linux

$ git clone https://aur.archlinux.org/neofetch.git
$ cd neofetch
$ makepkg -si

Gentoo

# emerge -a neofetch

Configuring Neofetch

Get The Default Configuration

Your distribution package may or may not have come with a default configuration file. In any case, the one available from the Neofetch git repository is great. You can choose to keep the one that shipped with Neofetch or use the git one. Either way, the configuration is located at ~/.config/neofetch/config.

$ cd ~/.config/neofetch
$ wget https://raw.githubusercontent.com/dylanaraps/neofetch/master/config/config


Enabling and Disabling Display Items

Neofetch displays information with a Bash function called print_info(). Inside that function is a list of items that can be shown by Neofetch. The script will display any items that aren’t commented in the function.

 print_info() {
    info title
    info underline
 
    info "OS" distro
    info "Model" model
    info "Kernel" kernel
    info "Uptime" uptime
    info "Packages" packages
    info "Shell" shell
    info "Resolution" resolution
    info "DE" de
    info "WM" wm
    info "WM Theme" wm_theme
    info "Theme" theme
    info "Icons" icons
    info "Terminal" term
    info "Terminal Font" term_font
    info "CPU" cpu
    info "GPU" gpu
    info "Memory" memory

    # info "CPU Usage" cpu_usage
    # info "Disk" disk
    # info "Battery" battery
    # info "Font" font
    # info "Song" song
    # info "Local IP" local_ip
    # info "Public IP" public_ip
    # info "Users" users
    # info "Install Date" install_date
    # info "Locale" locale # This only works on glibc systems.

    info line_break
    info cols
    info line_break
}

Those info lines display the output of a function with an accompanying label. You can write your own functions in the configuration file and use them here with info.

There is also a prin function that allows you to echo directly into Neofetch. It works exactly like echo.

You can change the color function along with one of the preprogrammed color values to change the color of stings.

prin "$(color 4)This is blue!"

Modifying Display Settings

Most of the rest of the configuration file provides options to tweak the way different pieces of information are displayed. Some give you the option of shortening information, like the example below.

# Example:
# on:    'i7-6500U (4) @ 3.1GHz'
# off:   'i7-6500U (4) @ 3.100GHz'
speed_shorthand="on"


There are other options that display additional information. Take a look at the option that allows you to display the CPU temperature.

# Example:
# C:   'Intel i7-6500U (4) @ 3.1GHz [27.2°C]'
# F:   'Intel i7-6500U (4) @ 3.1GHz [82.0°F]'
# off: 'Intel i7-6500U (4) @ 3.1GHz'
cpu_temp="C"

Everything in this section is very well documented in the default config from Github. You can explore and see what other adjustments you can make.

The Picture

Neofetch displays a picture on the left side of the terminal. It’s easily one of the coolest features that the script has to offer, and it allows a decent amount of customization.

By default, Neofetch displays an ASCII art version of Tux, but you can easily change that to one of the other distribution ASCII art options or something more custom.

The Backend settings comment begins the section of image related options. The first part is the image backend. It allows you to swap between ASCII images and other more graphical representations.

# Default:  'ascii'
# Values:   'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
# Flag:     --backend
image_backend="ascii"

The next section is the image source. You can point Neofetch at a specific image or ASCII art instead of using the default distribution art.

If you choose to stick with the distribution ASCII art, you can specify which distribution you want Neofetch to use.

ascii_distro="gentoo"

As you go, there are more options that allow you to control the size of the image and how Neofetch should handle cropping it.

Closing Thoughts

Neofetch is a unique way to display information about your system. It is very easy to customize Neofetch and make it fit with the look and feel of your system. Because you can write your own Bash functions to go along with it, it is nearly infinitely extensible too. Explore and experiment with Neofetch. Make your system’s badge of honor.



Comments and Discussions
Linux Forum