When you work with many files in a console environment, like moving or copying files, you may find the tasks tedious.
In a GUI environment, there’s a File Manager, which helps speed up your activities associated with files. You don’t have to remember every syntax or command related to files. Just click, drag, or use shortcuts to complete your tasks.
In the console, you need to remember commands and their syntax. But in Linux, there’s a text-based file manager called Midnight Commander, or MC for short, that works right in the console.
What is Midnight Commander
Midnight Commander (MC) is a powerful, text-based file manager for Linux and other Unix-like operating systems that provides a user-friendly interface for managing files and directories directly from the command line or terminal.
MC offers a dual-pane layout, allowing you to view and navigate two directories simultaneously, making file operations like copying, moving, and deleting files much easier
How to Install Midnight Commander in Linux
Usually, MC isn’t installed on a Linux system right away. You’ll have to install it yourself using the default package manager that comes with your specific Linux version.
sudo apt install mc [On Debian, Ubuntu and Mint] sudo yum install mc [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] sudo emerge -a sys-apps/mc [On Gentoo Linux] sudo apk add mc [On Alpine Linux] sudo pacman -S mc [On Arch Linux] sudo zypper install mc [On OpenSUSE] sudo pkg install mc [On FreeBSD]
Once the installation is complete, simply type “mc” (without quotes) into the console and hit Enter, which will launch Midnight Commander, giving you access to its dual-pane interface for managing files.
mc
Midnight Commander Features
MC has many features which are useful for a user or a Linux Administrator. Here are some features that may be useful on a daily basis.
Copy, Delete, Rename / Move, Create Directory
MC is divided into two columns: Left column and Right column. Those columns are independent windows from each other. Each window will represent an active directory.
You can switch between windows using the Tab button. At the bottom, you will see there are buttons which prefixed by a number. Those numbers represent F1
– F10
buttons.
To copy file(s) from one directory to another, simply highlight the file and press “F5
” key. If you want to copy multiple files, you need to press “Insert
” button for each file you want to copy.
MC will ask for your confirmation about the destination folder (To), Follow links, and Preserve attributes. Generally, you can only focus on the To parameter. Just press OK to commit the copy process.
Deleting file(s) is easier. Simply highlight the file(s) and press “F8
” key to confirm deletion. Moving file(s) can be done using “F6
” key.
Renaming files on the other hand is different. When you press “F6
” key, you need to make sure that you add a “New Filename” for the file in the To parameter.
Here’s a screenshot when you want to Rename a file.
To create a directory, you can press “F7
” key. MC will create a new directory in the current directory. For more details about what MC can do with the files, press “F9
” > File.
Internal Viewer
In console mode, there are many text editors such as vi, joe, and nano. MC has its own internal viewer.
If you want to view the content of a file text, you can highlight the file and press “F3
” key. You also can edit the file when you need to. Highlight the file and press “F4
” to start editing.
When you run the text editor for the first time, MC will ask you to choose default text editor for you.
Here’s a sample output:
pungki@mint15 ~ $ Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano
Then when you press “F4
” button to edit a file, MC will use the text editor that you have chosen. If you want to change your default editor, just press “F2
” button, choose ‘@
’ sign and type ‘select-editor’ (without quotes).
What if you want to use other text editors that are not detected by MC? Let’s say you want to use Vi text editor. In this case, you can do it another way. In your home directory, you will find a “.selected_editor” file. This is a hidden file, so it begins with a dot sign. Edit the file. You will see:
# Generated by /usr/bin/select-editor SELECTED_EDITOR="/usr/bin/vi"
File Permissions
Files and directories have permissions. Permission will manage who can read, write, and execute the files and directories. The command to manage it is chmod. You can see how to use chmod in detail by typing “man chmod” in the terminal.
man chmod
With MC, you only need to select a file and then press “F9
” > File > Chmod or press “Ctrl-x
” and “c
“. MC will show to you the current permission of the selected file and show to you more parameters that can be set.
File Owner
Files and directories also have owner and group owners. The privileges of these owners are managed by the chmod command above. The command to manage the owner is chown.
As usual, you can see how to use the chown command in detail by typing “man chown” in the terminal.
man chown
With MC, you only need to select a file and then press “F9
” > File > Chown or press “Ctrl-x
” and “o
“. Now you can set owner and group owner from the available list of user name and group name.
MC also has Advanced Chown. It’s a combination between chmod and chown. You can do 2 different tasks in 1 place. Press “F9
” > File > Advanced Chown.
FTP Link
By default, MC will show you 2 column interfaces. Left and Right. Those columns are not only for the local directory. You can make one of them or both connected to the remote computer using an FTP link.
In this case, MC will act as a FTP Client. To connect it to the FTP service, you need to press “F9
” > FTP Link. MC will ask for the credentials of the FTP. The credential format will be like this:
user:password@machine_or_ip_address
If it’s correct, then the column will show you directories on the remote computer.
To disconnect your FTP link, you can press “F9
” > Command > Active VPS Link. In the Active VFS directories list, you will see your FTP link. Choose your FTP link and press “Free VFSs” now.
If you only want to switch to a local folder without disconnecting the current FTP link, choose Change to.
If your network uses a proxy server, you can configure MC to use an FTP proxy. Press “F9
” > Options > Virtual FS > Always use ftp proxy.
Leaving Midnight Commander
To leave Midnight Commander, press “F9
” > File > Exit. Or just press “F10
” to quit. There are still a lot of features inside Midnight Commander.