Midnight Commander cheat sheet
Target audience
These notes are for those who want to use Midnight Commander (mc
) and have zero experience with it.
Note 📝 | This is a cheat sheet; it is not accurate, or complete, and omits a lot of details. But it should be good enough for a quick start. |
Why?
ls
and cd
are powerful enough for navigating the file system and viewing the content of directories, so why use something like mc
?
mc
is a dual-pane file manager
Contrary to many file managers, mc
is a dual-pane file manager
You can mostly ignore this feature (in fact, you can even hide the second pane), but it is practical, for example, when copying multiple files from one location to another.
With, for example, File Explorer on Windows, a typical workflow is
-
open a second instance of
explorer.exe
-
Ctrl+C on file in the first
explorer.exe
instance -
select the second
explorer.exe
instance -
Ctrl+V in the second
explorer.exe
instance
With a dual-pane file manager, there is no need to open multiple instances, and it is just one operation for copying (or moving) files from one pane to another, and you can see what the current status in both panes is.
mc
is not the only file manager with this property, in fact, it is a shared property of the clones of Norton Commander, there is a whole family of clones.
It is accessible
mc
can be controlled with a keyboard and/or a mouse.
This makes it an alternative to graphical managers too, which is very practical when there is no graphical session, for example when connecting via ssh
to a remote server.
Virtual file systems
It supports virtual file systems, for example, it is possible to navigate inside a .zip
archive or open an FTP connection.
One could mount those archives manually, but if one just wants to see the content and eventually copy it somewhere else, it is easier to use mc
and navigate inside the archive.
Stable interface
The interface is stable, as in, it does not change dramatically between releases. Once you’ve learned how to use it, you are probably good to go with all existing and future versions.
It can be extended, and it has a good shell integration
It is possible to provide custom keybindings or menus to adapt the tool to your custom workflow.
And you do not need to learn a new programming language, mc
can execute shell scripts and other programs directly.
It is portable
The first release of mc
was done over 30 years ago, and it has been ported to multiple systems (Windows too, unfortunately, it still is a second-class citizen, and the port is a separate project).
This means, the package manager of your distribution surely has a version of mc
, and you should be able to find an executable for the platform you are working on.
On Windows
On Windows, explorer.exe
cannot be executed with different administrator rights than the user is currently running.
This is not an issue for mc
(and other file managers too), which makes it very practical for executing from a non-administrator account multiple administrator task without confirming multiple UAC dialogs when copying and deleting files.
There is also another major difference. On Unix systems, there is one top-level directory: /
All other directories, even those on external drives, are in some subdirectories of /
.
In Windows, different partitions are generally mounted on different drive letters. The Windows port of mc
offers Alt+D as keybinding for switching between drives.
Keybindings
mc
uses the function keys (F1, F2, …) for many keybindings.
If your keyboard does not have those keys (unfortunately more and more laptops have a subpar keyboard), or if they are already mapped to some graphical application (terminal included) you can use the combination Alt+1 instead of F1, Alt+2 instead of F2, and so on.
For F10 (the default keybinding for closing dialogs and mc
itself) use Alt+0.
When navigating the menu, you might notice that some letters have a different color, pressing the colored letter on the keyboard is equivalent to clicking on the corresponding menu entry. If the dialog also has an input mask, typing a letter on the keyboard will fill the mask. For this reason, it is also possible to use Alt followed by a letter for selecting entries in dialogs.
Space (␣) can be used for toggling checkboxes, radio buttons, and opening a drop-down list.
Navigation
For navigating, use the arrows (⬇, ⬆, PgUp🠕, PgDn🠗, ⇱, Home, and ⇲) or click with the mouse on the element you are interested in, or use the scroll wheel. This holds both when navigating files and menu entries.
You can also use Alt+< instead of ⇱, Alt+> instead of Home.
Use ↵ Enter or F3 on directories for opening the directory, or on ..
to go one level up.
Opening files
↵ Enter on a file opens it, or executes it.
I believe that using the same action for opening and executing a file is a bad idea, at least, similarly to another file manager, it is possible to change the default action.
Click on "Command", then "Edit extension file", and change the "Default" section of the file to
[Default]
Open=vim %f
View=
With this setting, instead of executing scripts, they will be opened in vim
, or whatever your preferred editor is.
An alternative would be to use the keybinding F3, it will always open a file and works on directories too.
If you want to edit a file, use F4.
Note that you do not need to write those keybindings down, as mc
always shows them in the status bar:
1Help 2Menu 3View 4Edit 5Copy 6RenMov 7Mkdir 8Delete 9PullDn 10Quit
The default editor is mcedit
, but it can be customized too, as mc
respects the EDITOR
environment variables, it might be the easiest way.
Copy, create, delete, and move files and directories
You might have noticed that on the status bar, also following keybindings for "Copy", "RenMov", "Mkdir" and "Delete" are listed.
F5 is for copying files and directories. After pressing the key, a mask pops up, and one can define where the content is copied to (and some other details), the default action is to copy from the active pane to the inactive. If one wants a copy in the current folder of the active name, just write the filename in the mask.
F6 works like F5, but instead of copying the file, it moves it.
F7 creates a directory.
F8 is for deleting files and directories
For creating a new file, use ⇧ Shift+F4 (note that ⇧ Shift+Alt+4 does not seem to work as an alternative), mc
will open your preferred editor on a new file. Personally, I prefer to create a file name before, thus select and then "Ask new file name" (through keybindings: F9, O, C, S). After this change, similarly when creating a directory with F7, mc
will ask for a file name.
Operate on multiple files
Copy, moving, and deleting single files and directories, thanks to autocompletion, might be more productive on the command line; less so when one needs to operate on multiple files.
While moving, one can select multiple files by pressing the ⇧ Shift key, for example ⇧ Shift+⬆
Note that Ctrl+t and Ins are equivalent ⇧ Shift+⬇.
If the files one wants to select are not adjacent, do not keep ⇧ Shift pressed. You can unselect an erroneously selected file or directory with ⇧ Shift again.
Unfortunately using the ⇧ Shift key with a mouse often does not work, as the terminal will not send the information to the underlying application.
It is possible to use the right click for selecting and deselecting single files.
You can invert the selection with Alt+*
And you can use + for selecting multiple files according to a pattern, and kbd:[\\] for unselecting files.
Go to a file that begins with…
In File Explorer, Dolphin, and other file managers, it is possible to type the beginning of a file name to jump to it.
In mc
there exists a similar functionality, use Alt+S and then begin typing the name of the file or directory.
You can press Alt+S after typing some other characters, it will move the selection between all files that begin with the given prefix.
Open command prompt
No matter how powerful a tool is, one will be most efficient to one who knows best.
This means, especially at the beginning, one might want to resort to the shell to accomplish some tasks, even if those can be accomplished in mc
too.
mc
makes it trivial to switch between the shell and itself, use Ctrl+O to toggle between which of both programs is active.
Unfortunately, this feature does not seem to be supported on Windows, unless you are using the version that comes with Cygwin.
You can recognize that the shell is running inside mc
if the environment variable MC_SID
is defined, and if you close the shell (for example with exit
or Ctrl+D), then mc
will exit too.
You actually can type commands directly without switching to a console with Ctrl+O, but since Tab ↹ is used for switching between panes (you could use Esc+Tab ↹ to send Tab ↹ to the shell), and the output is not shown, I normally prefer to use Ctrl+O.
Note 📝 | When "inside an archive", as mc does not mount it, switching to the shell will not put you inside the archive, but outside of it. |
Other useful commands
-
Ctrl+X, S: open the
chmod
dialog -
Ctrl+X, O: open the
chown
dialog -
Ctrl+X, S: create symlink in the other pane
-
Ctrl+X, L: create hardlink in the other pane
mc
remembers internally in which folder you navigated, it is possible to change folders again by navigating the history
-
Alt+Y: move to the previous directory in history
-
Alt+U: move to the next directory in history
-
Alt+⇧ Shift+H: show the directory history. Might be easier to navigate than going back one entry at a time.
and
-
Alt+,: switch
mc
layout from left-right to top-bottom. Useful for operating on files with long names -
Alt+.: toggles the fact that
mc
shows hidden files (files that begin with a dot) -
Ctrl+R: refresh the directory view
-
Alt+I: synchronize the active panel with the other panel. That is, show the current directory in the other panel
-
Ctrl+U: swap panels
-
Alt+O: if the currently selected file is a directory, load that directory on the other panel and move the selection to the next file. This is practical for checking the contents of a list of directories.
-
Ctrl+␣: calculates the size of the selected directories. Look at the column determining the size, it will change its value.
Note that most, if not all listed keybindings can be discovered by looking at the menu entries.
mc
uses the same convention of emacs
for denoting keybindings, C-
is Ctrl followed by another character, M-
is Alt followed by another character, and F
followed by a number is one of the functional keys, like F1.
Do you want to share your opinion? Or is there an error, some parts that are not clear enough?
You can contact me anytime.