Select Page
Linux xz Command Tutorial for Beginners (7 Examples)

Linux xz Command Tutorial for Beginners (7 Examples)

There are several ways to compress and decompress files in Linux. While we have already discussed some (here and here), there are plenty that we still haven’t. So here, in this tutorial, we will discuss another such command line utility.

It’s dubbed xz. We will discuss the basics of this command line tool. But before we jump into that, it’s worth mentioning that all examples here have been tested on an Ubuntu 18.04 LTS machine.

Linux xz command

As already mentioned in the beginning, the xz command in Linux lets you compress and decompress files. Following is its syntax:

xz [option…]  [file…]

And here’s what the man page has to say about it:

     xz is a general-purpose data compression tool with command line syntax similar to gzip(1) 
and bzip2(1).  The native file format is the .xz format, but the legacy .lzma format used
by LZMA Utils and raw compressed streams with no container format headers are also supported.

     xz compresses or decompresses each file according to the selected operation mode.  If no files
are given or file  is  -,  xz  reads from standard input and writes the processed data to
standard output.  xz will refuse (display an error and skip the file) to write compressed data
to standard output if it is a terminal.  Similarly, xz will refuse to read compressed data
from standard  input if it is a terminal.

Following are some Q&A-styled examples that should give you a better idea on how xz works.

Q1. How to use the xz command?

Basic usage is fairly straight forward. Just pass the name of the file (that’s to be compressed) as an input argument to xz. Here’s an example:

xz file.txt

On my system, the aforementioned command produced the following file as output.

file.txt.xz

So you can see the xz command compressed file.txt. It’s worth mentioning that the operation replaces the original file (file.txt in this case) with the compressed version.

Q2. How to make xz retain original file as well?

As I mentioned in the previous section, the xz command replaces the original file with its compressed version. However, if you want, you can force xz to retain the original file as well. This can be done using the -k command line option.

For example:

xz -k file.txt

So this time, you’ll find both file.txt and file.txt.xz in the current working directory.

Q3. How to compress multiple files?

This is very simple. Just pass the names as input arguments to xz.

For example:

xz file1.txt file2.txt

This command will compress both these files in one go.

Q4. How to decompress .xz files?

To decompress .xz files, use the -d command line option. For example:

xz -d file.txt.xz

This command would produce file.txt in the current working directory.

Q5. How to make xz print information about compressed files?

This can be done using the -l command line option. For example:

xz -l file.txt.xz

This command produced the following information in my case:

Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename
    1       1         96 B         37 B  2.595  CRC64   file.txt.xz

Q6. How to specify a different compression/decompression format?

This can be done using the -F command line option. To use this option though, you need to understand the following:

-F format, --format=format
       Specify the file format to compress or decompress:

       auto   This is the default.  When compressing, auto is equivalent to xz.  When decompressing, the format of the  input  file
              is automatically detected.  Note that raw streams (created with --format=raw) cannot be auto-detected.

       xz     Compress to the .xz file format, or accept only .xz files when decompressing.

       lzma, alone
              Compress  to the legacy .lzma file format, or accept only .lzma files when decompressing.  The alternative name alone
              is provided for backwards compatibility with LZMA Utils.

       raw    Compress or uncompress a raw stream (no headers).  This is meant for advanced users only.  To decode raw streams, you
              need use --format=raw and explicitly specify the filter chain, which normally would have been stored in the container
              headers.

So you see, you can use any of the following formats: ‘auto’, ‘xz’, ‘lzma’, and ‘raw’.

Q7. How to make xz display progress indicator?

This can be made possible using the -v command line option. Here’s an example:

How to make xz display progress indicator

Conclusion

While we’ve discussed a handful of xz command line options in this tutorial, there are plenty more. Once you are done understanding and practicing these, head to the tool’s man page to learn more about it.

Himanshu Arora has been working on Linux since 2007. He carries professional experience in system level programming, networking protocols, and command line. In addition to HowtoForge, Himanshu’s work has also been featured in some of world’s other leading publications including Computerworld, IBM DeveloperWorks, and Linux Journal.

