You are on page 1of 4

Midnight Commander (mc) Guide: Powerful Text

based File Manager for Unix

Free eBook - Linux 101 Hacks. Get your copy now.

GNU Midnight Commander (mc) is a powerful text based file manager for
Unix. mc gives an jumpstart for Windows power-users who would like to transition to Unix. It also has several
advanced features to keep experienced Unix users happy. mc can run from any Unix terminal. If your terminal can
execute vi, you can execute mc to view the midnight commander user interface. Midnight commander supports mouse
when you are running it under xterm.

mc supports several virtual file systems (VFS) such as, tarfs to view the content of the several archive files (tar, tgz,
bz2, rpm etc.) , ftpfs to browse FTP repositories of a remote server, fish to manipulate files on a remote server over
ssh, undelfs to recover a deleted file.

1. Installation
mc comes with most of the Linux distributions. Verify whether your system already has mc:

# rpm -qa mc

If you don’t have mc, install it using yum:

# yum install mc

Execute mc -V to see all compiled options on your midnight commander:

# mc -V
GNU Midnight Commander 4.6.1-pre1a
Virtual File System: tarfs, extfs, cpiofs, ftpfs, fish, undelfs
With builtin Editor
Using system-installed S-Lang library with terminfo database
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support

Note: You can also install mc from source code. Download mc source code from GNU FTP site.

2. Midnight Commander layout

Launch midnight commander user interface using one of the following methods:

# mc

# mc -a
[Note: If display lines are not drawn properly, use -a]

# mc -c
[Note: Option -c will display mc in color]

Midnight commander user interface has four sections as explained below.

Section 1 - Menu bar: Located at the top of the screen and has the following options. Press F9 (or) Esc 9 to access the
menu bar.

Left - Options to control the display of the left directory panel

File - Options to manipulate files
Command - Options to edit various mc configuration files
Options - Options to change layout, setup VFS
Right - Options to control the display of the right directory panel

Section 2 - Directory panels: Located in the middle and occupies large part of the screen. By default, it displays both
left and right directory browsing panels, where you can view contents of two different directories at the same time.

Section 3 - Function keys: Located at the bottom and has following options. Press Esc key followed by the
corresponding menu number to access these functions.

1. Help - Display in-built mc help.

2. Menu - Displays user defined menu items. You can create custom menu item to execute some complex steps of
operations on the selected file. for e.g. compress the selected file and copy to a remote server with a single click.
To edit the menu item file, click F9 (invoke menu bar) -> Command -> Edit Menu File
3. View - View the selected file content using mcview, a viewer for midnight commander.
4. Edit - Edit the selected file using mcedit, an editor for midnight commander.
5. Copy - Copy the selected file. If both panels are displayed, it will copy the file to the other panel. mc will ask for
confirmation before doing any changes such as, copy file, delete file, move file etc.,
6. RenMov - Move/Rename the selected file.
7. Mkdir - Create a new directory under the selected directory.
8. Delete - Delete the selected file.
9. PullDn - This will highlight the Menu Bar. This option is helpful when F9 doesn’t work to invoke the menu bar.
10. Quit - To quite midnight commander, press Esc key followed by 0.
Section 4 - Command Line prompt: Using midnight commander does not take away the command line from power
user. You can start typing an Unix command anytime and press enter to execute it. Command line prompt is located
towards the bottom of the screen.

3. Basic keyboard shortcuts

Most of the mc keyboard shortcuts fall in one of the following category:

C-<chr>: Press Control key and a character key at the same time. For e.g. C-u to swap left and right panels.
M-<chr>: Press Alt key and a character key at the same time. For Alt key commands, you can also press ESC
key, release it and press the character key.
S-<chr>: Press Shit key and a character key at the same time.
C-<chr1> <chr2>: Press Control key and a character key at the same time, release it and press another character
key again. For e.g. C-x d to compare directories.

Following are some basic keyboard operation

Tab: To switch from one panel to another.

M-t: Change the panel display options. i.e Switch from a dual panel display to a single panel display.
C-s: Search for a file.
Use up-arrow, down-arrow, page-up, page-down, home and end keys to browse the directory content.

4.Sample mc usage scenarios

Copy multiple files together using ‘Insert’ and F5: Highlight a file and press ‘Insert’ key to tag the file for
group selection. Repeat this process for multiple files that you wish to copy. Selected files will be displayed in a
different color. Pressing F5 will display the following copy dialog screen, defaulting the destination directory
location to the directory displayed in the other panel

Display additional file information: To display additional file attributes in the directory panels, press F9 ->
Left or Right -> Listing Mode, and select “Full File List”
View the content of any compressed file using F3: Select the file and press F3 to view the content of the file.
For e.g. Select a rpm file and press F3, to view the content of the rpm file.
Toggle between command line and mc using C-o: Press C-o (Control key followed by o) to toggle between
full command-line and mc user interface.
Confirm file operations: To avoid mistakes, enable confirmation for copy, delete, overwrite and execute
functions. Press F9 -> Options -> Confirmations, which will display the following screen.

5. References and additional screenshots

Additional screenshots of GNU Midnight Commander running both in a terminal and with the GNOME GUI.
Directory listing on right panel and file info on left panel
Browsing an RPM file over FTP with quick view on the left
Internal editor with syntax highlighting editing Perl program
Eye candy - using transparent background in gnome-terminal

Tags: File Manager, GNU, linux file explorer, linux file manager, linux mc command, Linux Windows Explorer, mc,
Midnight Commander