8 Linux command-line tools

Linux програми за командния ред

1. Uniutils

Uniutils is a package of usefull commands for Unicode. It can be used to check the names of characters in a text and their positions in the Unicode table, or the frequency of characters in a text and more. It can be installed with the following command in Ubuntu-based distributions:

apt install uniutils

One of the commands Uniutils has is uniname. Here's an example of how it can be used:

echo "Текст." | uniname
:'
Output:
No LINES variable in environment so unable to determine lines per page.
Using default of 24.
character  byte       UTF-32   encoded as     glyph   name
        0          0  000054   54             T      LATIN CAPITAL LETTER T
        1          1  000065   65             e      LATIN SMALL LETTER E
        2          2  000078   78             x      LATIN SMALL LETTER X
        3          3  000074   74             t      LATIN SMALL LETTER T
        4          4  00002E   2E             .      FULL STOP
        5          5  00000A   0A                     LINE FEED (LF)

'

With unihist, we can view the histogram (frequency) of different glyphs in the second column:

echo 'This sentence contains the letter "e" 12 times and the letter "s" 6 times' | unihist
:'
Output:
	  1,351	       1	0x00000A
	 17,568	      13	0x000020
	  5,405	       4	0x000022	"
	  1,351	       1	0x000031	1
	  1,351	       1	0x000032	2
	  1,351	       1	0x000036	6
	  1,351	       1	0x000054	T
	  2,703	       2	0x000061	a
	  2,703	       2	0x000063	c
	  1,351	       1	0x000064	d
	 16,216	      12	0x000065	e
	  4,054	       3	0x000068	h
	  5,405	       4	0x000069	i
	  2,703	       2	0x00006C	l
	  2,703	       2	0x00006D	m
	  6,757	       5	0x00006E	n
	  1,351	       1	0x00006F	o
	  2,703	       2	0x000072	r
	  8,108	       6	0x000073	s
	 13,514	      10	0x000074	t
'

2. Аsciinema

Asciinema is used to record and play back terminal sessions. Not in the traditional way you might record your screen – recordings are saved as a cast file, which contains information about the entered commands, so that they can be played back later. These files are much smaller than a typical video. On Ubuntu-based distributions it can be installed with:

apt install asciinema

Recordings can be started with:

asciinema rec filename.cast

And to play back a recording you can use:

asciinema play path/to/recording.cast

3. Cava

Cava is more graphical compared to other tools on this list, because it's used to visualize sound. It can be installed with:

sudo apt install cava

And it's simple to use – start it with:

cava

After that you should see white bars moving based on the captured sound. You can play some audio and check it out. You can customize the color, quantity and width of the bars in canva's config file, usually found in ~/.config/cava/config

4. img2wav

With img2wav you can convert images to sound – by outputting certain frequencies, the audio's spectrogram can take the shape of the inputted image. The effect can be seen in programs like Audacity, by selecting spectrogram view. To install:

apt install img2wav

You can generate a wav file like so:

img2wav your-image.png

That can be used to hide messages in an audio's spectrogram.

Hidden message in a spectrogram viewed Audacity

5. ExifTool

ExifTool is an application for editing the metadata of different file types. You can install it with:

apt install libimage-exiftool-perl

Here's how you can use ExifTool:

# Adding a greeting "Hello!" in the metadata of a PDF document
exiftool -Greeting="Hello!" document.pdf
# Outputting the metadata of an mp3 file
exiftool --list audio.mp3

# Example of outputting the metadata of an image edited in GIMP:
:'
ExifTool Version Number         : 12.40
File Name                       : .face
Directory                       : .
File Size                       : 20 KiB
File Modification Date/Time     : 2023:05:14 10:06:35+03:00
File Access Date/Time           : 2024:09:29 19:52:35+03:00
File Inode Change Date/Time     : 2023:05:14 10:06:35+03:00
File Permissions                : -rw-r--r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 96
Image Height                    : 96
Bit Depth                       : 8
Color Type                      : RGB
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Profile Name                    : ICC Profile
Profile CMM Type                : Little CMS
Profile Version                 : 4.3.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 2023:05:14 07:05:56
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : 
Device Model                    : 
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Little CMS
Profile ID                      : 0
Profile Description             : GIMP built-in sRGB
Profile Copyright               : Public Domain
Media White Point               : 0.9642 1 0.82491
Chromatic Adaptation            : 1.04788 0.02292 -0.05022 0.02959 0.99048 -0.01707 -0.00925 0.01508 0.75168
Red Matrix Column               : 0.43604 0.22249 0.01392
Blue Matrix Column              : 0.14305 0.06061 0.71393
Green Matrix Column             : 0.38512 0.7169 0.09706
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option to extract)
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option to extract)
Chromaticity Channels           : 3
Chromaticity Colorant           : Unknown (0)
Chromaticity Channel 1          : 0.64 0.33002
Chromaticity Channel 2          : 0.3 0.60001
Chromaticity Channel 3          : 0.15001 0.06
Device Mfg Desc                 : GIMP
Device Model Desc               : sRGB
Exif Byte Order                 : Little-endian (Intel, II)
Image Description               : Created with GIMP
Orientation                     : Horizontal (normal)
X Resolution                    : 300
Y Resolution                    : 300
Resolution Unit                 : inches
Software                        : GIMP 2.10.30
Modify Date                     : 2023:05:14 10:06:19
User Comment                    : Created with GIMP
Color Space                     : sRGB
Subfile Type                    : Reduced-resolution image
Bits Per Sample                 : 8 8 8
Photometric Interpretation      : YCbCr
Samples Per Pixel               : 3
Thumbnail Offset                : 354
Thumbnail Length                : 7019
Image Size                      : 96x96
Megapixels                      : 0.009
Thumbnail Image                 : (Binary data 7019 bytes, use -b option to extract)
'