How to Install TIG Stack (Telegraf, InfluxDB, and Grafana) on Ubuntu 18.04 LTS

How to Install TIG Stack (Telegraf, InfluxDB, and Grafana) on Ubuntu 18.04 LTS

InfluxDB is an open-source time series database written in Go. Optimized for fast, high-availability storage and used as a data store for any use case involving large amounts of time-stamped data, including DevOps monitoring, log data, application metrics, IoT sensor data, and real-time analytics.

Telegraf is an agent for collecting, processing, aggregating, and writing metrics. It supports various output plugins such as influxdb, Graphite, Kafka, OpenTSDB etc.

Grafana is an open source data visualization and monitoring suite. It offers support for Graphite, Elasticsearch, Prometheus, influxdb, and many more databases. The tool provides a beautiful dashboard and metric analytics, with the ability to manage and create your own dashboard for your apps or infrastructure performance monitoring.

In this tutorial, I will show you how to install and configure the TIG Stack (Telegraf, influxdb, and Grafana) using a single Ubuntu 18.04 Server. We will be using the TIG Stack for monitoring the system loads such as Network, RAM Memory, Uptime etc.

Prerequisites

  • Ubuntu 18.04
  • Root privileges

What we will do?

  1. Install InfluxDB
  2. Create InfluxDB Database and User
  3. Install Telegraf Agent
  4. Configure Telegraf
  5. Install Grafana
  6. Setup Grafana Data Source
  7. Setup Grafana Dashboard

Step 1 – Install InfluxDB

In this first step, we will install the time series database influxdb on the Ubuntu system. We will install both ‘influxdb’ and the ‘telegraf’ from the same ‘influxdata’ Repository, both software were created by the same organization.

Add the influxdata Key.

sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add –

Add the influxdata repository.

source /etc/lsb-release
echo “deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable” | sudo tee /etc/apt/sources.list.d/influxdb.list

Now update the repository and install the ‘influxdb’ package using the apt command below.

sudo apt update
sudo apt install influxdb -y

Install InfluxDB

After the installation is complete, start the influxdb service and enable it to launch every time at system boot.

sudo systemctl start influxdb
sudo systemctl enable influxdb

Now check the opened ports on the system.

netstat -plntu

Check open ports with netstat

And make sure you get influxdb ports ‘8088’and ‘8086’ on the ‘LISTEN’ state.

Step 2 – Create InfluxDB Database and User

In order to store all data from telegraf agents, we need to set up the influxdb database and user.

InfluxDB provides the CLI tool named ‘influx’ for interacting with an InfluxDB server. Influx command is like the ‘mysql’ on MySQL, and ‘mongo’ on the MongoDB database.

Run the ‘influx’ command below.

influx

Now you are connected to the default influxdb server on port ‘8086’.

Create a new database and user ‘telegraf’ with the password ‘hakase-ndlr’ by running influxdb queries below.

create database telegraf
create user telegraf with password ‘hakase-ndlr’

Now check the database and user.

show databases
show users

Make sure you get the database and user named ‘telegraf’ on the influxdb server.

Create InfluxDB Database and User

Step 3 – Install Telegraf Agent

Telegraf was created by ‘influxdata’, same organization which created the influxdb. So when we add the influxdata key and repository to the system, it means we can install both applications.

Install the telegraf package using the apt command below.

sudo apt install telegraf -y

After the installation is complete, start the telegraf service and enable it to launch everytime at system startup.

sudo systemctl start telegraf
sudo systemctl enable telegraf

The telegraf agent is up and running, check it using the command below.

sudo systemctl status telegraf

Install Telegraf Agent

Step 4 – Configure Telegraf

Telegraf is a plugin-driven agent and has 4 concept plugins type.

  1. Using the ‘Input Plugins’ to collect metrics.
  2. Using the ‘Processor Plugins’ to transform, decorate, and filter metrics.
  3. Using the ‘Aggregator Plugins’ to create and aggregate metrics.
  4. And using the ‘Output Plugins’ to write metrics to various destinations, including influxdb.

