10 Cool Command Line Tools For Your Linux Terminal

In this article, we will share a number of cool command-line programs that you can use in a Linux terminal. By the end of this article, you will learn about some free, open source, and exciting, text-based tools to help you do more with boredom on the Command line.

1. Wikit

Wikit is a command line utility to search Wikipedia in Linux. It basically displays Wikipedia summaries. Once you have it installed, simply provide the search term as an argument (for example wikit linux).

Wikipedia Command Line View

Wikipedia Command Line View

2. Googler

Googler is a full-featured Python-based command line tool for accessing Google (Web & News) and Google Site Search within the Linux terminal. It is fast and clean with custom colors and no ads, stray URLs or clutter included. It supports navigation of search result pages from omniprompt.

In addition, it supports fetching of number of results in a go, users can start at the nth result, and supports limiting of search by attributes such as duration, country/domain specific search (default: .com), language preference.

Google Search from Linux Terminal

Google Search from Linux Terminal

3. Browsh

Browsh is a small, modern text based browser that play videos and render anything that a modern browser can, in TTY terminal environments.

It supports HTML5, CSS3, JS, video as well as WebGL. It is a bandwidth-saver, designed to run on a remote server and accessed via SSH/Mosh or the in-browser HTML service so as to notably reduce bandwidth.

It is practically useful when you don’t have good Internet connection.

Browsh Web Browsing

Browsh Web Browsing

4. Lolcat

Lolcat is a command-line program to output rainbow of colors in the Linux terminal. It concatenates the output of a command in a similar way as cat command and adds rainbow coloring to the final output.

To use lolcat, simply pipe the output of any command to lolcat.

Cowsay with Lolcat

Cowsay with Lolcat

5. Boxes

Boxes is a configurable program and text filter which can draw ASCII art boxes around its input text in a Linux terminal. It comes with a number of pre-configured box designs in example config file. It comes with several command-line options and supports regular expression substitutions on input text.

You can use it to: draws ASCII art boxes and shapes, generate regional comments in source code and more.

Boxes - Draw ASCII Art in Terminal

Boxes – Draw ASCII Art in Terminal

6. Figlet and Toilet

FIGlet is a useful command-line utility for creating ASCII text banners or large letters out of ordinary text. Toiletis a sub-command under figlet for creating colorful large characters from ordinary text.

Figlet - Create ASCII Text Banners in Terminal

Figlet – Create ASCII Text Banners in Terminal

7. Trash-cli

Trash-cli is a program that trashes files recording the original path, deletion date, and permissions. It is an interface to the freedesktop.org trashcan.

Manage ‘Trash’ from Linux Command Line

Manage ‘Trash’ from Linux Command Line

Trash-cli – A Trashcan Tool

Trash-cli – A Trashcan Tool

8. No More Secrets

No More Secrets is a text-based program recreates the famous data decryption effect seen in the 1992 movie Sneakers. It provides a command-line utility called nms, that you can use in a similar way as lolcat – simply pipe the out of another command to nms, and see the magic.

No More Secrets - Recreates Data Decryption Effect

No More Secrets – Recreates Data Decryption Effect

9. Chafa

Chafa is a another cool, fast and highly configurable terminal program that provides terminal graphics for the 21st century.

It works with most modern and classic terminals and terminal emulators. It converts all types of images (including animated GIFs), into ANSI/Unicode character output that can be displayed in a terminal.

Chafa supports for alpha transparency and multiple color modes (including Truecolor, 256-color, 16-color and simple FG/BG.) and color spaces, combining selectable ranges of Unicode characters to produce the desired output.

It is suitable for terminal graphics, ANSI art composition as well as even black and white print.

Chafa - Converts to ANSI Unicode Character

Chafa – Converts to ANSI Unicode Character

10. CMatrix

CMatrix is a simple command-line utility that shows a scrolling ‘Matrix‘ like screen in a Linux terminal.

It displays random text flying in and out in a terminal, in a similar way as seen in popular Sci-fi movie “The Matrix“. It can scroll lines all at the same rate or asynchronously and at a user-defined speed. One downside of Cmatrix is that it is very CPU intensive.

The Matrix in Linux Terminal

The Matrix in Linux Terminal

Here you have seen few cool command-line tools, but there is plenty more to explore. If you want to know more about such cool or funny Linux command-line tools, you can checkout our guides here:

  1. 20 Funny Commands for Your Linux Terminal
  2. 6 Interesting Funny Commands for Your Linux Terminal
  3. 10 Mysterious Commands for Your Linux Terminal
  4. 51 Useful Lesser Known Linux Commands

That’s all!

Source

10 Useful Chaining Operators in Linux with Practical Examples

Chaining of Linux commands means, combining several commands and make them execute based upon the behaviour of operator used in between them. Chaining of commands in Linux, is something like you are writing short shell scripts at the shell itself, and executing them from the terminal directly. Chaining makes it possible to automate the process. Moreover, an unattended machine can function in a much systematic way with the help of chaining operators.

Chaining Operators in Linux

10 Chaining Operators in Linux

Read Also: How to Use Awk and Regular Expressions to Filter Text in Files

This Article aims at throwing light on frequently used command­-chaining operators, with short descriptions and corresponding examples which surely will increase your productivity and lets you write short and meaningful codes beside reducing system load, at times.

1. Ampersand Operator (&)

The function of ‘&‘ is to make the command run in background. Just type the command followed with a white space and ‘&‘. You can execute more than one command in the background, in a single go.

Run one command in the background:

tecmint@localhost:~$ ping ­c5 www.tecmint.com &

Run two command in background, simultaneously:

root@localhost:/home/tecmint# apt-get update & apt-get upgrade &

2. semi-colon Operator (;)

The semi-colon operator makes it possible to run, several commands in a single go and the execution of command occurs sequentially.

root@localhost:/home/tecmint# apt-get update ; apt-get upgrade ; mkdir test

The above command combination will first execute update instruction, then upgrade instruction and finally will create a ‘test‘ directory under the current working directory.

3. AND Operator (&&)

The AND Operator (&&) would execute the second command only, if the execution of first command SUCCEEDS, i.e., the exit status of the first command is 0. This command is very useful in checking the execution status of last command.

For example, I want to visit website tecmint.com using links command, in terminal but before that I need to check if the host is live or not.

root@localhost:/home/tecmint# ping -c3 www.tecmint.com && links www.tecmint.com

4. OR Operator (||)

The OR Operator (||) is much like an ‘else‘ statement in programming. The above operator allow you to execute second command only if the execution of first command fails, i.e., the exit status of first command is ‘1‘.

For example, I want to execute ‘apt-get update‘ from non-root account and if the first command fails, then the second ‘links www.tecmint.com‘ command will execute.

tecmint@localhost:~$ apt-get update || links tecmint.com

In the above command, since the user was not allowed to update system, it means that the exit status of first command is ‘1’ and hence the last command ‘links tecmint.com‘ gets executed.

What if the first command is executed successfully, with an exit status ‘0‘? Obviously! Second command won’t execute.

tecmint@localhost:~$ mkdir test || links tecmint.com

Here, the user creates a folder ‘test‘ in his home directory, for which user is permitted. The command executed successfully giving an exit status ‘0‘ and hence the last part of the command is not executed.

5. NOT Operator (!)

The NOT Operator (!) is much like an ‘except‘ statement. This command will execute all except the condition provided. To understand this, create a directory ‘tecmint‘ in your home directory and ‘cd‘ to it.

tecmint@localhost:~$ mkdir tecmint 
tecmint@localhost:~$ cd tecmint

Next, create several types of files in the folder ‘tecmint‘.

