975 lines
40 KiB
HTML
975 lines
40 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>An Introduction to the Midnight Commander</TITLE>
|
|
</HEAD>
|
|
|
|
<BODY>
|
|
|
|
<CENTER>
|
|
<H1>An Introduction to the Midnight Commander</H1>
|
|
|
|
<B><FONT SIZE=-1>
|
|
by John M. Fisk <fiskjm@ctrvax.vanderbilt.edu><BR>
|
|
October, 1997<BR>
|
|
Nashville, TN
|
|
</FONT></B>
|
|
</CENTER>
|
|
|
|
<BLOCKQUOTE>
|
|
|
|
<CENTER><P><B>Abstract</B></CENTER>
|
|
|
|
<P>
|
|
The <B>Midnight Commander</B> is a directory browsing and file manipulation
|
|
program that provides a flexible, powerful, and convenient set of file
|
|
and directory operations. It is capable of running in either a console or
|
|
an xterm under X11; mouse support is native under X11 and is provided by
|
|
the <B>gpm</B> mouse server when used in a Linux console. A sophisticated
|
|
Virtual File System (VFS) supports directory-like browsing and file operations
|
|
for a variety of common archive formats as well as FTP and network connections.
|
|
Its basic operation is easily mastered by the novice while providing a rich
|
|
feature set and extensive customization.
|
|
|
|
</BLOCKQUOTE>
|
|
|
|
<H2>Introduction</H2>
|
|
|
|
<P>
|
|
The last couple years has seen the release of a bevy of well designed, X based
|
|
file managers including FileMan, FileRunner, Linux Explorer, TkDesk, X-Files,
|
|
and Xplorer to name a few. Some of these are "works in progress"
|
|
but all show promise and are well worth having a look at.
|
|
|
|
<P>
|
|
Despite this, one of my favorites, and now old enough in the "Linux
|
|
Epoch" to be called venerable, is Miguel de Icaza's Midnight Commander
|
|
(mc). The README describes mc as:
|
|
|
|
<BLOCKQUOTE>
|
|
<P>
|
|
a free Norton Commander Clone with many useful features... The Midnight
|
|
Commander is a directory browsing tool which bears a certain remote
|
|
resemblance to John Socha's Norton Commander for DOS.
|
|
</BLOCKQUOTE>
|
|
|
|
Its stability, ease of use, flexibility, and rich feature set make it quite a
|
|
powerful tool. Its simplicity makes it easy for novices to quickly master the
|
|
basics. Among the capacities it boasts are:
|
|
|
|
<UL>
|
|
<LI>support for all basic file operations including move, copy, rename,
|
|
delete, chown, link, view, and edit
|
|
<LI>a built in Virtual File System that allows browsing of archives such
|
|
as tar, compressed tar, rpm, deb, zip, cpio, lha, rar, and zoo files
|
|
as well as remote files via FTP or the Midnight Commander's own mcfs
|
|
protocol
|
|
<LI>mouse support in xterms under X or at the Linux console via the gpm
|
|
mouse server
|
|
<LI>built in text and hex viewer/editor as well as support for external
|
|
viewer and editors
|
|
<LI>subshell support for the bash, tcsh, and zsh shells
|
|
<LI>built in Find File capacity
|
|
<LI>background copy or move operations
|
|
<LI>online help system
|
|
<LI>and much more...
|
|
</UL>
|
|
|
|
<P>
|
|
The manual page for mc is well over 50 pages in length, giving some indication
|
|
of its complexity. In this short article I won't be able to cover mc in this
|
|
depth, but will try to touch on the basics: getting the sources, compiling
|
|
and installation, and basic use and features. This is probably best read
|
|
while sitting at your computer and experimenting with the various features as
|
|
you go. Let's start by compiling and installing mc.
|
|
|
|
<H2>Going To The Source</H2>
|
|
|
|
<P>
|
|
Sources and precompiled binaries are available at a number of locations
|
|
including the canonical GNU FTP archive prep.ai.mit.edu/pub/gnu/ and the
|
|
sunsite FTP archive at sunsite.unc.edu/pub/Linux/utils/file/managers/mc/. The
|
|
official web page is http://mc.blackdown.org/mc/ where the most recent public
|
|
and development releases may also be found. There are, additionally, mailing
|
|
lists for both users and developers to which you can subscribe from this site.
|
|
|
|
<P>
|
|
In addition, most Linux distributions including Debian, RedHat, Slackware, and
|
|
their derivatives provide precompiled packages in *.deb, *.rpm, or *.tgz
|
|
formats. If you feel a bit shaky at the prospect of compiling your own
|
|
programs, or are in a hurry to get going, then these provide an easy means of
|
|
obtaining and installing mc. Check the documentation that came with your
|
|
distribution as to the specifics of using the package management system they
|
|
provide. At a minimum you could try:
|
|
|
|
<PRE>
|
|
$ installpkg mc-xxx.tgz
|
|
-OR-
|
|
$ rpm -i mc-xxx.rpm
|
|
</PRE>
|
|
|
|
for Slackware or RedHat based systems in which "mc-xxx.{tgz,rpm}" is
|
|
the name of the package.
|
|
|
|
<P>
|
|
In the pioneering spirit of Linux's "Do It Yourself And Learn", I'd
|
|
like to suggest that you compile and install mc from its sources. It's not
|
|
that difficult and if you've not done much of this then mc is an ideal program
|
|
on which to start since it is quite well behaved.
|
|
|
|
<P>
|
|
For the purposes of this article I'll be using mc version 4.1.5 which is the
|
|
most current at the time of this writing. If you ftp the sources from sunsite
|
|
or one of its mirrors then you might also want to retrieve a couple other
|
|
useful packages that support mc: the rxvt X window terminal, Allesandro
|
|
Rubini's gpm mouse server, and Theodore T'so and Remy Card's e2fsprogs package
|
|
which allows file undelete capacity to be compiled into mc. All of these are
|
|
available at sunsite or its mirrors in the /pub/Linux/utils/file/managers/mc/
|
|
directory.
|
|
|
|
<H2>Compiling and Installing Midnight Commander</H2>
|
|
|
|
<P>
|
|
In this section, I'll assume that you've gotten the *.tar.gz source file, that
|
|
you'll unarchive the sources into /usr/src, and that you'll install mc and its
|
|
support files under /usr/local. You can obvious compile and install mc in
|
|
any directory you wish: just change the pathnames to suit your preferences.
|
|
To unarchive the sources do:
|
|
|
|
<PRE>
|
|
$ cd /usr/src
|
|
$ tar -xvzf /path/to/mc-4.1.5.tar.gz
|
|
</PRE>
|
|
|
|
in which "/path/to/mc-4.1.5.tar.g" is the path to the source file --
|
|
<I>i.e.,</I> if you downloaded the file to your home directory you'd use:
|
|
|
|
<PRE>
|
|
$ tar -xvzf ~/mc-4.1.5.tar.gz
|
|
</PRE>
|
|
|
|
This assumes that you're using the GNU version of tar which handles gzipped
|
|
files using the "-z" option. If you are using a different version
|
|
of tar you can also do:
|
|
|
|
<PRE>
|
|
$ gzip -dc /path/to/mc-4.1.5.tar.gz | tar -xvf -
|
|
</PRE>
|
|
|
|
<P>
|
|
After unarchiving the file change to the mc-4.1.5 directory where you'll find
|
|
both the sources and program documentation. The mc distribution comes with
|
|
two files outlining the installation process: INSTALL and INSTALL.FAST. If
|
|
you're not used to compiling programs from source then read INSTALL.FAST which
|
|
gives a concise explanation of the process as well as options that you can use
|
|
to customize where mc gets installed and what features it includes. If you're
|
|
a bit more adventurous, then have a look at the INSTALL document which goes
|
|
into a good deal more detail. For our purposes, I'll go through the process
|
|
of compiling mc with Virtual File System, SLang, and gpm mouse support (which
|
|
is very little work since these are the defaults). We'll install the mc
|
|
executable under /usr/local/bin and its support files under /usr/local/lib/mc.
|
|
You should log in as root in order to compile and install mc.
|
|
|
|
<P>
|
|
As with many other GNU programs, mc uses an autoconf script to detect the
|
|
various features of your system and then create the needed makefiles.
|
|
This greatly simplifies the build process. An additional feature that
|
|
this supports is the ability to declare compilation options such as what
|
|
features to include and where the program will be installed. Both INSTALL
|
|
and INSTALL.FAST give a listing of these features. We'll use:
|
|
|
|
<PRE>
|
|
$ ./configure --prefix=/usr/local --with-slang > configure.log 2>&1 &
|
|
$ tail -f configure.log
|
|
</PRE>
|
|
|
|
The mc configure script defaults to compiling in SLang, mouse, and X Window
|
|
support (so the --with-slang option wasn't really necessary). So as to have a
|
|
record of what happened use <KBD> > configure.log 2>&1</KBD> which
|
|
saves all the output to configure.log. Use <KBD>tail -f configure.log</KBD>
|
|
to view the log file as the configure script progresses. When configure is
|
|
finished it prints a summary of the features and compile options that will be
|
|
used. Use Control-C to exit out of tail.
|
|
|
|
<P>
|
|
If there were no error messages (and there should be none) then compiling and
|
|
installing is as simple as:
|
|
|
|
<PRE>
|
|
$ make
|
|
$ make install
|
|
</PRE>
|
|
|
|
If you want to create a log file of the build and installation process you can
|
|
use:
|
|
|
|
<PRE>
|
|
$ make > make.log 2>&1 &
|
|
$ tail -f make.log
|
|
$ make install > install.log 2>&1 &
|
|
$ tail -f install.log
|
|
</PRE>
|
|
|
|
<P>
|
|
And that should do it! To ensure that mc was installed properly type:
|
|
|
|
<PRE>
|
|
$ mc -V
|
|
|
|
Midnight Commander 4.1.5
|
|
with mouse support on xterm and the Linux console.
|
|
Edition: text mode
|
|
Virtual File System: tarfs, extfs, ftpfs, mcfs, undelfs.
|
|
With built in Editor
|
|
Using system-installed S-lang library with an unknown terminal database
|
|
With subshell support: as default
|
|
With DUSUM command
|
|
With support for background operations
|
|
</PRE>
|
|
|
|
This returns version and compilation information. If you've compiled and
|
|
installed the 4.1.5 version but <KBD>mc -V</KBD> returns a previous version
|
|
then you'll need to find and uninstall or rename the previous version. If
|
|
you use the bash shell, type:
|
|
|
|
<PRE>
|
|
$ type -a mc
|
|
</PRE>
|
|
|
|
This should return the paths to all mc executables. At this point, you can
|
|
either use your distribution's package manager to uninstall the previous
|
|
version or temporarily rename it to something like <KBD>mc.old</KBD>.
|
|
You should now be ready to start exploring mc!
|
|
|
|
<H2>The Midnight Commander Tour</H2>
|
|
|
|
<P>
|
|
Without trying to be exhaustive I'd like to touch on the following topics:
|
|
|
|
<UL>
|
|
<LI>the mc interface
|
|
<LI>directory navigation
|
|
<LI>file selection
|
|
<LI>basic file operations
|
|
<LI>viewing and editing files
|
|
<LI>using mc's panels
|
|
<LI>VFS coolness
|
|
<LI>popups, shortcuts, and a few more tricks
|
|
</UL>
|
|
|
|
and we'll finish with some closing remarks and suggestions. My aim is to
|
|
cover the salient features and give you a feel for what mc is able to do.
|
|
|
|
<H3>The mc Interface</H3>
|
|
|
|
While mc has a number of command line options, in normal use simply type
|
|
<KBD>mc</KBD> at the command prompt to start it. You can run mc either at the
|
|
console or in an xterm. If you use mc under X then I'd strongly suggest that
|
|
you rxvt instead of an xterm as both the colors and line drawing characters
|
|
are well supported under rxvt. As a side note, if you find that the line
|
|
drawing characters are not drawn correctly, then make sure that the TERM
|
|
environment variable has been set to "xterm":
|
|
|
|
<PRE>
|
|
$ echo $TERM
|
|
linux
|
|
|
|
(if this returns "linux" as above, then do the following:)
|
|
|
|
$ export TERM=xterm
|
|
$ echo $TERM
|
|
xterm
|
|
$ mc
|
|
</PRE>
|
|
|
|
At this point, you should see something like:
|
|
|
|
<P>
|
|
<IMG SRC="../gx/fisk/mc_main.gif" WIDTH=744 HEIGHT=394 ALIGN=BOTTOM>
|
|
|
|
<P>
|
|
This main screen is similar to what you'd see at the console (the window has
|
|
been sized to 80x24). It's main components are:
|
|
|
|
<UL>
|
|
<LI>menubar at the top which contains drop-down menus
|
|
<LI>directory panels which contain file listings
|
|
<LI>a "hint line"
|
|
<LI>a command line
|
|
<LI>function key labels at the bottom
|
|
</UL>
|
|
|
|
<P>
|
|
If you move the mouse around you should also see a pointer on the screen.
|
|
If you don't see a cursor when using mc at the console then make sure that the
|
|
gpm mouse server is running:
|
|
|
|
<PRE>
|
|
$ ps -ax | grep gpm
|
|
73 S0 S 0:00 /usr/bin/gpm -t ms
|
|
104 ? SW 0:00 (gpm-root)
|
|
5465 ? D 0:00 grep gpm
|
|
</PRE>
|
|
|
|
If it isn't then (assuming you're using a Microsoft-compatible serial mouse)
|
|
start it using <KBD>gpm -t ms</KBD>. The "-t" option specifies the
|
|
type of mouse; if you're using a different kind of mouse then consult the gpm
|
|
manual page for the command line option to use.
|
|
|
|
<P>
|
|
To activate one of the menus you can either click on it with the mouse or hit
|
|
the F9 key and use the arrow keys to move the desired menu item. This brings
|
|
up one of the important features of mc: almost all operations can be
|
|
performed using either the mouse or via keystrokes. Which method you use is a
|
|
matter of personal style and preference although, as we'll see in a bit, using
|
|
keystrokes can be a considerable time saver especially if you are a touch
|
|
typist.
|
|
|
|
<P>
|
|
The directory panels are where most of the action takes place. mc is normally
|
|
run in this two-panel mode although single panel mode is also supported.
|
|
The panels provide a view of two directories at once with one of them being the
|
|
"current directory." Most all file operations are performed on files
|
|
in this current directory (although copy, rename, and move operations default
|
|
to using the non-current directory as the "target" directory).
|
|
To select one directory panel simply click the mouse anywhere in the panel.
|
|
You can also use the TAB key to switch the current directory from one panel
|
|
to the other.
|
|
|
|
<P>
|
|
The command line at the bottom functions just as you'd expect: simply type
|
|
the command to execute and mc runs it just as if you'd entered it at the shell
|
|
prompt. Just above the command line is the hint line (at the console; in an
|
|
xterm it uses the title bar) which displays a series of hints and suggestions.
|
|
|
|
<P>
|
|
Finally, the bottom line of the window display the function key mappings.
|
|
Pressing F1 brings up the Help menu, F2 brings up the User Menu, F3 let's you
|
|
view a file, and so forth. Note that clicking on any of these with the mouse
|
|
results in the same action.
|
|
|
|
<P>
|
|
In addition to this main window there are a number of popup dialog boxes which
|
|
are used for specific operations. I'll cover several of these shortly. For
|
|
now, let's turn to issues of navigation.
|
|
|
|
<H3>Directory Navigation</H3>
|
|
|
|
Moving from one directory to another is quite simple: in the current
|
|
directory panel you can either:
|
|
|
|
<UL>
|
|
<LI>select a directory, by clicking on it with the mouse or moving to it
|
|
using the arrow keys, and then hit RETURN
|
|
<LI>double clicking on a directory using the mouse
|
|
<LI>use the <KBD>cd</KBD> command in the command line
|
|
</UL>
|
|
|
|
Any of these methods will cause the directory you've selected to be listed
|
|
in the current directory panel. Note that the <KBD>cd</KBD> command
|
|
understands "tilde expansion" which is a shortcut for referring
|
|
to your home directory -- <I>i.e.,</I> entering <KBD>cd ~/bin</KBD> would
|
|
change to the bin directory in your home directory. Also, clicking on the
|
|
".." entry will move to the current directory's parent as will
|
|
entering <KBD>cd ..</KBD> on the command line. There is also a Directory
|
|
Hotlist which we'll look at shortly that helps speed directory navigation.
|
|
|
|
<P>
|
|
One other navigation aid to keep in mind is that movement within the directory
|
|
panels can be accomplished using a variety of keystrokes, many of which are
|
|
modeled after the emacs text editor. These include:
|
|
|
|
<UL>
|
|
<LI>down arrow, Ctrl-n - move forward one line
|
|
<LI>up arrow, Ctrl-p - move backward one line
|
|
<LI>Page Down, Ctrl-v - move back one screen
|
|
<LI>Page Up, Alt-v - move backward one screen
|
|
<LI>Home, Alt-< - move to the top of the directory listing
|
|
<LI>End, Alt-> - move to the end of the directory listing
|
|
</UL>
|
|
|
|
Note that <I>Ctrl-n</I> means "hold down the control key and hit the
|
|
letter n." There are a few other movement keystrokes available, but
|
|
these are the most commonly used.
|
|
|
|
<P>
|
|
Once you know how to move from one directory to another the next thing to do
|
|
is learn how to perform basic file operations. But before doing that we'll
|
|
need to take a quick detour.
|
|
|
|
<H3>File Selection Mechanisms</H3>
|
|
|
|
Most of the time you'll be copying, renaming, deleting, or moving single files
|
|
and doing so is quite straightforward. However, there will assuredly be times
|
|
which you'll want to do something to several files or a group of related
|
|
files. Maybe you'll want to find an delete all the *.rej files after you've
|
|
run the patch program; or you want to find and move all *.tar.gz files to a
|
|
separate directory; or you want to copy selected documentation from a source
|
|
distribution to a /usr/doc directory for future reference. All of these
|
|
require selection of a group of files.
|
|
|
|
<P>
|
|
First, we need to make a distinction between the currently selected file or
|
|
directory and <I>marked or tagged</I> files. The currently selected file is
|
|
simply the one that is highlighted in the current directory panel. If you
|
|
want to delete <KBD>foo.txt</KBD> simply move the highlight bar to that file
|
|
and hit F8 to delete it. However, if you want to delete a group of files then
|
|
you'll need to <I>tag</I> them.
|
|
|
|
<P>
|
|
Tagging can be done in a couple ways. The simplest is to either click on the
|
|
file or directory using the right mouse button or move the highlight bar to
|
|
the file and hit Ctrl-t (that is, hold down the control key and hit t). In
|
|
this way you can tag any number of files for copy, deletion, moving, and so
|
|
forth.
|
|
|
|
<P>
|
|
If the files you want can be specified by a shell pattern (such as
|
|
<KBD>*.tar.gz</KBD> for all the gzipped tar files or <KBD>foo_??.txt</KBD> for
|
|
foo_01.txt, foo_02.txt, foo_03.txt, etc., then you can use the following
|
|
shortcuts:
|
|
|
|
<DL>
|
|
<DT><B>To select a group of files by pattern hit the "+" key</B>
|
|
<DD>This will cause a dialog box to appear in which you can enter the
|
|
search pattern. Note that entering the "*" wildcard will
|
|
select all the files in the directory.
|
|
<P>
|
|
|
|
<DT><B>To select all the files in the directory hit the "*"
|
|
key</B>
|
|
<DD>This has the same effect as using the + key and then entering
|
|
"*"
|
|
<P>
|
|
|
|
<DT><B>To unselect a group of files hit the "\" key or the
|
|
"-" key</B>
|
|
<DD>A dialog box similar to that with the + key will appear; if you want
|
|
to unselect all files then enter "*"
|
|
<P>
|
|
</DL>
|
|
|
|
<P>
|
|
Using pathname expansion (also known as filename globbing) is a fast and
|
|
powerful way to select a group of similar files. Having now selected your
|
|
files, let's see what you can do with them.
|
|
|
|
<H3>Basic File Operations</H3>
|
|
|
|
The Midnight Commander provides all of the basic UNIX file system operations
|
|
including copy, delete, move, rename, link, symbolic link, chown, view,
|
|
and edit. One of the nice features of mc is that it defaults to asking
|
|
for confirmation before taking destructive actions such as file deletion
|
|
or overwriting.This feature alone can save you a good deal of agony.
|
|
|
|
<P>
|
|
Below is a short summary of the file operations. In the next section we'll
|
|
look specifically at file viewing and editing. Keep in mind that while the
|
|
summary below indicates the keystrokes for the various operations, all of
|
|
these can be accessed using the "File" menu.
|
|
|
|
<DL>
|
|
<DT><B>copy: F5</B>
|
|
<DD>Normally, to copy a file from one directory to another select or tag
|
|
the file(s) to copy in the current directory panel and change to the
|
|
target directory in the other directory panel. Hit F5 or click on the
|
|
Copy function at the bottom. Doing so brings up a dialog box:
|
|
<P>
|
|
|
|
<IMG SRC="../gx/fisk/mc_copy.gif" ALIGN=BOTTOM WIDTH=744 HEIGHT=394>
|
|
|
|
<P>
|
|
If you want to use a different directory than the one in the other
|
|
panel or if you want to change the file name then you can use the
|
|
to: entry box to do so.
|
|
<P>
|
|
|
|
Also, when you perform a copy (and move or delete) operation mc
|
|
displays a dialog box with a progress meter indicating the progress on
|
|
the current file as well as the overall progress if a set of files has
|
|
been selected.
|
|
<P>
|
|
|
|
<DT><B>delete: F8</B>
|
|
<DD>After selecting or tagging a file or set of files hit F8 to delete
|
|
them. Note that you'll be asked for confirmation. Also, mc is able
|
|
to recursively delete a directory, but this, too, requires
|
|
confirmation. If you're having to clean out a directory then I'd
|
|
strongly suggest your using mc. It makes selecting files very easy
|
|
and helps prevent costly accidental deletions.
|
|
<P>
|
|
|
|
Note that at any time you can cancel an operation by hitting the
|
|
Escape key twice.
|
|
<P>
|
|
|
|
<DT><B>move/rename: F6</B>
|
|
<DD>These are very similar to the copy operation described above in that
|
|
the destination directory defaults to the non-current directory in the
|
|
case of the move operation. Note that renaming a file entails
|
|
"moving" it to another filename. In this case, use the to:
|
|
entry field in the dialog box to enter the new filename.
|
|
<P>
|
|
|
|
<DT><B>(hard) link: Ctrl-x l</B>
|
|
<DD>To create a hard link to a file, select that file and enter Ctrl-x
|
|
followed by the letter "l". A dialog box will prompt you
|
|
for the filename for the newly created link.
|
|
<P>
|
|
|
|
<DT><B>symbolic link: Ctrl-x s</B>
|
|
<DD>This is the same as that for a hard link except Ctrl-x is followed by
|
|
the letter "s".
|
|
<P>
|
|
|
|
<DT><B>chown: Ctrl-x o</B>
|
|
<DD>To change the owner or group of a file hit Ctrl-x followed by an
|
|
"o". A dialog box is presented that will allow you to select
|
|
owner and group from a list of valid values.
|
|
<P>
|
|
|
|
Note that an "Advanced Chown" facility is available under
|
|
the "File" menu. Until you're rather sure of what you're
|
|
doing, this is probably best left alone.
|
|
<P>
|
|
|
|
<DT><B>mkdir: F7</B>
|
|
<DD>While not a file operation <I>per se</I>, the MkDir command allows you
|
|
to create a new directory in the currently active directory. A dialog
|
|
box is presented that will prompt you for the new directory name.
|
|
<P>
|
|
</DL>
|
|
|
|
<P>
|
|
With these basic facilities you'll be able to do a good deal of day to day
|
|
file system maintenance. To round things out, though, we'll need to add a
|
|
couple other features.
|
|
|
|
<H3>File Viewing and Editing</H3>
|
|
|
|
The Midnight Commander comes with a very functional built in file viewer and
|
|
text/hex editor. To view or edit a file hit the F3 or F4 key respectively.
|
|
Of particular note is the fact that mc provides formatting support for
|
|
several common file formats including manual pages, HTML, and mail file. That
|
|
is, that rather than viewing the raw file, mc will format the file according
|
|
to the file format.
|
|
|
|
<P>
|
|
For example, to view a manual page (even a gzipped page!) simply select the
|
|
file and hit F3. If you have the mc source distribution handy, change to the
|
|
doc directory and select the mc.1 file. Hit F3 to see:
|
|
|
|
<P>
|
|
<IMG SRC="../gx/fisk/mc_view.gif" ALIGN=BOTTOM WIDTH=744 HEIGHT=394>
|
|
|
|
<P>
|
|
You can do similar things with HTML or mail files. In the case of HTML files
|
|
it is worth noting that "viewing" the file is probably not what you
|
|
expect as mc will strip out the hypertext tags leaving just the text. If you
|
|
want to view an HTML file it is best to select the file and hit the RETURN key.
|
|
Doing so "opens" the file and automatically executes (by default)
|
|
lynx if you are at a console or netscape if you are running under X.
|
|
|
|
<P>
|
|
The internal file view allows you to view files in one of two modes: ASCII or
|
|
hex. When using the file viewer you'll notice that the function keys at the
|
|
bottom change to a new set which are specific to the viewer. These include:
|
|
|
|
<UL>
|
|
<LI><B>F2</B> toggles line wrapping
|
|
<LI><B>F3</B> exit the viewer
|
|
<LI><B>F4</B> toggle hex view mode
|
|
<LI><B>F5</B> goto line; a dialog box appears which will prompt you for a
|
|
line number
|
|
<LI><B>F6</B> regular expression search
|
|
<LI><B>F7</B> normal search
|
|
<LI><B>F8</B> toggle raw or parsed mode
|
|
<LI><B>F9</B> toggle formated or unformatted mode: this affects attributes
|
|
such as bold or underline which are displayed using various colors
|
|
<LI><B>F10</B> exit the viewer
|
|
</UL>
|
|
|
|
<P>
|
|
In addition <B>Ctrl-s</B> and <B>Ctrl-r</B> can be used for normal or reverse
|
|
searches. Once you've started a search, hit the letter <B>n</B> to find the
|
|
next match. <B>Ctrl-l</B> will repaint the screen; <B>Alt-r</B> will toggle
|
|
the display of a ruler.
|
|
|
|
<P>
|
|
In terms of moving around the viewer, mc has a rather egalitarian attitude
|
|
and will accommodate almost any set of movement keystrokes that you've gotten
|
|
used including those for emacs, less, and even some vi. Some of these are:
|
|
|
|
<UL>
|
|
<LI><B>Home, Alt-<</B> - move to head of file
|
|
<LI><B>End, G, Alt-></B> - move to end of file
|
|
<LI><B>up/down arrows</B> - move forward or backward a single line
|
|
<LI><B>Ctrl-n, Ctrl-p</B> - move forward or backward a single line
|
|
<LI><B>left/right arrows</B> - scroll horizontally
|
|
<LI><B>Space, Page Down</B> - move forward one page
|
|
<LI><B>b, Page Up</B> - move back one page
|
|
</UL>
|
|
|
|
<P>
|
|
One very handy feature is that, if you are in View mode and hit <B>Ctrl-f</B>
|
|
then the viewer will move to the next file in the directory and display it.
|
|
In this way you can easily move through a set of files, viewing one right
|
|
after the other.
|
|
|
|
<P>
|
|
The internal file editor provides a full set of editing features and can be
|
|
used to edit both text and binary files up to a size of 16 megabytes. As with
|
|
the Viewer, function keys have been remapped to provide common file editing
|
|
functions. In addition, a popup menubar provides extensive editing
|
|
operations including file insertion, save, copy, and load; block operations
|
|
(copy, move, etc); search/replace functions; command macro recording and
|
|
execution; and the capacity to pipe selected text through various shell
|
|
commands such as indent or fmt. When not active, the menubar is hidden and
|
|
file information is displayed in the topmost line. Here's a screen dump of
|
|
the editor in action:
|
|
|
|
<P>
|
|
<IMG SRC="../gx/fisk/mc_editor.gif" ALIGN=BOTTOM WIDTH=744 HEIGHT=394>
|
|
|
|
<P>
|
|
Both the internal Viewer and Editor are designed to be fast and easy to use.
|
|
You may, however, wish to use an external viewer (such as <I>more</I>,
|
|
<I>less</I>, or <I>most</I>) or editor. To do so, you'll need to set your
|
|
PAGER and EDITOR environment variables to the appropriate program and then use
|
|
the Options->Configuration menu to unselect "use internal edit" or
|
|
"use internal view". If you were using the bash shell and wanted
|
|
to set the pager to "less" and the editor to "emacs",
|
|
then use something like:
|
|
|
|
<PRE>
|
|
$ export PAGER=less
|
|
$ export EDITOR=emacs
|
|
</PRE>
|
|
|
|
<P>
|
|
To make this change permanent you'd probably want to add these lines to your
|
|
~/.bashrc or ~/.bash_profile file. Having looked at the basic file operations
|
|
let's return to mc itself and take a look at some of its other features.
|
|
|
|
<H3>Using mc's Panels</H3>
|
|
|
|
We've already noted that the directory panels are where most of the
|
|
action takes place in terms of file operations. Accordingly there are a
|
|
number of keystroke (and mouse) shortcuts that quickly let you change the
|
|
panel view. In addition to directory listings, the panels can be quickly
|
|
changed to display directory trees, quick file views, or extensive
|
|
file information. If you spend much time at all working with files these
|
|
features are invaluable.
|
|
|
|
<H4>Basic Panel Operations</H4>
|
|
|
|
<P>
|
|
As previously noted, you can quickly switch from one panel to the other
|
|
using the <B>TAB</B> key (or <B>Ctrl-i</I>). You can also <I>swap</I>
|
|
panels using <B>Ctrl-u</I>; note that the currently active directory panel
|
|
does not change. Use <B>Ctrl-r</B> to refresh the directory display.
|
|
|
|
<P>
|
|
To change the sort order of the files being displayed, use the
|
|
<B>(Left|Right)->Sort Order...</B> menu item. This allows you to sort
|
|
files by name, size, various time stamps, inode number, and so forth.
|
|
You can also specify whether sorting should be case (in)sensitive or
|
|
reversed. Sorting by size is very useful when trying to cull out files to
|
|
recover disk space; sorting by date is useful when you are searching for a
|
|
recently installed, created, or modified file in a directory with many files
|
|
or are looking for ancient files that can safely be warehoused.
|
|
|
|
<P>
|
|
As with sorting, use the <B>(Left|Right)->Filter...</B> menu item to
|
|
filter the directory listing using shell patterns. For instance, suppose
|
|
that you wanted a listing containing only files with a .c extension.
|
|
In the Filter dialog simply enter "*.c" and all other files
|
|
are removed from the listing. This is very useful when you wish to
|
|
work with only a subset of files in a directory in an uncluttered setting.
|
|
|
|
<P>
|
|
You can also cycle from two-panel to single-panel modes using <B>Alt-t</B>.
|
|
This is particularly useful when you need to see the full directory
|
|
information for a particular file. Note that you can also use the
|
|
<B>(Left|Right)->Listing Mode...</B> menu item to customize what file
|
|
information the panel lists. In addition, resize the panels using the
|
|
<B>Options->Layout...</B> menu item. This allows you to split the panels
|
|
either vertically or horizontally as well as set the number of columns for
|
|
each panel using the ">" and "<" keys.
|
|
|
|
<H4>Panel Modes</H4>
|
|
|
|
Here's where the power of mc becomes apparent. The panels can be used in one
|
|
of four modes which can be switched using the <B>(Left|Right)</B> menus:
|
|
|
|
<DL>
|
|
<DT><B>Listing Mode...</B>
|
|
<DD>This is the default directory listing mode. As noted above, you can
|
|
customize what file information (name, permissions, time stamps, etc)
|
|
is displayed
|
|
<P>
|
|
|
|
<DT><B>Quick View...</B>
|
|
<DD>Provides a quick file viewer; it displays the file which has been
|
|
selected in the other panel. This is very handy if you need a quick
|
|
preview of a set of files. Note that the function key mappings at the
|
|
bottom of the window display the usual viewer operations: all of the
|
|
viewer features and keystrokes are available here. When previewing a
|
|
set of files try increasing the size of the viewing panel using the
|
|
<B>Options->Layout...</B> menu item.
|
|
<P>
|
|
|
|
<DT><B>Info</B>
|
|
<DD>This works in a manner similar to Quick View: it displays a wealth of
|
|
file or directory information.
|
|
<P>
|
|
|
|
<DT><B>Tree</B>
|
|
<DD>As with Quick View and Info, the Tree view works with the other panel:
|
|
it allows you to quickly navigate through the entire directory tree.
|
|
By double clicking on a directory (or selecting it and hitting RETURN)
|
|
its contents are displayed in the other panel
|
|
<P>
|
|
</DL>
|
|
|
|
<P>
|
|
One final shortcut to be aware of is <B>Alt-o</B> which makes use of both
|
|
panels: by selecting a directory in the active panel and hitting Alt-o, its
|
|
directory listing is displayed in the other panel. Hitting Alt-o repeatedly
|
|
lets you quickly preview through a series of directories.
|
|
|
|
<P>
|
|
Another powerful feature of mc is its ability to handle a multitude of archive
|
|
types: this feature alone makes it a "must have" utility!
|
|
|
|
<H3>VFS Coolness!</H3>
|
|
|
|
<P>
|
|
VFS refers to the "Virtual File System" which mc implements. It is
|
|
a powerful abstraction that allows you to view archives as though they were a
|
|
directory: all the basic file manipulation operations can then be applied.
|
|
The VFS file system handles an extraordinary number of archive types including
|
|
<B>tar</B>, <B>gzipped or compressed tar</B>, <B>RedHat's rpm package
|
|
archives</B>, <B>Debian's deb package archives</B>, <B>gzip</B>, <B>zip</B>,
|
|
<B>zoo</B>, <B>cpio</B>, <B>rar</B>, and <B>lha</B>.
|
|
|
|
<P>
|
|
To use it either select the file and hit RETURN or double click on the file.
|
|
It's contents are then displayed as a directory listing. Navigation through
|
|
the archive is the same as you'd use for a directory. This is a very useful
|
|
feature when you need a single file or set of files from an archive. Note
|
|
that if the archive is a compressed single file -- <I>i.e.,</I> a gzip, zip,
|
|
zoo, or lha compressed file -- then it is uncompressed and displayed.
|
|
|
|
<P>
|
|
The VFS also supports its own FTP capacity which allows you to transparently
|
|
manipulate files via FTP as though they were local to your machine. To log
|
|
into an FTP server use the <B>(Left|Right)->FTP Link...</B> menu item and
|
|
enter the URL or simply enter <KBD>cd ftp://"URL"</KBD> at the command line.
|
|
For example, to ftp to the Linux Incoming directory at sunsite you would
|
|
enter:
|
|
|
|
<PRE>
|
|
$ cd ftp://sunsite.unc.edu/pub/Linux/Incoming/
|
|
</PRE>
|
|
|
|
The hintbar at the console or the title bar under X will display progress
|
|
information (<I>e.g.,</I> logging in, retrieving directory listings, and so
|
|
forth). You can now view and copy files just as you would using ftp. On file
|
|
transfer (use F5 to "Copy" the file to your local machine) a
|
|
progress meter displays percent transfer completed, ETA (estimated time of
|
|
arrival), transfer rate, and the now commonplace "stalled" flag.
|
|
Use the <B>Options->Virtual FS...</B> menu item to customize the VFS
|
|
features such as anonymous login name and so forth.
|
|
|
|
<P>
|
|
<IMG SRC="../gx/fisk/mc_ftp.gif" ALIGN=BOTTOM WIDTH=744 HEIGHT=394>
|
|
|
|
<P>
|
|
Note that mc also provides FTP service via a proxy server as well as network
|
|
VFS. Having no experience with either of these I'll defer comment and simply
|
|
refer you to mc's manual page if you are interested.
|
|
|
|
<H3>Popups, Shortcuts, and a Few More Tricks...</H3>
|
|
|
|
<P>
|
|
In this last section let's look at a few more shortcuts and suggestions for
|
|
using mc effectively.
|
|
|
|
<P>
|
|
A number of popups are built into mc that considerably speed up various
|
|
operations. These include:
|
|
|
|
<DL>
|
|
<DT><B>Directory Hotlist: Ctrl-\</B>
|
|
<DD>Use this to create a popup hotlist of frequently accessed directories.
|
|
The hotlist keeps a list of "alias-directory path" pairs.
|
|
For example, if you use /usr/local/projects/C++/personal/ to store your
|
|
personal programming projects then you could create an entry using the
|
|
"New Entry" option and alias it to something like "Personal
|
|
C++ Projects".
|
|
<P>
|
|
|
|
If you use mc as an ftp client then you can use the directory hotlist
|
|
to keep the URL's for your frequented sites! To edit (add, modify, or
|
|
delete entries) the list type in <B>Ctrl-\</B> and then use "New
|
|
Entry" to create a new entry: enter the URL for the site,
|
|
including the path to the directory that you're interested in and then
|
|
fill in the alias. Now, anytime that you need to ftp just popup the
|
|
hotlist and select the site!
|
|
<P>
|
|
|
|
<DT><B>Filename Search: Ctrl-s, Alt-s</B>
|
|
<DD>At the bottom of each directory panel is a mini-status box which lists
|
|
the currently selected file or directory name. By hitting Ctrl-s or
|
|
Alt-s the status box becomes an entry box in which you type in a file
|
|
or directory name to search for. As you type, mc does an incremental
|
|
search and automatically selects the file which matches the search.
|
|
This is very handy when searching for a particular file in a large
|
|
directory.
|
|
<P>
|
|
|
|
<DT><B>Find File: Alt-?</B>
|
|
<DD>Find File provides an exceptionally fast and useful means of searching
|
|
for a particular file based on a filename pattern, its contents, or
|
|
both! For example, suppose that you kept a directory with USENET
|
|
postings that you wanted to save and you're now looking for
|
|
information on <I>mysql</I>. Use Find File with the "*"
|
|
pattern for the filename and "mysql" for its content. It
|
|
will then grep through the files and create a list of files containing
|
|
"mysql". Clicking on one of the files in the list selects
|
|
that file.
|
|
<P>
|
|
|
|
Alternatively, if you were looking for all files with
|
|
"announce" in the filename simply enter
|
|
"*announce*" in Filename: (and leave the Content:
|
|
entry box empty).
|
|
<P>
|
|
|
|
<DT><B>Active VFS Directories: Ctrl-x a</B>
|
|
<DD>This pops up a dialog box listing all of the active VFS directories
|
|
including those associated with FTP, archives, and so forth. When mc
|
|
creates a VFS directory for an archive, network, or ftp connection,
|
|
when you leave the directory the connection or resources are not
|
|
immediately freed. So, for example, if you created an ftp connection
|
|
to some host, you "close" it simply by changing back to a
|
|
local directory. Until the connection times out (which you can set
|
|
using the <B>Options->Virtual FS...->Timeout for freeing VFS's</B>
|
|
menu item) you can reestablish the connection once again. This also
|
|
works for archives (in this case, after the timeout, the memory
|
|
resources are deallocated).
|
|
<P>
|
|
|
|
<DT><B>Background Jobs: Ctrl-x j</B>
|
|
<DD>mc allows you to put copy and move operations into the background
|
|
(select this option from the Copy or Move dialog box) which allows you
|
|
to immediately return to mc. This is useful when you are
|
|
copying/moving a large number of files or for ftp. Use the Background
|
|
Jobs popup to quickly see what jobs are running and stop, restart, or
|
|
kill them
|
|
<P>
|
|
</DL>
|
|
|
|
<P>
|
|
Another very handy feature which mc provides is subshell support. The way
|
|
this works is by hitting <B>Ctrl-o</B> which creates a non-login interactive
|
|
shell. This works for bash, tcsh, and zsh shells. Use this shell just as you
|
|
would any ordinary shell. To immediately switch back to mc hit Ctrl-o once
|
|
again, which allows you to toggle back and forth easily.
|
|
|
|
<P>
|
|
If you are using the bash shell, keep in mind that non-login interactive
|
|
shells only source your ~/.bashrc file (and not the ~/.bash_profile file)
|
|
which means that if you have aliases or other customizations that you want to
|
|
use then you should put these in ~/.bashrc. For example, if you use color-ls
|
|
and find that file listings are not colorized, then you'll need to add
|
|
<KBD>alias ls='ls --color=tty'</KBD> to your ~/.bashrc.
|
|
|
|
<P>
|
|
One way to quickly create the "all-in-one-command-center" is execute
|
|
mc and then start a subshell. From here, you can execute your favorite editor
|
|
(emacs, xemacs, vim, etc.) and hit <B>Ctrl-z</B> to stop its execution and put
|
|
it in the background. This returns you to the shell. Now, if you need to run
|
|
mc then hit Ctrl-o; if you need to use your editor, type in <KBD>fg</KBD>
|
|
which will resume the stopped program; and if you need to run any other
|
|
program then use the shell as normal. This is a powerful means of keeping
|
|
productivity tools readily available.
|
|
|
|
<P>
|
|
One last feature I'd like to mention is mc's ability to help you sync
|
|
the contents of two directories. This is particularly useful if you are
|
|
keeping a backup set of files on another partition, a floppy, zip drive,
|
|
etc. To use this list the "source" directory in one panel and the
|
|
"target" directory in the other then hit <B>Ctrl-x d</B>. This will
|
|
pop up a dialog box that allows you to select the type of directory comparison:
|
|
<B>Size</B> simply compares files by size; <B>Quick</B> compares files by size
|
|
and date; and <B>Thorough</B> does an exhaustive byte-by-byte comparison.
|
|
After the comparison operation is complete (and after ensuring that the
|
|
<I>source</I> directory is in the active directory panel) hit F5 (Copy)
|
|
to copy files from your source directory to the target (backup) directory.
|
|
|
|
<H3>Closing Comments and Suggestions</H3>
|
|
|
|
I'd be remiss if I did not mention that mc comes with a very complete online
|
|
help system which is accessed using <B>F1</B>. All of the information
|
|
presented above, and a good deal more, can be accessed at any time from within
|
|
mc using the help facility. Additional information can be found in the source
|
|
distribution for mc: read the README, FAQ, and documents in the /doc
|
|
directory.
|
|
|
|
<P>
|
|
While I've attempted to cover most of the important features which mc offers
|
|
there are many more that I've not had time to cover that I'll leave for you to
|
|
discover! One suggestion would be to print out a copy of the mc manual page:
|
|
|
|
<PRE>
|
|
man mc | col -b | lpr -
|
|
|
|
-OR-
|
|
|
|
man mc | col -b > mc.txt
|
|
</PRE>
|
|
|
|
will print a copy of the manual page or save it to a text file which can be
|
|
further processed. Since the manual is quite long you might want to use a
|
|
program such as <B>a2ps</B> which converts ASCII files into Postscript. As
|
|
with most UNIX-type programs, a2ps has a slew of command line options
|
|
including the <KBD>-f</KBD> option which lets you specify the font size:
|
|
select something in the range of 7.0 to 9.0 to get a small font which cuts
|
|
down on the number of pages and leaves large margins in the sides for you to
|
|
scrawl notes in.
|
|
|
|
<P>
|
|
Also, while you are exploring, look through the <B>Options</B> menu for
|
|
various items which will let you customize mc. Menus are a great place to
|
|
poke around and see what facilities mc offers: most of the shortcut keystrokes
|
|
I've mentioned are menu items (so you don't have to memorize the entire list
|
|
of keystrokes!). For the adventurous:
|
|
|
|
<UL>
|
|
<LI>Have a look at the undelete file system if you are using ext2 under
|
|
Linux. You'll need the ext2progs distribution and libext2fs.a to
|
|
compile this support into mc.
|
|
<P>
|
|
<LI>Read about customizing the User Menu (this requires some knowledge of
|
|
shell programming and so was skipped in this introduction).
|
|
<P>
|
|
<LI>Read about customizing the Extension file which associates a file
|
|
extension with various actions (such as "viewing" or
|
|
"opening").
|
|
</UL>
|
|
|
|
<P>
|
|
Finally, enjoy mc! As with many powerful programs, you'll most likely learn
|
|
it incrementally, often just through the process of exploration and
|
|
"playing with it." I've found mc to be indispensable and, with a
|
|
bit of experience, I suspect that you will as well. Have fun!
|
|
|
|
<P>
|
|
<FONT SIZE=-1>
|
|
Date Last Modified: $Date: 2002/08/14 22:27:05 $
|
|
</FONT>
|
|
|
|
</BODY>
|
|
</HTML>
|