In this step, we will configure the Telegraf to use basic input plugins for collecting system metric of the server and using the influxdb as the output plugin.

Go to the ‘/etc/telegraf’ directory and rename the default configuration file.

cd /etc/telegraf/
mv telegraf.conf telegraf.conf.default

Now create a new other configuration ‘telegraf.conf’ using vim editor.

vim telegraf.conf

Paste configurations below.

# Global Agent Configuration
[agent]
  hostname = "hakase-tig"
  flush_interval = "15s"
  interval = "15s"


# Input Plugins
[[inputs.cpu]]
    percpu = true
    totalcpu = true
    collect_cpu_time = false
    report_active = false
[[inputs.disk]]
    ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
[[inputs.io]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.system]]
[[inputs.swap]]
[[inputs.netstat]]
[[inputs.processes]]
[[inputs.kernel]]

# Output Plugin InfluxDB
[[outputs.influxdb]]
  database = "telegraf"
  urls = [ "http://127.0.0.1:8086" ]
  username = "telegraf"
  password = "hakase-ndlr"

Save and exit.

Configure Telegraf

Note:

Telegraf provides telegraf command to manage the configuration, including generate the configuration itself, run the command as below.

telegraf config -input-filter cpu:mem:disk:swap:system -output-filter influxdb > telegraf.conf
cat telegraf.conf

Telegraf config

Restart the telegraf service and make sure there is no error.

sudo systemctl restart telegraf

Now test the telegraf settings using the command below.

sudo telegraf -test -config /etc/telegraf/telegraf.conf –input-filter cpu
sudo telegraf -test -config /etc/telegraf/telegraf.conf –input-filter net
sudo telegraf -test -config /etc/telegraf/telegraf.conf –input-filter mem

Test config

The InfluxDB and Telegraf configuration has been completed.

Step 6 – Install Grafana

In this step, we will install the beautiful Grafana Dashboard for data visualization.

Add the grafana key and repository.

sudo curl https://packagecloud.io/gpg.key | sudo apt-key add –
echo ‘deb https://packagecloud.io/grafana/stable/debian/ stretch main’ > /etc/apt/sources.list.d/grafana.list

Update the repository and install the grafana package using the apt command below.

sudo apt update
sudo apt install grafana -y

Install Grafana

After the installation is complete, start the grafana service and enable it to launch everytime at system boot.

sudo systemctl start grafana-server
sudo systemctl enable grafana-server

The grafana-server is up and running on default port ‘3000’, check it using netstat.

netstat -plntu

And you will get the result as below.

Check ports

Step 7 – Setup Grafana Data Source

Open your web browser and type the server IP address with port 3000.

http://192.168.33.15:3000/

Login with the default user ‘admin’ and password ‘admin’.

Login to Grafana

Now you will be prompted with the page for changing the default password, type your new password and click the ‘Save’ button.

Set new password

And you will be redirected to the default Grafana Dashboard.

Click the ‘Add data source’ button to add the influxdb data source.

Grafana Dashboard

Type details about the influxdb server configurations.

  • Name: influxdb
  • Type: influxdb
  • URL: http://localhost:8086/

Set influxdb details

Scroll to the bottom page and type details of influxdb database settings.

  • Database: telegraf
  • User: telegraf
  • Password: ‘hakase-ndlr’

Database settings

Click the ‘Save and Test’ button and make sure you get the ‘Data source is working’ result.

The InfluxDB data source has been added to the Grafana server.

Step 8 – Setup Grafana Dashboard

After adding the influxdb as a data source to the grafana server, in this step we will import the grafana dashboard based on our Telegraf input plugins setup.

Grafana provides the repository for grafana plugins and dashboards.

To import the grafana dashboard, click on the ‘+’ menu on the left panel and click ‘Import’.

Setup Grafana Dashboard