6. Tmux

Tmux allows you to split the terminal window and work on multiple sessions at once. To install the package:

apt install tmux

Then, to start tmux:

tmux

All keyboard shortcuts in tmux start with Ctrl+B, to avoid overlap with other shortcuts. To split the view horizontally " (Shift+'), and vertically % (Shift+5). To move around the windows use the arrow keys (don't forget the Ctrl+B prefix).

7. qrencode

With qrencode you can generate QR codes from the terminal. You can install it with:

apt install qrencode

And using it is very simple:

# Generate a qr code "пробен текст"
qrencode "пробен текст" -o qr_code.svg
Output:

8. fzf

fzf (fuzzy finder) is great for searching files. It's fast and allows for typos.

apt install fzf

Start with:

fzf

Бонус програми

Not all programs have to be usefull. Sometimes they can just be fun. Some commands are exactly for that. Here are some:

9. cowsay

cowsay prints a talking cow. You can specify what it says.

# Installation
apt install cowsay

# Usage
cowsay "Hello!"

:'
Output:
 __________
< Hello! >
 ----------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
'

It doesn't have to be a cow – you can choose between avaliable models, to check them use:

cowsay -l

Here's one of them:

cowsay -f fox "Fox!"

:'
 _________
< Fox! >
 ---------
         \     ,-.      .-,
          \    |-.\ __ /.-|
           \   \  `    `  /
                /_     _ \
              <  _`q  p _  >
              <.._=/  \=_. >
                 {`\()/`}`\
                 {      }  \
                 |{    }    \
                 \  --    .- \
                 |-      /    \
                 | | | | |     ;
                 | | |.;.,..__ |
               .-  ;`         `|
              /    |           /
              `-../____,..--- `

'

10. oneko

The oneko command summons a cat chasing the mouse cursor. To stop the program, press Ctrl+C

# Installation
apt install oneko

oneko

# Outputs dog instead of cat
oneko -dog

11. lolcat

lolcat simply colors the input text in the colors of the rainbow.

# Installation
apt install lolcat

# Usage
echo "Цветен текст" | lolcat

12. cmatrix

cmatrix creates the famous Matrix effect, with the letters scrolling down.

# Installation
apt install cmatrix

# Usage
cmatrix

13. cbonsai

cbonsai is a bonsai tree generator. It allows for viewing the different steps of growth.

# Installation
apt install cbonsai

# Usage
cbonsai

# Show growth (0,002 seconds between each step)
cbonsai -lt 0,002

# Continue generating trees every 2 seconds
cbonsai -iw 2

:'
Output
                                &
                                && &
                                  &&&&&&&
                            &    &&|&&&&
                              &&&&&\&&&&&&
                             &&&&&~\\&&&\
                          &  &&& &/& /|\ &
                           &&&&&&|\&&|&&&
                            &&\&/|&&\&/~\_
                            &&&&|/|/|&/|\
                             &&&||/ \|\|
                             &  /~&  /|\|\&&
                                 \|  |//&\   /
                                  /~/_&/&&_&&_/&&&
                                 /|\//&&/  &&&&&&&&
                                 /|\|//&    &&  &&&
                                 /~|~/_/ &  && && &&
                                  \/~/  / &/&&&_&&&
                                  \/~|   // &_&&&
                                    /~|  _/
                                      /~|
                                        /~~
                         :___________./~~~\.___________:
                          \                           / 
                           \_________________________/ 
                           (_)                     (_)
'