LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1700|回复: 0

外文资料-第二篇(the File Manager)

[复制链接]
发表于 2002-8-30 11:44:28 | 显示全部楼层 |阅读模式
Midnight Commander - The File Manager
Philipp Thomas

Introduction

The Midnight Commander, or in short, mc, stands in a long tradition of text-based file managers whose common ancestor is the Norton Commander for DOS. They all share the basic layout, with a menu bar at the upper margin, two large windows for displaying files or information, a command line and a key assignment display in the bottom line.

http://218.5.6.250/personal/fzucad/linux/suse_pic1.png

Anyone familiar with Norton Commander will feel at home immediately with Midnight Commander. In contrast to its ancestor, mc, as a Linux program, sports a number of additional features:

   Display of directories exported by external computers using NFS.
   Connection to external computers via FTP and representation of FTP directory trees in the window.
   Display of Tar archives, Cpio archives and RPM packages as a file tree.
   Support of Unix-specific operations such as changing the owner (chown) or the permissions (chmod) of a file, and the creation of hard and symbolic links (links and symlinks).
In addition, Midnight Commander offers far more configuration possibilities than its ancestor.

Configuration

Here are the first measures you should take following the first call-up of Midnight Commander. Press the F9 key to activate the menu and select Options. A window will appear with the configuration options. In the Configuration menu a vast amount of options are offered:


http://218.5.6.250/personal/fzucad/linux/suse_pic2.pngWindow Options

Display backup copies: Many programs, for example editors such as vi or joe, create backup copies. These files end with '~'. They are usually not displayed by Midnight Commander.
Display hidden files: Files beginning with a dot are usually not displayed, as in Linux the dot marks them as hidden files.
Downward marking: In the default setting, the selection bar automatically moves downwards if a file is highlighted (either with the Insert key or with Ctrl+c). If this option is deactivated, the bar remains where it is.
Dropdown menus: If you activate this option, a dropdown menu will appear immediately after pressing F9. If you deactivate this option, only the menu bar is activated, and you must first select a menu before the window is opened.
All files mixed: If this option is active, no distinction is made between files and directories on the display. Is it inactive, directories (and links to directories) are always displayed first.
Quick read: This option is usually inactive. When activated, Midnight Commander uses a trick to determine whether the directory content has changed. The directory will only be re-loaded once its i-node has changed. This trick causes the display to be refreshed only when a file is deleted or newly created, but not when a file changes (size, owner, access rights, etc.). In these cases, the display has to be refreshed manually (with Ctrl+r).
Pause after call-up
Following the execution of commands, the Midnight Commander can pause to give you a chance to view the output of these commands. There are three possible settings for this option:

Never: Means that you never want to view the output of your commands. When you use the Linux console or a terminal window, you can view the output by using Ctrl+o.
On dumb terminals: On such terminals (for the Midnight Commander this means anything which is neither a Linux console nor a terminal window), which are incapable of showing the output of the last executed command, the Midnight Commander pauses and issues a pause message.
Always: It always pauses.
Other Options Verbose operations: This option specifies whether a dialog window is displayed for each of the processes of copying, renaming or deleting files. If you are working on a slow terminal, you may wish to close this window. This option is automatically de-activated if your terminal is working at a speed lower than 9600 bps.
Calculating grand totals: When this option is activated, the Midnight Commander calculates the total size and the number of files affected before all file operations. In this way you receive a precise progress report, at the expense of just a little time.
Shell patterns: The select, deselect and filter commands normally use regular expressions similar to those provided by the shell. The following conversions are made to bring this about:
* is replaced by .* (zero or more characters),

? is replaced by . (exactly one character) and

. stands for a full stop.

When this option is deactivated, the regular expressions correspond to those of the ed program (see man ed).
Saving settings automatically: When this option is active, the Midnight Commander automatically saves all configuration options in the ini file located in the .mc subdirectory of your home directory.
Auto menus: If this option is activated, the user menu is automatically opened after the start of the Midnight Commander.
Using the internal editor: Specifies whether you want to use the built-in editor or an external one to edit files. When this option is deactivated, the Midnight Commander uses the editor specified in the EDITOR environment variable. If no editor is specified, the Midnight Commander uses the vi editor.

Using the internal viewer: If you do not wish to use the built-in viewer to view files, this option should be deactivated. The Midnight Commander then uses the viewer specified in the PAGER environment variable. If this is not specified, the view program is used.
Total: displaying everything: The Midnight Commander usually shows all possible completions when the input is ambiguous after pressing Esc-Tab or Alt-Tab twice. After the first time, it completes only as far as possible and beeps in case of ambiguity. If you wish to see all possible completions immediately after pressing Esc-Tab or Alt-Tab once, this option should be activated.
Rotating bar: This specifies whether the Midnight Commander should display a rotating bar in the upper right hand corner when it is busy with an operation (e.g., when reading a large directory).
lynx-type movements: When this option is active, you can use the cursor keys to change to a directory, if the selection bar is on a directory and the command line is empty.
Extended chown: Specifies whether the extended chown command is called when the chown or chmod command is executed. This extended chown combines chmod and chown in a single window in which owner/group and access rights can be set simultaneously.
cd follows links: When this option is active, the Midnight Commander follows the logical chain of directories in the same way that bash does. When it is deactivated, the Midnight Commander follows the actual directory structure. That means that a cd .. takes you to the real parent directory if you have reached a directory via a symbolic link, and not to the directory in which the link was located.
Safe deletion: If active, unintentional deletion of files is made more difficult. The default button in the confirmation dialog changes from the Yes to the No button, and when deleting directories which are not empty, the word Yes must be typed in.  

