Manage files and more
Midnight Commander can do more than just copy, move or delete files. Some would argue that it’s as versatile as Shashank Sharma.
As we’re celebrating 30 years of the Linux kernel, we’ve decided to focus on a wonderful command-line project that’s been around for nearly as long. Midnight Commander is an orthodox file manager that features a split-pane interface and is one of the oldest file managers that’s still being actively developed. Currently under the GPLv3+ license, Midnight Commander is part of the GNU project. First released in 1994, Midnight Commander quickly became a favourite of most of the Linux crowd. Despite its soaring popularity, with the ever-increasing focus on GUI applications in the late 90s to early 2000s, Midnight Commander slowly fell away by the wayside.
This explains why none of the popular desktop distributions offer it as part of the default installation. And yet, you can gauge the continuing popularity of the application from the simple fact that all distributions feature it in their software repositories, making it a breeze to install.
If you’re on a Debian/Ubuntu based distribution, you can run the SUDO APT INSTALL MC command to install it. You can similarly use the SUDO DNF INSTALL MC command to install Midnight Commander on RPM-based distributions such as Fedora.
Navigating the MC interface
Once installed, you can run
Midnight Commander with the mc command. Midnight Commander defaults to a colour mode, but the default colourscheme might not appeal to everyone. If you find the use of blue and green unpalatable, you can invoke Midnight Commander without colours using the MC -B command. Run the MC --HELP-COLORS command for more information on the supported colour schemes and how to switch between them.
Although Midnight Commander is a text utility, it has full mouse support, which means that you can left-click to select different files, or even access the different menus at the top of the interface.
The interface is split into two panes and you can move between the panes by pressing the Tab key. You’ll also find a menu bar at the top of the interface. The File and Command menus comprise various entries to help you perform a number of different operations such as copy or rename a file, change its attributes and find or compare files.
Each pane displays the current directory at the top-left. The panes list the directories at the
top, followed by files within the current directory and all hidden files are displayed by default. If you wish to sort the files, whether by extension, size, file name, modify time and so on, or switch the display to tree view, for example, then you can do so from under the Left or Right menu, which govern the behaviour of the two panes.
At the bottom of the interface is a strip comprising a series of actions, such as Help, Menu, Copy, Edit, Mkdir and Delete. Each of these actions is preceded by a number from 1-10. For instance, View is preceded by 3, while Deleted is preceded by 8. These number denote the Function keys on the keyboard. So, if you want to quit Midnight Commander, you can press F10. To delete the selected file, press F8. You can similarly press F3 to view a selected file.
You can use the scroll-wheel on your mouse or the up/down arrow keys to move though the contents of the current directory. Use left-click to select a file, or press the Insert key, which can also be used to select multiple files. To unselect a file, move to the file using the arrow keys, and press Insert key again to unselect it.
Unlike graphical file manager, Midnight Commander lacks the ability to drag files between directories. You must first select the file, and then choose an operation from the File or Command menu, or one of the actions at the bottom of the interface.
You can press the F9 key to select the top menu, and then use the arrow keys to navigate to the menu and its entries or press
Alt- first letter key combination. For instance. To open the Command menu, you can press F9 followed by Alt-C.
File operations
A file manager can be used to perform a variety of functions, such as copying or moving files, changing file permissions, viewing the contents of compressed files, or even compressing or uncompressing archives.
You can perform all these operations, and more, with Midnight Commander. It even supports viewing the contents of text and PDF files, and show you the contents of compressed archives without first uncompressing them. Even better, you can also edit text files using the default editor.
Due to space constraints, we can’t cover each of these operations in detail, but it’s so intuitive that you’ll be able to figure it out in almost no time at all.
If you wish to compress a number of files, first select them using the Insert key. Now, press F2 to open the User Menu. You’re presented with a number of choices, and for each choice there’s a corresponding keyboard shortcut. With time, you’ll be able to straight away use these shortcuts without having to read the different functions they perform.
Select the first option, ‘Do something on the tagged files’, which open the command dialog. You can now enter the command you wish to run to create the compressed archive of the selected file. For instance, run the TAR -CZVF TARBALL.TAR.GZ %S command to create a tar.gz compressed archive containing all the selected files. The %S parameter ensures that all selected files are added to the archive.
In fact, the main Midnight Commander interface also features a shell prompt at the bottom. It’s enabled by default, and can be used to perform the same operation without using any menus. You can run any commands on the selected files using this command prompt.
Instead of setting the two panes to display different directories on the local machine, you can also use Midnight Commander to connect to a remote machine via FTP. Press
F9, select the pane you wish to display the remote machine (Left or Right) and then select FTP.
There’s plenty more that you can do with Midnight Commander, and while much has been written about this great utility, there just isn’t any official documentation. The man pages and the MC --HELP command are the extent of documentation, although the project claims that it’s working to improve things on this front. Refer to the man page for quick introduction to keyboard shortcuts that can help you quickly access commonly used operations such as copy and move.