Manual |
Midnight Commander File Manager |
Written by the Midnight Commander development team mc-devel@nuclecu.unam.mx
v 4.5.27, 19 March 1999
This document describes how to use the GNU Midnight Commander, Unix file manager.
The [NEW] tag marks the sections which have been added since version 4.1.36
The [UPDATED] tag marks the sections which have been updated since version 4.1.36
mc [-abcCdfhkPstuUVx?] [-l log ] [dir1 [dir2]] [-v file] [-l file]
The Midnight Commander is a directory browser/file manager for Unix-like operating systems.
I know the bash function could be shorter for zsh and bash but the backquotes on bash won't accept your suspension the program with C-z.bash and zsh users:
mc () { MC=/tmp/mc$$-"$RANDOM" @prefix@/bin/mc -P "$@" > "$MC" cd "`cat $MC`" rm "$MC" unset MC; }
tcsh usres: alias mc 'setenv MC `@prefix@/bin/mc -P \!*`; cd $MC; unsetenv MC'
The screen of the Midnight Commander is divided into four parts. Almost all of the screen space is taken up by two directory panels. By default, the second bottommost line of the screen is the shell command line, and the bottom line shows the function key labels. The topmost line is the menu bar line. The menu bar line may not be visible, but appears if you click the topmost line with the mouse or press the F9 key.
The Midnight Commander provides a view of two directories at the same time. One of the panels is the current panel (a selection bar is in the current panel). Almost all operations take place on the current panel. Some file operations like Rename and Copy by default use the directory of the unselected panel as a destination (don't worry, they always ask you for confirmation first). For more information, see the sections on the Directory Panels, the Left and Right Menus and the File Menu.
You can execute system commands from the Midnight Commander by simply typing them. Everything you type will appear on the shell command line, and when you press Enter the Midnight Commander will execute the command line you typed; read the Shell Command Line and Input Line Keys sections to learn more about the command line.
The Midnight Commander comes with mouse support. It is activated whenever you are running on an xterm(1) terminal (it even works if you take a telnet or rlogin connection to another machine from the xterm) or if you are running on a Linux console and have the gpm(1) mouse server running.
When you left click on a file in the directory panels, that file is selected; if you click with the right button, the file is marked (or unmarked, depending on the previous state).
Double-clicking on a file will try to execute the command if it is an executable program; and if the extension file has a program specified for the file's extension, the specified program is executed.
Also, it is possible to execute the commands assigned to the function key labels by clicking on them.
If a mouse button is clicked on the top frame line of the directory panel, it is scrolled one pageful backward. Correspondingly, a click on the bottom frame line will cause a scroll of one pageful forward. This frame line method works also in the Help Viewer and the Directory Tree.
The default auto repeat rate for the mouse buttons is 400 milliseconds. This may be changed to other values by editing the ~/.mc/ini file and changing the mouse_repeat_rate parameter.
If you are running the Commander with the mouse support, you can bypass the Commander and get the default mouse behavior (cutting and pasting text) by holding down the Shift key.
Some commands in the Midnight Commander involve the use of the Control (sometimes labeled CTRL or CTL) and the Meta (sometimes labeled ALT or even Compose) keys. In this manual we will use the following abbreviations:
C-chr means hold the Control key while typing the character chr. Thus C-f would be: hold the Control key and type f.
M-chr means hold the Meta or Alt key down while typing chr. If there is no Meta or Alt key, type ESC, release it, then type the character chr.
All input lines in the Midnight Commander use an approximation to the GNU Emacs editor's key bindings.
There are many sections which tell about the keys. The following are the most important.
The File Menu section documents the keyboard shortcuts for the commands appearing in the File menu. This section includes the function keys. Most of these commands perform some action, usually on the selected file or the tagged files.
The Directory Panels section documents the keys which select a file or tag files as a target for a later action (the action is usually one from the file menu).
The Shell Command Line section list the keys which are used for entering and editing command lines. Most of these copy file names and such from the directory panels to the command line (to avoid excessive typing) or access the command line history.
Input Line Keys are used for editing input lines. This means both the command line and the input lines in the query dialogs.
Here are some keys which don't fall into any of the other categories:
This section lists the keys which operate on the directory panels. If you want to know how to change the appearance of the panels take a look at the section on Left and Right Menus.
This section lists keys which are useful to avoid excessive typing when entering shell commands.
The help viewer, the file viewer and the directory tree use common code to handle moving. Therefore they accept exactly the same keys. Each of them also accepts some keys of its own.
Other parts of the Midnight Commander use some of the same movement keys, so this section may be of use for those parts too.
The help viewer and the file viewer accept the following keys in addition the to ones mentioned above:
The input lines (they are used for the command line and for the query dialogs in the program) accept these keys:
The menu bar pops up when you press F9 or click the mouse on the top row of the screen. The menu bar has five menus: Left, File, Command, Options and Right.
The Left and Right Menus allow you to modify the appearance of the left and right directory panels.
The File Menu lists the actions you can perform on the currently selected file or the tagged files.
The Command Menu lists the actions which are more general and bear no relation to the currently selected file or the tagged files.
The outlook of the directory panels can be changed from the Left and Right menus.
The listing mode view is used to display a listing of files, there are four different listing modes available: Full, Brief, Long and User. The full directory view shows the file name, the size of the file and the modification time.
The brief view shows only the file name and it has two columns (therefore showing twice as many files as other views). The long view is similar to the output of ls -l command. The long view takes the whole screen width.
If you choose the User display format, then you have to specify the display format.
The user display format must start with a panel size specifier. This may be half or full, and they specify a half screen panel and a full screen panel respectively.
After the panel size, you may specify the two columns mode on the panel, this is done by adding the number 2 to the user format string.
After this you add the name of the fields with an optional size specifier. This are the available fields you may display:
Also you may use these field names for arranging the display:
To force one field to a fixed size (a size specifier), you just add a : and then the number of characters you want the field to have, if the number is followed by the symbol +, then the size specifies the minimum field size, if the program finds out that there is more space on the screen, it will then expand this field.
For example, the Full display corresponds to this format:
half type,name,|,size,|,mtime
And the Long display corresponds to this format:
full perm,space,nlink,space,owner,space,group,space,
size,space,mtime,space,name
This is a nice user display format:
half name,|,size:7,|,type,mode:3
Panels may also be set to the following modes:
The eight sort orders are by name, by extension, by modification time, by access time, and by inode information modification time, by size, by inode and unsorted. In the Sort order dialog box you can choose the sort order and you may also specify if you want to sort in reverse order by checking the reverse box.
By default directories are sorted before files but this can be changed from the Configuration (option "Mix all files").
The filter command allows you to specify a shell pattern (for example *.tar.gz) which the files must match to be shown. Regardless of the filter pattern, the directories and the links to directories are always shown in the directory panel.
The reread command reload the list of files in the directory. It is useful if other processes have created or removed files. If you have panelized file names in a panel this will reload the directory contents and remove the panelized information (See the section External panelize for more information).
The Midnight Commander uses the F1 - F10 keys as keyboard shortcuts for commands appearing in the file menu. The escape sequences for the Fkeys are terminfo capabilities kf1 trough kf10. On terminals without function key support, you can achieve the same functionality by pressing the ESC key and then a number in the range 1 through 9 and 0 (corresponding to F1 to F9 and F10 respectively).
The File menu has the following commands (keyboard shortcuts in parentheses):
This command is useful if you have a full command line and want to cd somewhere without having to yank and paste the command line. This command pops up a small dialog, where you enter everything you would enter after cd on the command line and then you press enter. This features all the things that are already in the internal cd command.
The Directory tree command shows a tree figure of the directories.
The Find file command allows you to search for a specific file. The "Swap panels" command swaps the contents of the two directory panels.
The Panels on/off command shows the output of the last shell command. This works only on xterm and on Linux and SCO console.
The Compare directories (C-x d) command compares the directory panels with each other. You can then use the Copy (F5) command to make the panels identical. There are three comparison methods. The quick method compares only file size and file date. The thorough method makes a full byte-by-byte compare. The thorough method is not available if the machine does not support the mmap(2) system call. The size-only compare method just compares the file sizes and does not check the contents or the date times, it just checks the file size.
The Command history command shows a list of typed commands. The selected command is copied to the command line. The command history can also be accessed by typing M-p or M-n.
The Directory hotlist (C-\) command makes changing of the current directory to often used directories faster.
The External panelize allows you to execute an external program, and make the output of that program the contents of the current panel.
Extension file edit command allows you to specify programs to executed when you try to execute, view, edit and do a bunch of other thing on files with certain extensions (filename endings). The Menu file edit command may be used for editing the user menu (which appears by pressing F2).
The Directory Tree command shows a tree figure of the directories. You can select a directory from the figure and the Midnight Commander will change to that directory.
There are two ways to invoke the tree. The real directory tree command is available from Commands menu. The other way is to select tree view from the Left or Right menu.
To get rid of long delays the Midnight Commander creates the tree figure by scanning only a small subset of all the directories. If the directory which you want to see is missing, move to its parent directory and press C-r (or F2).
You can use the following keys:
General movement keys are accepted.
The following actions are available only in the directory tree. They aren't supported in the tree view.
The mouse is supported. A double-click behaves like Enter. See also the section on mouse support.
The Find File feature first asks for the start directory for the search and the filename to be searched for. By pressing the Tree button you can select the start directory from the directory tree figure.
The contents field accepts regular expressions similar to egrep(1). That means you have to escape characters with a special meaning to egrep with "\", e.g. if you search for "strcmp (" you will have to input "strcmp \(" (without the double quotes).
You can start the search by pressing the Ok button. During the search you can stop from the Stop button and continue from the Start button.
You can browse the filelist with the up and down arrow keys. The Chdir button will change to the directory of the currently selected file. The Again button will ask for the parameters for a new search. The Quit button quits the search operation. The Panelize button will place the found files to the current directory panel so that you can do additional operations on them (view, copy, move, delete and so on). After panelizing you can press C-r to return to the normal file listing.
It is possible to have a list of directories that the Find File command should skip during the search (for example, you may want to avoid searches on a CDROM or on a NFS directory that is mounted across a slow link).
Directories to be skipped should be set on the variable find_ignore_dirs in the Misc section of your ~/.mc/ini file.
Directory components should be separated with a colon, here is an example:
[Misc] find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
You may consider using the External panelize command instead. Find file command is for simple queries only, while using External panelize you can do as mysterious searches as you would like.
The External panelize allows you to execute an external program, and make the output of that program the contents of the current panel.
For example, if you want to manipulate in one of the panels all the symbolic links in the current directory, you can use external panelization to run the following command:
find . -type l -print
Upon command completion, the directory contents of the panel will no longer be the directory listing of the current directory, but all the files that are symbolic links.
If you want to panelize all of the files that have been downloaded from your ftp server, you can use this awk command to extract the file name from the transfer log files:
awk '$9 ~! /incoming/ { print $9 }' < /usr/adm/xferlog
You may want to save often used panelize commands under a descriptive name, so that you can recall them quickly. You do this by typing the command on the input line and pressing Add new button. Then you enter a name under which you want the command to be saved. Next time, you just choose that command from the list and do not have to type it again.
The Directory hotlist command shows the labels of the directories in the directory hotlist. The Midnight Commander will change to the directory corresponding to the selected label. From the hotlist dialog, you can remove already created label/directory pairs and add new one. For adding you may want to use a standalone Add to hotlist command (C-x h), which adds the current directory into the directory hotlist, as well. The user is prompted for a label for the directory.
This makes cd to often used directories faster. You may also consider using the CDPATH variable as described in internal cd command description.
This will invoke your editor on the file ~/.mc/ext. The format of this file is as follows (the format has changed with version 3.0):
All lines starting with # or empty lines are thrown away.
Lines starting in the first column should have following format:
keyword/descNL, i.e. everything after keyword/ until new line is desc
keyword can be:
shell (desc is then any extension (no wildcards), i.e. matches all the files *desc. Example: .tar matches *.tar)
regex (desc is a regular expression)
type (file matches this if `file %f` matches regular expression desc (the filename: part from `file %f` islatex cur removed))
default (matches any file no matter what desc is)
Other lines should start with a space or tab and should be of the format:
keyword=commandNL (with no spaces around =), where keyword should be:
Open (if the user presses Enter or doubleclicks it), View (F3), Edit (F4), Drop (user drops some files on it) or any other user defined name (those will be listed in the extension dependent pop-up menu). Icon name is reserved for future use by mc.
command is any one-line shell command, with the simple macro substitution.
Target are evaluated from top to bottom (order is thus important). If some actions are missing, search continues as if this target didn't match (i.e. if a file matches the first and second entry and View action is missing in the first one, then on pressing F3 the View action from the second entry will be used. default should catch all the actions.
The user menu is a menu of useful actions that can be customized by the user. When you access the user menu, the file .mc.menu from the current directory is used if it exists, but only if it is owned by user or root and is not world-writable. If no such file found, ~/.mc/menu is tried in the same way, and otherwise mc uses the default system-wide menu @prefix@/lib/mc/mc.menu.
The format of the menu file is very simple. Lines that start with anything but space or tab are considered entries for the menu (in order to be able to use it like a hot key, the first character should be a letter). All the lines that start with a space or a tab are the commands that will be executed when the entry is selected.
When an option is selected all the command lines of the option are copied to a temporary file in the temporary directory (usually /usr/tmp) and then that file is executed. This allows the user to put normal shell constructs in the menus. Also simple macro substitution takes place before executing the menu code. For more information, see macro substitution.
Here is a sample mc.menu file:
A Dump the currently selected file od -c %fB Edit a bug report and send it to root vi /tmp/mail.$$ mail -s "Midnight Commander bug" root < /tmp/mail.$$
M Read mail emacs -f rmail
N Read Usenet news emacs -f gnus
H Call the info hypertext browser info
J Copy current directory to other panel recursively tar cf - . | (cd %D && tar xvpf -)
K Make a release of the current subdirectory echo -n "Name of distribution file: " read tar ln -s %d `dirname %d`/$tar cd .. tar cvhf ${tar}.tar $tar
= f *.tar.gz | f *.tgz & t n X Extract the contents of a compressed tar file tar xzvf %f
Default Conditions
Each menu entry may be preceded by a condition. The condition must start from the first column with a = character. If the condition is true, the menu entry will be the default entry.
Condition syntax: <cond> = <sub-cond> or: = <cond> | <cond> ... or: = <cond> & <cond> ...
Sub-condition is one of following:
f <pattern> current file matching pattern F <pattern> other file matching pattern d <pattern> current directory matching pattern D <pattern> other directory matching pattern t <type> current file of type T <type> other file of type ! <sub-cond> negate the result of sub-condition
Pattern is a normal shell pattern or a regular expression, according to the shell patterns option. You can override the global value of the shell patterns option by writing shell_patterns=x on the first line of the menu file (where "x" is either 0 or 1).
Type is one or more of the following characters:
For example rlf means either regular file, link or fifo. The t type is a little special because it acts on the panel instead of the file. The condition =t t is true if there are tagged files in the current panel and false if not.
If the condition starts with =? instead of = a debug trace will be shown whenever the value of the condition is calculated.
The conditions are calculated from left to right. This means
= f *.tar.gz | f *.tgz & t n
is calculated as
( (f *.tar.gz) | (f *.tgz) ) & (t n)
Here is a sample of the use of conditions:
= f *.tar.gz | f *.tgz & t n L List the contents of a compressed tar-archive gzip -cd %f | tar xvf -
Addition Conditions
If the condition begins with + (or +?) instead of = (or =?) it is an addition condition. If the condition is true the menu entry will be included in the menu. If the condition is false the menu entry will not be included in the menu.
You can combine default and addition conditions by starting condition with += or =+ (or +=? or =+? if you want debug trace). If you want to use two different conditions, one for adding and another for defaulting, you can precede a menu entry with two condition lines, one starting with + and another starting with =.
Comments are started with #. The additional comment lines must start with #, space or tab.
The Midnight Commander has some options that may be toggled on and off in several dialogs which are accessible from this menue. Options are enabled if they have an asterisk or "x" in front of them.
The Configuration command pops up a dialog from which you can change most of settings of the Midnight Commander.
The Display bits command pops up a dialog from which you may select which characters is your terminal able to display.
The Confirmation command pops up a dialog from which you specify which actions you want to confirm.
The Learn keys command pops up a dialog from which you test some keys which are not working on some terminals and you may fix them.
The Virtual FS command pops up a dialog from which you specify some VFS related options.
The Layout command pops up a dialog from which you specify a bunch of options how mc looks like on the screen.
The Save setup command saves the current settings of the Left, Right and Options menus. A small number of other settings is saved, too.
The options in this dialog are divided into three groups: Panel Options Pause after run and Other Options.
Panel Options
Pause after run
Other Options
This is used to configure the range of visible characters on the screen. This setting may be 7-bits if your terminal/curses supports only seven output bits, ISO-8859-1 displays all the characters in the ISO-8859-1 map and full 8 bits is for those terminals that can display full 8 bit characters.
In this menu you configure the confirmation options for file deletion, overwriting, execution by pressing enter and quitting the program.
This dialog lets you test if your keys F1-F20, Home, End, etc. work properly on your terminal. They often don't, since many terminal databases are broken.
You can move around with the Tab key, with the vi moving keys ('h' left, 'j' down, 'k' up and 'l' right) and after you press any arrow key once (this will mark it OK), then you can use that key as well.
You test them just by pressing each of them. As soon as you press a key and the key works properly, OK should appear next to the name of that key. Once a key is marked OK it starts to work as usually, e.g. F1 for the first time will just check that F1 works OK, but from that time on it will show help. The same applies to the arrow keys. Tab key should be working always.
If some keys do not work properly, then you won't see OK after the key name after you have pressed that key. You may then want to fix it. You do it by pressing the button of that key (either by mouse or using Tab and Enter). Then a red message will appear and you will be asked to type that key. If you want to abort this, press just Esc and wait until the message disappears. Otherwise type the key you're asked to type and also wait until the dialog disappears.
When you finish with all the keys, you may want either to Save your key fixes into your ~/.mc/ini file into the [terminal:TERM] section (where TERM is the name of your current terminal) or to discard them. If all your keys were working properly and you had not to fix any key, then (of course) no saving will occur.
This option gives you control over the settings of the Virtual File System information cache.
The Midnight Commander keeps in memory the information related to some of the virtual file systems to speed up the access to the files in the file system (for example, directory listings fetched from ftp servers).
Moreover in order to access the contents of compressed files (for eaxample, compressed tar files) the Midnight Commander has to create a temporary uncompressed file on your disk.
Since both the information in memory and the temporary files on disk take up resources, you may want to tune the parameters of the cached information to decrease your resource usage or to maximize the speed of access to frequently used file systems.
The Tar file system is quite clever about how it handles tar files: it just loads the directory entries and when it needs to use the information contained in the tar file, it goes and grab it.
In the wild, tar files are usually kept compressed (plain tar files are species in extinction), and because of the nature of those files (the directory entries for the tar files is not there waiting for us to be loaded), the tar file system has to uncompress the file on the disk in a temporary location and then access the uncompressed file as a regular tar file.
Now, since we all love to browse files and tar files all over the disk, it's common that you will leave a tar file and the re-enter it later. Since uncompression is slow, the Midnight Commander will cache the information in memory for a limited amount of time, after you hit the timeout, all of the resources associated with the file system will be freed. The default timeout is set to one minute.
The
Moreover you can define a proxy host for doing ftp transfers
and configure the Midnight Commander to always use the proxy host. See
the section on
The layout dialog gives you a possibility to change the
general layout of screen. You can specify whether the
menubar, the command prompt, the hintbar and the function
keybar are visible. On the Linux or SCO console you can specify
how many lines are shown in the output window.
The rest of the screen area is used for the two directory
panels. You can specify whether the area is split to the
panels in vertical or horizontal direction. The split can
be equal or you can specify an unequal split.
By default all contents of the directory panels are displayed with
the same color, but you can specify whether permissions and
file types are highlighted with special Colors.
If permission highlighting is enabled, the parts of the perm
and mode display fields
which are valid for the user running Midnight Commander
are highlighted with the color defined with the selected
keyword.
If file type highlighting is enabled, files are colored according
to their file type (e.g. directory, core file, executable, ...).
If the Show Mini-Status option is enabled, one line of status
information about the currently selected item is showed at the bottom
of the panels.
At startup the Midnight Commander will try to load
initialization information from the ~/.mc/ini file. If
this file doesn't exist, it will load the information from
the system-wide configuration file, located in
@prefix@/lib/mc/mc.ini. If the system-wide configuration
file doesn't exist, MC uses the default settings.
The Save Setup command creates the ~/.mc/ini file by
saving the current settings of the Left, Right and
Options menus.
If you activate the auto save setup option, MC will always
save the current settings when exiting.
There also exist settings which can't be changed from the
menus. To change these settings you have to edit the setup
file with your favorite editor. See the section on
Special Settings for more information.
You may execute commands by typing them directly in the
Midnight Commander's input line, or by selecting the
program you want to execute with the selection bar in one
of the panels and hitting Enter.
If you press Enter over a file that is not executable, the
Midnight Commander checks the extension of the selected
file against the extensions in the Extensions File. If a
match is found then the code associated with that
extension is executed. A very simple macro expansion
takes place before executing the command.
The cd command is interpreted by the Midnight Commander,
it is not passed to the command shell for execution. Thus
it may not handle all of the nice macro expansion and
substitution that your shell does, although it does some of
them:
Tilde substitution The (~) will be substituted with your
home directory, if you append a username after the tilde,
then it will be substituted with the login directory of
the the specified user.
For example, ~guest is the home directory for the user
guest, while ~/guest is the directory guest in your home
directory.
Previous directory You can jump to the directory you were
previously by using the special directory name '-' like
this: cd -
CDPATH directories If the directory specified to the cd
command is not in the current directory, then The Midnight
Commander uses the value in the environment variable
CDPATH to search for the directory in any of the named
directories.
For example you could set your CDPATH variable to
~/src:/usr/src, allowing you to change your directory to
any of the directories inside the ~/src and /usr/src
directories, from any place in the file system by using
it's relative name (for example cd linux could take you to
/usr/src/linux).
When accessing a user menu or executing an
extension dependent command
or running a command from the command
line input, a simple macro substitution takes place.
The macros are:
"%f" The current file name.
"%d" The current directory name.
"%F" The current file in the unselected panel.
"%D" The directory name of the unselected panel.
"%t" The currently tagged files.
"%T" The tagged files in the unselected panel.
The subshell support is a compile time option, that works
with the shells: bash, tcsh and zsh.
When the subshell code is activated the Midnight Commander
will spawn a concurrent copy of your shell (the one
defined in the SHELL variable and if it is not defined,
then the one in the /etc/passwd file) and run it in a
pseudo terminal, instead of invoking a new shell each time
you execute a command, the command will be passed to the
subshell as if you had typed it. This also allows you to
change the environment variables, use shell functions and
define aliases that are valid until you quit the Midnight
Commander.
If you are using bash you can specify startup
commands for the subshell in your ~/.mc/bashrc file and
special keyboard maps in the ~/.mc/inputrc file.
tcsh users may specify startup commands in the
~/.mc/tcshrc file.
When the subshell code is used, you can suspend
applications at any time with the sequence C-o and jump
back to the Midnight Commander, if you interrupt an
application, you will not be able to run other external
commands until you quit the application you interrupted.
An extra added feature of using the subshell is that the
prompt displayed by the Midnight Commander is the same
prompt that you are currently using in your shell.
The Options section has more
information on how you can control the subshell code.
The Midnight Commander defines an environment variable
MC_CONTROL_FILE. The commands executed by MC may give
instructions to MC by writing to the file specified by
this variable. This is only available if you compiled your
copy of the Midnight Commander with the WANT_PARSE option.
The following instructions are supported.
If the first letter of the instruction is in lower case it
operates on the current panel. If the letter is in upper
case the instruction operates on the other panel. The
additional letters must be in lower case. Instructions
must be separated by exactly one space, tab or newline.
The instructions don't work in the Info, Tree and Quick
views. The first error causes the rest to be ignored.
The Chmod window is used to change the attribute bits in a
group of files and directories. It can be invoked with the
C-x c key combination.
The Chmod window has two parts - Permissions and File.
In the File section are displayed the name of the file or
directory and its permissions in octal form, as well as
its owner and group.
In the Permissions section there is a set of check buttons
which correspond to the file attribute bits. As you change
the attribute bits, you can see the octal value change in
the File section.
To move between the widgets (buttons and check buttons)
use the arrow keys or the Tab key. To change the state of
the check buttons or to select a button use Space. You can
also use the hotkeys on the buttons to quickly activate
that selection (they are the highlit letters on the
buttons).
To set the attribute bits, use the Enter key.
When working with a group of files or directories, you
just click on the bits you want to set or clear. Once you
have selected the bits you want to change, you select one
of the action buttons (Set marked or Clear marked).
Finally, to set the attributes exactly to those specified,
you can use the [Set all] button, which will act on all
the tagged files.
[Marked all] set only marked attributes to all selected
files
[Set marked] set marked bits in attributes of all selected
files
[Clean marked] clear marked bits in attributes of all
selected files
[Set] set the attributes of one file
[Cancel] cancel the Chmod command
The Chown command is used to change the owner/group of a
file. The hot key for this command is C-x o.
The Advanced Chown command is the Chmod
and Chown command combined into one
window. You can change the permissions and owner/group of
files at once.
When you copy, move or delete files the Midnight Commander
shows the file operations dialog. It shows the files
currently being operated on and there are at most three
progress bars. The file bar tells how big part of the
current file has been copied so far. The count bar tells
how many of tagged files have been handled so far. The
bytes bar tells how big part of total size of the tagged
files has been handled so far. If the verbose option is
off the file and bytes bars are not shown.
There are two buttons at the bottom of the dialog.
Pressing the Skip button will skip the rest of the current
file. Pressing the Abort button will abort the whole
operation, the rest of the files are skipped.
There are three other dialogs which you can run into
during the file operations.
The error dialog informs about error conditions and has
three choices. Normally you select either the Skip button
to skip the file or the Abort button to abort the
operation altogether. You can also select the Retry button
if you fixed the problem from another terminal.
The replace dialog is shown when you attempt to copy or
move a file on the top of an existing file. The dialog
shows the dates and sizes of the both files. Press the Yes
button to overwrite the file, the No button to skip the
file, the alL button to overwrite all the files, the nonE
button to never overwrite and the Update button to
overwrite if the source file is newer than the target
file. You can abort the whole operation by pressing the
Abort button.
The recursive delete dialog is shown when you try to
delete a directory which is not empty. Press the Yes
button to delete the directory recursively, the No button
to skip the directory, the alL button to delete all the
directories and the nonE button to skip all the non-empty
directories. You can abort the whole operation by pressing
the Abort button.
If you have tagged files and perform an operation on them
only the files on which the operation succeeded are
untagged. Failed and skipped files are left tagged.
The copy/move operations lets you translate the names of
files in an easy way. To do it, you have to specify the
correct source mask and usually in the trailing part of
the destination specify some wildcards. All the files
matching the source mask are copied/renamed according to
the target mask. If there are tagged files, only the
tagged files matching the source mask are renamed.
There are other option which you can set:
You want to copy content of a directory foo to /bla/foo,
which is an already existing directory. Normally (when
Dive is not set), mc would copy it exactly into /bla/foo.
By enabling this option you will copy the content into /bla/foo/foo,
because the directory already exists.
When the shell patterns option is on you can use the '*'
and '?' wildcards in the source mask. They work like they
do in the shell. In the target mask only the '*' and
'\<digit>' wildcards are allowed. The first '*' wildcard in
the target mask corresponds to the first wildcard group in
the source mask, the second '*' corresponds to the second
group and so on. The '\1' wildcard corresponds to the
first wildcard group in the source mask, the '\2' wildcard
corresponds to the second group and so on all the way up
to '\9'. The '\0' wildcard is the whole filename of the
source file.
Two examples:
If the source mask is "*.tar.gz", the destination is
"/bla/*.tgz" and the file to be copied is "foo.tar.gz",
the copy will be "foo.tgz" in "/bla".
Let's suppose you want to swap basename and extension so
that "file.c" will become "c.file" and so on. The source
mask for this is "*.*" and the destination is "\2.\1".
When the shell patterns option is off the MC doesn't do
automatic grouping anymore. You must use '\(...\)'
expressions in the source mask to specify meaning for the
wildcards in the target mask. This is more flexible but
also requires more typing. Otherwise target masks are
similar to the situation when the shell patterns option is
on.
Two examples:
If the source mask is "^\(.*\)\.tar\.gz$", the destination
is "/bla/*.tgz" and the file to be copied is "foo.tar.gz",
the copy will be "/bla/foo.tgz".
Let's suppose you want to swap basename and extension so
that "file.c" will become "c.file" and so on. The source
mask for this is "^\(.*\)\.\(.*\)$" and the destination is
"\2.\1".
You can also change the case of the filenames. If you use
'\u' or '\l' in the target mask the next character will be
converted to uppercase or lowercase correspondingly.
If you use '\U' or '\L' in the target mask the next
characters will be converted to uppercase or lowercase
correspondingly up to the next '\E' or next '\U', '\L' or
the end of the file name.
The '\u' and '\l' are stronger than '\U' and '\L'.
For example, if the source mask is '*' (shell patterns on)
or '^\(.*\)$' (shell patterns off) and the target mask is
'\L\u*' the file names will be converted to have initial
upper case and otherwise lower case.
You can also use '\' as a quote character. For example,
'\\' is a backslash and '\*' is an asterisk.
The internal file viewer provides two display modes: ASCII
and hex. To toggle between modes, use the F4 key. If you
have the GNU gzip program installed, it will be used to
automatically decompress the files on demand.
The viewer will try to use the best method provided by
your system or the file type to display the information.
The internal file viewer will interpret some string
sequences to set the bold and underline attributes, thus
making a pretty display of your files.
When in hex mode, the search function accepts text in
quotes as well as hexadecimal constants.
You can mix quoted text with constants like this: "String"
0xFE 0xBB "more text". Text between constants and quoted
text is just ignored.
Some internal details about the viewer: On systems that
provide the mmap(2) system call, the program maps the file
instead of loading it; if the system does not provide the
mmap(2) system call or the file matches an action that
requires a filter, then the viewer will use it's growing
buffers, thus loading only those parts of the file that
you actually access (this includes compressed files).
Here is a listing of the actions associated with each key
that the Midnight Commander handles in the internal file
viewer.
It's possible to instruct the file viewer how to display a
file, look at the Extension File Edit section
The internal file editor provides most of the features of
common full screen editors. It is invoked using F4 provided
the use_internal_edit option is set in the initialization file. It has an
extensible file size limit of sixteen megabytes and edits binary files
flawlessly. The features it presently supports are: Block
copy, move, delete, cut, paste; key for key undo; pull-down
menus; file insertion; macro definition; regular expression
search and replace (and our own scanf-printf search and
replace); shift-arrow MSW-MAC text highlighting (for the
linux console only); insert-overwrite toggle; word-wrap; a variety of
tabbing options; syntax highlighting for various file types; and an option
to pipe text blocks through shell commands like indent and ispell.
The editor is very easy to use and requires no tutoring.
To see what keys do what, just consult the appropriate
pull-down menu. Other keys are: Shift movement
keys do text highlighting. Ctrl-Ins copies to the file
.cedit/cooledit.clip and Shift-Ins
pastes from .cedit/cooledit.clip.
Shift-Del cuts to .cedit/cooledit.clip, and
Ctrl-Del deletes highlighted text (all Linux console only).
The completion key also does a Return
without an automatic indent. Mouse highlighting also works, and you
can override the mouse as usual by holding down the shift key
while dragging the mouse to let normal terminal mouse highlighting
work.
You can also enable rudimentary Emacs key binding support
by adding the line
To define a macro, press Ctrl-R and then type out the key
strokes you want to be executed. Press Ctrl-R again when
finished. You can then assign the macro to any key you like
by pressing that key. The macro is executed when you
press Ctrl-A and then the assigned key. The macro is also
executed if you press Meta, Ctrl, or Esc and the assigned
key, provided that the key is not used for any other
function. Once defined, the macro commands go into the
file .cedit/cooledit.macros in your home directory.
You can delete a macro by deleting the appropriate line in
this file.
F19 will format C code when it is highlighted
and C-p will do spell checks. M-t will also
run the sort shell command. To see how
to set this up, look at the mcedit.1
man page.
You can use scanf search and replace to search and replace
a C format string. First take a look at the sscanf
and sprintf man pages to see what a format string
is and how it works. An example is as follows: Suppose I want
to replace all occurences of say, an open bracket, three
comma seperated numbers, and a close bracket, with the
word "apples", the third number, the word
"oranges" and then the second number, I would
fill in the Replace dialog
box as follows:
The last line specifies that the third and then the second
number are to be used in place of the first and second.
It is advisable to use this feature with Prompt on replace
on, because a match is thought to be found whenever the number
of arguments found matches the number given, which is not always
a real match. Scanf also treats whitespace as being elastic.
Note that the scanf format %[ is very useful for
scanning strings, and whitespace.
The editor also displays non-us characters (160+). When editing
binary files, you should set display bits to 7 bits in the
options menu to keep the spacing clean.
See also the mcedit.1 man page for lots more information,
including details on creating syntax highlighting rules.
A variety of tabbing and indenting options are available which
are described in this man page.
Let the Midnight Commander type for you.
Attempt to perform completion on the text before current
position. MC attempts completion treating the text as
variable (if the text begins with $ ), username (if the
text begins with ~ ), hostname (if the text begins with @)
or command (if you are on the command line in the
position where you might type a command, possible
completions then include shell reserved words and shell
builtin commands as well) in turn. If none of these
produces a match, filename completion is attempted.
Filename, username, variable and hostname completion works
on all input lines, command completion is command line
specific. If the completion is ambiguous (there are more
different possibilities), MC beeps and the following
action depends on the setting of the Complete: show all
option in the Configuration
dialog. If it is enabled, a
list of all possibilities pops up next to the current
position and you can select with the arrow keys and Enter
the correct entry. You can also type the first letters in
which the possibilities differ to move to a subset of all
possibilities and complete as much as possible. If you
press M-Tab again, only the subset will be shown in the
listbox, otherwise the first item which matches all the
previous characters will be highlighted. As soon as there
is no ambiguity, dialog disappears, but you can hide it by
canceling keys Esc, F10 and left and right arrow keys. If
Complete: show all
Configuration is disabled,
the dialog pops up
only if you press M-Tab for the second time, for the first
time MC just beeps.
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 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) or you may
directly change your current directory to it using the cd
command to a path name that looks like this:
/#ftp:[!][user@]machine[:port][remote-dir]
The, user, port and remote-dir elements are optional. If
you specify the user element, then the Midnight Commander
will try to logon on the mremote machine as that user,
otherwise it will use your login name. The optional pass element,
if present is the password used for the connection. This use
is not recomented (nor keeping this in your hotlist, unless you set
the appropiate permissions there, and then, it may not be entirely
safe anyways).
Examples:
To connect to sites behind a firewall, you will need to use the prefix
ftp://! (ie, with a bang character after the double slash) to make the
Midnight Commander use a proxy host for doing the ftp transfer. You
can define the proxy host in the Virtual FS
Virtual File System dialog box.
Another option to set is the Always use ftp proxy
option in the Virtual FS
dialog box. This will configure the program
to always use the proxy host. If this variable is set, the program
will do two things: consult the @prefix@/lib/mc.no_proxy file for
lines containing host names that are local (if the host name starts
with a dot, it is assumed to be a domain) and to assume that any
hostnames without dots in their names are directly accessible.
If you are using the ftpfs code with a filtering packet router that
does not allow you to use the regular mode of opening files, you may
want to force the program to use the passive-open mode. To use this,
set the ftpfs_use_passive_connections option in the initialization file.
The Midnight Commander keeps the directory listing in a cache. The cache
expire time is configurable in the Virtual FS
dialog box. This has the funny behavior that even if you make changes to a
directory, they will not be reflected in the directory listing until you
force a cache reload with the C-r key. This is a feature (when you think
it's a bug, think about manipulating files on the other side of the Atlantic
with ftpfs).
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]
The mc.ext file already provides a shortcut for tar files,
this means that usually you just point to a tar file and
press return to enter into the tar file, see the Extension
File Edit section for details on how this is done.
Examples:
The latter specifies the full path of the tar archive.
The fish file system is a network based file system that allows you to
manipulate the files in a remote machine as if they were local. To use
this, the other side has to either run fish server, or has to have
bash-compatible shell.
To connect to a remote machine, you just need to chdir
into a special directory which name is in the following
format:
/#sh:[user@]machine[:options]/[remote-dir]
The, user, options and remote-dir elements are optional. If
you specify the user element then the Midnight Commander
will try to logon on the remote machine as that user,
otherwise it will use your login name.
The options are 'C' - use compression and 'rsh' use rsh instead
of ssh. If the remote-dir element is present, your current
directory on the remote machine will be set to this one.
Examples:
The Midnight Commander file system is a network base file
system that allows you to manipulate the files in a remote
machine as if they were local. To use this, the remote
machine must be running the mcserv(8) server program.
To connect to a remote machine, you just need to chdir
into a special directory which name is in the following
format:
/#mc:[user@]machine[:port]/[remote-dir]
The, user, port and remote-dir elements are optional. If
you specify the user element then the Midnight Commander
will try to logon on the remote machine as that user,
otherwise it will use your login name.
The port element is used when the remote machine running
on a special port (see the mcserv(8) manual page for more
information about ports); finally, if the remote-dir
element is present, your current directory on the remote
machine will be set to this one.
Examples:
On Linux systems, if you asked configure to use the ext2fs undelete
facilities, you will have the undelete file system available.
Recovery of deleted files is only available on ext2 file systems. The
undelete file system is just an interface to the ext2fs library to:
retrieve all of the deleted files names on an ext2fs and provides and
to extract the selected files into a regular partition.
To use this file system, you have to chdir into the special file name
formed by the "/#undel:" prefix and the file name where the actual
file system resides.
For example, to recover deleted files on the second partition of the
first scsi disk on Linux, you would use the following path name:
It may take a while for the undelfs to load the required information
before you start browsing files there.
The Midnight Commander will try to detect if your terminal
supports color using the terminal database and your
terminal name. Sometimes it gets confused, so you may
force color mode or disable color mode using the -c and -b
flag respectively.
If the program is compiled with the Slang screen manager
instead of ncurses, it will also check the variable
COLORTERM, if it is set, it has the same effect as the -c
flag.
You may specify terminals that always force color mode
by adding the color_terminals variable to the Colors
section of the initialization file. This will prevent the
Midnight Commander from trying to detect if your terminal
supports color. Example:
The format is:
The program can be compiled with both ncurses and slang,
ncurses does not provide a way to force color mode:
ncurses uses just the information in the terminal
database.
The Midnight Commander provides a way to change the
default colors. Currently the colors are configured using
the environment variable MC_COLOR_TABLE or the Colors
section in the initialization file.
In the Colors section, the default color map is loaded
from the base_color variable. You can specify an
alternate color map for a terminal by using the terminal
name as the key in this section. Example:
The format for the color definition is:
The colors are optional, and the keywords are: normal,
selected, marked, markselect, errors, input, reverse, gauge;
Menu colors are: menu, menusel, menuhot, menuhotsel; Dialog colors
are: dnormal, dfocus, dhotnormal, dhotfocus; Help colors
are: helpnormal, helpitalic, helpbold, helplink, helpslink;
Viewer color is: viewunderline; Special highlighting colors are:
executable, directory, link, device, special, core; Editor colors
are: editnormal, editbold, editmarked.
input determines the color of input lines used in query dialogs.
gauge determines the color of the filled part of the progress bar
(gauge), which shows how many percent of files were copied
etc. in a graphical way.
The dialog boxes use the following colors: dnormal is
used for the normal text, dfocus is the color used for the
currently selected component, dhotnormal is the color used
to differentiate the hotkey color in normal components,
whereas the dhotfocus color is used for the highlighted
color in the currently selected component.
Menus use the same scheme but uses the menu, menusel,
menuhot and menuhotsel tags instead.
Help uses the following colors: helpnormal is used for
normal text, helpitalic is used for text which is
emphasized in italic in the manual page, helpbold is used
for text which is emphasized in bold in the manual page,
helplink is used for not selected hyperlinks and helpslink
is used for a selected hyperlink.
Special highlight colors determine how files are displayed
when file highlighting is enabled (see the section on
Layout).
directory is used for directories or symbolic links to directories;
executable for executable files;
link is used for symbolic links which are neither stalled nor linked
to a directory; stalledlink is used for stalled symbolic links;
device - character and block devices;
special is used for special files, such as FIFOs and IPC
sockets; core is for core files.
The possible colors are: black, gray, red, brightred, green,
brightgreen, brown, yellow, blue, brightblue, magenta,
brightmagenta, cyan, brightcyan, lightgray and white. An there is a special
keyword for transparent background. It is 'default'. The 'default' can only
be used for background color. Example:
Most of the settings of the Midnight Commander can be
changed from the menus. However, there is a small number
of settings which can only be changed by editing the setup
file.
These variables may be set in your ~/.mc/ini file:
The Midnight Commander provides a way to fix your system
terminal database without requiring root privileges. The
Midnight Commander searches in the system initialization
file (the mc.lib file located in the Midnight Commander
library directory) or in the ~/.mc/ini file for the
section "terminal:your-terminal-name" and then for the
section "terminal:general", each line of the section
contains a key symbol that you want to define, followed by
an equal sign and the definition for the key. You can use
the special \E form to represent the escape character and
the ^x to represent the control-x character.
The possible key symbols are:
For example, to define the key insert to be the
Escape + [ + O + p, you set this in the ini file:
The complete key symbol represents the escape sequences
used to invoke the completion process, this is invoked
with M-tab, but you can define other keys to do the same
work (on those keyboard with tons of nice and unused keys
everywhere).
You can use the cursor keys or mouse to navigate in the
internal help viewer.
Press down arrow to move to the next item or scroll down.
Press up arrow to move to the previous item or scroll up.
Press right arrow to follow the current link.
Press left arrow to go back in the history of nodes that
you have visited.
If you terminal doesn't support the cursor keys you can
use the space bar to scroll forward and the b key scroll
back. Use the TAB key to move to the next item and press
ENTER to follow the current link. The l (last) key may
be used to go back in the history of nodes that you have
visited. Press ESC to exit the help viewer.
The left mouse button will follow the link or scroll. The
right mouse button can be used to go back in the history
of nodes.
The full key list of the help viewer:
General movement keys are accepted.
Normally there is no sense in doing it
because the Midnight Commander automatically updates this
file for you.
The latest version of this program can be found at
ftp://ftp.nuclecu.unam.mx/linux/local/ and in
Europe from ftp://sunsite.mff.cuni.cz/GNU/mc and
ftp://ftp.teuto.de/lmb/mc.
ed(1), gpm(1), mcserv(8), terminfo(1), view(1), sh(1),
bash(1), tcsh(1), zsh(1).
The Midnight Commander page on the World Wide Web:
http://www.gnome.org/mc/
Alessandro Rubini (rubini@ipvvis.unipv.it) has been especially helpful
debugging and enhancing the program's mouse support, John
Davis (davis@space.mit.edu) made his S-Lang library
available to us under the GPL and answered my questions
about it, and the following people have contributed code
and many bug fixes (in alphabetical order):
See the file TODO in the distribution for information on
what remains to be done.
If you want to report a problem with the program, please send mail to
this address: mc-bugs@roxanne.nuclecu.unam.mx.
Provide a detailed description of the bug, the version of the program
you are running (mc -V display this information), the operating system
you are running the program on and if the program crashes, we would
appreciate a stack trace.
7.4.6 [UPDATED] Layout
7.4.7 Save Setup
8 Executing operating system commands
8.1 The cd internal command
8.2 Macro Substitution
8.3 The subshell support
8.4 Controlling Midnight Commander
9 Chmod
10 Chown
11 [NEW] Advanced Chown
12 File Operations
13 Mask Copy/Rename
14 Internal File Viewer
15 Internal File Editor
edit_key_emulation=1
in your ~/.mc/ini file. A zero value is for normal
keys.
Enter search string
(%d,%d,%d)
Enter replace string
apples %d oranges %d
Enter replacement argument order
3,2
16 [UPDATED] Completion
17 [UPDATED] Virtual File System
17.1 [UPDATED] FTP File System
/#ftp:ftp.nuclecu.unam.mx/linux/local
/#ftp:tsx-11.mit.edu/pub/linux/packages
/#ftp:!behind.firewall.edu/pub
/#ftp:guest@remote-host.com:40/pub
/#ftp:miguel:xxx@server/pub
17.2 [UPDATED] Tar File System
mc-3.0.tar.gz#utar/mc-3.0/vfs
/ftp/GCC/gcc-2.7.0.tar#utar
17.3 [NEW] FIle transfer over SHell filesystem
/#sh:onlyrsh.mx:r/linux/local
/#sh:joe@want.compression.edu:C/private
/#sh:joe@noncompressed.ssh.edu/private
17.4 [UPDATED] Network File System
/#mc:ftp.nuclecu.unam.mx/linux/local
/#mc:joe@foo.edu:11321/private
17.5 [UPDATED] Undelete File System
/#undel:/dev/sda2
17.6 [UPDATED] Colors
[Colors]
color_terminals=linux,xterm
color_terminals=terminal-name1,terminal-name2...
[Colors]
base_color=
xterm=menu=magenta:marked=,magenta:markselect=,red
<keyword>=<foregroundcolor>,<backgroundcolor>:<keyword>= ...
[Colors]
base_color=normal=white,default:marked=magenta,default
18 [UPDATED] Special Settings
19 Terminal databases
f0 to f20 Function keys f0-f20
bs backspace
home home key
end end key
up up arrow key
down down arrow key
left left arrow key
right right arrow key
pgdn page down key
pgup page up key
insert the insert character
delete the delete character
complete to do completion
insert=\E[Op
20 How to use help
21 FILES
find / -type d -print | sort < ~/.mc/tree
22 AVAILABILITY
23 SEE ALSO
24 [UPDATED] AUTHORS
25 BUGS
This document is written by Midnight Commander developers.
| Comments? |