© Brian Schell 2019
B. SchellComputing with the Raspberry Pihttps://doi.org/10.1007/978-1-4842-5293-2_6

6. Using the Command-Line Apps

Brian Schell1 
(1)
Flint, MA, USA
 

Now that you can get to a command line and move things around in there, it’s time to get some real work done.

In Chapter 4, I showed you the best two or three apps for most tasks. These were all well-known apps that have millions of users, and although some of them have been around a while, they’re all still constantly updated and maintained.

In this chapter, I’ll show you a few examples of the most common and popular commands to do most tasks, but keep in mind that people have been doing these tasks using similar tools literally for decades (Unix came about in the 1970s, and Linux is directly descended from those tools); there are probably dozens of solutions for each application available, and people are still coming up with new ways of doing the same things. So, after you’ve looked at my suggestions, do a little Internet research and see if there’s some way that fits your workflow better.

Writing Tools

Probably the main task for most people (other than maybe browsing the Web and email) is writing. Whether it’s simple notes, emails, or full-length books, there are some great text-only tools to do the job.

Unlike, say, Microsoft Word or Apple Pages, you can’t just highlight a word and make it bold or italic in a text-based terminal window. You usually will need to use some kind of a markup language, such as Markdown or LaTeX (see Chapter 7). Like almost everything else involved with switching to text mode, it’s more difficult in the beginning, but far more efficient and speedier once you know how it works.

Nano

Nano Details:

Installation: sudo apt install nano (default with Raspian)

Run command: nano <filename>

Dotfile: ~/.nanrc

Help: man nano

Web site: www.nano-editor.org/

Nano usually comes preinstalled on most Linux systems. It’s a really, really basic text editor. In truth, it’s almost too basic for most useful tasks—Nano’s customization options are very limited. That said, it’s almost certainly preinstalled on your system already, and it’s fine for quickly reading or making a fast change to a file. Throughout this book, my examples use Nano when we need to edit a text file. It’s simple and it’s on every system, so that’s the “standard” text editor for this book. We’ve already used Nano a few times in past chapters when adding lines to configuration files. Not only is it fairly simple to learn, but all the functions are easily discoverable via the two-line menu on the bottom of the screen. It’s not the “editor of a lifetime,” but it may be all you need. There’s a markdown version of this chapter visible in Nano in Figure 6-1.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig1_HTML.jpg
Figure 6-1

Nano text editor

Vim

Vim Details:

Installation: sudo apt install vim

Run command: vim <filename>

Dotfile: ~/.vimrc

Help: man vim

Web site: www.vim.org/

Vim and Emacs were designed to be text editors for coders, and if you’re a programmer, either of these would be an outstanding choice for you to master. Either one can be adapted for darned near anything, as every single feature you can imagine has myriad customization options and plug-ins.

Vim, at least in my opinion, is a bit harder to learn at first, but well worth it once you get past the learning curve. It’s a modal editor, meaning that you move around and navigate in one mode, type text in another mode, and visually select things in a third mode. It’s an unusual way to work coming from something like Microsoft Word, but there’s a lot of power there once you learn how the app works. Vim is shown in Figure 6-2.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig2_HTML.jpg
Figure 6-2

Vim text editor

Emacs

Emacs Details:

Installation: sudo apt install emacs25

Run command: emacs <filename>

Dotfile: ~/.emacs

Help: man emacs

Web site: www.gnu.org/software/emacs/

Then there’s Emacs, as shown in Figure 6-3. There are people who type stuff, check their email, add appointments to their calendars, change their to-do lists, and browse the Web…all without leaving Emacs. It’s easier to get started with than Vim, but the more you use it, the deeper the bottomless pit of Emacs becomes. Someone working at the “expert level” of Emacs could probably do everything we talk about in this book…without leaving Emacs. There are people who jokingly call Emacs an operating system in itself, but it’s so expandable that it’s almost not a joke.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig3_HTML.jpg
Figure 6-3

Emacs text editor

With both Emacs and Vim, nearly any aspect of the editor can be customized and made to work in many different ways. There are also add-ins, themes, and extensions that allow you to do things that even the original developers never imagined that people could in a text editor. For me, it’s always been a tough call deciding between these two major writing apps, and I dabble in each, spending far too much time waffling back and forth.

Note that the preceding apt command installs emacs25, not plain Emacs. You can choose to install the default Emacs, but for some reason, the Raspbian installer will install Emacs version 24 by default, which is a much older, more limited version. Don’t use this unless you know some specific reason why you might need it.

WordGrinder

WordGrinder Details:

Installation: sudo apt install wordgrinder

Run command: wordgrinder

Dotfile: ~/.wordgrinder.lua

Help: man wordgrinder

Web site: http://cowlark.com/wordgrinder/index.html

All three of the preceding editors were originally designed with programming/coding in mind. WordGrinder comes at writing from a different perspective. It’s a word processor specifically designed for writers. It has easy-to-use menus, the arrow keys work like you’d expect, and there are very few surprises here. You can make words bold or italic easily right in the text, and you don’t need to learn Markdown or any special coding.

On the other hand, unlike Emacs or Vim, it’s not very customizable; it pretty much works as it comes. There aren’t any plug-ins or fancy themes. It’s plain, but reliable and simple to use, and it simply works, as you can see in Figure 6-4.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig4_HTML.jpg
Figure 6-4

WordGrinder word processor with easy-to-find menus

My recommendation is to look at both Nano and WordGrinder first. Nano is great for quick-and-dirty text editing, while WordGrinder can handle most real writing tasks. If you decide you really want to become a “text master,” then upgrade to the much more powerful and flexible Vim and/or Emacs—they offer far more, but they also require quite a lot of effort to really master.

Email