Now open the sample Grafana dashboard from URL ‘https://grafana.com/dashboards/5955‘ and click the ‘Copy the ID to Clipboard’ button.

Paste the dashboard id.

Import dashboard config

And you will be redirected automatically to the dashboard setup.

On the options section, click the InfluxDB and choose your influxdb server, then click ‘Import’ button.

Influxdb server import

And below are some screenshots from the imported dashboard.

Imported dashboard 1

Imported dashboard 2

The TIG Stack (Telegraf, InfluxDB, and Grafana) installation on Ubuntu 18.04 has been completed successfully.

Reference

About Muhammad Arul

Muhammad Arul is a freelance system administrator and technical writer. He is working with Linux Environments for more than 5 years, an Open Source enthusiast and highly motivated on Linux installation and troubleshooting. Mostly working with RedHat/CentOS Linux and Ubuntu/Debian, Nginx and Apache web server, Proxmox, Zimbra Administration, and Website Optimization. Currently learning about OpenStack and Container Technology.

How to Install and Use logrotate to Manage Log Files in Ubuntu 18.04 LTS

How to Install and Use logrotate to Manage Log Files in Ubuntu 18.04 LTS

Log files are most important for Linux system security. the logrotate tool is specially designed to simplify the administration of log files on a Linux system that allows automatic rotation, compression, removal, and mailing of log files. You can easily set logrotate to handle a log file daily, weekly, monthly. The logrotate program used to rotate log files by removing the oldest ones from your system and creating new log files.

In this tutorial, I will explain how to use logrotate to manage logs on Ubuntu 18.04 server.

Requirements

  • A server running Ubuntu 18.04 server.
  • A non-root user with sudo privileges.

Install Logrotate

By default, logrotate is available in the Ubuntu 18.04 LTS server. If not then you can install it by running the following command:

sudo apt-get install logrotate -y

Once the logrotate has been installed, you can check the version of logrotate using the following command:

sudo logrotate

Output:

logrotate 3.11.0 - Copyright (C) 1995-2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License

Usage: logrotate [-dfv?] [-d|--debug] [-f|--force] [-m|--mail=command]
        [-s|--state=statefile] [-v|--verbose] [-l|--log=STRING] [--version]
        [-?|--help] [--usage] [OPTION...] 

Configure Logrotate

By default, logrotate’s main configuration file logrotate.conf is located at /etc/logrotate.conf. Other configuration files are available at /etc/logrotate.d. You can list out them with the following command:

ls /etc/logrotate.d

Output:

alternatives  apport  dpkg  mysql-server  rsyslog  unattended-upgrades
apache2       apt     lxd   openproject   ufw

The main options of logrotate are listed below:

missingok : Don’t raise an error if the log is missing

weekly: rotates the log files once a week

create: The old file is saved under a new name and a new file is created

compress: logrotate compress log files using gzip to save space

rotate 4: logrotate rotates a given log four times before deleting it, so this keeps four weeks of logs online

notifyempty: Don’t rotate the log file when it is empty

By default, logrotate runs on a daily basis by executing the shell script /etc/cron.daily/logrotate. Let’s test the apache logrotation by running the following command:

sudo logrotate -d /etc/logrotate.d/apache2

Output:

reading config file /etc/logrotate.d/apache2
Reading state from file: /var/lib/logrotate/status
Allocating hash table for state file, size 64 entries

Handling 1 logs

