Terminal Multiplexers: Byobu and Midnight Commander, Study notes of Computer Science

Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study Material & ebooks for MCA, Study

Typology: Study notes

2021/2022

Uploaded on 01/13/2023

akash-kumar-116
akash-kumar-116 🇮🇳

3 documents

1 / 263

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Adventures
with the
Linux Command Line
First Internet Edition
William Shotts
A LinuxCommand.org Book
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Terminal Multiplexers: Byobu and Midnight Commander and more Study notes Computer Science in PDF only on Docsity!

Adventures

with the

Linux Command Line

First Internet Edition

William Shotts

A LinuxCommand.org Book

Copyright ©2014- 2021 , William Shotts This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License. To view a copy of this license, visit the link above or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042. Linux®^ is the registered trademark of Linus Torvalds. All other trademarks belong to their respective owners. This book is part of the LinuxCommand.org project, a site for Linux education and advocacy devoted to helping users of legacy operating systems migrate into the future. You may visit the LinuxCommand.org project at https://linuxcommand.org. Release History Version Date Description 21.10 October 1, 2021 First Internet Edition.

“Amaze your friends! Baffle your enemies!” And the story continues. A long time ago (shortly after I finished college in 1977) I got my first computer, a TRS- 80 model 1. In the early days of personal computing, many computer peripherals, such as printers and floppy disk drives, were very costly and as a result, my dad (an electrical engineer) and I would cruise electronic surplus stores looking for deals on devices we could attach to our new computer. One day, as we were searching a large warehouse near the University of Maryland, I came across a store display featuring a small, clear, plastic box containing a battery, a few computer chips, and several randomly blinking LEDs. While the little device served no useful purpose, it did have blinking lights. Above it hung a handwritten sign that read simply: Amaze Your Friends! Baffle Your Enemies! The excitement pervasive in the early days of personal computing is hard to explain to people today. The computers of that period seem so laughably primitive by today’s standards but it was a revolution nonetheless and there were many explorers mapping the new, uncharted territory of personal empowerment and technical innovation. People entering the computer field now are at a disadvantage compared to those of us who came up in the 1970s and 1980s. The early computers were very simple, slow, and had tiny memories. All the attributes you need if you really want to understand how computers work. Today, computers are so fast, and software so large and complex that you can’t see the computer underneath anymore and that’s a shame. You can’t see the beauty of what they do. However, we are now in the midst of another revolution, extremely low-cost computing. Devices like the Raspberry Pi single board computer offer the opportunity to work on systems more simple and basic compared to contemporary desktop and mobile devices. But make no mistake, these low-cost computers are powerful. In fact, a $35 Raspberry Pi compares favorably to the $30,000 Unix workstations I used in the early 1990s.

What this book is about

This volume is a sequel/supplement to my first book, The Linux Command Line (TLCL) and as such, we will be referring back to the first book frequently, so if you don’t already have a copy, please download one from LinuxCommand.org or, if you prefer, pickup a printed copy from your favorite bookseller or library. This time around we are going to v

build on our experience with the command line and add some more tools and techniques to our repertoire. Like the first book, this second volume is not a book about Linux system administration, rather it is a collection of topics that I consider both fun and interesting. We will cover many tools that will be of interest to budding system administrators, but the tools were chosen for other reasons. Sometimes they were chosen because they are “classic” Unix, others because they are just “something you should know,” but mostly topics were chosen because I find them fun and interesting. Personal computing, after all, should be about doing things that are fun and interesting just as it was in the early days.

Who should read this book

This is a book for explorers and creators looking for adventure. I think computers are the coolest things ever and if you share that feeling of excitement with every new thing you can get your computer to do then you have come to the right place. Many people today come into the computer field only in hopes of developing enough skill to get a job. There is nothing wrong with that of course. Everyone needs to earn a decent living, but there is more to life than that. There is beauty and there is love, and if you are wise (and lucky) you will find these things in your career. Computers are powerful tools that, in the right hands, can improve the human condition. I think it’s a worthy goal to leave the world a little better than the way you found it. I hope you do too.

What’s in the first Internet edition

For the most part, you can think of this book as an expansion of Part 3 of TLCL. In fact, I considered some of these topics for inclusion in the first book, but ran out of space for them. That being said, this is definitely a work-in-progress. Future editions will contain more chapters and the existing chapters will contain additional content and the chapters will likely appear in a different order. Typography and layout will improve too.

How to read this book

This book is not as linear as TLCL so feel free to skip around. Some adventures are prerequisites for later ones. If an adventure requires an earlier one, it will be indicated. A few of the adventures call for supplemental material (typically code samples and datasets) that can be downloaded from LinuxCommand.org. vi

1 Midnight Commander At the beginning of Chapter 4 in TLCL there is a discussion of GUI-based file managers versus the traditional command line tools for file manipulation such as cp, mv, and rm. While many common file manipulations are easily done with a graphical file manager, the command line tools provide additional power and flexibility. In this adventure we will look at Midnight Commander, a character-based directory browser and file manager that bridges the two worlds of the familiar graphical file manager and the common command line tools. The design of Midnight Commander is based on a common concept in file managers: dual directory panes where the listings of two directories are shown at the same time. The idea is that files are moved or copied from the directory shown in one pane to the directory shown in the other. Midnight Commander can do this, and much, much more.

Features