Probably the primary business use of most computers today, email is a crucial tool. However, due to the prevalence of hackers and spammers, security with email is a major concern. That makes setting up an email client one of the most challenging tasks we’re going to run into.

Sendmail

Sendmail Details:

Installation: sudo apt install sendmail

Run command: sendmail

Dotfile: various files inside /etc/mail

Help: man sendmail

Web site: https://sendmail.org/~ca/email/doc8.12/op.html

This app is generally a little iffy. Sendmail is a notoriously difficult app to set up, and due to the possibility of being hacked or abused, it’s best left to experts. Raspbian’s default install does not include Sendmail, but other distributions might have it already set up and configured, so it’s worth giving it a try. Just type a message into a text file, save it, and type something similar to the following:
sendmail [email protected] < message.txt
Another option would be to try
sendmail -t [email protected]

and then type your message below that. Hit Ctrl-D to send the message or Ctrl-C to abort. This will either work or it won’t depending on the distribution of Linux you are running. Again, I recommend that if this doesn’t “just work” out of the box for you, you move on to other options, as it’s a powerful but dangerously complex app to configure.

Mutt

Mutt Details:

Installation: sudo apt install mutt

Run command: mutt

Dotfile: ~/.muttrc

Help: man mutt

Web site: www.mutt.org/

Mutt (and Alpine, in the following) is a much more complete email client than Sendmail. You get a full interface to search, sort, read, and reply to your emails; and it’s easy to deal with multiple folders and message attachments. Which you choose depends on what you need and which one you find more attractive and usable. They both do pretty much the same things.

One major disadvantage that I have found with Mutt is that it stores your passwords in the configuration files in plain text. If anyone got into your system, they could easily look at your email passwords and cause you a world of trouble. You can use Mutt and have it not store the passwords, but then you would need to reenter your email password every time you load Mutt, which is inconvenient, to say the least.

Still, for a text-based app, it’s attractive, includes some menuing options onscreen, and isn’t too hard to set up. Figure 6-5 shows an email from a blog I write for.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig5_HTML.jpg
Figure 6-5

Mutt email client

Alpine

Alpine Details:

Installation: sudo apt install alpine

Run command: alpine

Dotfile: ~/.pinerc

Help: man alpine

Web site: http://alpine.x10host.com/alpine/

Alpine doesn’t have the same ease of customization that Mutt has, but it does have the ability to store encrypted passwords on the server. If you have a remote system (i.e., you SSH into it) and you don’t want to be bothered typing your email password every time, this is the better option. It also can be configured from within the app via menus, while Mutt relies on figuring out how to modify a “dotfile,” which we’ll talk about later. Figure 6-6 will give you a hint of the menuing aspect of Alpine.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig6_HTML.jpg
Figure 6-6

Alpine email client

Other “Office” Apps

Writing and email are a big deal for most of us, but a great deal of useful work also involves numbers and presentations. In the GUI world, there is Microsoft Excel and PowerPoint, or even LibreOffice. Those don’t work on the command line, so we need to find something similar.

SC and SC-IM

SC Details:

Installation: sudo apt install sc

Run command: sc

Dotfile: ~/.scrc

Help: man sc

Web site: https://github.com/n-t-roff/sc

SC is short for Screen Calculator, otherwise known as the spreadsheet for text mode. It does all the basic stuff that spreadsheets like Excel do, but does it all through the keyboard and text screen. It wants to save all its files in CSV (comma-separated values), but it can read in Excel files. It allows right and left text alignment, cut and paste, and various decimal formatting options as well as a huge number of calculation and math functions. It’s not as pretty as a GUI spreadsheet, but the power is all there. If you remember back to the days of VisiCalc or Lotus 1-2-3, this will bring back either fond memories or nightmares.

The original SC program was created around 13 years ago; the SC-IM fork is still being developed and maintained, so even though it looks like it’s straight from the 1980s, it’s safe and well maintained. Figure 6-7 shows a simple calculation of totaling and averaging a column of numbers.
sudo apt install sc
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig7_HTML.jpg
Figure 6-7

SC spreadsheet calculator

You can find out more at these links:

Presentations

Out in the world of Windows and Mac, PowerPoint, Keynote, Impress, or even Google Slides are available for presentations. Slideshow presentations scream for graphics, so a text-based presentation may not be the best way to go most of the time. Still, sometimes you want to do something just to show that you can do a thing, so here are your presentation options: Beamer, Vimdeck, and MDP.

Beamer isn’t an app per se; it’s an extension of LaTeX (see Chapter 7) that allows you to create a file using a text editor and then output it as a PDF that can be shown on a projector, printed out, or emailed to recipients. It allows colored text, graphics, diagrams, and basically any kind of media that is supported by LaTeX. It doesn’t do any kind of animation, as it outputs in PDF, but any static imagery can be used.

Beamer Details:

Installation: sudo apt install latex-beamer (note: requires texlive-full and texmaker to be already installed)

Run command: load the output into your PDF viewer

Dotfile: none

Help: www.overleaf.com/learn/latex/Beamer_Presentations:_A_Tutorial_for_Beginners_(Part_1)%E2%80%94Getting_Started

Web site: https://github.com/josephwright/beamer

Vimdeck is a tool that allows you to write a file using Markdown (see Chapter 7) and compile it into a presentation that can be viewed using Vim. You don’t have to use Vim to create the file, but the final presentation is optimized for use within Vim. The “slide” in Figure 6-8 is actually just a page within a big text file displayed in Vim.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig8_HTML.jpg
Figure 6-8

Vimdeck presentation

Vimdeck Details:

Installation: sudo gem install vimdeck

Run command: vimdeck

Dotfile: none

Help: vimdeck

Web site: https://github.com/tybenz/vimdeck