tecmint@localhost:~/tecmint$ touch a.doc b.doc a.pdf b.pdf a.xml b.xml a.html b.html

See we’ve created all the new files within the folder ‘tecmint‘.

tecmint@localhost:~/tecmint$ ls 

a.doc  a.html  a.pdf  a.xml  b.doc  b.html  b.pdf  b.xml

Now delete all the files except ‘html‘ file all at once, in a smart way.

tecmint@localhost:~/tecmint$ rm -r !(*.html)

Just to verify, last execution. List all of the available files using ls command.

tecmint@localhost:~/tecmint$ ls a.html  b.html

6. AND – OR operator (&& – ||)

The above operator is actually a combination of ‘AND‘ and ‘OR‘ Operator. It is much like an ‘if-else‘ statement.

For example, let’s do ping to tecmint.com, if success echo ‘Verified‘ else echo ‘Host Down‘.

tecmint@localhost:~/tecmint$ ping -c3 www.tecmint.com && echo "Verified" || echo "Host Down"
Sample Output
PING www.tecmint.com (212.71.234.61) 56(84) bytes of data. 
64 bytes from www.tecmint.com (212.71.234.61): icmp_req=1 ttl=55 time=216 ms 
64 bytes from www.tecmint.com (212.71.234.61): icmp_req=2 ttl=55 time=224 ms 
64 bytes from www.tecmint.com (212.71.234.61): icmp_req=3 ttl=55 time=226 ms 

--- www.tecmint.com ping statistics --- 
3 packets transmitted, 3 received, 0% packet loss, time 2001ms 
rtt min/avg/max/mdev = 216.960/222.789/226.423/4.199 ms 
Verified

Now, disconnect your internet connection, and try same command again.

tecmint@localhost:~/tecmint$ ping -c3 www.tecmint.com && echo "verified" || echo "Host Down"
Sample Output
ping: unknown host www.tecmint.com 
Host Down

7. PIPE Operator (|)

This PIPE operator is very useful where the output of first command acts as an input to the second command. For example, pipeline the output of ‘ls -l‘ to ‘less‘ and see the output of the command.

tecmint@localhost:~$ ls -l | less

8. Command Combination Operator {}

Combine two or more commands, the second command depends upon the execution of the first command.

For example, check if a directory ‘bin‘ is available or not, and output corresponding output.

tecmint@localhost:~$ [ -d bin ] || { echo Directory does not exist, creating directory now.; mkdir bin; } && echo Directory exists.

9. Precedence Operator ()

The Operator makes it possible to execute command in precedence order.

Command_x1 &&Command_x2 || Command_x3 && Command_x4.

In the above pseudo command, what if the Command_x1 fails? Neither of the Command_x2Command_x3Command_x4 would executed, for this we use Precedence Operator, as:

(Command_x1 &&Command_x2) || (Command_x3 && Command_x4)

In the above pseudo command, if Command_x1 fails, Command_x2 also fails but Still Command_x3 and Command_x4 executes depends upon exit status of Command_x3.

10. Concatenation Operator (\)

The Concatenation Operator (\) as the name specifies, is used to concatenate large commands over several lines in the shell. For example, The below command will open text file test(1).txt.

tecmint@localhost:~/Downloads$ nano test\(1\).txt

Source

Linux Performance Monitoring with Vmstat and Iostat Commands

This is our on-going series of commands and performance monitoring in LinuxVmstat and Iostat both commands are available on all major Unix-like (Linux/Unix/FreeBSD/Solaris) Operating Systems.

If vmstat and iostat commands are not available on your box, please install sysstat package. The vmstatsarand iostat commands are the collection of package included in sysstat – the system monitoring tools. The iostat generates reports of CPU & all device statistics. You may download and install sysstat using source tarball from link sysstat, but we recommend installing through YUM command.

Linux Vmstat and Iostat Commands

Linux Performance Monitoring with Vmstat and Iostat

Install Sysstat in Linux

# yum -y install sysstat
  1. vmstat – Summary information of MemoryProcessesPaging etc.
  2. iostat – Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
6 Vmstat Command Examples in Linux

1. List Active and Inactive Memory

In the below example, there are six columns. The significant of the columns are explained in man page of vmstat in details. Most important fields are free under memory and si, so under swap column.

[root@tecmint ~]# vmstat -a

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 810420  97380  70628    0    0   115     4   89   79  1  6 90  3  0
    1. Free – Amount of free/idle memory spaces.
    2. si – Swaped in every second from disk in Kilo Bytes.
    3. so – Swaped out every second to disk in Kilo Bytes.

Note: If you run vmstat without parameters it’ll displays summary report since system boot.

2. Execute vmstat ‘X’ seconds and (‘N’number of times)

With this command, vmstat execute every two seconds and stop automatically after executing six intervals.

[root@tecmint ~]# vmstat 2 6

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 810420  22064 101368    0    0    56     3   50   57  0  3 95  2  0
 0  0      0 810412  22064 101368    0    0     0     0   16   35  0  0 100  0  0
 0  0      0 810412  22064 101368    0    0     0     0   14   35  0  0 100  0  0
 0  0      0 810412  22064 101368    0    0     0     0   17   38  0  0 100  0  0
 0  0      0 810412  22064 101368    0    0     0     0   17   35  0  0 100  0  0
 0  0      0 810412  22064 101368    0    0     0     0   18   36  0  1 100  0  0

3. Vmstat with timestamps

vmstat command with -t parameter shows timestamps with every line printed as shown below.

[tecmint@tecmint ~]$ vmstat -t 1 5

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 632028  24992 192244    0    0    70     5   55   78  1  3 95  1  0        2012-09-02 14:57:18 IST
 1  0      0 632028  24992 192244    0    0     0     0  171  514  1  5 94  0  0        2012-09-02 14:57:19 IST
 1  0      0 631904  24992 192244    0    0     0     0  195  600  0  5 95  0  0        2012-09-02 14:57:20 IST
 0  0      0 631780  24992 192244    0    0     0     0  156  524  0  5 95  0  0        2012-09-02 14:57:21 IST
 1  0      0 631656  24992 192244    0    0     0     0  189  592  0  5 95  0  0        2012-09-02 14:57:22 IST

4. Statistics of Various Counter

vmstat command and -s switch displays summary of various event counters and memory statistics.

[tecmint@tecmint ~]$ vmstat -s

      1030800  total memory
       524656  used memory
       277784  active memory
       185920  inactive memory
       506144  free memory
        26864  buffer memory
       310104  swap cache
      2064376  total swap
            0  used swap
      2064376  free swap
         4539 non-nice user cpu ticks
            0 nice user cpu ticks
        11569 system cpu ticks
       329608 idle cpu ticks
         5012 IO-wait cpu ticks
           79 IRQ cpu ticks
           74 softirq cpu ticks
            0 stolen cpu ticks
       336038 pages paged in
        67945 pages paged out
            0 pages swapped in
            0 pages swapped out
       258526 interrupts
       392439 CPU context switches
   1346574857 boot time
         2309 forks

5. Disks Statistics

vmstat with -d option display all disks statistics.

[tecmint@tecmint ~]$ vmstat -d

disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
ram0       0      0       0       0      0      0       0       0      0      0
ram1       0      0       0       0      0      0       0       0      0      0
ram2       0      0       0       0      0      0       0       0      0      0
ram3       0      0       0       0      0      0       0       0      0      0
ram4       0      0       0       0      0      0       0       0      0      0
ram5       0      0       0       0      0      0       0       0      0      0
ram6       0      0       0       0      0      0       0       0      0      0
ram7       0      0       0       0      0      0       0       0      0      0
ram8       0      0       0       0      0      0       0       0      0      0
ram9       0      0       0       0      0      0       0       0      0      0
ram10      0      0       0       0      0      0       0       0      0      0
ram11      0      0       0       0      0      0       0       0      0      0
ram12      0      0       0       0      0      0       0       0      0      0
ram13      0      0       0       0      0      0       0       0      0      0
ram14      0      0       0       0      0      0       0       0      0      0
ram15      0      0       0       0      0      0       0       0      0      0
loop0      0      0       0       0      0      0       0       0      0      0
loop1      0      0       0       0      0      0       0       0      0      0
loop2      0      0       0       0      0      0       0       0      0      0
loop3      0      0       0       0      0      0       0       0      0      0
loop4      0      0       0       0      0      0       0       0      0      0
loop5      0      0       0       0      0      0       0       0      0      0
loop6      0      0       0       0      0      0       0       0      0      0
loop7      0      0       0       0      0      0       0       0      0      0
sr0        0      0       0       0      0      0       0       0      0      0
sda     7712   5145  668732  409619   3282  28884  257402  644566      0    126
dm-0   11578      0  659242 1113017  32163      0  257384 8460026      0    126
dm-1     324      0    2592    3845      0      0       0       0      0      2

6. Display Statistics in Megabytes

The vmstat displays in Megabytes with parameters -S and M(Uppercase & megabytes). By default vmstatdisplays statistics in kilobytes.

[root@tecmint ~]# vmstat -S M 1 5

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0    346     53    476    0    0    95     8   42   55  0  2 96  2  0
 0  0      0    346     53    476    0    0     0     0   12   15  0  0 100  0  0
 0  0      0    346     53    476    0    0     0     0   32   62  0  0 100  0  0
 0  0      0    346     53    476    0    0     0     0   15   13  0  0 100  0  0
 0  0      0    346     53    476    0    0     0     0   34   61  0  1 99  0  0
6 Iostat Command Examples in Linux

7. Display CPU and I/O statistics

iostat without arguments displays CPU and I/O statistics of all partitions as shown below.

[root@tecmint ~]# iostat