The representation options are self-explanatory. I would only like to stress the options for partitioning windows. In Linux, the names of files and directories can become very long. By splitting the display window vertically, the Midnight Commander may have to abbreviate names. However, if you split the window horizontally, the wide windows provide far more display space for long names.


http://218.5.6.250/personal/fzucad/linux/suse_pic3.png



Working with these horizontal windows may be somewhat unfamiliar, but displaying more information of names makes up for this.

Possibly the most important configuration options are hidden behind the Display bits menu entry. Here you can determine whether the Midnight Commander displays and lets you enter special national characters. You should select ISO 8859-1 for output and activate the complete 8 bit entry option.

The description of the remaining configuration options would go beyond the scope of this introduction, please refer to the on-line help.

Working with the Midnight Commander

Now that the Midnight Commander has been configured, you will undoubtedly want to know what can be done with it.

Navigation can be carried out either with the keyboard or the mouse. Therefore, you can select a directory either with the Enter key or by double-clicking the left mouse button. You switch between windows with the Tab key. You can mark or unmark individual files with the Insert key. With the '+' key you can select whole groups of files via a dialog window, deselect groups with the '-' key and invert your selection with the '*' key. If you wish to delete the contents of a directory, retaining only a small number of the files, you first mark the files you wish to keep. Now press '*', the selection will be inverted, the files you previously selected will be unmarked, and the selected remainder can be safely disposed of with the F8 key.

Working with menus can sometimes be too circumstantial to the more experienced user. Here the command line of the Midnight Commander enters the scene. All commands can be entered in the same way you are familiar with from working with the console or in a terminal window. However, the Midnight Commander offers several additional possibilities. You can copy the name of the directory displayed in one of the windows into the command line, using Ctrl-x, Ctrl-p for the inactive window, Ctrl-x, p for the active window. You can copy the names of all selected files in the active window into the command line with Ctrl-x, t , and those of the inactive window with Ctrl-x, Ctrl-t.

http://218.5.6.250/personal/fzucad/linux/suse_pic4.png


If you want to copy all the selected files in the active window into a directory which is not currently displayed, having just enter mv Ctrl-x,t desired directory in the command line after having carried out the selection, and confirm with the Enter key.

Furthermore, if you want to mark any information in the mc display to be copied, you only need to keep pressing the left mouse button while highlighting. Then the text can be highlighted and copied just as you would in the console or in the terminal window.

Navigation through packed files (tar, rpm, zip)
Now the Midnight Commander cannot only navigate through real directories, but it also allows you, via its virtual file system, to treat archives as real directories which have been created by compression programs such as Zip or Tar. This also applies to files in RPM format (the packages on your CDs). You select the file with the Enter key. At the beginning you're just presented the information that is directly contained in the RPM package. Open its subdirectoty INFO for information regarding version and ChangeLog etc. In case, the particular package contained scripts being executed at the times of installation or deinstallation, those can be found under INFO/SCRIPTS. Back in the main directory you won't find that much information at first, but it's here where the actual package lies, CONTENTS.cpio. It may now take a while for the Midnight Commander to extract the file. It then shows the contents of the package in the active window, and you can move around in the file as if it was a normal directory. So you can, for example, easily copy a single file from a Zip, Tar or RPM archive, or view it using F3.

You can also access FTP servers in the same way. You can either select FTP connection from the menu of the appropriate window (menu item Left/Right or Up/Down), or you can enter a special form of the cd command. If you choose to use the menu, you can enter the URL in the subsequent dialog window. Enter the name of the FTP server here, and an anonymous connection is made. If a log-on with user name is required, enter username@computername. The Midnight Commander will then ask for a password. This can be entered directly by typing username:password@computername, but then other people present might be able to read your password, so this method is strongly discouraged.

If, instead, you wish to establish an FTP connection via the command line, just use cd in combination with an URL that can be used in Web browsers such as Netscape. Two examples:

cd ftp://ftp.gwdg.de
cd ftp://philipp@my.computer/my/homedirectory
When the connection is made, you can move through the directories of the FTP server as if you were in your local file system, and access, copy or delete files (provided you have the appropriate access privileges).

http://218.5.6.250/personal/fzucad/linux/suse_pic5.png

However, you should note that you cannot apply any external commands to files inside such virtual directories, but only commands built into the Midnight Commander. This means that the command line is not available!

Have Fun!

This was just a quick trip through the most interesting possibilities of the Midnight Commander. It offers you many additional possibilities which you will discover only with time. Studying the on-line help and the Midnight Commander documentation will bring even more unknown capabilities to light, which I highly recommend. For many users, at least, the Midnight Commander has become an indispensable tool and is something they would not want to do without during their everyday work, and you might well soon feel the same.

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表