MDP is an app that runs a presentation in text. Beamer and Vimdeck were tools to create presentation files, while MDP takes markdown text and does the actual presentation (see Figure 6-9), with lots of nice options including color, citations, headers, nested lists, and lots of other text-based (still no graphics) elements.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig9_HTML.jpg
Figure 6-9

MDP presentation

MDP Details:

Installation: sudo apt install mdp

Run command: mdp

Dotfile: none

Help: man mdp

Web site: https://github.com/visit1985/mdp

Notes Apps

Making quick notes is one of the things GUI operating systems excel at, but sometimes you need to copy some text for later or make a detailed note for another time and you don’t want to leave the command line. We’ll look at two major players here: Terminal Velocity is an app that makes it super quick to jot down and find text-based notes, while Emacs Org-mode is an outliner, scheduler, to-do manager, and complete organizing system built into the word processor Emacs.

Terminal Velocity

Terminal Velocity is a fairly recent app inspired by the Mac OSX app called Notational Velocity. To create a new note, type a title for the note and hit Enter. The note will be opened in your text editor. As you type the title, the list of notes filters to show notes that match what you’ve typed, giving you a chance to open a related note instead of making a new one. This means that you use the same line to type a new note as you do to search for an existing one, which makes the whole process of searching and creating very fast. I use this one in conjunction with Dropbox to keep my notes with me on all my devices.

Terminal Velocity is installed differently from other apps we’ve looked at, as it’s not in the Raspbian repositories. We’ll use an app called Pip to install it.

Terminal Velocity Details :

Installation: sudo pip install terminal-velocity

Run command: terminal_velocity

Dotfile: ~/.tvrc

Help: see web site

Web site: https://vhp.github.io/terminal_velocity/

Emacs Org-mode

We’ve already discussed Emacs in the “Writing Tools” section, but it deserves another mention here. “Org-mode” is a special mode that Emacs offers that allows you to type in text that is viewed as a sort of outline. You write files in a format similar to Markdown; but you can also use the Tab key to quickly collapse or expand outline trees, move whole sections up and down, and quickly create things like to-do lists, outlines, and notes of all kinds. If you already have some familiarity with Emacs, it’s easy to get started using Org-mode, but there is so much you can do with it that the options can get extensive.

Figure 6-10 shows my to-do list for June 13. Even without explaining how the to-do format works in Org-mode, you can understand exactly what’s going on in the file.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig10_HTML.jpg
Figure 6-10

Emacs Org-mode file

Security

One thing you don’t generally have to worry about when using Linux is viruses. Due to the way everything is split up and restricted by usernames and permissions, it’s much harder to catch a virus than on, say, a Windows machine. That does not, however, mean you don’t still have to be concerned about security. One major area of concern worth looking at is password security.

Pass

Pass is a password management system. It can keep track of a database of thousands of web sites and passwords and is especially useful in creating secure passwords. You can request a new password, specifying the number of symbols, and it generates what you need completely randomly and copies it to the clipboard.

