تخطَّ إلى المحتوى

Midnight Commander Cheat Sheet

Overview

Midnight Commander (mc) is a full-featured, visual terminal file manager with a classic two-panel interface inspired by Norton Commander. It provides an intuitive text-based GUI for file management, including copying, moving, renaming, searching, and editing files. MC includes a built-in text editor (mcedit), file viewer (mcview), and supports virtual filesystems for browsing archives, FTP, SFTP, and SMB shares.

MC runs on Linux, macOS, and other Unix-like systems. It is particularly popular among system administrators for its ability to manage files on remote servers over SSH without a graphical environment. Its two-panel design makes comparing directories and moving files between locations efficient and straightforward.

Installation

# Ubuntu/Debian
sudo apt install mc

# macOS
brew install midnight-commander

# Arch Linux
sudo pacman -S mc

# Fedora
sudo dnf install mc

# CentOS/RHEL
sudo yum install mc

# openSUSE
sudo zypper install mc

# Alpine
apk add mc

# Start Midnight Commander
mc

Core Key Bindings

Panel Navigation

KeyAction
TabSwitch between panels
Up/DownNavigate files
EnterOpen directory / execute file
HomeGo to first file
EndGo to last file
Page UpScroll up one page
Page DownScroll down one page
Alt+OLoad current dir in other panel
Alt+IMake other panel same as current
Ctrl+\Show directory hotlist
Alt+YPrevious directory in history
Alt+UNext directory in history

Function Keys

KeyAction
F1Help
F2User menu
F3View file
F4Edit file
F5Copy
F6Move/Rename
F7Create directory
F8Delete
F9Pull-down menus
F10Quit

File Selection

KeyAction
InsertSelect/deselect file
+ (Plus)Select by pattern
- (Minus)Unselect by pattern
* (Star)Invert selection
Ctrl+TSelect current file

Quick Navigation

KeyAction
Alt+CQuick cd dialog
Ctrl+\Directory hotlist
Alt+HDirectory history
Alt+Shift+HCommand history
Ctrl+SQuick search
Alt+SQuick search (case-insensitive)

File Operations

# Copy files (F5)
# 1. Select files with Insert or + pattern
# 2. Press F5
# 3. Confirm destination (other panel by default)

# Move/Rename (F6)
# 1. Select files
# 2. Press F6
# 3. Edit destination path or new name

# Delete (F8)
# 1. Select files
# 2. Press F8
# 3. Confirm deletion

# Create directory (F7)
# 1. Press F7
# 2. Enter directory name

# Change permissions
# 1. Select file(s)
# 2. Go to File menu (F9 > File)
# 3. Select "Chmod" or "Chown"

Built-in Editor (mcedit)

# Open editor standalone
mcedit filename.txt

# Or press F4 on a file in MC

# Editor key bindings:
# F2          Save
# F10         Quit
# F3          Mark block start
# F5          Copy block
# F6          Move block
# F8          Delete block
# Ctrl+Y      Delete line
# Ctrl+U      Undo
# Ctrl+S      Search
# Ctrl+T      Search and replace
# F7          Search
# Shift+F7    Search again
# F17         Replace
# Ctrl+N      New file
# F2          Save
# Shift+F2    Save as

Built-in Viewer (mcview)

# Open viewer standalone
mcview filename.txt

# Or press F3 on a file in MC

# Viewer key bindings:
# F2          Toggle wrap
# F4          Toggle hex mode
# F7          Search
# F8          Toggle raw/parsed
# Shift+F7    Search again
# q           Quit

Virtual Filesystems

# FTP access
# In the command line or Alt+C:
cd ftp://user:password@ftp.example.com/path

# SFTP/SSH access
cd sh://user@server.example.com/path

# Browse archives as directories
# Navigate to a .tar.gz, .zip, .rpm, etc. and press Enter

# SMB access (if smbfs is available)
cd smb://server/share

# Access ISO files
cd iso9660://image.iso