Linux 2.6.32-279.el6.i686 (tecmint.com)         09/03/2012      _i686_  (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.12    0.01    1.54    2.08    0.00   96.24

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               3.59       161.02        13.48    1086002      90882
dm-0              5.76       159.71        13.47    1077154      90864
dm-1              0.05         0.38         0.00       2576          0

8. Shows only CPU Statistics

iostat with -c arguments displays only CPU statistics as shown below.

[root@tecmint ~]# iostat -c

Linux 2.6.32-279.el6.i686 (tecmint.com)         09/03/2012      _i686_  (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.12    0.01    1.47    1.98    0.00   96.42

9. Shows only Disks I/O Statistics

iostat with -d arguments displays only disks I/O statistics of all partitions as shown.

[root@tecmint ~]# iostat -d

Linux 2.6.32-279.el6.i686 (tecmint.com)         09/03/2012      _i686_  (1 CPU)

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               3.35       149.81        12.66    1086002      91746
dm-0              5.37       148.59        12.65    1077154      91728
dm-1              0.04         0.36         0.00       2576          0

10. Shows I/O statistics only of a single device.

By default it displays statistics of all partitions, with -p and device name arguments displays only disks I/Ostatistics for specific device only as shown.

[root@tecmint ~]# iostat -p sda

Linux 2.6.32-279.el6.i686 (tecmint.com)         09/03/2012      _i686_  (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.11    0.01    1.44    1.92    0.00   96.52

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               3.32       148.52        12.55    1086002      91770
sda1              0.07         0.56         0.00       4120         18
sda2              3.22       147.79        12.55    1080650      91752

11. Display LVM Statistics

With -N (Uppercase) parameter displays only LVM statistics as shown.

[root@tecmint ~]# iostat -N

Linux 2.6.32-279.el6.i686 (tecmint.com)         09/03/2012      _i686_  (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.11    0.01    1.39    1.85    0.00   96.64

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               3.20       142.84        12.16    1086002      92466
vg_tecmint-lv_root     5.13       141.68        12.16    1077154      92448
vg_tecmint-lv_swap     0.04         0.34         0.00       2576          0

12. iostat version.

With -V (Uppercase) parameter displays version of iostat as shown.

[root@tecmint ~]# iostat -V

sysstat version 9.0.4
(C) Sebastien Godard (sysstat  orange.fr)

Note: vmstat and iostat contains number of columns and flags which may not possible to explain in details. If you want to know more about it you may refer man page of vmstat and iostat. Please share it if you find this article is useful through our comment box below.

Source

Inxi – A Powerful Feature-Rich Commandline System Information Tool for Linux

Inxi is a powerful and remarkable command line-system information script designed for both console and IRC(Internet Relay Chat). It can be employed to instantly deduce user system configuration and hardware information, and also functions as a debugging, and forum technical support tool.

It displays handy information concerning system hardware (hard disk, sound cards, graphic card, network cards, CPU, RAM, and more), together with system information about drivers, Xorg, desktop environment, kernel, GCC version(s), processes, uptime, memory, and a wide array of other useful information.

However, it’s output slightly differs between the command line and IRC, with a few default filters and color options applicable to IRC usage. The supported IRC clients include: BitchX, Gaim/Pidgin, ircII, Irssi, Konversation, Kopete, KSirc, KVIrc, Weechat, and Xchat plus any others that are capable of showing either built in or external Inxi output.

How to Install Inxi in Linux System

Inix is available in most mainstream Linux distribution repositories, and runs on BSDs as well.

$ sudo apt-get install inxi   [On Debian/Ubuntu/Linux Mint]
$ sudo yum install inxi       [On CentOs/RHEL/Fedora]
$ sudo dnf install inxi       [On Fedora 22+]

Before we start using it, we can run the command that follows to check all application dependencies plus recommends, and various directories, and display what package(s) we need to install to add support for a given feature.

$ inxi --recommends 
Inxi Checking
inxi will now begin checking for the programs it needs to operate. First a check of the main languages and tools
inxi uses. Python is only for debugging data collection.
---------------------------------------------------------------------------
Bash version: 4.3.42(1)-release
Gawk version: 4.1.3,
Sed version: 
Sudo version: 1.8.16
Python version: 2.7.12
---------------------------------------------------------------------------
Test One: Required System Directories (Linux Only).
If one of these system directories is missing, inxi cannot operate:

/proc....................................................................... Present
/sys........................................................................ Present

All the  directories are present.
---------------------------------------------------------------------------
Test Two: Required Core Applications.
If one of these applications is missing, inxi cannot operate:

df (info: partition data)................................................... /bin/df
gawk (info: core tool)...................................................... /usr/bin/gawk
grep (info: string search).................................................. /bin/grep
lspci (info: hardware data)................................................. /usr/bin/lspci
ps (info: process data)..................................................... /bin/ps
readlink.................................................................... /bin/readlink
sed (info: string replace).................................................. /bin/sed
tr (info: character replace)................................................ /usr/bin/tr
uname (info: kernel data)................................................... /bin/uname
wc (info: word character count)............................................. /usr/bin/wc

All the  applications are present.
---------------------------------------------------------------------------
Test Three: Script Recommends for Graphics Features.
NOTE: If you do not use X these do not matter (like a headless server). Otherwise, if one of these applications
is missing, inxi will have incomplete output:

glxinfo (info: -G glx info)................................................. /usr/bin/glxinfo
xdpyinfo (info: -G multi screen resolution)................................. /usr/bin/xdpyinfo
xprop (info: -S desktop data)............................................... /usr/bin/xprop
xrandr (info: -G single screen resolution).................................. /usr/bin/xrandr

All the  applications are present.
---------------------------------------------------------------------------
Test Four: Script Recommends for Remaining Features.
If one of these applications is missing, inxi will have incomplete output:

dig (info: -i first wlan ip default test)................................... /usr/bin/dig
dmidecode (info: -M if no sys machine data; -m memory)...................... /usr/sbin/dmidecode
file (info: -o unmounted file system)....................................... /usr/bin/file
hciconfig (info: -n -i bluetooth data)...................................... /bin/hciconfig
hddtemp (info: -Dx show hdd temp)........................................... /usr/sbin/hddtemp
ifconfig (info: -i ip lan-deprecated)....................................... /sbin/ifconfig
ip (info: -i ip lan)........................................................ /sbin/ip
sensors (info: -s sensors output)........................................... /usr/bin/sensors
strings (info: -I sysvinit version)......................................... /usr/bin/strings
lsusb (info: -A usb audio;-N usb networking)................................ /usr/bin/lsusb
modinfo (info: -Ax,-Nx module version)...................................... /sbin/modinfo
runlevel (info: -I runlevel)................................................ /sbin/runlevel
sudo (info: -Dx hddtemp-user;-o file-user).................................. /usr/bin/sudo
uptime (info: -I uptime (check which package owns Debian)).................. /usr/bin/uptime

All the  applications are present.
---------------------------------------------------------------------------
Test Five: Script Recommends for Remaining Features.
One of these downloaders needed for options -i/-w/-W (-U/-! [11-15], if supported):

wget (info: -i wan ip;-w/-W;-U/-! [11-15] (if supported))................... /usr/bin/wget
curl (info: -i wan ip;-w/-W;-U/-! [11-15] (if supported))................... /usr/bin/curl

All the  applications are present.
---------------------------------------------------------------------------
Test Six: System Directories for Various Information.
(Unless otherwise noted, these are for GNU/Linux systems)
If one of these directories is missing, inxi may have incomplete output:

/sys/class/dmi/id (info: -M system, motherboard, bios)...................... Present
/dev (info: -l,-u,-o,-p,-P,-D disk partition data).......................... Present
/dev/disk/by-label (info: -l,-o,-p,-P partition labels)..................... Present
/dev/disk/by-uuid (info: -u,-o,-p,-P partition uuid)........................ Present

All the  directories are present.
---------------------------------------------------------------------------
Test Seven: System Files for Various Information.
(Unless otherwise noted, these are for GNU/Linux systems)
If one of these files is missing, inxi may have incomplete output:

/proc/asound/cards (info: -A sound card data)............................... Present
/proc/asound/version (info: -A ALSA data)................................... Present
/proc/cpuinfo (info: -C cpu data)........................................... Present
/etc/lsb-release (info: -S distro version data [deprecated])................ Present
/proc/mdstat (info: -R mdraid data)......................................... Present
/proc/meminfo (info: -I memory data)........................................ Present
/etc/os-release (info: -S distro version data).............................. Present
/proc/partitions (info: -p,-P partitions data).............................. Present
/proc/modules (info: -G module data)........................................ Present
/proc/mounts (info: -P,-p partition advanced data).......................... Present
/var/run/dmesg.boot (info: -D,-d disk data [BSD only])...................... Missing
/proc/scsi/scsi (info: -D Advanced hard disk data [used rarely])............ Present
/var/log/Xorg.0.log (info: -G graphics driver load status).................. Present

The following files are missing from your system:
File: /var/run/dmesg.boot
---------------------------------------------------------------------------
All tests completed.

Basic Usage of Inxi Tool in Linux

Below are some basic Inxi options we can use to collect machine plus system information.

Show Linux System Information

When run without any flags, Inxi will produce output to do with system CPU, kernel, uptime, memory size, hard disk size, number of processes, client used and inxi version:

$ inxi

CPU~Dual core Intel Core i5-4210U (-HT-MCP-) speed/max~2164/2700 MHz Kernel~4.4.0-21-generic x86_64 Up~3:15 Mem~3122.0/7879.9MB HDD~1000.2GB(20.0% used) Procs~234 Client~Shell inxi~2.2.35

Show Linux Kernel and Distribution Info

The command below will show sample system info (hostname, kernel info, desktop environment and disto) using the -S flag:

$ inxi -S

System: Host: TecMint Kernel: 4.4.0-21-generic x86_64 (64 bit) Desktop: Cinnamon 3.0.7
        Distro: Linux Mint 18 Sarah

Find Linux Laptop or PC Model Information

To print machine data-same as product details (system, product id, version, Mobo, model, BIOS etc), we can use the option -M as follows:

$ inxi -M

Machine:   System: LENOVO (portable) product: 20354 v: Lenovo Z50-70
           Mobo: LENOVO model: Lancer 5A5 v: 31900059WIN Bios: LENOVO v: 9BCN26WW date: 07/31/2014

Find Linux CPU and CPU Speed Information

We can display complete CPU information, including per CPU clock-speed and CPU max speed (if available) with the -C flag as follows:

$ inxi -C

CPU:       Dual core Intel Core i5-4210U (-HT-MCP-) cache: 3072 KB 
           clock speeds: max: 2700 MHz 1: 1942 MHz 2: 1968 MHz 3: 1734 MHz 4: 1710 MHz

Find Graphic Card Information in Linux

The option -G can be used to show graphics card info (card type, display server, resolution, GLX renderer and GLX version) like so:

$ inxi -G

Graphics:  Card-1: Intel Haswell-ULT Integrated Graphics Controller
           Card-2: NVIDIA GM108M [GeForce 840M]
           Display Server: X.Org 1.18.4 drivers: intel (unloaded: fbdev,vesa) Resolution: 1920x1080@60.05hz
           GLX Renderer: Mesa DRI Intel Haswell Mobile GLX Version: 3.0 Mesa 11.2.0

Find Audio/Sound Card Information in Linux

To get info about system audio/sound card, we use the -A flag:

$ inxi -A

Audio:     Card-1 Intel 8 Series HD Audio Controller driver: snd_hda_intel Sound: ALSA v: k4.4.0-21-generic
           Card-2 Intel Haswell-ULT HD Audio Controller driver: snd_hda_intel

Find Linux Network Card Information

To display network card info, we can make use of -N flag:

$ inxi -N

Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169
           Card-2: Realtek RTL8723BE PCIe Wireless Network Adapter driver: rtl8723be

Find Linux Hard Disk Information

To view full hard disk information,(size, id, model) we can use the flag -D:

$ inxi -D

Drives:    HDD Total Size: 1000.2GB (20.0% used) ID-1: /dev/sda model: ST1000LM024_HN size: 1000.2GB

Summarize Full Linux System Information Together

To show a summarized system information; combining all the information above, we need to use the -b flag as below:

$ inxi -b 

System:    Host: TecMint Kernel: 4.4.0-21-generic x86_64 (64 bit) Desktop: Cinnamon 3.0.7
           Distro: Linux Mint 18 Sarah
Machine:   System: LENOVO (portable) product: 20354 v: Lenovo Z50-70
           Mobo: LENOVO model: Lancer 5A5 v: 31900059WIN Bios: LENOVO v: 9BCN26WW date: 07/31/2014
CPU:       Dual core Intel Core i5-4210U (-HT-MCP-) speed/max: 2018/2700 MHz
Graphics:  Card-1: Intel Haswell-ULT Integrated Graphics Controller
           Card-2: NVIDIA GM108M [GeForce 840M]
           Display Server: X.Org 1.18.4 drivers: intel (unloaded: fbdev,vesa) Resolution: 1920x1080@60.05hz
           GLX Renderer: Mesa DRI Intel Haswell Mobile GLX Version: 3.0 Mesa 11.2.0
Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169
           Card-2: Realtek RTL8723BE PCIe Wireless Network Adapter driver: rtl8723be
Drives:    HDD Total Size: 1000.2GB (20.0% used)
Info:      Processes: 233 Uptime: 3:23 Memory: 3137.5/7879.9MB Client: Shell (bash) inxi: 2.2.35  

Find Linux Hard Disk Partition Details

The next command will enable us view complete list of hard disk partitions in relation to size, used and available space, filesystem as well as filesystem type on each partition with the -p flag:

$ inxi -p

Partition: ID-1: / size: 324G used: 183G (60%) fs: ext4 dev: /dev/sda10
           ID-2: swap-1 size: 4.00GB used: 0.00GB (0%) fs: swap dev: /dev/sda9

Shows Full Linux System Information

In order to show complete Inxi output, we use the -F flag as below (note that certain data is filtered for security reasons such as WAN IP):

$ inxi -F 

System:    Host: TecMint Kernel: 4.4.0-21-generic x86_64 (64 bit) Desktop: Cinnamon 3.0.7
           Distro: Linux Mint 18 Sarah
Machine:   System: LENOVO (portable) product: 20354 v: Lenovo Z50-70
           Mobo: LENOVO model: Lancer 5A5 v: 31900059WIN Bios: LENOVO v: 9BCN26WW date: 07/31/2014
CPU:       Dual core Intel Core i5-4210U (-HT-MCP-) cache: 3072 KB 
           clock speeds: max: 2700 MHz 1: 1716 MHz 2: 1764 MHz 3: 1776 MHz 4: 1800 MHz
Graphics:  Card-1: Intel Haswell-ULT Integrated Graphics Controller
           Card-2: NVIDIA GM108M [GeForce 840M]
           Display Server: X.Org 1.18.4 drivers: intel (unloaded: fbdev,vesa) Resolution: 1920x1080@60.05hz
           GLX Renderer: Mesa DRI Intel Haswell Mobile GLX Version: 3.0 Mesa 11.2.0
Audio:     Card-1 Intel 8 Series HD Audio Controller driver: snd_hda_intel Sound: ALSA v: k4.4.0-21-generic
           Card-2 Intel Haswell-ULT HD Audio Controller driver: snd_hda_intel
Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169
           IF: enp1s0 state: up speed: 100 Mbps duplex: full mac: 28:d2:44:eb:bd:98
           Card-2: Realtek RTL8723BE PCIe Wireless Network Adapter driver: rtl8723be
           IF: wlp2s0 state: down mac: 38:b1:db:7c:78:c7
Drives:    HDD Total Size: 1000.2GB (20.0% used) ID-1: /dev/sda model: ST1000LM024_HN size: 1000.2GB
Partition: ID-1: / size: 324G used: 183G (60%) fs: ext4 dev: /dev/sda10
           ID-2: swap-1 size: 4.00GB used: 0.00GB (0%) fs: swap dev: /dev/sda9
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 56.0C mobo: N/A
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 234 Uptime: 3:26 Memory: 3188.9/7879.9MB Client: Shell (bash) inxi: 2.2.35 

Linux System Monitoring with Inxi Tool

Following are few options used to monitor Linux system processes, uptime, memory etc.

Monitor Linux Processes Memory Usage

Get summarized system info in relation to total number of processes, uptime and memory usage:

$ inxi -I

Info:      Processes: 232 Uptime: 3:35 Memory: 3256.3/7879.9MB Client: Shell (bash) inxi: 2.2.35 

Monitoring Processes by CPU and Memory Usage

By default, it can help us determine the top 5 processes consuming CPU or memory. The -t option used together with c (CPU) and/or m (memory) options lists the top 5 most active processes eating up CPU and/or memory as shown below:

----------------- Linux CPU Usage ----------------- 
$ inxi -t c 
Processes: CPU: % used - top 5 active
           1: cpu: 53.7% command: plugin-container pid: 3066
           2: cpu: 20.0% command: java pid: 1527
           3: cpu: 19.7% command: firefox pid: 3018
           4: cpu: 4.6% command: Xorg pid: 2114
           5: cpu: 3.0% command: cinnamon pid: 2835
----------------- Linux Memoery Usage ----------------- 
$ inxi -t m
Processes: Memory: MB / % used - Used/Total: 3212.5/7879.9MB - top 5 active
           1: mem: 980.51MB (12.4%) command: plugin-container pid: 3066
           2: mem: 508.96MB (6.4%) command: java pid: 1527
           3: mem: 507.89MB (6.4%) command: firefox pid: 3018
           4: mem: 244.05MB (3.0%) command: chrome pid: 7405
           5: mem: 211.46MB (2.6%) command: chrome pid: 6146
----------------- Linux CPU and Memory Usage ----------------- 
$ inxi -t cm
Processes: CPU: % used - top 5 active
           1: cpu: 53.7% command: plugin-container pid: 3066
           2: cpu: 20.0% command: java pid: 1527
           3: cpu: 19.7% command: firefox pid: 3018
           4: cpu: 4.6% command: Xorg pid: 2114
           5: cpu: 3.0% command: cinnamon pid: 2835
           Memory: MB / % used - Used/Total: 3223.6/7879.9MB - top 5 active
           1: mem: 991.93MB (12.5%) command: plugin-container pid: 3066
           2: mem: 508.96MB (6.4%) command: java pid: 1527
           3: mem: 507.86MB (6.4%) command: firefox pid: 3018
           4: mem: 244.45MB (3.1%) command: chrome pid: 7405
           5: mem: 211.68MB (2.6%) command: chrome pid: 6146

We can use cm number (number can be 1-20) to specify a number other than 5, the command below will show us the top 10 most active processes eating up CPU and memory.

$ inxi -t cm10

Processes: CPU: % used - top 10 active
           1: cpu: 53.4% command: plugin-container pid: 3066
           2: cpu: 19.8% command: java pid: 1527
           3: cpu: 19.5% command: firefox pid: 3018
           4: cpu: 4.5% command: Xorg pid: 2114
           5: cpu: 3.0% command: cinnamon pid: 2835
           6: cpu: 2.8% command: chrome pid: 7405
           7: cpu: 1.1% command: pulseaudio pid: 2733
           8: cpu: 1.0% command: soffice.bin pid: 7799
           9: cpu: 0.9% command: chrome pid: 5763
           10: cpu: 0.5% command: chrome pid: 6179
           Memory: MB / % used - Used/Total: 3163.1/7879.9MB - top 10 active
           1: mem: 976.82MB (12.3%) command: plugin-container pid: 3066
           2: mem: 511.70MB (6.4%) command: java pid: 1527
           3: mem: 466.01MB (5.9%) command: firefox pid: 3018
           4: mem: 244.40MB (3.1%) command: chrome pid: 7405
           5: mem: 203.71MB (2.5%) command: chrome pid: 6146
           6: mem: 199.74MB (2.5%) command: chrome pid: 5763
           7: mem: 168.30MB (2.1%) command: cinnamon pid: 2835
           8: mem: 165.51MB (2.1%) command: soffice.bin pid: 7799
           9: mem: 158.91MB (2.0%) command: chrome pid: 6179
           10: mem: 151.83MB (1.9%) command: mysqld pid: 1259

Monitor Linux Network Interfaces

The command that follows will show us advanced network card information including interface, speed, mac id, state, IPs, etc:

$ inxi -Nni

Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169
           IF: enp1s0 state: up speed: 100 Mbps duplex: full mac: 28:d2:44:eb:bd:98
           Card-2: Realtek RTL8723BE PCIe Wireless Network Adapter driver: rtl8723be
           IF: wlp2s0 state: down mac: 38:b1:db:7c:78:c7
           WAN IP: 111.91.115.195 IF: wlp2s0 ip-v4: N/A
           IF: enp1s0 ip-v4: 192.168.0.103

Monitor Linux CPU Temperature and Fan Speed

We can keep track of the hardware installed/configured sensors output by using the -s option:

$ inxi -s

Sensors:   System Temperatures: cpu: 53.0C mobo: N/A
           Fan Speeds (in rpm): cpu: N/A

Find Weather Report in Linux

We can also view whether info (though API used is unreliable) for the current location with the -w or -W<different_location> to set a different location.

$ inxi -w
Weather:   Conditions: 93 F (34 C) - smoke Time: February 20, 1:38 PM IST

$ inxi -W Mumbai,India
Weather:   Conditions: 93 F (34 C) - smoke Time: February 20, 1:38 PM IST

$ inxi -W Nairobi,Kenya
Weather:   Conditions: 70 F (21 C) - Mostly Cloudy Time: February 20, 11:08 AM EAT

Find All Linux Repsitory Information

We can additionally view a distro repository data with the -r flag:

$ inxi -r 

Repos:     Active apt sources in file: /etc/apt/sources.list.d/dawidd0811-neofetch-xenial.list
           deb http://ppa.launchpad.net/dawidd0811/neofetch/ubuntu xenial main
           deb-src http://ppa.launchpad.net/dawidd0811/neofetch/ubuntu xenial main
           Active apt sources in file: /etc/apt/sources.list.d/dhor-myway-xenial.list
           deb http://ppa.launchpad.net/dhor/myway/ubuntu xenial main
           deb-src http://ppa.launchpad.net/dhor/myway/ubuntu xenial main
           Active apt sources in file: /etc/apt/sources.list.d/official-package-repositories.list
           deb http://packages.linuxmint.com sarah main upstream import backport
           deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
           deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
           deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
           deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
           deb http://archive.canonical.com/ubuntu/ xenial partner
           Active apt sources in file: /etc/apt/sources.list.d/qbittorrent-team-qbittorrent-stable-xenial.list
           deb http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu xenial main
           deb-src http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu xenial main
           Active apt sources in file: /etc/apt/sources.list.d/slgobinath-safeeyes-xenial.list
           deb http://ppa.launchpad.net/slgobinath/safeeyes/ubuntu xenial main
           deb-src http://ppa.launchpad.net/slgobinath/safeeyes/ubuntu xenial main
           Active apt sources in file: /etc/apt/sources.list.d/snwh-pulp-xenial.list
           deb http://ppa.launchpad.net/snwh/pulp/ubuntu xenial main
           deb-src http://ppa.launchpad.net/snwh/pulp/ubuntu xenial main
           Active apt sources in file: /etc/apt/sources.list.d/twodopeshaggy-jarun-xenial.list
           deb http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu xenial main
           deb-src http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu xenial main
           Active apt sources in file: /etc/apt/sources.list.d/ubuntu-mozilla-security-ppa-xenial.list
           deb http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu xenial main
           deb-src http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu xenial main

To view it’s current installed version, a quick help, and open the man page for a full list of options and detailed usage info plus lots more, type:

$ inxi -v   #show version
$ inxi -h   #quick help
$ man inxi  #open man page

For more information, visit official GitHub Repository: https://github.com/smxi/inxi

That’s all for now! In this article, we reviewed Inxi, a full featured and remarkable command line tool for collecting machine hardware and system info. This is one of the best CLI based hardware/system information collection tools for Linux, I have ever used.

 
Source

How to Test Network Throughput Using iperf3 Tool in Linux

iperf3 is a free open source, cross-platform command line based program for performing real time network throughput measurements. It is one of the poweful tools for testing the maximum achievable bandwidth in IP networks (supports IPv4 and IPv6).

Read Also16 Bandwidth Monitoring Tools to Analyze Network Usage in Linux

With iperf, you can tune several parameters associated with timing, buffers and protocols such as TCP, UDP, SCTP. It comes in handy for network performance tuning operations.

In order to acquire maximum or rather improved network performance, you need to increase the throughput as well as latency of your network’s receiving and sending capabilities. However, before you can go into actual tuning, you need to perform some test to gather overall network performance statistics that will guide your tuning process.

Its results include time interval in seconds, data transfered, bandwidth (transfer rate), loss, and other useful network performance parameters. It is primarily intended to assist in tuning TCP connections over a particular path and this is what we will focus on in this guide.

Requirements:

  • Two networked computers which both have iperf3 installed.

How to Install iperf3 in Linux Systems

Before you start using iperf3, you need to install it on the two machines you will use for benchmarking. Since iperf3 is available in the official software repositories of most common Linux distributions, installing it should be easy, using a package manager as shown.

$ sudo apt install iperf3	#Debian/Ubuntu
$ sudo yum install iperf3	#RHEL/CentOS
$ sudo dnf install iperf3	#Fedora 22+ 

Once you have iperf3 installed on your both machines, you can start testing network throughput.

How to Test Network Throughput Between Linux Servers

Firt connect to the remote machine which you will use as the server and fireup iperf3 in server mode using -sflag, it will listen on port 5201 by default.

You can specify the format (kmg for KbitsMbitsGbits or KMG for KBytesMbytesGbytes) to report in, using the -f switch as shown.

$ iperf3 -s -f K 

If port 5201 is being used by another program on your server, you can specify a different port (e.g 3000) using the -p switch as shown.

$ iperf 3 -s -p 3000

Optionally, you can run the server as a daemon, using the -D flag and write server messages to a log file, as follows.

$ iperf 3 -s -D > iperf3log 

Then on your local machine which we will treat as the client (where the actual benchmarking takes place), run iperf3 in client mode using -c flag and specify the host on which the server is running on (either using its IP address or domain or hostname).

$ iperf 3 -c 192.168.10.1 -f K

After about 18 to 20 seconds, the client should terminate and produce results indicating the average throughput for the benchmark, as shown in the following screenshot.

Test Network Throughput Between Servers

Test Network Throughput Between Servers

Important: From the benchmark results, as shown in the above screenshot, there is a variation in values from the server and client. But, you should always consider using the results obtained from the iperf client machine in every test you carry out.

How to Peform Advance Network Test Throughput in Linux

There are a number of client specific options for performing advanced test, as explained below.

One of the important factors that determines the amount of data in the network a given time is the TCP window size – it is important in tuning TCP connections. You can set the window size/socket buffer size using the -wflag as shown.

$ iperf 3 -c 192.168.10.1 -f K -w 500K	

To run it in reverse mode where the server sends and client receives, add the -R switch.

$ iperf 3 -c 192.168.10.1 -f K -w 500K -R	

To run a bi-directional test, meaning you measure bandwidth in both directions simultaneously, use the -doption.

$ iperf 3 -c 192.168.10.1 -f K -w 500K -d

If you want to get server results in the client output, use the --get-server-output option.

$ iperf 3 -c 192.168.10.1 -f K -w 500K -R --get-server-output

Get Server Network Results in Client

Get Server Network Results in Client

It is also possible to set the number of parallel client streams (two in this example), which run at the same time, using the -P options.

$ iperf 3 -c 192.168.10.1 -f K -w 500K -P 2

For more information, see the iperf3 man page.

$ man iperf3

iperf3 Homepagehttps://iperf.fr/

That’s all! Remember to always perform network performance tests before going for actual network performance tuning. iperf3 is a powerful tool, that comes in handy for running network throughput tests. Do you have any thoughts to share or questions to ask, use the comment form below.

Source

ccat – Show ‘cat Command’ Output with Syntax Highlighting or Colorizing

ccat is command line similar to cat command in Linux that displays the content of a file with syntax highlighting for the following programming languages: JavascriptJavaGoRubyCPython and Json.

To install ccat utility in your Linux distribution, first assure that the wget utility is present in your system. If the wget command line is not installed in the system, issue the below command to install it:

# yum install wget        [On CentOS/RHEL/Fedora]
# apt-get install wget    [On Debian and Ubuntu]

In order to install the latest version of ccat command line via the latest compiled binaries, first download the compressed tarball by issuing the below command. The binary and source code releases archives can be found at the official ccat github webpage.

-------------- On 64-Bit -------------- 
# wget https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz 

-------------- On 32-Bit -------------- 
# wget https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-386-1.1.0.tar.gz 

After archive download completes, list the current working directory to show the files, extract the ccat tarball(the linux-amd64-1.x.x Tarball file) and copy the ccat executable binary from the extracted tarball into a Linux executable system path, such as /usr/local/bin/ path, by issuing the below commands.

# ls
# tar xfz linux-amd64-1.1.0.tar.gz 
# ls linux-amd64-1.1.0
# cp linux-amd64-1.1.0/ccat /usr/local/bin/
# ls -al /usr/local/bin/

ccat Command Executable Files

ccat Command Executable Files

If for some reasons the ccat file from your executable system path has no executable bit set, issue the below command to set executable permissions for all system users.

# chmod +x /usr/local/bin/ccat

In order to test ccat utility capabilities against a system configuration file, issue the below commands. The content of the displayed files should be highlighted according to file programming language sytnax, as illustrated in the below command examples.

# ccat /etc/sysconfig/network-scripts/ifcfg-ens33 
# ccat /etc/fstab 

ccat Command Usage

ccat Command Usage

In order to replace cat command with ccat command system wide, add a bash alias for ccat in system bashrcfile, log out from the system and log in back again to apply the configuration.

-------------- On CentOS, RHEL & Fedora -------------- 
# echo "alias cat='/usr/local/bin/ccat'" >> /etc/bashrc 
# exit

-------------- On Debiab & Ubuntu -------------- 
# echo "alias cat='/usr/local/bin/ccat'" >> /etc/profile
# exit

Finally, run cat command against an arbitrary configuration file to test if ccat alias has replaced cat command, as shown in the below example. The output file syntax should be highlighted now.

# cat .bashrc

Replace cat Command with ccat

Replace cat Command with ccat

ccat utility can also be used to concatenate multiple files and display the output in HTML format, as illustrated in the below example.

# ccat --html /etc/fstab /etc/sysconfig/network-scripts/ifcfg-ens33> /var/www/html/ccat.html

However, you will need a web server installed in your system, such as Apache HTTP server or Nginx, to display the content of the HTML file, as illustrated in the below screenshot.

Display File Content in HTML

Display File Content in HTML

For other custom configurations and command options visit ccat official github page.

Source

Lynis – Security Auditing and Scanning Tool for Linux Systems

Lynis is an open source and much powerful auditing tool for Unix/Linux like operating systems. It scans system for security information, general system information, installed and available software information, configuration mistakes, security issues, user accounts without password, wrong file permissions, firewall auditing, etc.

Lynis is one of the most trusted automated auditing tool for software patch management, malware scanning and vulnerability detecting in Unix/Linux based systems. This tool is useful for auditorsnetwork and system administratorssecurity specialists and penetration testers.

A new major upgrade version of Lynis 2.5.5 is released just now, after months of development, which comes with some new features and tests, and many small improvements. I encourage all Linux users to test and upgrade to this most recent version of Lynis.

In this article we are going to show you how to install Lynis 2.5.5 (Linux Auditing Tool) in Linux systems using source tarball files.

Installation of Lynis

Lynis doesn’t required any installation, it can be used directly from any directory. So, its good idea to create a custom directory for Lynis under /usr/local/lynis.

# mkdir /usr/local/lynis

Download stable version of Lynis source files from the trusted website using wget command and unpack it using tar command as shown below.

# cd /usr/local/lynis
# wget https://cisofy.com/files/lynis-2.5.5.tar.gz

Download Lynis Linux Audit Tool

Download Lynis Linux Audit Tool

Unpack the tarball

# tar -xvf lynis-2.5.5.tar.gz

Unpack Lynis Tool

Unpack Lynis Tool

Running and Using Lynis Basics

You must be root user to run Lynis, because it creates and writes output to /var/log/lynis.log file. To run Lynis execute the following command.

# cd lynis
# ./lynis

By running ./lynis without any option, it will provide you a complete list of available parameters and goes back to the shell prompt. See figure below.

Lynis Basic Options and Help

Lynis Basic Options and Help

To start Lynis process, you must define a --check-all parameter to begin scanning of your entire Linuxsystem. Use the following command to start scan with parameters as shown below.

# ./lynis --check-all

Once, you execute above command it will start scanning your system and ask you to Press [Enter] to continue, or [CTRL]+C to stop) every process it scans and completes. See figure attached below.

Lynis: Scanning Entire Linux System

Lynis: Scanning Entire Linux System

Lynis Security Scan Details

Lynis Security Scan Details

To prevent such acknowledgment (i.e. “press enter to continue”) from user while scanning, you need use -cand -Q parameters as shown below.

# ./lynis -c -Q

It will do complete scan without waiting for any user acknowledgment. See the following screencast.

Lynis: Scanning Linux File System

Lynis: Scanning Linux File System

Creating Lynis Cronjobs

If you would like to create a daily scan report of your system, then you need to set a cron job for it. Run the following command at the shell.

# crontab -e

Add the following cron job with option --cronjob all the special characters will be ignored from the output and the scan will run completely automated.

30	22	*	*	*	root    /path/to/lynis -c -Q --auditor "automated" --cronjob

The above example cron job will run daily at 10:30pm in the night and creates a daily report under /var/log/lynis.log file.

Lynis Scanning Results

While scanning you will see output as [OK] or [WARNING]. Where [OK] considered as good result and [WARNING] as bad. But it doesn’t mean that [OK] result is correctly configured and [WARNING] doesn’t have to be bad. You should take corrective steps to fix those issues after reading logs at /var/log/lynis.log.

In most cases, the scan provides suggestion to fix problems at the end of the scan. See the attached figure that provides a list of suggestion to fix problems.

Lynis Suggestions Tips

Lynis Suggestions Tips

Updating Lynis

If you want to update or upgrade current lynis version, simple type the following command it will download and install latest version of lynis.

# ./lynis update info         [Show update details]
# ./lynis update release      [Update Lynis release]

See the attached output of the above command in the figure. It says our lynis version is Up-to-date.

Update Lynis Auditing Tool

Update Lynis Auditing Tool

Lynis Parameters

Some of the Lynis parameters for your reference.

  1. --checkall or -c : Start the scan.
  2. --check-update : Checks for Lynis update.
  3. --cronjob : Runs Lynis as cronjob (includes -c -Q).
  4. --help or -h : Shows valid parameters
  5. --quick or -Q : Don’t wait for user input, except on errors
  6. --version or -V : Shows Lynis version.

That’s it, we hope this article will be much helpful you all to figure out security issues in running systems. For more information visit the official Lynis page at https://cisofy.com/download/lynis/.

Source

The Silver Searcher – A Code Searching Tool for Programmers

The Silver Searcher is a free and open source, cross platform source code searching tool similar to ack (a grep-like tool for programmers) but faster. It runs on Unix-like systems and Windows operating systems.

The major difference between the silver searcher and ack is that the former is designed for speed, and benchmark tests prove that it is indeed faster.

If you spend a lot of time reading and searching through your code, then you need this tool. It aims at being fast and ignoring files that you don’t want to be searched. In this guide, we will show how to install and use The Silver Searcher in Linux.

How to Install and Use The Silver Searcher in Linux

The silver searcher package is available on most Linux distributions, you can easily install it via your package manager as shown.

$ sudo apt install silversearcher-ag					#Debian/Ubuntu 
$ sudo yum install epel-release the_silver_searcher		        #RHEL/CentOS
$ sudo dnf install silversearcher-ag					#Fedora 22+
$ sudo zypper install the_silver_searcher				#openSUSE
$ sudo pacman -S the_silver_searcher           				#Arch 

After installing it, you can run the ag command line tool with the following syntax.

$ ag file-type options PATTERN /path/to/file

To see a list of all supported file types, use the following command.

$ ag  --list-file-types

This example shows how to recursively search for all scripts that contain the word “root” under the directory ~/bin/.

$ ag root ./bin/

Search a Pattern in Files

Search a Pattern in Files

To print the filenames matching PATTERN and the number of matches in each file, other than the number of matching lines, use the -c switch as shown.

$ ag -c root ./bin/

Print Number of Matches

Print Number of Matches

To match case-sensitively, add the -s flag as shown.

$ ag -cs ROOT ./bin/
$ ag -cs root ./bin/

Match Case Sensitive

Match Case Sensitive

To print statistics of of a search operation such as files scanned, time taken, etc., use the the --stats option.

$ ag -c root --stats ./bin/

Print Search Operations Summary

Print Search Operations Summary

The -w flag tells ag to only match whole words similar to grep command.

$ ag -w root ./bin/

You can show column numbers in results using the --column option.

$ ag --column root ./bin/

Show Column Numbers in Output

Show Column Numbers in Output

You can also use ag to search through purely text files, using the -t switch and the -a switch is used to search all types of files. In addition, the -u switch enables searching though all files, including hidden files.

$ ag -t root /etc/
OR
$ ag -a root /etc/
OR
$ ag -u root /etc/

Ag also supports searching through the contents of compressed files, using the -z flag.

$ ag -z root wondershaper.gz

Search Content in Compressed Files

Search Content in Compressed Files

You can also enable following of symbolic links (symlinks in short) with the -f flag.

$ ag -tf root /etc/ 

By default, ag searches 25 directories deep, you can set the depth of the search using the --depth switch, for example.

$ ag --depth 40 -tf root /etc/

For more information, see the silver searcher’s man page for a complete list of usage options.

$ man ag

To find out, how the silver searcher works, see its Github repository: https://github.com/ggreer/the_silver_searcher.

That’s it! The Silver Searcher is a fast, useful tool for searching through files that make sense to search. It is intended for programmers for quickly searching though large source-code base.

Source

Fzf – A Quick Fuzzy File Search from Linux Terminal

Fzf is a tiny, blazing fast, general-purpose, and cross-platform command-line fuzzy finder, that helps you to search and open files quickly in Linux and Windows operating system. It is portable with no dependencies and has a flexible layout with support for Vim/Neovim plugin, key bindings, and fuzzy auto-completion.

The following GIF shows how it works.

Fzf - File Finder for Linux

To install Fzf, you need to git clone the fzf’s Github repository to any directory and run install script as shown on your Linux distribution.

$ git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
$ cd ~/.fzf/
$ ./install

After running the script, you will be prompted to enable fuzzy auto-completion, key bindings and update your shell configuration file. Answer y (for yes) to the questions as shown in the following screenshot.

Install Fzf in Linux

Install Fzf in Linux

On Fedora 26 and above, and Arch Linux, you can install it via a package manager as shown.

$ sudo dnf install fzf	#Fedora 26+
$ sudo pacman -S fzf	#Arch Linux 

Now that you have installed fzf, you can start using it. When you run fzf, it will open an interactive finder; reads the list of files from stdin, and writes the selected item to stdout.

Simply type the name of the file you are looking for in the prompt. When you find it, click enter and the relative path of the file will be printed to stdout.

$ fzf

Fzf Prompt

Fzf Prompt

Alternatively, you can save the relative path of the file your are searching, to a named file and view the content of the file using a utility such as cat command or bcat.

$ fzf >file
$ cat file
OR
$ bat file

You can also use it in conjunction with the find command, for example.

$ find ./bin/ -type f | fzf >file
$ cat file

How to Use Fuzzy Completion in Bash and Zsh

To trigger fuzzy completion for files and directories, add the ** characters as a trigger sequence.

$ cat **<Tab>

Auto Completion of Filenames

Auto Completion of Filenames

You can use this feature while working with environmental variables on the command-line.

$ unset **<Tab>
$ unalias **<Tab>
$ export **<Tab>

Auto Completing Env Variable in Linux

Auto Completing Env Variable in Linux

The same applies to the ssh and telnet commands, for auto-completing host names that are read from the /etc/hosts and ~/.ssh/config.

$ ssh **<Tab>

Auto Completing Hostnames

Auto Completing Hostnames

It also works with the kill command, but without the trigger sequence as shown.

$ kill -9 <Tab>

Auto Completion for Kill Command

Auto Completion for Kill Command

How to Enable fzf as Vim plugin

To enable fzf as a vim plugin, append the following line in your Vim configuration file.

set rtp+=~/.fzf

fzf is being actively developed and can be easily upgraded to latest version using following command.

$ cd ~/.fzf && git pull && ./install

To see the complete list of usage options, run man fzf or check out its Github Repository: https://github.com/junegunn/fzf.

Read AlsoThe Silver Searcher – A Code Searching Tool for Programmers

Source

ctop – Top-like Interface for Monitoring Docker Containers

ctop is a free open source, simple and cross-platform top-like command-line tool for monitoring container metrics in real-time. It allows you to get an overview of metrics concerning CPU, memory, network, I/O for multiple containers and also supports inspection of a specific container.

Docker Container Monitoring

Docker Container Monitoring

At the time of writing this article, it ships with built-in support for Docker (default container connector) and runC; connectors for other container and cluster platforms will be added in future releases.

How to Install ctop in Linux Systems

Installing the latest release of ctop is as easy as running the following commands to download the binary for your Linux distribution and install it under /usr/local/bin/ctop and make it executable to run it.

$ sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.1/ctop-0.7.1-linux-amd64  -O /usr/local/bin/ctop
$ sudo chmod +x /usr/local/bin/ctop

Alternatively, install ctop via Docker using following command.

$ docker run --rm -ti --name=ctop -v /var/run/docker.sock:/var/run/docker.sock quay.io/vektorlab/ctop:latest

Once you have installed ctop, you can run it to list all your containers whether active or not.

$ ctop

Monitor Docker Containers

Monitor Docker Containers

You can use the Up and Down arrow keys to highlight a container and click Enter to select it. You will see a menu as shown in the following screenshot. Choose “single view” and click on it to inspect the selected container.

Monitor Single Docker Container

Monitor Single Docker Container

The following screenshot shows the single view mode for a specific container.

Inspect a Single Container

Inspect a Single Container

To display active containers only, use the -a flag.

$ ctop -a 

Check Active Docker Container

Check Active Docker Container

To display CPU as % of system total, use the -scale-cpu option.

$ ctop -scale-cpu

You can also filter containers using the -f flag, for example.

$ ctop -f app

Additionally, you can select initial container sort field using the -s flag, and see the ctop help message as shown.

 
$ ctop -h

Note that connectors for other container and cluster systems are yet to be added to ctop. You can find more information from the Ctop Github repository.

ctop is a simple top-like tool for visualizing and monitoring container metrics in real-time. In this article, we’ve expalined how to install and use ctop in Linux.

Source

WP2Social Auto Publish Powered By : XYZScripts.com