This kind of app is tremendously helpful. I’ve gone from weak passwords such as
USER: brianschell
PASSWORD: PENCIL (or the cat's name or something)
to
USER: brianschell
PASSWORD: zagw@JPTfVquVkQjvAetx2ZiA

Obviously, a password like that is hard, if not impossible, to remember—or type for that matter; fortunately, Pass will copy the password into the clipboard for you.

Pass Details:

Installation: sudo apt install pass

Run command: pass

Dotfile: none

Help: man pass

Web site: www.passwordstore.org

Also, a Pass installation and tutorial can be found at www.2daygeek.com/pass-command-line-password-manager-linux/ .

rTorrent

rTorrent Details :

Installation: sudo apt install rtorrent

Run command: rtorrent

Dotfile: ~/.rtorrent.rc

Help: man rtorrent

Web site: http://rakshasa.github.io/rtorrent/

As I mentioned back in Chapters 3 and 4, when we talked about the Deluge app, BitTorrent gets a lot of bad press for being one method people use to share “pirated” files, but it has many legitimate uses as well. Many alternative Linux distributions are available via torrent, and it’s actually a very efficient means of transferring large files.

In order to download files distributed through torrents, you need a torrent client. There are many good ones available for the GUI (we already talked about Deluge), but sometimes it’s nice to be able to do it from the command line. We’ll look at one app called rTorrent here.

You will also need at least one .torrent file to download. One good place to find legal torrents is at www.offensive-security.com/kali-linux-arm-images/ , and if you go there, you can find something to download, even if it’s only to test the system. The file I downloaded was kali-linux-2019.2a-rpi3-nexmon.img.xz.torrent, a Linux distribution for the Raspberry Pi that I’ve never tried before.

Start the rTorrent app by typing rtorrent at the command line. It will then run in full-screen mode, as in Figure 6-11.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig11_HTML.jpg
Figure 6-11

rTorrent running in full-screen mode

Next, hit the Enter key, and it will give you a prompt, load.normal>, at the bottom of the screen, just like in Figure 6-12.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig12_HTML.jpg
Figure 6-12

Adding the .torrent file

You will need to be sure to type (or cut and paste) the entire filename exactly correctly. Hit Enter, and the file will appear in the main section of the screen, the active torrent list, as shown near the top of Figure 6-13.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig13_HTML.jpg
Figure 6-13

rTorrent with one torrent added

You can add as many .torrent files as you wish this way. rTorrent can easily support hundreds of torrents if that’s something you want to deal with. You can move through the list of torrents with the up and down arrow keys to select individual torrents.

Ctrl-O changes the destination directory. I prefer ~/Downloads, but you can put your files wherever you like. The default is the user’s root directory.

Ctrl-S starts the download. You can watch the numbers and statistics at the bottom of the screen to see how things are progressing.

Ctrl-D pauses the download. If you hit Ctrl-D a second time, the download will be deleted.

The right arrow allows you get information about the files being downloaded.

Ctrl-K allows you to close a torrent.

For more information and documentation on all the features of rTorrent, their web site is at https://rakshasa.github.io/rtorrent/ .

Web Browsers

Wait—browsing the Web in text mode? Yes, you can!

The following three browsers have all been around for decades, and all three have the ability to deal with mostly-text web sites. Some allow for image viewing through external viewers, while some allow in-line image viewing with plug-ins. None are as robust or pretty as modern GUI browsers, but they often can get the job done.

There are benefits to using text-mode browsers. First, they are blazing fast compared to graphical browsers—they don’t run the embedded JavaScript codes, and they don’t download all those images (including the invisible tracking images). Since all they do is download the text, they’re fast even on a slow system. Also, because they’re text-only, they allow easy integration with text-to-speech software and work very well for the visually impaired.

Googler

Googler Details:

Installation: sudo apt install googler

Run command: googler <keywords>

Dotfile: (none)

Help: man googler

Web site: https://github.com/jarun/googler

Sometimes you don’t want to open a full web browser to check something on Google, but in the GUI world, that’s the only way to do it. Not so with the command line! The little app “Googler” will let you type in your search phrase right on the command line, and it’ll show you multiple results with short little abstracts about what Google has found. If you see something you want, then you have the option of loading it in a browser.

Lynx

Lynx Details:

Installation: sudo apt install lynx

Run command: lynx <URL>

Dotfile: ~/.lynxrc

Help: man lynx

Web site: https://lynx.browser.org/

This is the oldest of the browsers, as it was first begun as a project in 1992. Due to this longevity, it’s quite stable and safe. It doesn’t work with sites requiring JavaScript but does handle sites with cookies.

As shown in Figure 6-14, it can take a regular web site, strip out the graphical elements, and reformat everything so it shows up entirely on a text-based screen. This is very similar to how certain assistive technologies allow blind people to use the Web, as the resulting text can easily be channeled into a screen reader.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig14_HTML.jpg
Figure 6-14

Lynx browser

W3M

W3M Details:

Installation: sudo apt install w3m (Raspian preinstalled)

Run command: w3m <URL>

Dotfile: ~/.w3m/config

Help: man w3m

Web site: http://w3m.sourceforge.net/

W3M is also quite old, begun in 1995. It has support for tables, frames, SSL connections, color, and inline images on suitable terminals. Generally, it renders pages in a form as true to their original layout as possible. W3M is one of the more actively maintained browsers and has many extensions and plug-ins, so this may be the best choice if you need to do a lot of text-based web use.

Figure 6-15 shows the W3M rendering of the same web site as in Figure 6-14’s Lynx browser. Compare the differences.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig15_HTML.jpg
Figure 6-15

W3M browser

ELinks

ELinks Details:

Installation: sudo apt install elinks

Run command: elinks <URL>

Dotfile: ~/.elinks

Help: man elinks

Web site: http://elinks.or.cz/

This is the most “modern-looking” of the three browsers, as you can see in Figure 6-16. It has a color display, and when you press the Esc key, navigation menus appear that make the whole thing easier to figure out. It supports the mouse, tabs, cookies, and more.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig16_HTML.jpg
Figure 6-16

ELinks browser

Communications

One of the most popular things to do back when the Internet started becoming available to everyone was to hang out in IRC chat rooms. Before Facebook, before Twitter, even back before MySpace, there was IRC (Internet Relay Chat).

IRC: WeeChat and IRSSI

WeeChat Details:

Installation: sudo apt install weechat

Run command: weechat

Dotfile: ~/.weechat

Help: man weechat

Web site: https://weechat.org/

IRSSI Details:

Installation: sudo apt install irssi

Run command: irssi

Dotfile: ~/.irssi/config

Help: man irssi

Web site: https://irssi.org/

Believe it or not, IRC is still very popular and still going strong, especially among the tech community. There are numerous ways to get on IRC, even through the command line. Both of the apps presented here, WeeChat and IRSSI, are actively developed and going strong. Figure 6-17 shows WeeChat, but both apps are similar to the picture.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig17_HTML.jpg
Figure 6-17

WeeChat IRC client

Both offer scripting, plug-ins, themes, filters, help screens, and everything else you need to get started.

VOIP

As far as I know, there is no command-line replacement for Skype, FaceTime, or other VOIP software. There is an “experimental” project called Twinkle that exists but is reported to be crash-prone and unreliable.

If this is something you badly need, you might want to take a look. The app comes from https://github.com/LubosD/twinkle .

Social Media

Most command-line apps are actively developed versions of apps that were originally created decades ago. Social media is a relatively new area of computing, and the command line has a ways to go to catch up here. Also, most social media sites rely heavily on graphics, and obviously, that’s not a great match for text mode. Still, there are a few good apps out there, and remember you can easily access most social media sites through one of the text-based web browsers if necessary.

Twitter

Rainbow Stream Details:

Installation: sudo pip install rainbowstream

Run command: rainbowstream

Dotfile: ~/.rainbow_config.json

Help: Hit "h" in the app

Web site: https://github.com/orakaro/rainbowstream

You wouldn’t think Twitter clients would be all that hard to come by, but there’s only one that I could really recommend: Rainbow Stream. It’s easy to install and configure, and it allows you to post and narrow the stream into list view and does almost anything else you would want to do with Twitter.

Of course, you can use Twitter through any of the text-based web browsers by going to http://twitter.com instead of using a specialized client app.

Facebook

There’s not a “regular” Facebook client for the command line, but you can use their site through any of the text-based web browsers. There is, however, a command-line client for Facebook Messenger.
sudo apt install npm
sudo npm install -g fb-messenger-cli

Graphics, Art, and Photos

You wouldn’t think graphics and art would even be a category in the world of text, but there are some excellent tools to work on images, even from text mode. Asciiview is just a fun app to create “pictures” using only text characters. FIGlet is a fun little thing that lets you create text banners, and ImageMagick is a monstrous tool that can do nearly anything involving changing graphic formats and editing pictures—without even seeing them.

Asciiview

Asciiview Details:

Installation: sudo apt install aview

Run command: aview <filename.bpm>

Dotfile: none

Help: man aview

Web site: http://aa-project.sourceforge.net/tune/

For years, our cameras have been advertising more and more megapixels. Sometimes, once in a while, it’s more fun to go the other way around and look for the lowest resolutions possible. One of those cases would be when you need to display a photograph or graphic image on a text-only terminal.

One way to get this done is to use Asciiview. Figure 6-18 is a photo of me run through Asciiview, which was then converted into textual symbols. If you look closely, you will see that there are no graphic characters at all; it’s just letters, numbers, and symbols.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig18_HTML.jpg
Figure 6-18

The author’s photo in Asciiview

To convert an image, type
aview myphoto.bpm

FIGlet

FIGlet Details :

Installation: sudo apt install figlet

Run command: figlet <text string>

Dotfile: none

Help: man figlet

Web site: www.figlet.org/

FIGlet is just a little command-line tool to take a line of text and make a sort of textual “banner” from it. You can enter a single word or a whole sentence, depending on your needs. For example,
figlet Brian
will then return
____       _
| __ ) _ __(_) __ _ _ __
|  _ | '__| |/ _' | '_
| |_) | |  | | (_| | | | |
|____/|_|  |_|\__,_|_| |_|

ImageMagick

ImageMagick Details :

Installation: sudo apt install imagemagick

Run command(s): convert, identify, mogrify, compare, montage, composite, display, and so on. It’s a suite of commands.

Dotfile: none

Help: man imagemagick

Web site: www.imagemagick.org/

Both the preceding Ascii apps are little more than toys. Sometimes you need to actually do some graphical work, and for that, there’s ImageMagick.

The full documentation for ImageMagick is at www.imagemagick.org/script/command-line-processing.php .

It includes tools to create, edit, compose, or convert bitmap images. It can read and write images in over 200 formats, including PNG, JPEG, GIF, HEIC, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG.

You can use ImageMagick to resize, flip, mirror, rotate, distort, shear, and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses, and Bézier curves.

The ImageMagick command-line tools can be as simple as this, which converts and image in jpg format to the same image in png format:
convert image.jpg image.png
Or it can be outrageously complex with a plethora of options, as in the following:
convert -delay 100 -size 100x100 xc:SkyBlue -page +5+10  balloon.gif -page +35+30 medical.gif -page +62+50 present.gif -page +10+55 shading.gif -loop 0  animation.gif

Audio and Video

The computer can get boring at times with just text on the screen. Fortunately, you don’t have to sit there and work in silence. Computers were playing music long before GUI interfaces, and you can play all your music with command-line tools. It’s actually even easier to create playlists and automate your music using these tools. If you want to watch a movie while you work, that’s completely possible too.

Music Players

The Raspberry Pi has excellent hardware for playing music, either through the audio jack or through HDMI. The command line has numerous excellent (and very customizable) music players. My two favorites are MOC and CMUS.

Both work better if you have your music library organized in individual artist directories. At one point, I had all my music in Apple iTunes; so I just downloaded all the songs from there, copied the giant “Music” folder to its own directory, and pointed the music players at them—the default organization leftover from iTunes works without any modification. I’m not saying you need iTunes to organize your music, but a lot of people already have that somewhere, and if you do, it’s one easy way to go.

MOC (Music on Console)

MOC Details :

Installation: sudo apt install moc

Run command: mocp

Dotfile: ~/.moc/config

Help: man moc

Web site: http://moc.daper.net/

I like this one, especially when I am working with a playlist. It has two columns, and the default layout looks a lot like the Midnight Commander app. As Figure 6-19 shows, you can see your music files on the left pane, and the playlist you are working with lives in the right pane. Select a file and “add” it to the list, and you can visually see what you’re doing. It’s theme-able and has an equalizer built in, the keys can be remapped to your preferences, and it even has support for Internet streams. It’s got a convenient help screen; just hit “H,” and all the commands will pop up for you.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig19_HTML.jpg
Figure 6-19

MOC (Music on Console)

Run the MOC player with mocp (note the p at the end).

CMUS (C Music Player)

CMUS Details:

Installation: sudo apt install cmus

Run command: cmus

Dotfile: /usr/share/cmus/rc

Help: man cmus

Web site: https://cmus.github.io/

While MOC is great for working with playlists, I like CMUS better for just browsing and playing songs on a whim (see Figure 6-20); the navigation feels nicer to me. While MOC has a navigation system reminiscent of Midnight Commander, CMUS looks and feels more like Ranger. Your choice of music player may be closely related to which file browsing system you prefer.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig20_HTML.jpg
Figure 6-20

CMUS (C Music Player)

CMUS supports most music formats from the default install: Ogg Vorbis, MP3, FLAC, Opus, Musepack, WavPack, WAV, AAC, MP4, audio CD, and everything supported by ffmpeg (WMA, APE, MKA, TTA, SHN, etc.) and libmodplug. If you get your music from various sources, then being able to not worry about your format being understood is a nice plus.

Like MOC, CMUS has remappable keys, theming, and color customizing. This one, however, also allows for music streaming from online radio stations if you can find the url for the stream, that is, http://beirutnights.com/live.m3u .

Install with sudo apt install cmus.

MPC/MPD (Music Player Daemon/Controller)

MPD Details:

Installation: sudo apt install mpd

Run command: mpd

Dotfile: /etc/mpd.conf

Help: man mpd

Web site: www.musicpd.org

Both of the previous entries, MOC and CMUS , were full-screen apps that relied heavily on visually navigating files and directories. Both interfaces were inspired by file management systems, and both are at least somewhat interactive with their controls.

An alternative is the Music Player Daemon, or MPD. It is a flexible, powerful, server-side application for playing music. Through plug-ins and libraries, it can play a variety of sound files while being controlled by its network protocol. Since it’s a daemon, it just runs silently in the background and waits for commands from an external client program.

MPC is the parallel client app. It connects to MPD and controls it according to commands and arguments passed to it. If no arguments are passed, current status is given. It’s strictly a command-line tool, with no visuals whatsoever.

There are, however, a number of other clients that work with the MPD server. Some are graphical, some are for the Web, while others are for use on the console. It’s a bit harder to set up, but it’s very flexible and powerful.

MPD Daemon home page: www.musicpd.org/

MPD clients: www.musicpd.org/clients/

Essentially the point of MPD is that with the client/server architecture, you can set up one machine in your house with all the music files stored on it and then access and play that music from other computers located on the network without storing your music files in multiple places.

Movie Viewers

Movies are obviously visual. The old-style terminals and computers back in the early days of Unix couldn’t play video files because the monitors just couldn’t handle it. Your Raspberry Pi, on the other hand, can play movies easily. The model 4 Pi can even handle dual 4K outputs. These systems can play videos, and there’s no real reason why you cannot play your movies from the command line.

MPlayer

MPlayer Details:

Installation: sudo apt install mplayer

Run command: mplayer <filename>

Dotfile: various files inside /etc/mplayer/

Help: man mplayer

Web site: www.mplayerhq.hu/

MPlayer is a movie player which runs on many systems. It plays most MPEG/VOB, AVI, Ogg/OGM, VIVO, ASF, WMA, WMV, QT, MOV, MP4, RealMedia, Matroska, NUT, NuppelVideo, FLI, YUV4MPEG, FILM, RoQ, and PVA files, supported by many native, XAnim, and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx, DivX 3/4/5, WMV, and even H.264 movies.

In most cases, you can enjoy movies either in full-screen mode or in a window. There’s a screenshot of the title of a movie beginning in Figure 6-21.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig21_HTML.jpg
Figure 6-21

MPlayer status on the left, MPlayer movie on the right

Even with all this, you still may prefer to watch your videos in the GUI with an app like VLC (discussed elsewhere), but it’s good to know you have the ability to watch on the command line if you need it.

News and Weather

News is mostly text, so it’s not a huge leap to think that there would be a number of ways to get the news on the command line. Here are two great ways to get started:

Instantnews

Instantnews Details:

Installation: sudo pip install instantnews

Run command: instantnews

Dotfile: None

Help: man instantnews

Web site: https://github.com/shivam043/instantnews

Instantnews retrieves all news headlines from the News API and then displays what you want to see in text. There are dozens of professional news sources, and you can choose from one or any combination of them to display on your screen. It requires you to sign up for a free API key.

Haxor-News

Haxor-News Details:

Installation: sudo pip install haxor-news

Run command: hn <command>

Dotfile: various files inside ~/.haxornewsconfig

Help: hn --help

Web site: https://github.com/donnemartin/haxor-news

A slightly more “fun” news program that works similarly is Haxor-News. Haxor-News brings hacker and nerd news to the terminal, allowing you to view and filter the following without leaving your command line:
  • Posts

  • Post comments

  • Post-linked web content

  • Monthly hiring and freelancers posts

  • User info

  • Onion posts

Once you are in, you type various commands starting with “hn” such as hn top to show the top stories right now. Figure 6-22 shows an example of the output.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig22_HTML.jpg
Figure 6-22

Haxor-News top stories

Once you find a story that you want to read, type hn view # to view that particular story. Figure 6-23 shows what I get after entering “hn view 10.”
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig23_HTML.jpg
Figure 6-23

News article “Magnesium and Major Depression”

Then hit “q” to go back to the article list and choose more.

Newsboat

Newsboat Details:

Installation: sudo apt install newsboat

Run command: newsboat

Dotfile: ~/.config/newsboat/config

Help: man newsboat

Web site: https://newsboat.org/

Newsboat is an RSS reader. Many web sites, including most major news sources, offer an RSS feed containing their stories, so there’s a huge variety of possible news sources that you can tap into. Various commands will be displayed that show how to set it up. Once you have a collection of RSS feeds installed in it, you will see something like Figure 6-24.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig24_HTML.jpg
Figure 6-24

Newsbeuter/Newsboat list of feeds

Weather

There are a great many utilities for getting weather information from the command line, so here are a few fun apps:

Finger

For the lucky people who live in a supported city, you can simply type
sudo apt install finger
at the command line, substituting your city name for “city” in the command, and the result is something like Figure 6-25.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig25_HTML.jpg
Figure 6-25

Getting the weather for New York City

Alternately, you can simply type
curl wttr.in/your_location

at the command line, substituting your city name for “your_location” in the command.

For example, if I type
curl wttr.in/flint
the output will result in something along the lines of Figure 6-26.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig26_HTML.jpg
Figure 6-26

Getting the weather for Flint, Michigan

Ansiweather

Ansiweather Details:

Installation: sudo apt install ansiweather

Example run command: ansiweather -l Flint -u imperial -f 3 -s true

Dotfile: ~/.ansiweatherrc

Help: man ansiweather

Web site: https://github.com/fcambus/ansiweather

The preceding example run command looks up the weather for Flint and reports it for 3 days, in Imperial units (i.e., not metric) along with weather symbols. As Figure 6-27 demonstrates, the preceding Ansiweather command outputs a single line with all the information on it.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig27_HTML.jpg
Figure 6-27

Ansiweather for Flint, Michigan

Books, Comics, and Reading

This is text mode we’re dealing with now, so obviously you can read text on it. We’ve talked about text editors in a previous section, and those are all wonderful for simply reading text. Sometimes, however, you have a file in a non-textual format that needs to be read. Ebook formats such as EPUB, MOBI, PRC, and the like all require specialized readers; and we’ll look at how to access these now.

EPUB Documents

EPUBReader Details:

Installation (type as one line):

sudo pip3 install git+ https://github.com/wustho/epr.git

Run command: epr <filename.epub>

Dotfile: none

Help: epr --help

Web site: https://github.com/wustho/epr/

Generally, reading from the command line is done through a text editor such as Vim or Emacs or even Nano. Still, more and more books are being made available in ebook formats. Once installed, just type
epub FILENAME.epub

and the ebook (in EPUB format) will display on the screen. The instructions are very easy to follow.

Non-EPUB Formats

Calibre Details:

Installation: sudo apt install calibre

Run command: calibre (or command in the following)

Dotfile: set in the app through a menu

Help: man calibre

Web site: https://calibre-ebook.com/

Other ebook formats, such as .mobi, .azw, and .prc, will need to be converted to .epub or text format before use. The most common way to do this from within a graphical user interface is with the app Calibre. Since we’re talking about command-line tools here, most of Calibre’s features won’t be available, but Calibre does come with several powerful command-line tools.

Once you have Calibre installed, you can use its graphic interface if you choose (as in Figure 6-28), but if you want to do it all from the command line, check out the command-line tools installed alongside Calibre.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig28_HTML.jpg
Figure 6-28

Calibre on the desktop

Documented commands :
  • calibre

  • calibre-customize

  • calibre-debug

  • calibre-server

  • calibre-smtp

  • calibredb

  • ebook-convert

  • ebook-edit

  • ebook-meta

  • ebook-polish

  • ebook-viewer

  • fetch-ebook-metadata

  • lrf2lrs

  • lrfviewer

  • lrs2lrf

  • web2disk

The list and associated instructions can be found at

https://manual.calibre-ebook.com/generated/en/cli-index.html .

Probably the most useful one is ebook-convert. If, for example, you have an ebook file in .mobi format and you want to change it to .epub format, just type
ebook-convert myfile.mobi myfile.epub -h

It’s really fast, and the output looks perfect. Then you can just use the EPUB reader to read the file.

Task Management

There are many command-line tools for calendaring, scheduling, and task management. Here are my favorites:

Cal

From way back in the early days of the original Unix systems, there is the ancient cal command . It displays a monthly calendar with today’s date highlighted. I can’t begin to tell how many times I’ve used this over the years. Other than displaying the month, it doesn’t do anything special, but it’s still incredibly convenient.

It’s part of the operating system, so you don’t need to install anything. Just type
cal

Calcurse

Calcurse Details:

Installation: sudo apt install calcurse

Run command: calcurse

Dotfile: Various files in ~/.calcurse/

Help: man calcurse

Web site: https://calcurse.org/

Calcurse is a visual, text-based calendar, scheduler, and to-do manager for the command line. It has commands listed along the bottom two lines, much like the Nano editor, and additional commands can be had by hitting the “o” key. It allows customizations of colors, the layout of the three main window panes, and a few other things that you can select. If you aren’t worried about syncing between your computer and other devices, this is probably the nicest way to go. There’s a nice screenshot in Figure 6-29.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig29_HTML.jpg
Figure 6-29

Calcurse

Todo.txt

If you are concerned about syncing your appointments and tasks between devices, this process is more complex than Calcurse, but allows for use on any device. The concept is simple: A group of users have gotten together and created a standardized text file format that can contain all your to-do lists and appointments. Then you use a file-syncing system like Dropbox to make that file available to your computer, phone, tablet, and whatever other devices you use. It’s easy to set this system up, it’s reliable, and it’s surprisingly flexible.

If what I’ve just described is something that appeals to you, then by all means go for it right now and design your own methodology and system. Put a todo.txt file in your Dropbox on your phone and set your computer to access that file. You’re all set!

Or you can use a system already available that does all this. There’s a whole online community that has built up around this concept, and they’ve come up with what they believe is a “standard” for todo.txt files. The home page for the organizations is at

http://todotxt.org

and the specific “rules” they have set up are at

https://github.com/todotxt/todo.txt .

You might ask, “Why use such a complicated set of rules for simply managing a to-do list in a text file?” The answer is that if you use their standardized format, then you can take advantage of the various apps that have been created to support the format. If you don’t care about these apps, then you could just do it any way you want, managing your files with a text editor.

There is todo.txt-cli at

https://github.com/todotxt/todo.txt-cli/releases

as well as other apps that do the same thing. This idea especially appeals when you realize there are phone apps that work with these files. My favorite for the iPhone is SwiftoDo, found at http://swiftodoapp.com/ . Figure 6-30 shows the app. Text files and command lines are great on a full-sized computer, but on a little phone, specialized apps really are easier to deal with than trying to edit a text file with a general writing app.
../images/485525_1_En_6_Chapter/485525_1_En_6_Fig30_HTML.jpg
Figure 6-30

SwiftoDo for iPhone

Coding/Programming/Web Design

The options and availability of Linux-based programming and coding tools are nearly unlimited. Almost every computer language compiler is available as a command-line tool, and, under the surface, even most GUI programming tools simply run a command-line tool in the background. The best way to get into coding is to choose a text editor program such as Vim, Emacs, or something of that sort and then start looking at the various syntax tools and programming-specific plug-ins.

All the major text editors are used heavily by developers, mostly due to their customizability, plug-in capability, and speed. Which editor you choose is largely a matter of taste and how much effort you want to put into learning it; it’s completely possible to use nothing more than Nano to type in code and then compile it on the command line using the language of your choice, but most coders are going to want something more and will quickly advance into Emacs or Vim (although there are other choices out there that are excellent as well). There’s no way I can even begin to scratch the surface of how to use these advanced editors in the development world, so I won’t. Just keep in mind that coding in text mode is just as capable, if not more, as working in a GUI environment.

One coding tool that has exploded in the past few years is Git. Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning-fast performance. It ties in with Github.com , the online repository and home of most of today’s open source projects. The command-line version of Git is available at https://git-scm.com and can be installed as either a command-line version or GUI tool. Once you make some changes to a source file (whatever kind, from C++ to HTML to Prose Text), you commit changes to a repository, and then if you decide to branch off or restore from a previous version at a later time, you can. It’s tremendously useful for keeping multiple versions of files, collaboration, and, of course, bug fixes.

Web Apps and Services

Installing command-line software isn’t the only option to get things done anymore. There are also countless web applications available over the Internet for free or for a subscription fee. Some people survive just fine using nothing but a Chromebook as their primary computer, and, until recently, those machines used nothing but web applications, and we’re looking at them in this book as almost an afterthought. Many advanced web sites depend heavily on JavaScript and other scripting languages that do not work well (or at all) from a text-based browser, but some work well in text mode.

There are command-line tools to access many web-based services. Todoist is one very popular to-do list manager that works great on most mobile devices, and there is at least one good command-line interface for it. The todo.txt system is another system that works to sync between mobile/GUI and text.

This book isn’t going to focus too heavily on web apps, as I cover them extensively in my other book, Going Chromebook: Living Life in the Cloud, and really only intend to cover text-mode specific tools here. Just keep in mind that if you can’t find a tool you need, there may be a tool on the Web for your needs.

Using Command-Line Tools with the GUI

Sometimes the best tool for a job is not the one you want to be using. Sometimes, the GUI really is the more efficient way to do things. Drawing and video work are two good examples, as is image-intensive web development. Most heavily visual game programming requires a GUI. Plus, some modern tools only work under a windowing system, not even making their features available from the command line. Sometimes you need a GUI to get things done.

The days of dumb terminals and text-based teletype machines are long past us. Nostalgia and minimalism are enjoyable, but there is a reason that computers have moved past those things. If you’re running a command-line tool on a server with SSH, then you can do a lot of powerful things that way, but if you add that power alongside the best tools that a GUI system can offer, wouldn’t that be better still? Sometimes, you may find yourself following a ten-step process to get something done that you could be using a different tool for and doing it in a single step.

My point is that now that you’ve learned how you can do just about everything in text mode, it’s time to select what works best for you and use those tools alongside your desktop software. If you’ve been running a command line from within a terminal window on a Raspbian machine, or SSH-ing into your Pi from a Mac, then you’re already doing this. Terminator or Terminal on Linux is the same thing; you’re running a terminal screen from within a GUI. That’s not “cheating”; that’s the smart way to do it.

For example, writing a book is one task that needs both ways of working to finish a project. Go ahead and write that book in LaTeX or Markdown using Vim. Use the command-line version of Git to manage your versions. Compile it into a PDF with Pandoc. But then use some graphic app such as Okular to view the resulting PDF. This is called “using the right tool for the right job” and is the most efficient way to get the project done. If you can’t find a command-line PDF viewer that you enjoy using, then don’t do it that way. It’s all about what gets things done in the most efficient and enjoyable manner. It’s OK to get hung up in your work; just don’t get bogged down by the tools.

Learn how to cut and paste from the terminal window into a graphical window. Learn how to copy files from your home directory onto the desktop of the graphical desktop. Sometimes it’s easier to use Ranger to browse the file system than it is to use the File Manager, and sometimes the opposite is true.

Just off the top of my head, I’ve provided two lists of tasks that I believe are better suited for one method or the other (Table 6-1). You can do all these things from one “side” or the other; these are just what I find preferable. Your opinion is free to vary.
Table 6-1

Command Line vs. GUI

Better from the Command Line

Better in a Graphical Environment

Mutt for email

PDF and comic reading

Text editing using Vim or Emacs

Complex desktop publishing layouts

Ranger/MC for file operations

Drawing and graphic creation

Music and playlist creation

Most games

File backups, large-scale file transfers, and big downloads

Web browsing

My point here is that the command line doesn’t have to be a “lifestyle.” It’s one more tool in your arsenal of computer power. By learning the command line and some of the more useful tools, you can gain faster and more powerful ways to do things in a more customizable environment, often using less-powerful equipment. This whole concept is meant to be fun, not a prison sentence.

Conclusion

There are some tasks, like video and audio editing, that really demand the use of graphic mode and a mouse. That said, most tasks work just fine from the command line. They may not have all the pretty bells and whistles that accompany most desktop apps, but they often are far more configurable and easier to access and have extremely advanced automation possibilities. It’s just a matter of figuring out how they work without all the easy menus that a GUI offers.

In the next chapter, we’ll look at advanced topics and things that didn’t fit elsewhere. We’ve discussed Markdown and LaTeX, and we’ll do a quick introduction to those tools and then look at customizing your command-line apps with dotfiles and configuration files. We’ll look at some additional resources you can find online.

Lastly, we look at some projects you can use a spare Raspberry Pi for that require a dedicated machine. I’ve found that the RPi are so cheap, you tend to buy a new one every time they have a significant upgrade. I recently looked, and I have five of them lying around!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.174.168