Panel Modes

KeyDescription
Alt+,Switch panel layout mode
Ctrl+X, LCreate symlink
Ctrl+X, SEdit symlink

Panel Display Options (F9 > Left/Right)

  • File listing mode: Full, Brief, Long, Custom
  • Sort order: Name, Extension, Size, Time, Unsorted
  • Filter: Show only matching files
  • Encoding: Set character encoding

Search (Alt+?)

# Search for files
# 1. Press Alt+? (or Command > Find file)
# 2. Enter search pattern (supports wildcards)
# 3. Optionally enter content search string
# 4. Set search directory
# 5. Navigate results in panel

# Quick search in current panel
# Ctrl+S then start typing
# Alt+S for case-insensitive

User Menu (F2)

# Create custom menu entries
# Edit ~/.config/mc/menu or use F9 > Command > Edit menu file

# Example menu entries:
# a  Compress current directory
#     tar czf "../%d.tar.gz" .
#
# b  Extract archive here
#     tar xzf %f
#
# c  Git status
#     git status; read -p "Press Enter"
#
# d  Docker ps
#     docker ps; read -p "Press Enter"

Configuration

# Configuration files location
~/.config/mc/ini          # Main configuration
~/.config/mc/panels.ini   # Panel settings
~/.config/mc/hotlist       # Directory hotlist
~/.config/mc/menu         # User menu
~/.config/mc/mc.ext       # File associations
~/.local/share/mc/skins/  # Custom skins

# Access settings
# F9 > Options > Configuration
# F9 > Options > Layout
# F9 > Options > Panel options
# F9 > Options > Appearance (skins)

File Associations (mc.ext)

# ~/.config/mc/mc.ext.ini
# Define how files are opened

[pdf]
Type=^PDF
Open=zathura %f &
View=pdftotext %f -

[image]
Regex=\.(png|jpg|jpeg|gif|bmp|webp)$
Open=sxiv %f &
View=chafa %f

[video]
Regex=\.(mp4|mkv|avi|mov|webm)$
Open=mpv %f &

Advanced Usage

Subshell

# MC includes an embedded subshell
# Ctrl+O   Toggle between MC and subshell
# Commands typed in the bottom panel run in the subshell
# The shell shares the current directory with MC

# Use %f for current file, %d for current directory
# Example: grep -r "pattern" %d

Directory Hotlist

# Ctrl+\   Open hotlist
# Add current directory to hotlist from menu
# Or edit ~/.config/mc/hotlist directly

# hotlist format:
# ENTRY "/home/user/projects" "Projects"
# ENTRY "/var/log" "Logs"
# ENTRY "/etc" "Config"

Panel Comparison

# Compare directories
# F9 > Command > Compare directories

# Compare files
# Select a file in each panel
# F9 > Command > Compare files

Command Line Integration

# mc passes selected file to command line
# Alt+Enter  Insert current filename to command line
# Ctrl+Enter Insert current filename to command line
# Alt+A      Insert current directory to command line

# Run command on selected files
# Type command in bottom prompt using %f, %d macros

Skins

# List available skins
ls /usr/share/mc/skins/

# Set skin via command line
mc --skin=gotar

# Set in configuration
# F9 > Options > Appearance
# Or edit ~/.config/mc/ini:
# [Midnight-Commander]
# skin=gotar

Troubleshooting

IssueSolution
Function keys not workingCheck terminal emulator key mapping; try ESC+number
Colors wrongSet TERM=xterm-256color; try different skin
Mouse not workingEnable mouse in Options > Configuration; check terminal
SFTP connection failsVerify SSH config; check mc has SSH access
Editor opens wrong programSet $EDITOR or configure in Options > Configuration
Archives not openingInstall required tools (unzip, unrar, p7zip)
Slow on remote filesystemsUse SFTP instead of FISH; reduce panel refresh
UTF-8 characters brokenSet correct locale; verify terminal UTF-8 support