How to use midnight commander, a file manager

Thomas Hayes
6 min readDec 6, 2020

Midnight commander? What is this thing?

Midnight Commander is an orthodox file manager with two windows that you manipulate the files on. It has numerous advanced options and useful tools, like sftp and shell linking, tools for bulk management of files, and more.

Why should I use it?

It is useful if you need to manage files on a headless server. If you can’t run an x session or other GUI on your server, you won’t be able to use most file management software. Because midnight commander is a command-line utility, it can be used quite easily on such machines.

Midnight commander’s two-pane window system often makes it more flexible than traditional file managers, especially for dealing with large numbers of files. It also has a command prompt built-in, so for advanced users, it has all of the advanced command line functionality easily accessible.

Installation.

Installing Midnight Commander varies depending on your platform. To install it in Windows, download it from SourceForge, https://sourceforge.net/projects/mcwin32/. For a Mac, Get it from the Mac App Store. If you are going to install it on Linux, it is probably in your distro’s repository, and the package name is usually shortened to mc. For example, to install it on a Debian based distro, you would type ‘sudo apt-get install mc’.

Basic stuff — copy, delete, rename, select.

To start midnight commander, type mc into a terminal, or launch it from a desktop shortcut.

First, let’s look at the most basic thing of all — navigating around. When you start midnight commander, you should see the two panes with the contents of your home folder listed in them, and a cursor at the top of the left panel. To move the cursor around in a pane, just use the up and down arrow key. To switch panes press tab. Finally, to switch to different folders, just press enter with the cursor on the folder you want to enter, and to go up in the directory, press enter on /.., which is at the top of the folder.

Let’s look at the stuff you will probably do most often first. To copy a file, move your cursor over the file and press f5, and hit enter, and the file will be copied to the other pane. To delete a file, press f8 with it selected and enter. And to rename a file, press f6 with both panes showing the same folder, rename it in the dialog box and hit enter. To move a file, set the other pane to where you want the file moved to, press f6, and hit enter.

To select files, press insert and the file will be highlighted. Once you select a few files, you can copy, delete, and move them all in bulk, using the same keys.

Other useful tools

Midnight commander can do a lot more than just copy and move files in bulk. You can do stuff like compress/decompress files, edit text files, and other useful features.

If you want to know how to do something, f1 brings up a useful help menu.

F2 brings up a menu allowing you to compress and decompress files into many different formats, selectively delete duplicate files, use command-line tools on the selected files, append files, and send bug reports to the developers.

F3 allows you to view text files and folder contents.

F4 opens the selected file in the inbuilt text editor, which is very similar to the vi text editor.

F7 makes a new folder, just type the name you want and hit enter.

F9 accesses the menu at the top of the screen — in the ‘pull-down menu’, as it is called.

F10 quits midnight commander, returning you to a command prompt.

Pull-down menu

The menu at the top of the screen, called the pull-down menu, can be accessed by pressing f9. It has five menus, left, file, command, options, and right, that you access with the arrow keys.

The left menu affects the left panel of the screen, and has options to list files, show a tree-like hierarchy of the folders on your computer, list, filter, and sort files and folders, and view information on the file selected in the other pane. Best of all it has, FTP and ssh links between other computers — more on that in the next section.

File has all manner of options for manipulating files, from creating links to modifying permissions of a file, and options for viewing and editing files.

Command has quite a few miscellaneous tools. It has tools for looking at your command line history, finding files on your computer, and comparing files and directories. The best tool of all here is easily the directory hotlist, though. It allows you to create shortcuts to other folders, including folders that you access through sftp.

Options has various settings to control the layout of Midnight Commander, from changing the appearance to altering the layout of the various panels. You can change the appearance to one of the loaded presets, and make it so the panels are arranged horizontally rather than vertically.

The right menu has the same options as the left menu, but they are for the right panel.

Ftp links and ssh integration

This is probably the best thing about midnight commander — the way that it integrates with ssh and sftp allows you to easily transfer files to and from other computers, as long as you can link to the other computer via ssh. To do this, press f9, then go to the left or right menu, and select FTP link, shell link, or SFTP link, depending on which tool you want to use. You’ll be asked for the hostname of the computer you want to connect to, and have to enter that machine’s password to connect. Once you have done that, you will have one panel with the filesystem of the remote computer on it — and you can easily copy, move and delete files from it just as you would on a local machine.

If you regularly access the same machine, you can save the folder in the directory hotlist for easy access. Just set up the remote link to the folder you access often, press f9, go to command, directory hotlist, and press tab until “new entry” is highlighted on the bottom of the screen. Hit enter, and optionally name it if you wish. Hit enter again, and it will save to the list. Now whenever you want to access that computer, go to command, directory hotlist, select the shortcut you made, and hit enter to access the remote filesystem.

Command-line tools

Integrated into midnight commander is one of the most powerful computer tools ever created — the command prompt. All command-line tools should work out of the box in midnight commander, and if you want to switch to a plain computer terminal, you can switch to it with

ctrl + o.

Make it readable.

Another thing I suggest is changing the color scheme — the default blue and white scheme is hard to see. Press f9, go to options, appearance, and choose one that looks a little better. I suggest gotar or madarcon16 for good contrast, but there are several different appearances for you to play with.

Conclusion.

Midnight Commander is a piece of software from a bygone age. I’ts usefulness, however is still as great as ever. Due to it’s advanced features and robust design, it is a wonderful tool for administering remote servers and managing bulk files. Despite file managers like this being over forty years old, Midnight Commander still has a part to play in the computer reliant world of today.

--

--

Thomas Hayes

Programmer, web developer, computer hardware enthusiast. Interested in everything.