rotating pattern: /var/log/apache2/*.log  after 1 days (14 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/access.log
Creating new state
  Now: 2018-10-11 16:04
  Last rotated at 2018-10-11 16:00
  log does not need rotating (log has been already rotated)
considering log /var/log/apache2/error.log
Creating new state
  Now: 2018-10-11 16:04
  Last rotated at 2018-10-11 16:00
  log does not need rotating (log has been already rotated)
considering log /var/log/apache2/other_vhosts_access.log
Creating new state
  Now: 2018-10-11 16:04
  Last rotated at 2018-10-11 16:00
  log does not need rotating (log has been already rotated)
not running prerotate script, since no logs will be rotated
not running postrotate script, since no logs were rotated

By default, logrotate is run as a daily cron job. You can check /etc/cron.daily/logrotate for more information about cron job. You can also configure the cron job for logrotate to run hourly, weekly and yearly.

Hitesh Jethva

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.

Linux whatis Command Tutorial for Beginners (5 Examples)

Man pages are one of the most useful resources when it comes to understanding command line utilities. A man page, however, contains a lot of details about the command. There may be times when you’d want to quickly know – may be in a small line or so – what a command line tool does. Well, you’ll be glad to know there exists a command that’s specifically built for this purpose.

In this tutorial, we will discuss the basics of the whatis command using some easy to understand examples. But before we do that, it’s worth mentioning that all examples here have been tested on an Ubuntu 18.04 LTS machine.

Linux whatis command

The whatis command in Linux lets you display one line manual page descriptions. Following is its syntax:

whatis  [-dlv?V]  [-r|-w]  [-s  list]  [-m  system[,…]] [-M path] [-L
       locale] [-C file] name …

And here’s how the tool’s man page explains it:

       Each manual page has a short description available within  it.   whatis
       searches  the  manual  page names and displays the manual page descrip?
       tions of any name matched.

       name may contain wildcards (-w) or be a regular expression (-r).  Using
       these  options, it may be necessary to quote the name or escape () the
       special characters to stop the shell from interpreting them.

Following are some Q&A styled examples that should give you a better idea on how the whatis command works.

Q1. How to use the whatis command?

Basic usage is pretty simple. Just pass a tool name as input, and whatis will search and display a one line description for it.

Here’s an example:

whatis ls

The following output was produced by the aforementioned command:

ls (1)               - list directory contents

Q2. How to get information for more than one commands?

This is also pretty easy – just pass the tool names as input to whatis. Following is an example:

whatis ls cp rm mv

And here’s the output produced by this command:

ls (1)               - list directory contents
cp (1)               - copy files and directories
rm (1)               - remove files or directories
mv (1)               - move (rename) files

So you can see the whatis command handles multiple input easily.

Q3. Can we use wildcards with whatis?

Yes, it’s possible to use wildcards with the whatis command. The -w command line option enables this feature.

Here’s an example;

whatis -w ‘who*’

And following is the output:

who (1)              - show who is logged on
whoami (1)           - print effective userid

Q4. How to make whatis produce debugging information?

The -d option makes the whatis command produce debugging information in output. Needless to say, this option is mainly for developers.

Here’s an example:

whatis -d ls

And following is the output produced by this command:

From the config file /etc/manpath.config:

Mandatory mandir `/usr/man'.
Mandatory mandir `/usr/share/man'.
Mandatory mandir `/usr/local/share/man'.
Path `/bin' mapped to mandir `/usr/share/man'.
Path `/usr/bin' mapped to mandir `/usr/share/man'.
Path `/sbin' mapped to mandir `/usr/share/man'.
Path `/usr/sbin' mapped to mandir `/usr/share/man'.
Path `/usr/local/bin' mapped to mandir `/usr/local/man'.
Path `/usr/local/bin' mapped to mandir `/usr/local/share/man'.
Path `/usr/local/sbin' mapped to mandir `/usr/local/man'.
Path `/usr/local/sbin' mapped to mandir `/usr/local/share/man'.
Path `/usr/X11R6/bin' mapped to mandir `/usr/X11R6/man'.
Path `/usr/bin/X11' mapped to mandir `/usr/X11R6/man'.
Path `/usr/games' mapped to mandir `/usr/share/man'.
Path `/opt/bin' mapped to mandir `/opt/man'.
Path `/opt/sbin' mapped to mandir `/opt/man'.
Global mandir `/usr/man', catdir `/var/cache/man/fsstnd'.
Global mandir `/usr/share/man', catdir `/var/cache/man'.
Global mandir `/usr/local/man', catdir `/var/cache/man/oldlocal'.
Global mandir `/usr/local/share/man', catdir `/var/cache/man/local'.
Global mandir `/usr/X11R6/man', catdir `/var/cache/man/X11R6'.
Global mandir `/opt/man', catdir `/var/cache/man/opt'.
Added section `1'.
Added section `n'.
Added section `l'.
Added section `8'.
Added section `3'.
Added section `2'.
Added section `3posix'.
Added section `3pm'.
Added section `3perl'.
Added section `3am'.
Added section `5'.
Added section `4'.
Added section `9'.
Added section `6'.
Added section `7'.
`/usr/man'    `'    `1'
`/usr/share/man'    `'    `1'
`/usr/local/share/man'    `'    `1'
`/bin'    `/usr/share/man'    `0'
`/usr/bin'    `/usr/share/man'    `0'
`/sbin'    `/usr/share/man'    `0'
`/usr/sbin'    `/usr/share/man'    `0'
`/usr/local/bin'    `/usr/local/man'    `0'
`/usr/local/bin'    `/usr/local/share/man'    `0'
`/usr/local/sbin'    `/usr/local/man'    `0'
`/usr/local/sbin'    `/usr/local/share/man'    `0'
`/usr/X11R6/bin'    `/usr/X11R6/man'    `0'
`/usr/bin/X11'    `/usr/X11R6/man'    `0'
`/usr/games'    `/usr/share/man'    `0'
`/opt/bin'    `/opt/man'    `0'
`/opt/sbin'    `/opt/man'    `0'
`/usr/man'    `/var/cache/man/fsstnd'    `-1'
`/usr/share/man'    `/var/cache/man'    `-1'
`/usr/local/man'    `/var/cache/man/oldlocal'    `-1'
`/usr/local/share/man'    `/var/cache/man/local'    `-1'
`/usr/X11R6/man'    `/var/cache/man/X11R6'    `-1'
`/opt/man'    `/var/cache/man/opt'    `-1'
`1'    `'    `-5'
`n'    `'    `-5'
`l'    `'    `-5'
`8'    `'    `-5'
`3'    `'    `-5'
`2'    `'    `-5'
`3posix'    `'    `-5'
`3pm'    `'    `-5'
`3perl'    `'    `-5'
`3am'    `'    `-5'
`5'    `'    `-5'
`4'    `'    `-5'
`9'    `'    `-5'
`6'    `'    `-5'
`7'    `'    `-5'

path directory /usr/local/sbin is in the config file
adding /usr/local/man to manpath
adding /usr/local/share/man to manpath

path directory /usr/local/bin is in the config file
/usr/local/man is already in the manpath
/usr/local/share/man is already in the manpath

path directory /usr/sbin is in the config file
adding /usr/share/man to manpath

path directory /usr/bin is in the config file
/usr/share/man is already in the manpath

path directory /sbin is in the config file
/usr/share/man is already in the manpath

path directory /bin is in the config file
/usr/share/man is already in the manpath

path directory /usr/games is in the config file
/usr/share/man is already in the manpath

path directory /usr/local/games is not in the config file
but does have a ../man, man, ../share/man, or share/man subdirectory
/usr/local/man is already in the manpath

path directory /snap/bin is not in the config file
and doesn't have ../man, man, ../share/man, or share/man subdirectories

adding mandatory man directories

warning: /usr/man: No such file or directory
/usr/share/man is already in the manpath
/usr/local/share/man is already in the manpath
add_nls_manpaths(): processing /usr/local/man:/usr/local/share/man:/usr/share/man
checking for locale en_IN
adding /usr/local/man to manpathlist
adding /usr/local/share/man to manpathlist
adding /usr/share/man to manpathlist
adding /usr/local/man to manpathlist
adding /usr/local/share/man to manpathlist
adding /usr/share/man to manpathlist
Removing duplicate manpath entry /usr/local/share/man (1) -> /usr/local/man (0)
Removing duplicate manpath entry /usr/local/man (2) -> /usr/local/man (0)
Removing duplicate manpath entry /usr/local/share/man (2) -> /usr/local/man (0)
Removing duplicate manpath entry /usr/share/man (2) -> /usr/share/man (1)
final search path = /usr/local/man:/usr/share/man
path=/usr/local/man
warning: can't read the fallback whatis text database /usr/local/man/whatis
path=/usr/share/man
name:      ls
sec. ext:  1
section:   1
comp. ext: gz
id:        A
mtime:     1516268629.000000000
pointer:   -
filter:    -
whatis:    list directory contents

ls (1)               - list directory contents
hashtable_free: 1 entries, 1 (100%) unique

Q5. How whatis performs its searches?

Here’s a relevant excerpt from the man page:

       index databases are used during the search,  and  are  updated  by  the
       mandb  program.   Depending  on your installation, this may be run by a
       periodic cron job, or may need to be  run  manually  after  new  manual
       pages  have  been installed.  To produce an old style text whatis data?
       base from the relative index database, issue the command:

       whatis -M manpath -w '*' | sort > manpath/whatis

       where manpath is a manual page hierarchy such as /usr/man.

Conclusion

If you are too much into the Linux command line tools, or your daily work involves dealing with man pages, the whatis command may be a helpful tool for you. We’ve already discussed some whatis command line options here. For more info, head to the tool’s man page.

Himanshu Arora has been working on Linux since 2007. He carries professional experience in system level programming, networking protocols, and command line. In addition to HowtoForge, Himanshu’s work has also been featured in some of world’s other leading publications including Computerworld, IBM DeveloperWorks, and Linux Journal.

Linux tload Command Tutorial for Beginners (with Examples)

Linux tload Command Tutorial for Beginners (with Examples)

While there are a lot of UI-based tools in Linux that you can use to see a graphical representation of system load, the number of command line tools that do the same work is pretty less. One such utility is tload, which will be discussing in this tutorial.

But before we do that, it’s worth mentioning that all examples in this article have been tested on an Ubuntu 18.04 LTS machine.

Linux tload command

The tload command in Linux provides you with a graphic representation of system load average. Following is its syntax:

tload [options] [tty]

And here’s how the tool’s man page explains it:

tload  prints  a  graph  of the current system load average to the specified tty (or the tty of 
the tload process if none is specified).

Following are some Q&A-styled examples that should give you a better idea on how the tload command works.

Q1. How to use tload?

Basic usage is pretty straight forward – just execute ‘tload’ sans any option. The graph produced in output will likely take some time to build up, but after sometime, you’ll see something like this:

The graph, as you can see, consists of symbols like *, =, and -. While the tool’s man page doesn’t say anything about these symbols, there’s some useful explanation about this on a serverfault thread.

It's just the graphical (weird) representation of the last minute load average of the system over 
the time.

The "*"s are just the representation of the level of load average. Understand it as a clasical
"area graph". The "-" sings just define the unities of load, and the "=" substitute the "-" when
the bar passes the line that marks the unit of the graph.

Q2. Does tload provide any scaling option?

Yes, it does. The option is -s. Here’s how the tool’s man page explains it:

The scale option allows a vertical scale to be specified for the display  (in  characters  
between  graph  ticks);  thus, a smaller value represents a larger scale, and vice versa.

For example:

tload -s 20

Q3. How to set delay in graph updates?

When you run the tload command, you’ll notice that the graph it produces continuously updates. However, if you want, you can set a delay between graph updates.

This can be done using the -d command line option. For example:

tload -d 5

This command will ensure the graph updates after 5 seconds.

Conclusion

Agreed, this command is mostly for system admins. The number of options it offers is also limited. We have already discussed the major options this utility offers. To learn more, head to the tload man page.

Himanshu Arora has been working on Linux since 2007. He carries professional experience in system level programming, networking protocols, and command line. In addition to HowtoForge, Himanshu’s work has also been featured in some of world’s other leading publications including Computerworld, IBM DeveloperWorks, and Linux Journal.