Midnight Commander(mc) console file manager for Linux. Ten Tips for Using Midnight Commander Effectively

If you are a novice webmaster, then you probably work with files on servers either via FTP, or using a file manager through a browser, or via SSH from the command line. All of these methods are associated with a number of inconveniences. From this article you will learn about another method that does not have many disadvantages.

We will talk about the Midnight Commander program (abbreviated mc). This powerful tool, often available on unix servers. For those who have been working with file managers in the Windows family for a long time, they will seem very similar Total programs Commander or Far.

To run Midnight Commander, you need to connect to the server via SSH using the Putty program. The connection parameters are usually the same as those used for FTP. After authorization, enter the mc command and press Enter. If Midnight Commander is installed on the server, you will see a screen like this.

Basic file operations

The screen is divided into two panels. In each, use the arrows and Enter to navigate through the folder tree. Mouse is also supported.

With your files you can produce standard operations: copy (F5 key, in one panel open the folder with the current file, in another - the folder you want to copy the file to), move (F6), rename (also F6), delete (F8), edit (F4), view ( F3). Function tips at the bottom of the screen.

Groups of files can be selected using the Insert and * keys.

Open the same folder in the next panel – Alt+i.

How to unpack a zip archive

Below the panels there is a command line. Enter the unzip archive_name command into it. To avoid retyping the archive name into the command line, select the archive using the arrows, then press Alt+Enter.

For gzip archives, use the gunzip archive_name command.

For *.tar.gz files, use the command tar xvfz filename.tar.gz.

How to create a new text file

Press Shift+F4.

How to find out the sizes of all directories

Press Ctrl+Space.

How to temporarily minimize Midnight Commander

To return to full screen mode command line press Ctrl+o. By clicking on these buttons again, you can return to the minimized mc.

This feature is only available when mc is built with a subshell.

How to change file permissions

You can manage file owners, groups, and file rights. For example, if you want to set permissions to 777 on the tmp directory, you just need to select File -> Chmod or Ctrl+x in the top menu and then c.

If you need to change the owner of a file or its group (naturally, if you have such permissions in the system), you can use File -> Chown, or the combination Ctrl+x followed by o.

Working with other remote servers

Not bad mc helps to communicate via data transfer protocols such as FTP/SSH/SMB.

Example: you needed a file located on another FTP server. You can, without leaving mc, connect to the required FTP server and copy the required file to your server.

Using Shell and SMB is no different from FTP - it is additional types protocols that may be found on the network, so you can easily connect to Samba Share or even perform ssh command on a remote server.

Customize mc settings

There is a convenient, editable menu called up by pressing F2, in which you can pre-set regularly required operations on files or directories, as well as launch various scripts.

Other settings (terminal settings, display of certain files when working in the manager) – Options -> Configuration.

Solving technical problems

Separately, it is worth noting the Display Bits and learn keys section. By virtue of various reasons differences in the terminal environment and client software for using mc may cause difficulties, for example, not all keys will work or will not work as expected, the first tab will help display 8 bit characters, and the second will help identify the buttons if they are for some reason reason we got lost.

For Linux servers, when working from standard putty, I recommend using: "export LC_ALL=C" before starting mc, in this case there will be no problems Linux servers did not occur, FreeBsd servers behave normally with mc by default.

2) In some types of terminal, the “-d” key can be useful; it disables the mouse; there have been cases when 1 mouse movement was understood by the MC as a dozen or two commands from the keyboard. But in general it is not required, it works fine without it.

In the standard case, it starts either without switches or with the “-c” switch (turn on color).

Do you have your own tricks when working with mc? Please write in the comments.

1.1. Installing Midnight Commander

Although to manage the file system and generally work with files, you can use OS commands such as pwd, ls, cd, mv, mkdir, rmdir, cp, rm, cat, more etc., it is much more convenient to do most of the file system maintenance work using a program Midnight Commander, which clearly represents all the actions performed, thereby facilitating the implementation of these operations.
Midnight Commander(for brevity we will denote it mc) is a program that allows you to view directory structures and perform basic file system management operations.
If you have experience working with Norton Commander (nc) in DOS or with far in Windows, then you can easily work with mc, since even the basic “hot combinations” of keys are the same. In this case, in order to work with Midnight Commander, you just need to quickly review the material below. For those who are not familiar with nc or far(are there such things?) I recommend that you carefully study this section, because Midnight Commander makes working with the OS much easier.

Program Midnight Commander is not installed automatically during system installation. But I strongly recommend that you install it as soon as you have installed the OS. This will make your future life much easier. Since installing new software packages will only be discussed in one of the following sections, I will present the most important ones here. brief instructions on installation Midnight Commander-A.

First, mount the Black Cat Linux distribution CDROM (you already know the mount command). Let's assume that the CDROM is mounted in the /mnt/cdrom directory. Now go to the /mnt/cdrom/RedHat/RPMS directory, using the cd command that is also already familiar to you. Next you need to determine the exact name of the package containing Midnight Commander, why give the command
ls mc*
Now all that remains is to dial in command line a command something like this:
rpm -i mc-4.50.i386.rpm
where instead of "mc-4.50.i386.rpm" you need to substitute the exact name of the rpm package, which was reported to you by the ls program. Once the shell prompt appears again, you can run the program Midnight Commander. You will find out how this is done below.

3.11.00. By the way, Valery Studennikov wrote a wonderful one that allows you to select code pages when viewing a file. It is intended for the latest official version (4.5.51, 4228 Kb).

1.2. Screen appearance when working with Midnight Commander

Notes: 1. The description given is compiled in relation to version 4.5.30 of the program, although it can be used for other (especially earlier) versions.
2. This description fully applicable only in cases where the program is launched from a terminal. When work is done through a terminal emulator in graphic mode, some parts of the description may not correspond to the program's response, presumably because keystrokes are initially intercepted graphical shell. Most often, such a discrepancy will occur where we're talking about about hot keys.

In order to run Midnight Commander, you need to type two characters on the shell command line: mc and press . If the program does not start, you need to find where the executable file with the name is located mc using the command find / -name "mc", then specify the full path on the command line, for example, I have this /usr/bin/mc. After launch, you will see a blue screen, very similar to the screen of the Norton Commander program for MS-DOS or FAR programs E. Roshal, which is widely used in a DOS window under Windows.

Almost the entire screen space when working with Midnight Commander is occupied by two “panels” displaying lists of files in two directories (generally speaking, different, but, in a particular case, may be the same directory).
Above the panels there is a menu bar, and you can switch to selecting items in this menu using the key or using the mouse (if immediately after starting mc You don’t see the menu bar, don’t worry - whether the menu bar is visible or not is determined by the program settings).

