# mc — Midnight Commander, the Visual Terminal File Manager

> Practical guide to Midnight Commander (mc) — manage, edit and transfer files in the terminal with a dual-pane interface, and browse inside archives.

Source: https://www.jpkc.com/db/en/cheatsheets/files-text/mc/

<!-- PROSE:intro -->
Midnight Commander (`mc`) is a visual file manager for the terminal with the classic dual-pane interface: you see a directory on the left and right, and copy, move, edit or delete files with function keys. Keep in mind that mc is third-party software and not preinstalled everywhere – install it from your package manager when needed (for example `apt install mc`). Through its shell VFS you can even browse inside archives and on remote servers (SSH, FTP) as if they were local folders, and with the built-in editor `mcedit` you edit files without leaving mc. Be aware that `F8` deletes files directly; this guide walks you through the shortcuts that let you move around mc safely and fast.
<!-- PROSE:intro:end -->

## Launch & Navigation

`mc` — Start Midnight Commander.

```bash
mc
```

`mc <dir1> <dir2>` — Start with specific directories in left and right panels.

```bash
mc /var/log /tmp
```

`mc -b` — Start in black and white mode (no colors).

```bash
mc -b
```

`Tab` — Switch between left and right panel.

```bash
Tab
```

`Arrow keys / Page Up / Page Down` — Navigate files in the active panel.

```bash
Up/Down to move, Enter to open directory
```

`Alt+o` — Open the current directory in the other panel.

```bash
Alt+o
```

`Alt+i` — Make the other panel show the same directory.

```bash
Alt+i
```

`Alt+y` — Go to the previous directory in history.

```bash
Alt+y
```

## File Operations

`F5` — Copy selected file(s) to the other panel.

```bash
F5
```

`F6` — Move or rename selected file(s).

```bash
F6
```

`F7` — Create a new directory.

```bash
F7
```

`F8` — Delete selected file(s).

```bash
F8
```

`Insert` — Select/deselect a file (move to next).

```bash
Insert
```

`+ (Plus)` — Select files by pattern (glob/regex).

```bash
+ then type *.log
```

`- (Minus)` — Deselect files by pattern.

```bash
- then type *.tmp
```

`* (Asterisk)` — Invert selection (toggle all files).

```bash
*
```

`Ctrl+x c` — Change file permissions (chmod).

```bash
Ctrl+x c
```

`Ctrl+x o` — Change file ownership (chown).

```bash
Ctrl+x o
```

## View, Edit & Search

`F3` — View the selected file (internal viewer).

```bash
F3
```

`F4` — Edit the selected file (opens mcedit).

```bash
F4
```

`Alt+?` — Find file by name (search dialog).

```bash
Alt+?
```

`Alt+s` — Quick search: start typing a filename to jump to it.

```bash
Alt+s then type file prefix
```

`Ctrl+s` — Quick search forward in the file list.

```bash
Ctrl+s
```

`Alt+Shift+?` — Find file by content (grep through files).

```bash
Alt+Shift+?
```

## Panel & Display

`Ctrl+u` — Swap left and right panels.

```bash
Ctrl+u
```

`Alt+,` — Toggle horizontal/vertical panel layout.

```bash
Alt+,
```

`Ctrl+o` — Toggle panels off/on (show shell output underneath).

```bash
Ctrl+o
```

`Alt+t` — Cycle panel listing mode (full, brief, long, custom).

```bash
Alt+t
```

`Alt+.` — Toggle hidden files (show/hide dotfiles).

```bash
Alt+.
```

`Ctrl+x t` — Copy tagged filenames to the command line.

```bash
Ctrl+x t
```

`Ctrl+x p` — Copy the current panel path to the command line.

```bash
Ctrl+x p
```

## Shell & Menu

`F9` — Open the top menu bar.

```bash
F9
```

`F10 / Esc Esc` — Quit Midnight Commander.

```bash
F10
```

`F2` — Open the user menu (custom commands).

```bash
F2
```

`Ctrl+Enter` — Copy current filename to the command line.

```bash
Ctrl+Enter
```

`Alt+Enter` — Copy current filename with full path to command line.

```bash
Alt+Enter
```

`Alt+h` — Show command-line history.

```bash
Alt+h
```

`Ctrl+x q` — Toggle quick view (preview file in the other panel).

```bash
Ctrl+x q
```

## Remote & Archives

`cd sh://<user>@<host>` — Connect to a remote server via SSH (Shell VFS).

```bash
cd sh://admin@server.example.com/var/www
```

`cd ftp://<user>@<host>` — Connect to an FTP server.

```bash
cd ftp://admin@ftp.example.com
```

`Enter (on archive)` — Browse inside an archive file (tar, zip, rpm, deb, etc.).

```bash
Navigate to archive.tar.gz and press Enter
```

`F5 (inside archive)` — Extract files from an archive to the other panel.

```bash
Enter archive → select files → F5
```

`Ctrl+x d` — Compare directories (highlight differences).

```bash
Ctrl+x d
```

## mcedit — Internal Editor

`mcedit <file>` — Open a file directly in the Midnight Commander editor.

```bash
mcedit /etc/nginx/nginx.conf
```

`F2` — Save the current file.

```bash
F2
```

`F10 / Esc` — Quit the editor.

```bash
F10
```

`F7` — Search for text.

```bash
F7
```

`F4` — Search and replace.

```bash
F4
```

`F3` — Start / end block selection (mark text).

```bash
F3 to start, move cursor, F3 to end
```

`F5` — Copy selected block.

```bash
Select with F3, position cursor, F5
```

`F6` — Move selected block.

```bash
Select with F3, position cursor, F6
```

`F8` — Delete selected block.

```bash
Select with F3, then F8
```

`Shift+F5` — Insert file content at cursor position.

```bash
Shift+F5
```

`Ctrl+y` — Delete the current line.

```bash
Ctrl+y
```

`F9` — Open the editor menu bar (File, Edit, Search, etc.).

```bash
F9
```

`Ctrl+s` — Toggle syntax highlighting on/off.

```bash
Ctrl+s
```

`Alt+n` — Toggle line numbers.

```bash
Alt+n
```

<!-- PROSE:outro -->
## Conclusion

Midnight Commander is a surprisingly complete file manager for the terminal: with two panels, function keys and the built-in editor `mcedit` you handle managing, editing and transferring files in one place – without a mouse and without a graphical interface. Especially strong is the shell VFS, which lets you browse archives and remote servers (SSH, FTP) like local folders. Because mc is third-party software, install it from your package manager first if needed. Be careful with the function keys: `F8` deletes the tagged files directly – check your selection beforehand, because an accidental `F8` on many tagged files happens fast.

## Further Reading

- [Midnight Commander – official site](https://midnight-commander.org/) – the project home page with docs, downloads and the manual
- [mc(1) manual page](https://linux.die.net/man/1/mc) – the full reference for command-line options and key bindings
<!-- PROSE:outro:end -->

## Related Commands

- [vim](https://www.jpkc.com/db/en/cheatsheets/files-text/vim/) – powerful editor as an alternative to mcedit
- [nano](https://www.jpkc.com/db/en/cheatsheets/files-text/nano/) – simple editor you can wire up as the external editor in mc
- [ls](https://www.jpkc.com/db/en/cheatsheets/files-text/ls/) – lists directory contents on the command line

