• United States
Unix Dweeb

Using the Midnight Commander to browse Linux directories

Oct 30, 20205 mins

Midnight Commander is a powerful tool that provides an easy way to browse, compare, move, modify and manipulate files.

Midnight Commander – the “mc” command – provides an easy way to browse directories and to view, move, delete, compare, change and edit files. Similar in some ways to ranger, mc makes it easy to move around directories and offers side-by-side file/directory listings that work independently of each other. In addition, it provides a very wide range of actions that you can take through simple menu choices.

To start Midnight Commander, simply type “mc” in a terminal window. When you open mc, both the left and right sides of the display will look the same and will show the contents of whatever directory you started in. You can switch sides using the tab key or simply by clicking on a directory or file in the side of the display. You can select a file or directory simply by clicking on it. You can also browse directory contents using the up and down arrow keys.

As you move around the files on one side of the display, the other side will remain as it was.

As an example of using mc, you can edit a file simply by clicking on the file name and then clicking on the word Edit on the bottom of the display. This opens the file in nano.

Speaking of the line at the bottom of your display, you’ll notice that it shows a list of actions that you can take. You can click on any of them to invoke the designated action. That line will look something like this:

1Help  2Menu  3View  4Edit  5Copy  6RenMov  7Mkdir  8Delete  9 PullDn  10Quit

These choices are both numbered and named because they can be invoked by clicking on the names, by using the associated function key (e.g., F1 for Help), or by using an escape sequence (e.g., Esc-3 for View).

These choices do the following:

  • Help brings up a help page that you can exit by pressing the Esc key.
  • Menu opens a menu showing commands that you can run. For example, you can compress the selected file with bzip2 just by typing “b”.
  • View displays file contents. Press the space bar to continue to the next screenful of data and the escape key to exit. For some file types, you will only see descriptive information (not file contents).
  • Edit opens the file in a text editor and allows you to make and save changes.
  • Copy makes a copy of the selected file after opening a form that provides a way for you to specify a file name.
  • RenMov renames and moves a file after opening a form that allows you to specify the details.
  • Mkdir creates a new directory after opening a form that provides a way for you to specify a name.
  • Delete deletes the selected file or directory. You can even choose to remove a directory recursively.
  • PullDn allows you to use the pull-down menus at the top of the display. They offer many additional options (e.g., using the File pull-down, you can change file permissions, edit symlinks, etc.).
  • Quit exits Midnight Commander

Pressing on Menu brings up these choices:

@	Do something on the current file 
0	Edit a bug report an send it to root 
2	Call the info hypertext browser 
3	Compress the current subdirectory (tar.gz) 
4	Compress the current subdirectory (tar.bz2) 
5	Compress the current subdirectory (tar.xz) 
6	Compress the current subdirectory (tar.xz) 
7	Compress the current subdirectory (tar.zst)
a	Append file to opposite
d	Delete file is a copy exists in the other directory
m	View manual page 
n	Inspect gzip'ed newsbatch file 
h	Strip headers from current newsarticle 
r	Copy file to remote host 
y	Gzip or gunzip current file 
b	Bzip2 or bunzip2 current file

As you can see, the changes that you can make with a single key press are impressive.

Press Esc to exit this listing.

Command examples

To move into a directory, select it and press the Enter key.

To view a file, select it and press View. Press the space bar to view more of the file and Esc to exit the content display.

To delete a file, select it and press Delete. You will need to confirm the deletion.

To rename a file, select it and press RenMov. You will be prompted for the new name. Then press OK.

To change file permissions, press PullDn, mouse right to File and down arrow to chmod and press Enter. A very user friendly form will open that allows you to select the permissions you want. Then click on Set.

To exit Midnight Commander, click on Quit. If this doesn’t work, you probably still need to press Esc first to exit some other listing you were viewing.

This is just a sampling of things that you can do with this tool.

Listing order

In Midnight Commander, the listing will show directories and then files. The “hiddens” (those starting with “.”) will be listed first, followed by those starting with capital and then lowercase letters.

File will be color-coded by type.

  • Directories — white
  • Files — gray
  • Images — light blue
  • Compressed files — pink
  • Video files — green
  • Background — blue

You can make some changes by editing mc’s configuration file. This  will be ~/.config/mc/ini or ~/.mc/ini.


Midnight Commander is a powerful tool for browsing, comparing, moving, modifying and manipulating files in what many would consider a user-friendly manner. That is, you don’t have to type a lot of Linux commands, but you do have to get used to clicking your way around its menus and forms. Some of its features – such as the ability to compare file listings side-by-side or change permissions by clicking on permissions boxes – are fairly unique. For most of us, mc could make working on Linux a very different experience.

Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author