Midnight Commander instruction

Midnight Commander

Introduction

A long time ago, when computers were big and monitors were small, computer work was carried out mainly in text form. Console and its commands are a legacy of that period. However, people have always sought to simplify their tasks. Then people created pseudographic visual file managers:

  • DOS Norton Commander and Volkov Commander.
  • *nix Midnight Commander.
  • This format became popular and resulted in releasing FAR Manager for Windows.

Their interfaces and operating principle are very similar, which include two panels, ability to create, delete, copy, rename, etc.
Open the console and enter the command:

mc

If there’s no command, we will install a package:

sudo apt-get install mc

After that, we will still run =).

You can see the two panels on the screen under which the command line and prompt messages for hotkeys are seen. Digits from 1 to 10 signify F1-F10 function keys. MC and a mouse are connected. However, you can work faster without a mouse.
The two panels are cozy. Use a panel to work with files locally. Also, you can work with another one on the remote host. Enter Tab to switch panels.

Let’s figure out how you can work consistently here.

Here are 2 focus parts:

  1. Usual work. We use arrow keys to click files and write texts in the console below.
  2. Open the menu and pop-up window. If you push F2, a pop-up window appears in which you can choose options such as zip, view, copy, etc. If you push F9 and focus on the upper menus, the menu opens when you click the down arrow or enter (Esc means to escape). In this case, pushing keys is interpreted as a menu command. You can see the action section that describes the association between keys and actions.

Attentive readers have already noticed that we have not only file lists, but also a console. And we can enter console commands and get the result. For example, let’s enter the command:

cat /proc/cpuinfo

If you push Enter and the screen doesn’t change, don’t panic. It’s okay. To see command results, you need to change visibility. MC includes the two visibility types:

  1. File manager.
  2. Console.

You can switch visibility by pushing Ctrl + o.

Attention! There is one nuance you must memorize. If the console is empty, the file opens when you push Enter. If it has characters, first, it requires carrying out what’s been written there.

Well, we’ve already understood modes. Now we’re going to fulfill practical tasks.

File system navigation

We need to use Up, Down, and Enter keys to navigate in the file system. Using the arrow keys, we scroll the list up and down. We push Enter to open files. Directory folder is considered as a file within *nix terms.

You can open the folder, but you don’t know how to leave it.

You’re to dig into the structure of the Linux file system.

  • First, any object of the file system is a file. There are files with many characteristics such as textual, binary, socket, buffer, link, and so on.
  • The *nix directory system is tree-type. Its “/” root is the same. There is no Windows division such as C or D disk. Any mounted disk is associated with a folder within the tree-type system. When you navigate in the file system, you don’t know that there are a few disks mounted (network drives also can be there).
  • Each directory has not only user files but also two system files. One of them is marked as a dot that indicates its own folder.
  • The second one is marked as two dots, which indicates the folder of a higher hierarchy. In a nutshell, if you open the “…” file, you leave the folder.

Well, it’s logical and comfortable. We have less than 1 abstraction in comparison with Windows.


Here are the exit and folder up to the hierarchy.

Now you can test your skills and navigate in the file system. Also, you can navigate by using the console. For example:

Let’s create a folder

Then you’re to create and remove directories. To keep the file system clean, you should conduct experiments in /tmp folder. It is good at deleting itself when it is rebooted. Then click the folder and push F7. In the dialog box that appears, enter the name of the future folder and press Enter.

Here is the folder:

If you want to get the same result, enter it in the console

mkdir Name_Folder

Now let’s delete the folder.

You’re to hover a cursor over it and push F8. If you don’t want to delete files by chance, the file manager requires confirmation. You will see a red pop-up window warning you. Thus, you can confirm deleting a folder or refusal.


Thus, you can delete any file system, directory, textual file, socket, and so on, if you have rights to do it.

Let’s create and edit a file

You can’t find a button and keys for creating an empty file within settings (by default). Therefore, use the console.

touch NewFile.txt

Here it is.

Now you can see it (F3) or edit it (F4). If you’re doing it for the first time, you will choose one of console text editors. Also, you can get Midnight Commander and MCEdit. If you still have no favorite editor, you can choose it. Then you see an editor with an empty field appear before you. If you choose an edit mode, you can write any text and save it by pushing F2. Or you can leave an editor in the file manager by pushing F10.

The text editor is set by $EDITOR host environment directive by default. It must be set in a configuration file of the Bash command shell. We’ve set it one time. To train skills, you should set MCEdit as an editor by default.

To do it, we’re to visit the home directory:

cd ~

Open the .bashrc file. If you have no file, you’d better create it. Then you write the line at the beginning:

export $EDITOR="/usr/bin/mcedit"

Like this:

Save the file. When you enter the console, MCEdit works as a text editor by default. MC and Crontab programs use it by editing planner configuration.

Copy or replace the file.

Two panes designed for copying/replacing a file fit visual perception very well. Let’s copy .bashrc into /tmp folder. To do it, you’re to click the right pane (Tab) in which you visit /tmp folder (cd /tmp). Then click the left pane (Tab), hover the cursor arrows over the .bashrc file, and push F5. In the pop-up, you should edit a path and copy the file. The path to the folder in the right console will be indicated by default (if you copy one from the right console, the path from the left one will be pasted).

You can choose Next or Background. If you have a little file, you push Next. If you have a big one to continue working on, push Background. You keep on copying it, so we continue working in the file manager (don’t leave it =) ).

Replace it in the same way.