The bottom line is a row of on-screen buttons, each of which is associated with one of the function keys - . You can consider this line as a hint on using the function keys, or you can directly launch the corresponding commands by clicking on the on-screen key.
The display of the line with on-screen buttons can be disabled if you want to save screen space (this will be discussed later, when we talk about program settings). Such savings are justified for two reasons. Firstly, you will quickly remember the purpose of these 10 keys and you will no longer need a hint (and it is not always convenient to click on these keys with the mouse). Secondly, even if you have forgotten which key you need to perform the currently required action, you can always use the “File” drop-down menu of the program’s main menu (just remember that you can access the main menu by pressing the F9 key). Through the "File" menu, it is possible to perform any of the operations associated with the function keys (except F1 and F9, but you won't forget these keys, I hope!).

The second line from the bottom on the screen (on a black background) is the command line of the program Midnight Commander(more precisely - the command line of the current shell), where you can enter and execute any system command. Above it (but below the panels) a “helpful tips” (tips) field may be displayed, which can be removed by adjusting the program settings accordingly.

Each panel consists of a title, a list of files in a certain directory, and a mini-status line (the latter may not be visible, this is also set by the program settings). The panel header indicates the full path to the directory, the contents of which are displayed in the panel, as well as three on-screen buttons - "<", "v" и ">", which are used to control the program with the mouse. The "mini-status" line displays some data about the file or directory that the highlight is currently pointing to (for example, the file size and access rights to it).

One of the panels is current (active), as evidenced by the highlighting in one of the lines of this panel and the highlighting of the directory name in the panel header. Accordingly, in the shell in which the program was launched Midnight Commander, the current directory is the one displayed in active panel. Almost all operations are performed in this directory. Copy type operations ( ) or file transfer ( ) use the directory displayed in the second panel as the destination directory (to which the copy or transfer is performed).

In the active panel, one line is highlighted (sometimes we will say that the cursor is pointing to this line). The backlight can be moved using the navigation keys.
The built-in file viewer, tooltip viewer, and directory viewer use the same program code to control navigation. Consequently, the same key combinations are used for movement (but each subroutine also has combinations that are used only in that subroutine). Here is a short table listing common keys motion control.

Table 1.1

As you have already noticed, keys are indicated by a symbol printed on the key, enclosed in angle brackets. If two such brackets are connected by a hyphen, this means that you need to hold down the first key and press the second at the same time. If the key designations are separated by a space, then you need to press the first key (or combination of keys) in sequence, release it, and then press next key. Let us also note that in the documentation for the Midnight Commander program there is often mention of certain keys (for example, the key ), which are not available on a regular keyboard IBM-PC compatible computers. We will use the key designations that are found on familiar IBM-PC keyboards.

1.3. Getting help

When working with the program Midnight Commander Almost at any time you can access the interactive hint, which can be called by pressing a key . Since the tooltip is organized as hypertext, its text contains hypertext links to certain sections of the tooltip. Such links are highlighted with a blue background.
To move around in the tooltip viewing window, you can use the cursor keys (arrow keys) or the mouse. In addition to the general motion control combinations given in Table 1.1, the help viewer also accepts the following combinations, which also operate in the file viewer subroutine:

Table 1.2

In addition to the combinations already listed, when viewing a hint, some other key combinations can be used that work only when viewing a hint.

Table 1.3

Go to next link.
- Go to previous link.
<стрелка вниз> Moves to the next link or moves the text up one line.
<стрелка вверх> Moves to the next link or moves text down one line.
<стрелка вправо>or Follow the current link.
<стрелка влево>or key Go to previously viewed sections.
Help on using the hint itself.
Go to the next help section.

Go to the previous help section.
Go to the table of contents of the tooltip.
, Exits the tooltip viewing window.

If your terminal does not support arrow keys, you can use the spacebar to move to the next help page and the to go to the previous page. The program remembers the sequence of clicks on links and allows you to return to previously viewed sections by using the key (last).
If mouse support is enabled (see the next subsection), then you can use the mouse when viewing the tooltip. By clicking the left mouse button, you follow a link or move through the tooltip text. Right-clicking is used to navigate to previously viewed sections.

1.4. Mouse support.

Program Midnight Commander provides mouse support. This property is implemented if the mouse server is running gpm, regardless of whether you are working on a Linux console or a program Midnight Commander launched via terminal xterm(1)(even if you are using a connection to a remote machine from xterm through telnet or rlogin

By clicking the left button you can move the highlight (cursor) to any file in any of the panels. In order to mark (select) any file, just right-click on the file name. To remove a mark, use the same right button.

Double-clicking the left mouse button on the file name means an attempt to run the file for execution (if it is an executable program); or, if the extension file contains a program associated with this extension, this program is launched and the selected file is transferred to it for processing.

By clicking on a function button, you can also call up the program associated with the function buttons; clicking on an item in the top menu brings up a drop-down submenu.

If you click on the top frame of the panel, it displays a very long list of files. the list moves back one column. Clicking on the bottom frame of the panel leads, accordingly, to moving forward through the list a whole column. This navigation method also works when viewing the inline tooltip and viewing the Directory Tree window.

If Commander is running with mouse support, you can cut and paste text by holding down the key (note that this property does not work in a terminal emulator window).

1.5. Panel management

The panels of the Midnight Commander program most often display the contents of some directories of the file system (therefore they are sometimes called directory panels). However, not only the contents of directories, but also some other information can be displayed on the panel. This section will tell you how to change the appearance of the panel or the way information is presented on the panel.

File list display formats

The appearance of the panels in which lists of files and subdirectories are displayed can be changed through the drop-down menu items of the left and right panels “Left” and “Right” of the main menu.
If you want to change the format of the file list in the panel, you can use the "List Format..." item of the corresponding (left or right) panel. It is possible to select one of 4 options for presenting the file list: “Standard” (Full), “Shortened” (Brief), “Extended” (Long) and “User-defined”.

The "standard" format displays the file name, its size, and the time it was last modified.

The "shortened" (brief) format displays only file names, which allows the panel to fit two columns (and shows twice as many names).

In the "extended" (long) format, the contents of a directory are represented as the "ls -l" command does. In this format, the panel takes up the entire screen.

If you select the "User Defined" format, you must specify the structure of the information displayed.

When specifying the structure, the size of the panel is first specified: "half" (half the screen) or "full" (the entire screen). After the panel size, you can specify that the panel should have two columns. This is done by adding the number 2 to the format line.
Next, you need to list the field names with an optional field width parameter. The following words can be used as field names:
- name, display the file name.
- size, display file size.
- bsize, display the size in an alternative form, which displays file sizes, and for subdirectories only displays "SUB-DIR" or "UP--DIR".
- type, display a one-character type field. This symbol can take values ​​from a subset of the symbols output by the ls command with the -F option:

* (asterisk) - for executable files; / (slash) - for directories; @ (at-sign) - for links; = (equal sign) - for sockets (for sockets) - (hyphen) - for byte-oriented devices; + (plus) - for block-oriented devices; | (pipe) - for FIFO type files, ~ (tilde) - for symbolic links to directories; ! (exclamation mark) - for stalled symbolic links (links pointing to nowhere).

- mtime, the time of the last modification of the file.
- atime, time of the last access to the file.
- ctime, file creation time.
- perm, a string indicating the current file permissions.
- mode, an octal representation of the current file permissions.
- nlink, the number of links to this file.
- ngid, Group Identifier (GID), in digital form.
- nuid, user identifier (UID), in digital form.
- owner, the owner of the file.
- group, the group that has permissions on the file.
- inode, file inode number.

You can also use the following field names to display information on the display:
- space- insert a space when displaying.
- mark- insert an asterisk (asterisk) if the file is marked, a space - if it is not marked.
- | - insert a vertical line when displayed.

In order to set a fixed field width, you need to add a colon ":", after which indicate the number of positions that are allocated for this field. If after the number you put
"+" symbol, the specified number will be interpreted as the minimum field width, and if the screen allows, the field will be expanded.

For example, the "standard" output format is given by the line:

half type,name,|,size,|,mtime

and "extended" - with the line:

full perm,space,nlink,space,owner,space,group,space,size,space,mtime,space,name

Here's an example of a user-defined format:

half name,|,size:7,|,type,mode:3

The list of files in any of the panels can be displayed in accordance with one of eight sorting orders:
- by name;
- by extension;
- by file size;
- by modification time;
- by the time of the last access to the file;
- by node number (inode);
- without sorting.

You can set the sort order by selecting the "Sort order..." item in the menu of the corresponding panel. In this case, a dialog box appears (see the figure below), in which, in addition to the desired sort order, you can indicate that the sorting is performed in reverse order (using the spacebar by placing a mark in parentheses next to the word “Reverse”).


By default, subdirectories are shown at the top of the list, but this can be changed by checking the "Mix all files" option in the "Configuration" menu of the "Settings" menu.

You can display not all lists of files in a given directory in the panel, but only those corresponding to a specific template. The "Filter" menu item allows you to specify a pattern that must match the file names displayed in the panel (for example, "*.tar.gz"). Subdirectory names and links to subdirectories are always displayed, regardless of the template.

In the menu of the left and right panels there is also a “Reread” item. "Reread" command (hot keys -) updates the list of files displayed in the panel. This is useful in cases where other processes are creating or deleting files. If you have executed the "Panelization Criterion" menu item (redirecting the command output to the panel), this command will again display the contents of the directory, and the information displayed on the panel will be deleted (for more details, see the "Panelization Criteria" section).

Other display modes

In addition to the fact that the output format for the file list panel can be set, any panel can be switched to one of the following modes:

"Information" mode
In this mode, the panel displays information about the file highlighted in another panel and about the current file system (type, free space and number of free inodes).


Tree mode
In the directory tree display mode, you will see in one of the panels an image similar to the one shown in the following figure:

This mode is similar to the one you will see when you select "Directory Tree" from the "Commands" menu.

"Quick View" mode
In this mode, the panel switches to displaying the contents of the file, highlighted
in another panel. As an example, here is the screen view when quickly viewing the /etc/fstab file.


When displaying the Quick View results in the panel, the built-in file viewer is used, so if you switch with the key in the viewing panel, you will be able to use all viewing control commands, in particular those listed in tables 1.1 - 1.2.

"Network connection" and "FTP connection" modes
These two modes are used to display a list of directories located on remote computers. Otherwise, the information output format is similar to the formats used to display local directories. A description of how to use these modes will be given later.

Keyboard commands for controlling panels

To control the panel operating modes, you can use the menu items mentioned above, but it is more convenient to use control key combinations.

, - . Change the current (active) panel. The highlight moves from the panel that was previously active to another panel that becomes active.

-, -, - . Used to move the highlight, respectively, to the top, middle or bottom file from those currently displayed on the panel.

- . Cyclically switches display modes of the list of files in the current directory. Use this key combination to quickly switch from standard output mode
(long listing) to shortened or user-defined mode.

-<\> (control-backslash). Show directory directory and go to the selected directory.

<стрелка вверх>, -

. Moves the highlight to the previous position in the panel file list.

<стрелка вниз>, - . Moves the highlight to the next position in the panel file list.

, -"<" . Moves the highlight to the first position of the file list (I have to deviate from the key convention here).

, -">" . Moves the highlight to the last position in the file list.

, - . Moves the highlight down one page.

, - . Moves the highlight up one page.

- . If a directory name is highlighted in the active panel, and a list of files is displayed in the second panel, then the second panel switches to the mode of displaying the files of the highlighted directory (similar to the key -in the Emacs editor). If the highlight in the active panel indicates a file, then the contents of the parent directory of the current one are displayed in the second panel.

-, - . If only mc launched from the Linux console: the transition is performed accordingly ( chdir) to the parent directory ("..") or to the highlighted directory.

- . Move to the previous directory from the directory navigation history; is equivalent to clicking the mouse on the symbol "<" в верхнем углу панели.

- . Move to the next directory from the directory navigation history; is equivalent to clicking the ">" symbol with the mouse.

1.6. Function keys and the File menu

So far we have only talked about the appearance of the program screen Midnight Commander and how to change this look. Now it’s time to tell you how to work with files using this program.
Most frequently performed in Midnight Commander operations are bound to function keys - . We present a summary in the form of a table.

Table 1.4.

Functional
key
Action to be performed
F1 Calls up a context-sensitive tooltip
F2 Calls up a user-created menu
F3 View the file indicated by the highlight in the active panel
F4 Calls the built-in editor for the file indicated by the highlight in the active panel.
F5 Copies a file or group of marked files from the directory displayed in the active panel to the directory displayed in the second panel. When copying one file, you can change its name. You can also specify the name of the directory where the copy will be made (if you need to copy to a directory different from the directory displayed in the second panel).
F6 Moves a file or group of marked files from the directory displayed in the active panel to the directory displayed in the second panel. As with copying, you can change the name of the file or destination directory.
F7 Create a subdirectory in the directory displayed in the active panel.
F8 Deleting a file (subdirectory) or a group of marked files.
F9 Calling the main program menu (displayed above the panels).
F10 Exit the program.

The operations (commands) listed in this table can be performed not only by pressing the corresponding function key, but also by clicking on the on-screen buttons or using the corresponding “File” menu items.

Selecting (checking) files

Before performing any of the operations indicated in Table 1.4 or specified by menu items, you must select a file or group of files that will be the objects of the operation. To select only one file, just move the highlight in the active panel to it (of course, you first need to go to the corresponding directory). If you want to perform some operation on a group of files at once, these files must be marked. To mark the file currently highlighted, use the key or combination - . In this case, the file name in the panel is displayed in a different color. The same combinations are used to unmark a file.

You can also select a group of files for further processing using the " Mark group""File" menu. This command is used to mark a group of files using a given pattern. Midnight Commander will provide an input line in which you must specify a regular expression that defines the desired group of names. If the "Shell-style patterns" option is enabled (see the "Program Settings" section), regular expressions are built according to the same rules that operate in the shell (* means zero or more any characters, and ? replaces one arbitrary character). If the "Shell-style patterns" option is disabled, then files are tagged according to the rules for processing normal regular expressions (see ed (1)).
If expressions begin or end with a slash (/), then the mark will be placed on directories, not files.
The hot key for the operation of marking a group of files is the key <+> .

Operation " Uncheck"(hot key - <\> - backslash) is the reverse of the operation of marking a group of files and uses the same rules for generating patterns. Used to uncheck a group of files.

Operation " Invert elevation (<*>) is used to uncheck all marked files in the current directory, while simultaneously marking all files that have not been marked.

If the current directory contains many files (so that they all do not fit on the panel), then before you mark the file, you still need to find it. In such cases, it is convenient to use keyboard shortcuts - And - . After pressing one of these combinations, a search mode for file names in the current directory is initiated using the first characters of the name, in which the entered characters are displayed not in the command line, but in the search line. If the "Show mini-status" mode is enabled, this line is displayed in place of the mini-status line. In this case, while entering characters, the highlight line moves to the next file, the name of which begins with the entered string of characters. Keys or can be used to correct errors. If -pressed again, the next matching file is searched.

After selecting and marking files for processing, simply press one of the function keys to perform the desired file operation, such as copying files, moving or deleting. It is especially convenient, compared to working from the command line, to use Midnight Commander viewing or editing files because Midnight Commander There are built-in programs for these purposes. But in this section we will not consider the built-in editor, postponing its description until section 1.4. ().
As already mentioned, it is not at all necessary to use function keys to call the associated commands. Any of these commands can be executed through the "File" menu.
In addition to the commands associated with the function keys, the "File" menu also contains the following commands (the corresponding hot keys are indicated in parentheses):

Access rights (- )
Allows you to change access rights to selected or marked files.

Owner/Group (- )
Allows you to execute the chown command.

Rights (extended)
Allows you to change file permissions and ownership.

If you don't know what links are: creating a link is in some ways like copying a file, but both the original filename and the link point to the same actual file on disk. Therefore, if you, for example, edit a file, the changes will appear in both copies. Synonyms for the term “link” are the terms alias and shortcut.

A hard link looks like a real file. Once a hard link is created, it is impossible to distinguish between which is the original file and which is the link. If you delete one of these files (more precisely, one of these names), then the file is still saved on disk (as long as it has at least one link name). It is very difficult to distinguish between the original file name and the later created hard links to it. Therefore, hard links are used where tracking differences is not required.

A symbolic link is a link to the name of the source file. If the original file is deleted, the symbolic link becomes useless. A symbolic link can be easily distinguished from the original file name and program Midnight Commander indicates symbolic links by displaying the "@" sign in front of the name of such a link (except for links to subdirectories, which are indicated by the tilde sign "~"). If a mini-status line is displayed on the screen (the "Show mini-status" option is enabled), then it displays the name of the file to which the link points. Use symbolic links when you want to avoid the confusion associated with hard links.

Quick directory change (-)
Use this menu item if you know the full path to the directory you want to go to (which you want to make current).

View command output (-)
With this command, an input line appears on the screen in which you can enter any command with parameters (by default, it is proposed to use the name of the highlighted file as a parameter). The output of this command will be displayed on the screen via the built-in viewer.

As you can see, the "File" menu contains all the most common commands that we need for normal operations of processing files in the current directory. Naturally, the operations most often used are associated with function keys. So let's return to the description of these commands to provide some additional clarification.

1.7. File masks for copy/rename operations

When performing operations of copying and moving (or renaming) files, you have the opportunity to change the names of the copied or moved files. To do this, you must specify a mask for the names of source files and a mask for the names of files that will be created (destination files). Typically this second mask is a few wildcards at the end of a line that specifies the destination of the files being created. Masks are specified in the input lines displayed in the window that appears after accessing the copy/transfer commands:


All files matching the source mask will be renamed (copied or moved with new names) according to the destination file mask. If there are marked files, then only marked files that satisfy the specified mask for source files are copied (moved).

There are several more options that affect the execution of file copying / moving operations, and which are set in the same request window where file name masks are set, or through the "Settings / Configuration" menu item:

The "Follow links" option determines whether when copying hard or symbolic links in the destination directory (and recursively in subdirectories), the same links will be created, or the files (and subdirectories) to which these links point will be copied.

The "Dive into subdirs" option determines what to do if there is already a subdirectory in the destination directory whose name is the same as the name of the file (directory) that is being copied (source). By default (option disabled), the contents of the source directory are copied to the destination directory. If the option is enabled, a new subdirectory with the same name will be created in the destination directory, into which the copying will be carried out.

It's better to show this with an example:
Let's say you want to copy the contents of the foo directory to the /bla/foo directory, which already exists. Normally (option disabled) mc will simply copy all files from foo to /bla/foo.
If the option is enabled, files will be copied to /bla/foo/foo.

The "Preserve attributes" option determines whether the attributes of the source file will be preserved when copying/moving: access rights, timestamps and, if you are root, the UID and GID of the source file. If the option is disabled, the attributes will be set according to the current umask value.

Option "Shell style samples" (menu " "). When the "Shell Style Patterns" option is enabled, you can use wildcards "*" and "?" in the source mask. They are processed in the same way as in the shell. Only "*" and "\" are allowed in the receiver mask<цифра>". The first "*" character in the destination mask matches the first group of replacement characters in the source mask, the second "*" character matches the second group, etc.
Likewise, the wildcard character "\1" matches the first group of wildcard characters in the source mask, the character "\2" matches the second group, and so on. The character "\0" corresponds to the entire name of the source file.

Two examples:

If the source mask is "*.tar.gz" and the destination is "/bla/*.tgz" and the name of the copied file is "foo.tar.gz", the copy will be named "foo.tgz" and will be located in the directory "/ bla".

Let's say you want to swap the file name and extension so that "file.c" becomes "c.file". The source mask for this should be “*.*”, and the destination mask should be “\2.\1”.

When the Use shell patterns option is turned off, the MC does not perform automatic grouping. To specify groups of characters in the source mask that will match the replacement characters in the destination mask, you must use the parentheses "\(...\)" in this case. This method is more flexible, but requires more input effort.

Two examples:

If the source mask is "^\(.*\)\.tar\.gz$", the copy is made to "/bla/*.tgz" and the file "foo.tar.gz" is copied, then the result will be "/bla /foo.tgz".

Let's say you want to swap the file name and extension so that names like "file.c" become "c.file". The source mask for this is "^\(.*\)\.\(.*\)$" and the destination mask is "\2.\1".

"Case Conversion"

You can also convert the case of characters in file names. If you use "\u" or "\l" in the destination mask, the next name character will be uppercase (uppercase) or lowercase (lowercase), respectively.

If you use "\U" or "\L" in the destination mask, all subsequent characters will be converted to the appropriate case, up to the next occurrence of "\E" or "\U", the occurrence of the "\L" character, or the end of the file name.

Using "\u" and "\l" provides more functionality than "\U" and "\L".

For example, if the source mask is "*" (the "Shell-Style Patterns" option is enabled) or "^\(.*\)$" (the "Shell-Style Patterns" option is disabled) and the destination mask is "\L\u" *", file names will be converted so that the first letters of the name are uppercase and all others are lowercase.

The "\" character in masks is used to override special interpretation of individual characters. For example, "\\" simply means backslash and "\*" simply means asterisk.

1.8. Features of performing file copy/move operations

When you perform copy, move, or delete operations on files, Midnight Commander displays a dialog box on the screen that shows which file(s) are currently being processed and how the processing is progressing. To display the processing process, up to three progress bars are displayed on the screen. The first (file bar) shows which part of the current file has been processed (for example, copied). The second (count bar) shows what percentage of marked files have been processed at the moment. The third (bytes bar) shows the share of completed work as a percentage of the total volume (in bits) of marked files. If the "Operation Details" option is disabled (see the description of the "Settings/Configuration" menu item), the last two diagrams are not displayed.

There are two buttons at the bottom of this dialog box. Pressing a button<Пропустить>will cause processing of the current file to be skipped. Pressing a button<Прервать>interrupts the execution of the specified operation, all remaining files will be skipped.

While performing file operations, you can see three more types of windows.

Error window informs about the error and offers three options to continue. Usually you choose either option<Пропустить>in order to exclude from processing the file on which the program stumbled, or<Прервать>to cancel the specified operation altogether. Third option<Повторить>, is selected when you managed to eliminate the cause of the failure (for example, by using another terminal).

Confirmation window overwrite appears when you try to overwrite an existing file. This window displays the creation time and size of the source and destination files (that is, the overwritten file that will actually be destroyed).
Below are two questions. The first question (“Would you like to rewrite this file?”) offers three possible answers:
- agree (button<Да>);
- refuse, that is, skip overwriting the current file (button<Нет>);
- append the contents of the source file to the end of the destination file (button<Дописать в Конец>).
Selecting one of the answer options to the second question (“Rewrite all files?”) allows you to make one decision on all files selected for processing (so that the request window does not appear every time). There are 4 possible solutions:
- <Все>- all selected files were overwritten without additional questions;
- <Устаревшие>- only files that were created before the source file will be overwritten (overwritten);
- <ни Одного>- do not overwrite files (but if there is no destination file, the source will be copied);
- <Различающиеся по длине>.
You can refuse to perform an operation if you press the key<Прервать>at the bottom of the request window. Select the desired on-screen button using the arrow keys or the tab key.

Query window on recursive deletion appears when you try to delete a non-empty directory. By button<Да>the directory will be deleted along with all files,<Нет>means refusal to delete the directory,<Все>you need to select if you have marked a group of subdirectories for deletion and are confident in your choice,<ни Одного>- to skip all non-empty directories from those marked,<Прервать>means refusal to perform the delete operation. Choose<Да>or<Все>only if you are really sure that you want to delete a directory with all its subdirectories.

If you have marked a group of files for processing, then after the operation is completed, only those files that have been successfully processed will be unmarked. Skipped files will remain marked.

1.9. Shell command line

As was said when describing the appearance of the screen when working in the program Midnight Commander, the shell command line is always present at the bottom of the screen.

In order to ensure that when working with M.C. To run any OS command, you must either type the name of the corresponding program in the command line, or select the program name in one of the panels (by moving the highlight to the program file name), and then press the key.

If you press a key while the highlight is indicating a non-executable file name, Midnight Commander compares the extension of the selected file with the extensions specified in the "extension file" ~/mc.ext. If there is a subsection in the extension file that specifies procedures for processing files with this extension, then the file is processed in accordance with the commands specified in this subsection.
Simple macro substitutions are performed before processing.

Often, entering commands requires entering a large number of characters (especially taking into account the fact that you need to specify the command parameters and, including the full names of the files being processed, including paths). To make it easier to enter Midnight Commander There are several keyboard commands that can help you reduce the number of keystrokes you make when typing and editing commands on the command line.

-. Copies the highlighted file or directory name to the command line.

-. Same thing as -, but only works on the Linux console.

-. Attempts to complete a filename, command name, variable, username, or hostname (depending on what you started typing and what command element you entered).

- , - -. Copies the names of the marked files (or the highlighted name if there are none marked) from the active panel ( - ) or passive panel ( - -).

-

, - -

The first key combination copies the name of the current directory to the command line, and the second - the name of the directory displayed in the passive panel.

-. This command (the quote command) is used to insert characters that are somehow interpreted by itself Midnight Commander-om (for example, the "+" symbol).

-

, - -

Causes moving one command back through the list of previously launched commands, and -- move one team forward.

-. Displays the history of the current input line (for the command line, the history of commands).

Editing input lines

Input lines are not only the shell command line, but also input lines in the dialog boxes of various routines. In all cases, when an input line appears on the screen, you can use the following control key combinations:

-. Moves the cursor to the beginning of the line.

-. Moves the cursor to the end of the line.

-, <стрелка-влево>. Moves the cursor one position to the left.

-, <стрелка-вправо>. Moves the cursor one position to the right.

-. Moves the cursor forward one word.

-. Moves the cursor back one word.

-, . Deletes the character preceding the cursor.

-, . Deletes the character at the cursor position.

-<@>. Sets a mark to cut (copy to the clipboard) part of the text.

-. Copies the text between the cursor and the label to the buffer, removing the text from the input line.

-. Copies the text located between the cursor and the label to the clipboard.

-. Inserts the contents of the buffer into the input line before the cursor position.

-. Deletes text from the cursor to the end of the line.

-

, -. These combinations are used to navigate through the command history. -

Moves to the previous command, -- to the next one.

--, -. Remove the preceding word.

-. Attempts to perform input completion on a filename, command, variable, username, or hostname.

Finally, I will give an example of the similarity of Windows commands:

Text selection- place the cursor in the right place, hold down Shift and select with the left mouse button to the desired place

Copy text- right-click on the selected text, done, text in the buffer

We insert the text - place the cursor in the right place, hold down Shift, right-click OR place the cursor in the right place and click on +

Deleting text - place the cursor in the desired place, hold down the left mouse button and highlight to the desired place, press F8

Call top menu- press +

1.10. Commands Menu

The "Commands" drop-down submenu of the main menu allows you to perform a number of other operations to manage the file system, as well as execute some commands that change the appearance of the panels Midnight Commander and information displayed in the panel.

When accessing the menu item " Directory tree"A window displays the directory structure of the file system.

The directory tree can be called up in two ways: through the "Directory Tree" item from the "Commands" menu and the "Tree" item from the right or left panel menu.

To get rid of long delays during directory tree creation, Midnight Commander creates a tree by viewing only a small subset of all directories. If the directory you need is not displayed, go to its parent directory and click -(or ).
There are two modes for displaying the directory tree. In static navigation mode, only the up/down arrows are used to select a directory (i.e. move the highlight to another directory name). All subdirectories currently known to the program are shown.

In dynamic mode, the up/down arrows are used to move to the next directory at the same level. To go to the parent directory, use the left arrow key, and use the right arrow to move to the descendants of the current directory, that is, one level lower. This displays only superior directories (including the parent and above), adjacent directories of the same level, and immediate children. The view of the directory tree changes dynamically after each move through the tree.

The following key combinations can be used to control directory tree browsing:

All movement control keys work (see ).

. In the directory tree view window, pressing this key exits the view mode and displays a list of files in the selected directory in the active panel. When a directory tree is displayed in one of the panels, when you press the Enter key, the corresponding directory is displayed in the second panel, and the tree remains in the current panel.

(Forget). Remove the current directory from the tree. This command is used to remove erroneously displayed tree branches. If you need to return a subdirectory to the tree, go to its parent directory and press the key .

(Static/Dynamic). Switch between static (default) and dynamic tree navigation modes.

(Copy). Copy a subdirectory (an input line appears in which you need to indicate where to copy).

(RenMov). Move subdirectory.

(Mkdir). Create a subdirectory in the current (highlighted) directory.

(Delete). Remove the highlighted directory from the file system.

-, -. Find the next directory that matches the specified search pattern. If such a directory does not exist, the highlight is simply shifted down one line.

-, . Removes the last character in the search string (pattern).

<Любой другой символ>. This character is added to the search pattern and moved to the next directory name that matches the pattern. In directory tree viewing mode, you must first activate the search mode using the keys -. The search pattern will be displayed in the mini status bar.

The following actions are only possible in the directory tree view window and are not supported when viewing the tree in one of the panels

(Help). Calls up a tooltip displaying a help section about the directory tree window.

, . Exits the directory tree window. The current directory does not change.

The directory tree view window supports the mouse. Double clicking is the same as pressing a key .
Team " Search for a file" (-) allows you to find a file with a given name on disk. After selecting this “File Search” menu item, you are first asked for the name of the file you are looking for and the name of the directory from which you want to start the search. By pressing the screen button<Дерево>You can select the starting search directory from the directory tree. In the "Contents" field you can set a regular expression according to the rules of the egrep(1) command. This means that characters that have a special meaning for egrep must be preceded by a "\" character, for example, if you need to search for the string "strcmp (", you must specify the search pattern as "strcmp \(" (without double quotes).
To start searching, press the on-screen button<Дальше>. During the search, you can pause it with the button<Остановить>and continue using the button<Продолжить>.
You can view the list of found files by using the up arrow and down arrow keys. Button<Перейти>used to go to the directory that contains the highlighted file. Button<Повтор>serves to set parameters for a new search.
Button<Выход>serves to exit the search mode.
Pressing a button<Панелизация>will cause the search results to be displayed on the currently active panel, so that you can perform some other actions with the selected files (view, copy, move, delete, and so on). Once displayed on the panel, you can click -to return to the normal file list.

In addition, it is possible to specify a list of directories that the "Find File" command will skip during the search (for example, you know that the file you are looking for is not on the CDROM or you do not want to search in directories connected via NFS over a very slow channel).
The directories to be skipped should be specified in the find_ignore_dirs variable in the Misc section of your ~/.mc/ini file. Directory names are separated by colons, as follows:


find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs

You can use panel redirection (see Panelization Criterion) to perform some complex sequences of actions, while File Search only allows you to perform simple queries.

Team " Rearrange panels" (-) swaps the contents of the right and left panels.

On command" Disable panels" (-) shows the output of the last shell command executed. This command only works via xterm and on the Linux console.

On command" Compare catalogs" (- ) compares the contents of the directories displayed in the left and right panels. After comparison, you can use the "Copy" command (F5) to make the contents of the directories identical.
There are three comparison methods. The fast method compares only the size and creation date of files with the same name. With the byte-by-byte method, the contents of files are compared (byte by byte). This method is not available if the machine does not support the mmap(2) system call. When comparing by size, only the sizes of the corresponding files are compared, and the creation date is not checked.

Menu item " Panelization criterion" (which would be more correctly called "Panel Output Redirection") allows you to execute an external program, making its output the contents of the currently active panel (a typical example is panelizing the output of the find command). For example, if you want to perform some action on all symbolic links of the current directory, you can use the "Panelization Criteria" item to run the following command:

find . -type l -print

After executing this command, the current panel will not display the contents of the corresponding directory, but only all the symbolic links located in it.
If you want to display in your dashboard all the files that have been downloaded from your FTP site, you can use the following command to extract the desired names from the log file:

awk "$9 ~! /incoming/ ( print $9 )"< /usr/adm/xferlog

If you want, you can save frequently used panelization commands under separate, descriptive names so that you can quickly call them up by those names. To do this, type the command in the input line and press the button<Добавить>. After this, you will need to enter the name by which you will call the command. Next time, you will only need to select the desired name from the list, rather than entering the entire command again.

Menu item " Team history" displays a window with a list of previously executed commands. The highlighted line from the history can be copied to the shell command line (move the highlight with the up/down arrows, copy with the key ).
Command history can also be accessed using keyboard shortcuts -

Or -, however, in this case you do not see a window with a list of commands. Instead, one command from the list is displayed on the command line and in combination -

This command is replaced by the previous one, and -- to the next command from the command history.

Menu item " Directory directory" (-<\>) allows you to create a list of directories that are often used, and provide quick navigation to the desired directory from this list. To do this, a list of labels (conventional names) assigned to the most frequently used directories is created. This list can be used to quickly navigate to the desired directory. Using the directory lookup dialog box, you can add a new tag to the list or
delete a previously created label/directory pair. You can also use the keyboard shortcut ( - ), by which the current directory is added to the directory directory.
The program will prompt you to enter a label for this directory.

Menu item " Background jobs" allows you to manage background jobs running from Midnight Commander(such tasks can only be copying and moving files). Using this menu item or hotkeys - You can stop, resume or cancel any of the background jobs.

After selecting the menu item " Extensions file"You get the opportunity to edit the file mc.ext, in which you can associate with a specific file extension (the end of the name after the last dot) a program that will be launched to process (view, edit or execute) a file with that extension. The selected program will be launched after setting the highlight to the file name and pressing a key.

Paragraph " Menu file" is used to edit the user menu (which appears after pressing the key ).

1.11. Setting up the Midnight Commander program

Program Midnight Commander has a number of settings (options), each of which can be turned on or off, for which there are several dialog boxes accessible through the “Settings” menu. An option is enabled if there is an asterisk or an "x" in parentheses before the option name. Let's consider sequentially the items in the "Settings" menu, through which these options are enabled/disabled.

Item "Configuration".

When you select this menu item, the following dialog box appears


The configuration parameters set in this window are divided into three groups: "Panel Settings", "Pause After Execution" and "Other Settings".

In the "Panel Settings" field you specify the values ​​of the following parameters:

Show backup files. By default, Midnight Commander does not show files whose names end in "~" (similar to the -B option of the GNU ls command).

Show hidden files. By default, Midnight Commander shows all files whose names begin with a dot (like ls -a).

A mark moves the cursor. When you mark a file (using -or ), then by default the highlighting on the file name is shifted one line down.

Menu drops down when calling. If this option is enabled, then when you call the main menu by pressing the key , a list of menu items (drop-down menu) will be immediately displayed. Otherwise, only the main menu items are activated and you must (after selecting one of them using the arrow keys) press the Enter key, or select the desired item by the first letter of the name, and only then will you be able to select the drop-down menu item.

Mix files/directories. If this option is enabled, file and directory names are displayed interspersed. If the option is disabled, directories (and links to directories) are shown at the beginning of the list, and file names are shown after the names of all directories.

. By default this option is disabled. If you activate it, Midnight Commander will use the following trick to output the contents of the directory:
the contents of the directory are reread only if the entry in the i-node of the directory has changed, that is, if files have been created or deleted in the directory; if only the entries in the i-node of directory files were changed (file size, access mode or owner changed, etc.), the contents of the panel are not updated. In this case (if the option is enabled) you must update the list of files manually (using the -).

"Pause after execution" field.

After executing your command, Midnight Commander can provide a pause so you can review and examine the command's output. There are three options for setting this option:
<Никогда>This means that you do not want to see the output of the command. On the Linux console or while using xterm You can view this output by clicking -.
<На "тупых" терминалах>The pause will be created on terminals that are not capable of displaying the output of the last command executed (this is any terminal other than xterm or Linux console).
<Всегда>The program will provide a pause after executing any command.

In the "Other settings" field you specify the values ​​of the following parameters:

Operation details(Verbose operation). This switch determines whether copy, move, and delete operations produce an additional window to display the progress of the operation. If you have a slow terminal, you can disable this output. It is disabled automatically if the speed of your terminal is less than 9600 bps.

Compute totals. If this option is enabled, Midnight Commander Before performing copy, move and delete operations, it counts the total number of files being processed and their total size and shows the progress of the operation on these files in the form of a bar chart (although this slightly slows down the execution of operations). This option does not work if the Transaction Details option is disabled.

Shell Patterns. By default, the Select, Unselect, and Filter commands use shell-like regular expressions. In order to achieve this effect, the following transformations are performed: "*" is replaced with ".*" (zero or more characters); "?" is replaced by "." (exactly one character) and "." is replaced by a regular dot (literal dot). If the option is disabled, then regular expressions must be constructed as described in ed(1).

Autosave settings. If this option is enabled, then when exiting the program Midnight Commander the values ​​of all configurable parameters are saved in the ~/.mc/ini file.

Automatic menus. If this option is enabled, the custom menu will be automatically displayed on the screen when the program starts. This can be useful if the computer is operated by inexperienced users (operators) who must perform only standard operations.

Built-in editor. If this option is enabled, the built-in editor is called to edit files. If the option is disabled, the editor specified in the EDITOR environment variable will be used. If no such editor is specified, vi will be called.

Embedded View. If this option is enabled, the built-in viewer is called to view files. If the option is disabled, the program specified in the PAGER environment variable is called. If such a program is not specified, the view command is used.

Addition: show all(Complete: show all). In the process of entering commands Midnight Commander can perform "Input Completion" when pressing keys -, trying to guess the ending of the entered command. Default on first click -it searches for all possible completions and, if the completions are ambiguous (there are many different options), then it only makes a beep. On second press -all possible completions are displayed. If you want to see all possible completion options after the first click -, enable this option.

Rotating dash. If this option is enabled, Midnight Commander displays a rotating dash in the upper right corner as an indicator that some task (operation) is being performed.

Lynx style navigation(Lynx-like motion). If this option is enabled, you can use the right arrow keys to go to the currently highlighted directory and the left arrow keys to go to the current directory's parent (assuming the command line is empty). By default the option is disabled.

Extended chown command. If this option is enabled, when calling the Chmod or Chown commands, the Extended Chown command will be called instead.

Changing directory using links. Setting this option causes Midnight Commander will follow a logical chain of subdirectories when executing directory change commands both in the panel and with the cd command. This is how bash behaves by default. If the option is not enabled, Midnight Commander will follow the actual directory structure when executing the cd command, so if you entered the current directory by linking to it, then by cd .. you will end up in its parent directory, and not in the directory where the link is located.

Safe removal. If this option is enabled, it will be more difficult to delete a file unintentionally. In the delete confirmation dialog, the default button offered changes from "Yes" to "No" and the operation to delete a non-empty directory will have to be confirmed by selecting the "Yes" button. By default this option is disabled.

Item "Appearance"

The Appearance dialog box gives you the opportunity to change some of the display options for the Midnight Commander main window.


You can display or cancel the display of the main menu bar, command line, hint bar, mini-status bar, function key prompt bar. On a Linux or SCO console, you can set the number of lines that will be left to display the command output.
You can also specify whether the panels should be positioned horizontally or vertically and change the size of the panels.

By default, all information is displayed in one color, but you can have access rights and file types highlighted in different colors. If color highlighting of access rights is enabled, the perm and mode fields in the output formats show the rights of the user running the program Midnight Commander, are highlighted with the color specified by the selected keyword (see section Colors). If file type highlighting is enabled, then directories, memory dumps (core files), executable files, etc. are highlighted in different colors.

If the "Mini Status" option is enabled, a line of information about the highlighted file or directory of each panel is displayed at the bottom of each panel.

Item "Character bits.."

In the "Character Bits..." dialog box, you specify in what format your terminal will process (enter and display) information represented by bytes (for example, written in a file).


If the terminal only supports 7-bit output, then you need to select the "7-bit" setting. Selecting "ISO-8859-1" will get all the characters from the ISO-8859-1 table, and selecting "Full 8-bit output" makes sense on terminals that can display all 8-bit characters. So that when viewing or editing files in Midnight Commander see the Cyrillic alphabet on the screen, set the options “Full 8-bit output” and “Full 8-bit input” (as in the figure) and press the [Next] screen button.

"Confirmations" item

Using this menu item, you can make sure that before performing operations of deleting, overwriting and launching a file for execution, as well as before exiting the program mc, an additional confirmation request was issued (or cancel such requests, which is somewhat risky).

Item "Key recognition.."

The item "Learn keys" brings up a dialog box in which you can test the operation of some keys ( -, , ), which do not work on all types of terminals.
A table appears in the dialog box with the names of the keys that are to be tested. You can move the highlight across titles using the key or keys used in the editor vi (- left, - down, -up, - to the right). If you press the arrow keys once, after which the OK mark appears next to their names in the table, then they can also be used to control movement.

To test the operation of the keys, you need to press each key listed in the table. If it works normally, an OK mark will appear next to its name in the table. After this mark appears, the key begins to work in its normal mode. For example, the first keystroke leads only to the appearance of a mark (if it works normally), and the next presses will bring up a hint window.
The same applies to the arrow keys. Key always works.

If a key does not work, then after pressing it the OK mark will not appear. In this case, it is possible to associate the system reaction that should have followed the pressing of a non-working (missing) key with the pressing of another key or key combination. To do this, you need to move the backlight to the name of the non-working key (using a mouse or key ) and press or the spacebar. A red window should appear asking you to press the key that will be used instead of the one that is not working. To cancel the operation, press and wait until the red window disappears. Or select and press the key combination that will serve as a replacement for the non-working key (and also wait until the window closes).

When you have finished testing and configuring all the keys, you can save these settings in a section of your file ~/.mc/ini(where TERM is the name of the terminal used) or refuse to remember changes. If all keys work normally, then saving, of course, is not required.

Item "Virtual FS" brings up a dialog box in which you can set the values ​​of some parameters related to the use of virtual file systems.

And the last menu item "Settings" ( "Save settings" ) ensures that the selected parameter values ​​are saved in the program’s ini file.

I hope that the material presented in this section will allow you to get started working with the OS using the program Midnight Commander. But the capabilities of this program are much wider than what is described in this section. In section 12 you will read more about the built-in editor Midnight Commander. And, if fate favors me, I hope to provide additional material on this program in the second part of this book. If any circumstances prevent the implementation of this plan, then refer to the built-in hint, called up by pressing the key. The translation of the hint file into Russian (in the form) can be found on my website. Unzip it, place it in the /usr/lib/mc directory, replacing the mc.hlp file located there, and you will receive a hint in Russian when you press a key.

But in order for our file manager to be more convenient and complete, to be able to view the contents of a file, for example: Word, Excel, Acrobat, to launch audio or video in the Debian text interface, additional configuration of the “Commander” and installation of viewers will be required.

Setting up a file manager involves editing the mc.ext config file, which is responsible for which program and what types of documents will support in the console or desktop environment (we'll talk about graphical applications later).

First you need to make a choiceconsole applications necessary for these purposes.

I have created this list:

antiword - DOC (Word)


catdoc - XLS,RTF (Excel, WordPad)

Excel docs are viewed using a small program called xls2csv, which is built into catdoc.


odt2txt - ODT (LibreOffice,OpenOffice)

Don't expect office documents to open with formatting in all their glory. They will appear to us in plain text. But often like this sometimes it is quite enough to urgently open some instruction, book or, for example,Linux command reference.

fbgs (included in the fbi package) - PDF (Acrobat Reader)

Depending on the launch method, the PDF document can be either black and white (with higher resolution, launched without additional options) or color (with lower resolution, is launched in this form: fbgs -c).

Now I'll tell you about DJVU format, maybe it will be useful to someone.The method is not very convenient, but I have not found another, more elegant one. Sorry.

For this we need:

djvu2pdf - DJVU to PDF converter

First you need to convert the selected book into pdf formatwith the same name to the current folder, and only then view the resulting new option like a regular PDF document using FBGS. PackageI didn’t see djvu2pdf in the Debian repositories, but downloaded it from this link:

http://0x2a.at/s/projects/djvu2pdf

There are instructions for installing it using dpkg -i, and below is a link to download the required deb package. For the converter to work, you need to install two additional packages from the Debian repository:

djvulibre-bin

ghostscript

Well, the last thing on my list that might be useful:

rtorrent - torrent files


To complete the picture, I will list the packages that we have already installed earlier. They will also work with "Commander":

fbi - GIF, JPG, JPEG, BMP, PNG, TIFF, etc. (Pictures, photos)


links2 -g - HTML (Internet pages)


mplayer - MP3, OGG, AVX, WMA, WAV, FLAC, etc. (Music)

mplayer (with option -vo fbdev2 -zoom -xy 1024 -fs for console version) - AVI, ASFX, DVI, MKV, MOV, MP4, MPEG, WMV, etc. (Video)

gpm - launches the mouse in the console

It's been a while since we updated our Debian. Let's fix this before installing additional viewers:


After that, immediately enter the command:

Let's start the installation:


After the process is completed, we will move on to editing the extensions/associations config file and make the necessary changes to it to work with viewers. There is nothing complicated there; it is important to understand the principle itself, how it is composed. I will show with examples how this is done:


+++ Example for pictures +++

We enter into mc.ext all the extensions of pictures and photographs that you are going to view, in this form (most likely, they are already listed there, and if not, then add the missing ones):



After the list of all extensions, you need to indicate which programs will launch them in console and graphical modes:



If you want, you can take my config, which I rewrote for all the programs listed above and for graphical lightweight applications that I usually use. You can adjust it as you wish. Here is the download link:
https://yadi.sk/d/H2iX_gUTgGfFf

After you extract mc.ext from the ZIP archive, copy it to the directories: root/.config/mc (logged into the MS as root) and ~/.config/mc (logged in as user).

Well, friends, about that, with the help of MS, I basically told. Perhaps the applications from my list will be useful to you, or maybe you use more convenient console programs to fully implement . Interesting to know about this. Write and share about it in the comments :) .

Good luck and fewer pitfalls in successfully mastering Linux. You can subscribe to receive news about blog updates. And next time we will deal with the question, .

Sincerely! Dmitry Zamyatin

28.04.2015

Midnight Commander (translated as " midnight commander") is one of the most popular file managers in the Unix environment. It has a text interface, so it can work both in a bare console and in a graphical one. It has a huge number of settings and capabilities.
Possibilities

  • Copying and moving files
  • Works with most archives and file system images
  • Working with network file systems Samba, FTP, SFTP
  • Its own built-in text editor with syntax highlighting.
  • In addition to the normal mode, the program works in various terminal emulators and through remote connections, for example, via the SSH protocol (Midnight Commander will not work via the telnet protocol)
  • Multilingual interface
  • Working with different encodings
  • Has a customizable user menu

Many users use Midnight Commander only to copy/transfer files and edit them. But once you remember a dozen hotkeys, the speed and efficiency of your work will be at least twice as fast.
In this article I will not describe all hotkeys, but only those that are convenient in my opinion. For those who find this not enough, you can find all existing key combinations on the Internet or in help.

Hotkeys for working with the file system

Ctrl+\- quick access directories.
They are used for quickly moving through the local file system, as well as for entering network folders (samba, ftp, etc.). First, we set the directories (network folders) in which we work most often, and then simply use ctrl+\ to move between them.
There is a special syntax for adding network file systems. The full syntax is in the Midnight Commander help.
Add FTP - #ftp:user@host
Add samba - #smb:host/share
Add scp - #sh:user@host or #sh:user@host:path_to_directory
Typically, after entering a network folder, you are required to enter a password. To avoid asking for a password for ftp, you must specify it in the connection, which is unsafe, but for ssh there is a .

Ctrl+s- search for a file or folder in a directory.
After entering this combination, enter the first letters of the file or directory. The cursor will move to the files (directories) corresponding to the input. Always remember that in Unix file names are case sensitive and if a file is named with a capital letter, start searching for it with a capital letter.

Alt+Enter (Ctrl+Enter, ESC+Enter)- copying the name of the file (directory) under the cursor into the Midnight Commander command line.
Typically used for operations on files and directories.

Insert- select individual directories and files.
Also analogous to this command are the symbol " * " And " + ", which serve to select files and groups of files by a given mask.

Ctrl+x c- visual command chmod. (First press "ctrl+x", release, then press "c")
We set (look at) the rights for a file (directory), a group of directory files. To apply to a group, select (Set All)
Comment- for a group of files, viewing does not give an accurate picture of the rights; the rights will be displayed for the file or directory that is first in the list.

Ctrl+x o- visual command chown
Change, see the owner of a file or directory.
Comment- for a group of files, viewing does not give an accurate picture of who the owner is; the owner will be displayed of the file or directory who is first in the list.

Alt+p, Alt+n(ESC+p, ESC+n) - last executed command p- previous, n- next (if you have already moved to previous teams)
In a regular console, using the up-down keys selects commands from those already typed in the current session; in Midnight Commander it’s more complicated, but you can get used to it

ESC+h- see the entire team history
While viewing the history, you can bring up the command and press Enter, this will copy the command to the command line. Remember that this hotkey can be used in any menu where you once typed commands. If there is a symbol at the end of the line in which you type something, then there is a history of commands for this line.

Alt+?- search for a file in the file system.
To type "?" you need to hold down the Shift key. So consider pressing three keys at the same time.

ESC+a- copy the path to the file into the address bar.
Very useful when creating symbolic links via command ln from the console.

Ctrl+xd- compares directory files of the right and left panels.

Ctrl+x - Ctrl+s- change symbolic link
First you will need to get used to such a long hotkey. First, perform one key combination, and then the second.

Ctrl+o- remove the right-left panel from the screen
It is usually used to see how the previous command execution completed, or just to work in a regular console.

Ctrl+R- directory update
If a new file appears in the directory, for example, you just downloaded it with a browser, then this hotkey is required for the file to be displayed. Also works on network file systems.

Ctrl+L- clears the screen
Sometimes after entering passwords in the command line or after launching programs from Midnight Commander, the screen begins to look incorrect. Using this hotkey, the screen is redrawn to normal.

And finally, people often ask me how to do auto-completion for commands (directories). In fact, it is an analogue of the indispensable Tab key on the command line. There is also such a hotkey..
ESC - Tab (Alt-Tab)- auto-completion of directories (commands) in the Midnight Commander command line, if necessary, press 2 times.
In my opinion, the hotkey is inconvenient and therefore not so effective. Not only will the alternative Alt-Tab combination not work in most window managers, because... processed by the window manager, but also note that the keys must be pressed not simultaneously, but sequentially.
You need to press 2 times if the beginning of the command (directory) has alternative endings. For example, we want to type the command “killall”, type kill and click autocompletion. Because There is also just a “kill” command, then this hotkey will have to be repeated twice and then we will see such a menu

Working with a file editor

Shift+F4 - create a text file
The following hotkeys should be typed in the editor
F3 + cursor arrows. Select the text block. F3 finish selection again.
F5 - copy selected block
F6 - move selected block
Shift+F5 - copying a block to the file's text buffer. Defaults to ~/.mc/cedit/cooledit.clip. Convenient if you need to transfer selected text between different files
Ctrl+F5 - paste all text from the text buffer ~/.mc/cedit/cooledit.clip.
Shift+Del - deletes the selected block and automatically copies it to the text buffer ~/.mc/cedit/cooledit.clip.
F4 - search and replace
Shift+Insert - pastes text from the clipboard

Customizable custom menu

Called by the F2 key. To change this menu, you need to edit the ~/.mc/mc.menu file. Read the help for the file syntax.

Midnight Commander working with new file types

The manager can work with most archives, runs video files, etc. perfectly. But there are types of files that it cannot process. To teach him this, you need to edit the extensions file mc.ext. In most cases the file is located in /usr/share/mc/. The file syntax here is more or less clear - do it by analogy with the same types of files. For each user, this file can be made personal - by copying the file to $HOME/.mc.ext

If you don't like the blue color of the file manager, you can change the colors to others. True, the range of colors there is not very large.
You can read the documentation on the opennet website about all the options of this wonderful manager that I briefly mentioned here.

Article viewed 27,719 times

Question 1

Why is Esc acting so strange?

Midnight Commander uses the Esc key as a prefix for emulation Alt keys and Meta (for keyboards that do not have these keys). For example, pressing the "Esc" key and then "a" is equivalent to pressing Alt+a (Meta+a), etc. Therefore, if Escape itself is needed, you need to press the "Esc" key twice.

You can disable this behavior by adding to your ~/.mc/ini (or system-wide /etc/mc/mc.ini):

Old_esc_mode = 1

IN in this case After the first press of the "Esc" key, there will be a wait of 500 milliseconds (half a second) for another key to be pressed (half a second, the Esc key will be considered as Meta). After this time, the Esc key will act as a double press.

To reduce the timeout for another key, use the environment variable "KEYBOARD_KEY_TIMEOUT_US". The variable value is specified in microseconds. For example, to make MC process pressing the ESC key with a delay of 25 milliseconds, write in ~/.bashrc:

Export KEYBOARD_KEY_TIMEOUT_US=25000

Starting from version 4.7.3, this setting is available through the configuration dialog "Configuration Options" (menu "Settings" -> "Configuration...").

Question 2

How to run mc with an interface in a different language (encoding)?

Enter in the command line "LANG=en_EN.UTF-8 mc" (English), "LANG=ru_RU.UTF-8 mc" (Russian UTF-8), "LANG=ru_RU.KOI8-R mc" (Russian KOI8-R ), "LANG=it_IT.UTF-8 mc" (Italian UTF-8), etc.

Panels

Question 1

I want that when you press Enter on the tar.lzma archive, MS goes into the archive, starts watching the video by pressing Enter, opens the file by pressing F3, F4, etc.

Most of the functionality is already in /etc/mc/mc.ext (for FreeBSD /usr/local/etc/mc/mc.ext). The ~/.mc/bindings file completely overrides these settings. It is enough to transfer them to bindings or, by analogy, add your own.

Question 2

How to create new file by means of mc?

To create a new file, just like in FAR, just press Shift+F4. If instead you see “26~” on the screen, then you can do this - F9 -> settings -> Key recognition... -> “Function 14” assign Shift+F4.

Question 3

My list format is shortened, how can I see the more readable (convenient) file size below?

Go to F9-> Left (Right) panel -> List format -> [x] Mini-status line in user format -> half type name | size:4 | perm

Editor

Question 1

When copying text from the editor to the clipboard, the test is pasted with periods and "<---->" .

You can remove the highlighting of spaces and tabs by pressing "alt-shift- -".

Question 2

When copying formatted code from the clipboard to mcedit, the test is pasted as a ladder.

In the editor, press F9-Settings-General... - Auto-indent by “Entering”, uncheck the box.