Midnight Commander

Es gibt 2 Antworten in diesem Thema, welches 1.341 mal aufgerufen wurde. Der letzte Beitrag () ist von HostBuster.

  • GNU Midnight Commander, kurz mc, ist ein freier Klon des DOS-Tools Norton Commander (zweispaltige Ansicht) und gehört zu den bekanntesten Konsolen-Programmen unter Linux. Über ein VFS ist auch ein transparenter Zugriff auf Archive und Netzwerkserver möglich, wie z. B. FTP oder Samba.


    MidnightCommander_4.7-de.png


    Der Midnight Commander wurde 1994 entwickelt und in früheren Versionen von 1999 bis 2001 hatte mc zusätzlich eine grafische Benutzeroberfläche gmc und war der erste Dateimanager des Gnome-Projekts, galt aber als sehr fehlerhaft. Nach der Integration von Nautilus als Standard-Dateimanager in GNOME wurden die grafischen Funktionen wieder aus mc entfernt. Das fehlende GUI ist aber auch ein Vorteil, da sich der mc so auch über eine Telnet- oder SSH-Verbindung (die in einer Konsole läuft) auf einem Zielsystem nutzen lässt. IMHO ein absolutes Muss auf jedem Server!


    Auf vielen Servern bzw. Distributionen ist der Midnight Commander bereits installiert und kann durch Eingabe von mc gestartet werden.


    Ist das nicht der Fall, kann Midnight Commander aus der Source compiliert werden oder unter Fedora und CentOS über yum -y install mc, unter Ubuntu durch sudo apt-get install mc installiert werden.


    Wer unter Ubuntu im reinen Textmodus arbeitet, kann zusätzlich

    • gpm

    Paketliste zum Kopieren:

    Code
    sudo apt-get install gpm 

    Oder mit apturl die Pakete installieren. Link: apt://gpm installieren, um auch mit der Maus arbeiten zu können.


    vmod.info/filebase/index.php?file/573/
  • Konfiguration

    Programmmenü

    Das Programmmenü ruft man durch F9 oder Alt + 9 auf. Im Punkt "Optionen" gibt es die Unterpunkte "Konfiguration..." und "Layout...", über die sich bereits einiges einstellen lässt. Anschließend speichert man die Einstellungen über "Optionen → Einstellungen speichern" ab. Für Anfänger ist es sinnvoll, die Menüzeile und Tastenzeile, welche Gedankenstützen zu den Funktionstasten anbietet, einzublenden, bis man diese auswendig kennt. Als geübter Benutzer wird man diese eher ausschalten, um mehr Informationen sehen zu können.

    ini-Datei

    Es gibt für jeden Benutzer eine ~/.config/mc/ini-Datei, in der sich weitere Eigenschaften einstellen lassen, etwa:

    vergrößern

    Funktionstasten

    • F1 Hilfe
    • F2 Konfigurierbares Spezialmenü
    • F3 Anzeigeprogramm für Textdateien, HTML, Archive, Sourcecode, ...
    • F4 Editor inkl. Hexeditormodus
    • F5 kopieren
    • F6 verschieben/umbenennen
    • F7 Verzeichnis erstellen
    • F8 löschen
    • F9 Menüzeile aktivieren
    • F10 beenden

    Viele Funktionen sind mannigfach zu erreichen. So kann man mit der Funktionstaste F5 eine Kopie anstoßen, oder indem man mit der Maus die eingeblendete Funktionstastenleiste an der Stelle F5 klickt, oder man geht über das Menü zu "Datei", und wählt dort "kopieren" - auch dies ist wahlweise mit Tastatur oder Maus möglich.

    Menü, populärste Befehle

    • "Left" / "Right" ("Links" / "Rechts")
      • Einstellung, wie detailliert die Dateiliste angezeigt werden soll
      • Schnellansicht der Datei des gegenüberliegenden Fensters
      • Ausführliche Information zur Datei des gegenüberliegenden Fensters
      • Baumansicht des Verzeichnisses
    • "File" ("Datei")
      • Dateien kopieren/umbenennen/löschen/ansehen/bearbeiten
      • (symbolische) Links anlegen/ändern/löschen
      • chown/chmod
      • Gruppenauswahl nach Namensmustern
      • Auswahl umkehren (etwa: alle *.html-Dateien auswählen, dann umkehren, um alle Nicht-HTML-Dateien auszuwählen).
    • "Command" ("Befehl")
      • Verzeichnisse vergleichen
      • Panel ein/ausschalten
      • Dateisuche
    • "Options" ("Optionen")
      • Hotkeys (Tastenkürzel)
      • Konfiguration
      • Layout (Ansicht)
      • Bestätigungen festlegen (Nachfragen bei Löschen usw.)


    Shortcuts


    Shortcuts
    Befehl Beschreibung
    Strg + S erlaubt das schnelle Springen zu bestimmtem Verzeichnis oder Datei
    Alt + . zeigt versteckte Dateien / Verzeichnisse an
    Alt + Y springt zum vorherigem Verzeichnis
    Alt + I spiegelt den Verzeichnisbaum
    Alt + O zeigt den Inhalt des vorherigen Verzeichnisses an


    Tipps und Tricks

    Kommandozeile

    Am unteren Bildschirmrand ist in der Voreinstellung eine Kommandozeile eingeblendet - zusätzliche Ausgabezeilen kann man sich dazukonfigurieren (Layout). Alternativ kann man sich längere Ausgaben, die außerhalb des sichtbaren Bereichs sind, mit Strg + O erschließen, in dem man den MC ausblendet (während er aber weiterläuft). Erneutes Drücken von Strg + O macht ihn wieder sichtbar.

    Netzwerk-Verbindung

    Im LAN befindliche Dateisysteme können über den Menüpunkt "Links/Rechts → Shell link" aufgerufen werden. In der sich öffnenden Eingabemaske wird z.B. der ssh-Host in der Form

    Code
    user@host

    eingetragen.

    FTP- und SSH-Zugangsdaten

    In der Datei:

    Code
    .config/mc/hotlist

    kann man die Zugangsdaten für die FTP und für SSH eintragen. Welche immer vorhanden sind. Die Einträge in der Datei sehen wie folgt aus:

    Code
    ENTRY "ftp.example.de" URL "/ftp://benutzername:[email protected]"
    ENTRY "ssh.example.com" URL "/sh://benutzername:[email protected]/var/www/"

    Jede weitere Zeile erweitert den Eintrag um einen weiteren Zugang.

    Um den Zugriff auf die Hotlist aus dem Midnight Commander zu erlangen, drückt man:

    Strg + Alt Gr + \

  • MIDNIGHT COMMANDER / MC TUTORIAL


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

    Launch mc

    Check that mc is installed in your distribution - it is no longer installed by default in some distros, such as openSUSE, but easy to do with a package manager. See Advanced Operations on installing from source.
    Start Midnight Commander by typing mc in a terminal window. The main section will be the two directory panels, with a dropdown menu line above, a command line below, and below that a list of the present functions of the F (function) keys. Above the command line is a Hint line that shows random tips.
    Your mc may also open the F2 file operation menu on start-up. If it irritates you (as it does me) untick "Auto Menus' when configuring Midnight Commander.
    To quit mc, use key F10.

    The Basics: Navigation in the Directory Panels

    Generally, you want to display different directories either side, so you can action files between them.
    Navigate around mc with the keyboard:

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


    To change up into a parent directory, arrow up to the top line and enter on /.. (usual parent directory notation). To change down into a subdirectory, arrow down then Enter. See Configuration on how to enable 'lynx-like motion'. Without needing to scroll to the top, the back arrrow will change you directly into the parent directory.


    Keyboard Shortcuts

    The 'F' (function) keys are widely used in mc for file operations. Read the bar at the bottom for their current function, which may differ according to the context, eg. browsing a directory, using the file viewer, or the editor.
    In normal browsing mode:
    F1 - help. More readable than the 2000-line man page, although difficult to browse.
    F2 - user menu ( offers option to gzip files, etc.)
    F3 - view (handy to check the contents of an rpm or tgz file, or read contents of files)
    F4 - edit with internal editor, mcedit
    F5 - copy
    F6 - rename or move
    F7 - create a directory
    F8 - delete
    F9 - pull-down - accesses the menu bar at the top.
    F10 - quit. Closes mc, as well as mcedit and any unwanted open menu.


    If you don't have F keys, use Esc - number sequence (1-0) instead.
    F10 key in Gnome Terminal: opens the main terminal File menu instead, so click quit with mouse.


    Other basic keyboard usages:

    • Switch back and forth to the console with Ctrl–o while keeping mc running. (also called hiding panels or subshell support.)
    • In menus, arrow up or down and Enter, or use the 'hotkey' - the highlighted letter in each menu item.
    • Toggle tick boxes on or off with the space bar, and
    • select multiple files with the insert key
    • Mac users without an Insert Key: Use Ctrl-t instead.
    • Tab key also moves sequentially through fields of selection boxes


    All shortcuts are noted in the menus. In mc's keyboard shortcut notation, 'C-x i' would mean press Ctrl and x simultaneously, release both then press i. M refers to the Alt key. A few common shortcuts:


    • Ctrl R - refresh or rescan directory view
    • Alt-shift ? - find file
    • Ctrl-x d - compare directories (release ctrl-x before pressing d)
    • Ctrl \ - open directory hotlist
    • Ctrl-x c (o,s,l) - chmod, chown, symlink, link
    • Alt c - quick cd (opens a box, quicker to type than arrowing through if you know its full path)
    • (Shift) + - select group. Can enter wildcards to highlight a certain type or name of file.
    • (Shift) * - reverse selection. Changes highlighting to all unselected files. Handy to use these two in combination if you are trying to quickly select all but a certain group.
    • \ - unselect group. Opposite of +.

    Menus

    Along the top is the drop-down menu bar. F9 highlights the Left / Right menu, then arrow sideways across. (See Configuration to set drop-down menus, so you will not have to Enter to display that menu.)
    To select a menu item, arrow down and Enter, or use the hotkey - the highlighted letter.
    Browse through the menus and see what features they offer. A brief overview:


    • Left / Right menus: refer to actions on the respective side panel.
    • Sort Order option allows you to choose how to display directory contents - by name, size, date and case sensitive/insensitive, etc.
    • Listing Mode allows you to change how your directory is displayed. Brief: shows contents in two columns on that pane. Full: gives a standard view. Long: shows permissions, ownership and long file names in full, but removes the other pane to make space. You can also cycle through these views by using Alt - t.
    • In Listing Mode, tick "User Mini Status" which will handily display the permissions of the presently highlighted file or directory within the separate line at the bottom of the panel.\
    • File menu: gives you a number of options to link, change ownership and permissions.
    • Command menu: has several handy operations:
      • - 'Directory Hotlist' to bookmark your favourite directories, including remote machines and FTP sites, then quickly access the list with Ctrl-\ .
      • - 'Undelete files' to recover deleted files on Linux/Unix. It works on ext2 and ext3 partitions. See Advanced Operations.
      • - Other useful features are showing directory sizes and comparing two directories.
    • Options: for layout, confirmation options, and Configuration to set up your Midnight Commander.

    Configure Midnight Commander

    Select Options menu, Configuration. To mark or unmark the boxes, use the Space bar or mouse click. (The top left section, 'Panel Options' is a separate listing in the main Options drop-down menu in version 4.7.3. Regardless of location, Panel Options is where to select 'show hidden files' and 'lynx-like motion'.)
    Mark 'drop-down menus' - otherwise F9 will only highlight the menu name, and you will still have to enter on it to display the menu.
    Unmark 'show hidden files' unless you want to see them, or they clutter up your directory. Also untick 'mix all files' and 'fast dir reload'.
    In 'Pause after run', tick 'always' to enable you to read output or error messages in the terminal after executing a command.
    In the right hand menu 'Other Options' mark all - except 'auto menus' and 'safe delete'. 'Auto menus' will irritatingly open the F2 menu when launching mc, and 'safe delete' defaults to No when you press F8, so it's only if you want to be twice as careful before confirmation.
    'Lynx-like motion' is one of the handiest options, and enables you to enter sub- and parent directories with the forward and back arrow keys, from wherever you are in the directory. Otherwise you would have to scroll back up to the top and enter to return.
    Remember to save when you are done.


    Sometimes, too much fiddling with the configuration messed up my mc – and I couldn't restore it as I didn't know what I had done. No problem – just delete the .mc directory in your home directory, relaunch mc and reconfigure from scratch. The profile is specific to each user.


    File and Directory Operations

    Files and directories can be moved, copied, deleted and the contents viewed easily through the F keys - always refer to the options list underneath. If you are moving or copying files, it will first assume you are actioning to the opposite directory, giving you the option to change the destination.


    Select Files
    In the directory panels, select single files simply by arrowing to them, and select multiple files by using Insert key to highlight – and Insert again on any file to unselect.
    You can filter for groups of files: the + key will bring up a selection box into which you can enter wildcards. For instance, when I had moved a bunch of cartoon files by mistake into my Songs directory, I selected *jpg and it automatically highlighted them all. Then F6, which moved them across to the Cartoons directory on the other side.
    File Operations
    View contents or edit files using the F keys, and Enter or double-click on file to execute or open it with an external program. Many of these external programs (Imagemagick, xpdf etc) may not be installed by default in your distro, so the programs to open images, pdfs and word processor docs etc. can be edited by the truly confident via Command menu, Edit Extension File.
    There are two 'file' menus. The top one - F9 - is for accessing operations such as changing permissions or ownership, linking and symlinking. The 'file user' menu from the bottom bar - F2 - deals mostly with zipping and extracting files and subdirectories, and also for opening the man page.


    Advanced Directory Operations

    • Find files in large directories with mc's search function by using shortcut Alt - ? (Alt+shift ?)
    • Compare the contents of two directories by opening them in panels side by side, then Command menu, Compare directories, or shortcut Ctrl-x d. This will highlight all files that are different in the two sides.
    • To view or hide hidden (dot) files, enter the configuration menu under Options and tick or untick.
    • The delete function, F8, will delete non-empty directories, after confirmation. Very handy.


    The command line

    Although I don't use the command line much in mc, it should execute whatever you have typed into it. If you wish to su, it will return you to the terminal to type in your password. Then relaunch mc as root; if you ctl-o, it will take you back as user.
    While anything remains typed into the command line, the sideways arrow keys move through the text and won't work to navigate in the panels. If your arrow keys suddenly don't work, check and clear the command line.
    To scroll back and forth through command history, use alt - p for previous and alt - n for next command instead of the the up and down arrow keys (as in the terminal window), since mc uses them for navigating.


    Using the mouse in mc – For click-click fans

    The mouse works in mc, but the keyboard is handy to know when the battery goes flat in your cordless mouse... From the man page:


    The Midnight Commander comes with mouse support. 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.


    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.


    If your mouse does not work in mc, check that gpm mouse server is installed and running.


    Accessing Contents of Archives

    All sorts of archives - RPM, deb, tgz, iso, rar, cpio etc. are accessible with mc. The individual files can be viewed and extracted without needing to unpack or install - even password-protected archives.
    Certain types of archive files need other packages installed to look inside: eg. to access .deb on an rpm-based system, install package deb which includes dpkg, etc. And to access iso files, I needed package cdrkit-isotools (may be installed by default on your distro, but not on PCLinuxOS).


    To see an overall view, F3 directly onto the file. In this screen, the F keys have different functions again. To quit this screen, use F10 (or click on quit at the bottom, if F10 instead activates a menu from your Gnome terminal).
    To access the contents, Enter onto the file, then drill down into the contents, where you can now read the text files with F3 or copy out individual files. This is very handy for rpms, where you can copy out a needed library, for instance, in a package you can't install due to conflict or dependency issues.


    Zip archives can be similarly viewed and files browsed and copied before unzipping (unzip .zip by command line only - the F2 unzip function only works with .gz or .bz2 extensions. This may be enabled in future versions).
    The F2 file user menu also gives options to tar or zip files in a directory.


    Install RPM and tgz

    RPM: If not already root, su and relaunch mc. Enter on the rpm and select install or upgrade. I only figured out how to install them singly, though, so for multiple rpm's use the command line.
    If you have configured mc to always pause after run, the terminal will show you the output. Otherwise, it flashes back to mc after running and you won't know you have an error message unless you ctl–o to check in the terminal window.


    TGZ: To extract a tarball, F2 for a file user menu, then x to extract. You can cd to the extracted directory, then ./configure, make and make install from the command line, as per the INSTALL file instructions (which you read with F3), although there remains the problem of having to su to root halfway when you start as user.


    Editing files with mcedit

    MC's integral editor is easy to use, and even if you're not in mc, you can start it directly from the command line: mcedit <filename>.
    In mc, open a file to edit with F4. Once finished, F2 to save and F10 to quit (or click quit at the bottom). If it won't save your file, that means you forgot to edit it as root and now you're going to have to su and do it all over again! (Remember to relaunch mc once you are root.)
    Note the F keys have slightly different uses in the editor - refer to the function bar at the bottom.
    Mouse highlighting to copy and paste works similarly to the terminal, but use the shift key at the same time: shift, highlight, then shift and paste with the middle button. Or, paste other items on your clipboard with Shift-Insert.
    A shortcut to jump to the top or bottom of a long file while editing is Ctl-home or Ctl-end.


    Using mc to FTP

    MC can ftp via the command line, the Left / Right menu, or to a site you have 'bookmarked' in your directory hotlist.
    If you access the site regularly, add it to your directory hotlist for fastest access. Go to Command menu - Directory Hotlist - add by either typing it in, or if you are connected in a panel already, simply Add Current. Access the list with Ctl - \ .
    To disconnect ftp, type cd in the command line and it will return you to your home directory.


    Command line: For anonymous sites, the format is cd Create Your Own Free Website - Best Website Builder | 1-Click easy Free Website Builder for 2019 - Yoursite.com


    To connect to a site with a password (non-anonymous), cd Web Server's Default Page:[email protected]
    (This may return an error message if you did not specify a directory, but will connect you anyway.)
    Or type in the full path: cd Web Server's Default Page:[email protected]/public_html


    Left / Right dropdown menu: will connect on that respective side. Arrow down to FTP link, or use hotkey P. A dialog box will request the FTP address in the same format:
    Anonymous: ftp.yoursite.com
    Non-anonymous: username:[email protected]/public_html


    For all methods, the username alone can be entered, eg. [email protected] and and a box will request the password. If the command line is used, this is more secure, as the password may be read in plain language when scrolling back through the command line history.


    What if you have @ in the username? Originally, support for this was missing. Try enclosing the username in double quotation marks "user@name":[email protected]
    If, however, the username itself includes ftp, such as "ftp@Create Your Own Free Website - Best Website Builder | 1-Click easy Free Website Builder for 2019 - Yoursite.com" then mc will not connect. Either use another ftp client, or this workaround:




    Now connect to the site using the same format as an anonymous connection, and it will log you in instantly.


    Change ftp configuration settings under Options menu, Virtual FS. This is where you can change the anonymous password, use of .netrc file, passive mode and proxy.


    Networking with Samba

    It would appear that the latest versions of mc don't have samba support, but it is planned to be included again in the future. If your version supports samba:
    In the same way as with ftp, select Left / Right menu and SMB link (or hotkey B), and a box will open for the machine name, into which I entered the IP.AD.DR.ES. Or, command-line format: cd smb://IP.AD.DR.ES/
    I'm not a samba expert, so for more commands consult the man page.


    Advanced operations

    Installing from Source: First, put on your patient hat! Read the INSTALL and README files carefully, especially for the list of libraries that must be pre-installed, to avoid unnecessary gnashing of teeth. If you install binary (rpm) versions of the libraries, note that many also require the -devel packages.
    The INSTALL file also gives a list of configure options - many common ones are on by default, but samba and undelete must be selected on.
    And, when I installed version 4.7.1, the binary landed up in a strange place well out of the normal path.


    CD burning: A cd burning patch, MC-Burn, is available from Friesoft, but only as a tgz and for older versions of mc.


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


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

    More help: Official FAQ here and Wiki here.


    Midnight Commander for Mac

    I installed MC on 10.9 Mavericks using a universal binary from http://louise.hu/poet/tag/mc This includes all the libraries and was lighting fast to download and install.
    MC on Mac saves the day if you are having Finder problems, as you can easily access your files to manage them.


    Mouse support: not possible in Terminal.app, so run it on iTerm iTerm2 - macOS Terminal Replacement


    The F key problem: Easiest fix for regular users - open System Preferences -> Keyboard, tick to use the F keys as normal function keys. Otherwise, use Ctrl-t in place of the insert key to select multiple files, and Esc - 1-0 in place of the F keys.
    Access the network and external drives from 'volumes' in the root directory.

Schon gewusst…?

Das Team VMOD lehnt jegliche kommerzielle Nutzung ab - auch durch Werbung. In diesem Sinne bitten wir Mitglieder von Gruppen, die einen kommerziellen Vorteil bezwecken, von einer Registrierung abzusehen. Ein Ausschluss wäre ohnehin nur eine Frage der Zeit ....