opened image

Midnight Commander file manager

It is often necessary to perform operations on files on a Linux server. For example, copy or move files, view the file structure, etc. For experienced Linux users, the command line is sufficient. But you can install and use a file manager.

Midnight Commander is a two-pane file manager that allows you to perform most operations on files and directories, including copying data to a remote source - via FTP, SSH and others. It is similar to Norton Commander designed for MS-DOS or Far Manager and Total Commander (in principle) for Windows.

Log in using the SSH protocol to work with the program. To do this, you can use the PuTTY program for Windows or the built-in ssh program, which is available on Windows, Mac, and Linux systems.

You can install the program on almost any system using the package manager. For deb-likedistributions, run the command:

apt-get install mc

 


For rpm-likerun:

 

yum install mc

 


To run the program, enter on the command line:

 

mc

 


The main window of Midnight Commanderlooks like this.

 

 
Image 1. Appearance of the program Midnight Commander


At the top of the "window" is the main menu. In the center - 2 panels in which the same or different folders can be opened. Below is a line of hints  and a command line, and at the very bottom is a cheat sheet of function keys.

Management is made from the keyboard by arrows and keyboard combinations. In most cases, you can also control the program using the mouse. You can switch between panels using the TAB button.

The main menu can be selected with the left mouse button or by pressing the F9 button. To exit the main menu mode, press ESC.

The following is a description of the program functions that can be performed by pressing the function keys F1-F12.
F1 - help
F2 - menu of useful commands
F3 - view file
SHIFT+F3 - quick view file (ignoring file type)
F4 - edit file (the first time you run it, there will be an editor choice)
SHIFT+F4 - create a new text file (then you can save it under the desired name in the editor)
F5 - copy
SHIFT+F5 - copy to the same folder (make a copy of the file or folder)
F6 - move file
SHIFT + F6 - rename file or folder
F7 - create directory
F8 - delete file or directory. Removal to the Trash is not provided
F9 - as mentioned above - open the menu
F10 - Quit Midnight Commander

You can perform batch operations on files. Press the INS button to select files. To select a group of files by mask, press the '+' button and enter an asterisk ('*') - this will select all files. You can instead select files by any name mask or extension. For example, to select all php files press '+' and then enter *.php. To deselect all files, press '-' and enter '*'.

The general editor settings are found in the F9 - Options - Configuration menu. You can navigate through the items with the TAB button or the arrows on the keyboard (or select with the mouse). Then, with the SPACE button, you can set or remove marks. For example, you can check if the built-in editor mcedit is selected for editing files (highlighted in the image below). This is a handy multifunctional text editor that has everything you may need when creating text or code. Its description is the subject of another article. The Options menu also contains other settings, as well as the Save setupitem, which saves the current configuration.

 
Image 2. Settings window


The program also has some advanced combinations with which you can do certain things.
CTRL+O - hide/show panels. In this case, it becomes possible to fully work with the command line
CTRL+X, C (or File - Chmod) - show a window for viewing and changing access rights to a folder or file. To enter such combinations, first press CTRL + X, then C
ALT+SHIFT+?- search for files, including the content of the files. Search window - in the image below

 
Image 3. Finding files


To search for files, enter a dot in the Start at field (search in the current directory). In the File name field, enter the file name or name mask. In the Content field, you can enter the search text. If the conditions are correct, click OK. From the search results window, you can immediately view or edit the file. The editor window immediately moves to the found fragment.

The program menu has combination tips for most menu items. In this case, the capital letter means the ALT button, capital C - CTRL. For example, if you open the Left (or Right) menu, you can see that you can view information about the file selected in another panel by typing CTRL + X, i. This is denoted as C-x i.

Using the Left and Right menus, you can also open a remote file storage via FTP or SSH (Shell link), perform file operations, and copy to/from a remote source.

Not all the features of the file manager are described here. The program has official documentation, which can be found following by link. But, unfortunately, it is not complete. More information can be found online from various sources.