Midnight Commander is quite powerful and boasts an extensive set of features:

  • Performs all the common file and directory manipulations such as copying, moving, renaming, linking, and deleting.
  • Allows manipulation of file and directory permissions.
  • Can treat remote systems (via FTP or SSH) as though they were local directories.
  • Can treat archive files (like .tar and .zip) as though they were local directories.
  • Allows creation of a user-defined “hotlist” of frequently used directories.
  • Can search for files based on file name or file contents, and treat the search results like a directory.

Availability

Midnight Commander is part of the GNU project. It is installed by default in some Linux distributions, and is almost always available in every distribution’s software repositories as the package “mc”.

Invocation

To start Midnight Commander, enter the command mc followed optionally by either 1 or 2 directories to browse at start up. Midnight Commander 1

Using the Keyboard and Mouse

Being a character-based application with a lot of features means Midnight Commander has a lot of keyboard commands, some of which it shares with other applications; others are unique. This makes Midnight Commander a bit challenging to learn. Fortunately, Midnight Commander also supports mouse input on most terminal emulators (and on the console if the gpm package is installed), so it’s easy to pick up the basics. Learning the keyboard commands is needed to take full advantage of the program’s features, however. Another issue when using the keyboard with Midnight Commander is interference from the window manager and the terminal emulator itself. Many of the function keys and Alt- key combinations that Midnight Commander uses are intercepted for other purposes by the terminal and window manager. To work around this problem, Midnight Commander allows the Esc key to function as a Meta-key. In cases where a function key or Alt-key combination is not available due to interference from outside programs, use the Esc key instead. For example, to input the F key, press and release the Esc key followed by the “1” key (use “0” for F10). The same method works with troublesome Alt-key combinations. For example, to enter Alt-t, press and release the Esc key followed by the “t” key. To close dialog boxes in Midnight Commander, press the Esc key twice.

Navigation and Browsing

Before we start performing file operations, it’s important to learn how to use the directory panels and navigate the file system. As we can see, there are two directory panels, the left panel and the right panel. At any one time, one of the panels is active and is called the current panel. The other panel is conveniently called the other panel in the Midnight Commander documentation. The current panel can be identified by the highlighted bar in the directory listing, which can be moved up and down with the arrow keys, PgUp, PgDn, etc. Any file or directory which is highlighted is said to be selected. Select a directory and press Enter. The current directory panel will change to the selected directory. Highlighting the topmost item in the listing selects the parent directory. It is also possible to change directories directly on the command line below the directory panels. To do so, simply enter cd followed by a path name as usual. Pressing the Tab key switches the current panel. Midnight Commander 3

Changing the Listing Format

The directory listing can be displayed in several different formats. Pressing Alt-t cycles through them. There is a dual column format, a format resembling the output of ls -l, and others. There is also an “information mode.” This will display detailed file system information in the other panel about the selected item in the current panel. To invoke this mode, type Ctrl-x i. To return the other panel to its normal state, type Ctrl-x i again. Directory panel in information mode

Setting the Directory on the Other Panel

It is often useful to select a directory in the current panel and have its contents listed on the other panel; for example, when moving files from a parent directory into a subdirectory. To do this, select a directory and type Alt-o. To force the other panel to list the same directory as the current panel, type Alt-i.

The Directory Hotlist

Midnight Commander can store a list of frequently visited directories. This “hotlist” can displayed by pressing Ctrl-. 4 Midnight Commander

Directory and command line history mouse controls

Viewing and Editing Files

An activity often performed while directory browsing is examining the content of files. Midnight Commander provides a capable file viewer which can be accessed by selecting a file and pressing the F3 key. File viewer 6 Midnight Commander

As we can see, when the file viewer is active, the function key labels at the bottom of the screen change to reveal viewer features. Files can be searched and the viewer can quickly go to any position in the file. Most importantly, files can be viewed in either ASCII (regular text) or hexadecimal, for those cases when we need a really detailed view. File viewer in hexadecimal mode It is also possible to put the other panel into “quick view” mode to view the currently selected file. This is especially nice if we are browsing a directory full of text files and want to rapidly view the files, as each time a new file is selected in the current panel, it’s instantly displayed in the other. To start quick view mode, type Ctrl-x q. Midnight Commander 7

mcedit

Tagging Files

We have already seen how to select a file in the current directory panel by simply moving the highlight, but operating on a single file is not of much use. After all, we can perform those kinds of operations more easily by entering commands directly on the command line. However, we often want to operate on multiple files. This can be accomplished through tagging. When a file is tagged, it is marked for some later operation such as copying. This is why we choose to use a file manager like Midnight Commander. When one or more files are tagged, file operations (such as copying) are performed on the tagged files and selection has no effect.

Tagging Individual Files

To tag an individual file or directory, select it and press the Insert key. To untag it, press the Insert key again.

Tagging Groups of Files

To tag a group of files or directories according to a selection criteria, such as a wildcard pattern, press the + key. This will display a dialog where the pattern may be specified. Midnight Commander 9

File tagging dialog This dialog stores a history of patterns. To traverse it, use Ctrl up and down arrows. It is also possible to un-tag a group of files. Pressing the / key will cause a pattern entry dialog to display.

We Need a Playground

To explore the basic file manipulation features of Midnight Commander, we need a “playground” like we had in Chapter 4 of TLCL.

Creating Directories

The first step in creating a playground is creating a directory called, aptly enough, playground. First, we will navigate to our home directory, then press the F7 key. 10 Midnight Commander