jump to navigation

Midnight Commander (mc) Guide: Powerful Text based File Manager for Unix January 10, 2011

Posted by Tournas Dimitrios in Linux.

Midnight Commander is a console file manager and directory browser. It is a friendly system for many tasks in the terminal window, and the quickest way to copy, move or delete multiple files. MC can also do fast ftp and network file transfers. Other unique features are the ability to browse inside archives and undeleted files. 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.

mc is not installed by default on CentOs 5.x , so it must be installed with yum package manager “yum  install mc ” . And that’s it ……….

This article is not tageted to teach you all the posibilities of this wonderfull utility , you have to explore them by yourself . I ‘ll just scratch the surface to get you started .
Start Midnight Commander by typing mc in a terminal window. The main section will be the two directory panels, with a drop down menu line above, a command line below, and below that a list of the present functions of the F (function) keys. Above the command line is a Hint line that shows random tips. Your mc may also open the F2 file operation menu on start-up, a little irritating, so cancel this by unticking “Auto Menus’ when configuring Midnight Commander. To quit mc, use key F10.

Basic Navigation in the Directory Panels :

Generally, you want to display different directories either side, so you can move files between them .Also it is possible to have one panel on a FTP session and the other panel as your filesystem listing .
Navigate around mc with the keyboard:

  • Tab key to change to the opposite directory panel
  • scroll through directories with up/down arrow keys
  • Home and End to jump to the top or bottom of a long directory
  • pg-up and pg-down to scroll one screen at a time
  • back/left arrow to change to parent directory (with lynx-like motion enabled)

To change up into a parent directory, arrow up to the top line and enter on /.. (usual parent directory notation). To change down into a subdirectory, arrow down then Enter.
See Configuration on how to enable ‘lynx-like motion’. Without needing to scroll to the top, the back arrrow will change you directly into the parent directory.
The ‘F’ (function) F1-F10 keys are widely used in mc for file operations and navigation . Read the bar at the bottom for their current function, which may differ according to the context, eg. browsing a directory, using the file viewer, or the editor.

MC ‘s   Virtual filesystems

The Midnight Commander is provided with a code layer to access the file system; this code layer is known as the virtual file system switch. The virtual file system switch allows the Midnight Commander to manipulate files not located on the Unix file system.

Currently the Midnight Commander is packaged with some Virtual File Systems (VFS): the local file system, used for accessing the regular Unix file system; the ftpfs, used to manipulate files on remote systems with the FTP protocol; the tarfs, used to manipulate tar and compressed tar files; the undelfs, used to recover deleted files on ext2 file systems (the default file system for Linux systems), fish (for manipulating files over shell connections such as rsh/ssh) and finally the mcfs (Midnight Commander file system), a network based file system.

The VFS switch code will interpret all of the path names used and will forward them to the correct file system, the formats used for each one of the file systems is described later in their own section.

The VFS for the command line :

The Midnight Commander  let you switch to a terminal (ctl-o) and  execute whatever command you  typed into it. If you wish to su, it will just request to type in your password. If you ctl-o, it will take you back as user.
While anything remains typed into the command line, the sideways arrow keys move through the text and  won’t work to navigate in the panels. If your arrow keys suddenly don’t work, check and clear the command line.
To scroll back and forth through command history, use alt – p for previous and alt – n for next command instead of the the up and down arrow keys (as in the terminal window), since mc uses them for navigating.

The VFS for the FTP  :

The ftpfs allows you to manipulate files on remote machines, to actually use it, you may try to use the panel command FTP link (accessible from the menubar : F9–>left–>ftp link) or you may directly change your current directory to it using the cd command to a path name that looks like this: /#ftp:yourFtpUrl . example: /#ftp:ftp.ntua.gr

The VFS for the tar :

The tar file system provides you with read-only access to your tar files and compressed tar files by using the chdir command. To change your directory to a tar file, you change your current directory to the tar file by using the following syntax: filename.tar#utar[dir-inside-tar]  , or highlight a tar file /rpm file and press F3 .

Undeleting files :
MC can recover deleted files on Linux/Unix. Works on ext2 and ext3 filesystems.

  • su to root and relaunch mc
  • it is recommended to unmount the affected partition: umount /dev/sda2 (your partition)
  • access Command menu, Undelete files and enter your partition in the box
  • after a few moments search, it will show a directory containing the inode numbers (the file contents, missing the header or filename)
  • Sort and arrange by time, size etc. through Left / Right menu, Sort Order
  • F3 to view the contents of a file
  • Copy required files over to a new directory on your mounted filesystem
  • if unmounted, remount partition: mount /dev/sda2
  • rename and move your recovered files back.

More help: For a detailed guide by the developers of Midnight Commander, see here.
Official FAQ here.


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s