Introduction to Midnight Commander on Ubuntu 22.04
This tutorial explores Midnight Commander (mc), a versatile file manager for streamlined file and directory management within an Ubuntu 22.04 environment. We'll guide you through installing the Midnight Commander package and mastering its intuitive interface for efficient command-line file system navigation.
Midnight Commander is a popular file manager, offering a user-friendly alternative to standard command-line operations. Learn how to navigate the file system, copy, move, and delete files with ease. This lab provides practical examples and step-by-step instructions, enabling you to become proficient in using Midnight Commander on your Ubuntu 22.04 system.
Install Midnight Commander (mc) on Ubuntu 22.04: A Step-by-Step Guide
This section details the installation of Midnight Commander (mc) on your Ubuntu 22.04 system. Follow these instructions for a successful setup.
First, update your system's package list:
sudo apt-get update
Example output:
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Fetched 324 kB in 1s (324 kB/s)
Reading package lists... Done
Next, install the mc package using apt:
sudo apt update
sudo apt-get install -y mc
Example output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libglib2.0-0 libslang2
Suggested packages:
mc-data
The following NEW packages will be installed:
libglib2.0-0 libslang2 mc
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,063 kB of archives.
After this operation, 5,500 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libglib2.0-0 amd64 2.72.1-1ubuntu1 [1,231 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libslang2 amd64 2.3.2-5build2 [368 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/universe amd64 mc amd64 3.4.3-3build1 [464 kB]
Fetched 2,063 kB in 1s (2,063 kB/s)
Selecting previously unselected package libglib2.0-0:amd64.
(Reading database ... 14868 files and directories currently installed.)
Preparing to unpack .../libglib2.0-0_2.72.1-1ubuntu1_amd64.deb ...
Unpacking libglib2.0-0:amd64 (2.72.1-1ubuntu1) ...
Selecting previously unselected package libslang2:amd64.
Preparing to unpack .../libslang2_2.3.2-5build2_amd64.deb ...
Unpacking libslang2:amd64 (2.3.2-5build2) ...
Selecting previously unselected package mc.
Preparing to unpack .../mc_3.4.3-3build1_amd64.deb ...
Unpacking mc (3.4.3-3build1) ...
Setting up libglib2.0-0:amd64 (2.72.1-1ubuntu1) ...
Setting up libslang2:amd64 (2.3.2-5build2) ...
Setting up mc (3.4.3-3build1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
Midnight Commander (mc) is now successfully installed on your Ubuntu 22.04 system, ready for use.
Navigating the Midnight Commander Interface: A Comprehensive Overview
This section provides a detailed exploration of the Midnight Commander (mc) interface, highlighting its key elements and functionalities.
Launch Midnight Commander by typing the following command in your terminal:
mc
The Midnight Commander interface features two main panels. The left panel displays the content of your current directory. By default, the right panel shows the contents of your previous location.
The menu bar at the top provides access to various commands and functions. Navigate using the arrow keys and select options with Enter.
The command line below the menu bar displays your current working directory. You can also use it to execute shell commands.
The main area is split into the two panels mentioned previously. Use the Tab key to switch between them. Within each panel, use the arrow keys to select files and directories.
Here are some essential features and keyboard shortcuts to explore within Midnight Commander:
- File Operations: Use F5 to copy, F6 to move/rename, F8 to delete, and F7 to create new directories.
- Directory Navigation: Use the arrow keys to move the cursor and press Enter to open a directory.
- File Searching: Press Ctrl+F to open a search dialog and locate specific files or directories.
- File Viewing: Press F3 to view the content of the selected file.
- Exiting Midnight Commander: Press F10 to exit the Midnight Commander application.
Spend some time exploring the Midnight Commander interface, familiarizing yourself with its commands and features to improve your systemadmin skills.
Mastering File and Directory Operations with Midnight Commander
This section guides you through performing essential file and directory operations using Midnight Commander (mc).
First, create a new directory named mc_demo
inside your ~/project
directory:
mkdir ~/project/mc_demo
Example output:
labex@ubuntu:~/project$ mkdir ~/project/mc_demo
labex@ubuntu:~/project$
Now, launch Midnight Commander and navigate to the mc_demo
directory:
mc
Use the arrow keys to locate the mc_demo
directory and press Enter to access it.
Next, create a new file inside the mc_demo
directory:
- Press F7 to initiate file creation.
- Enter the desired file name, for example,
example.txt
, and press Enter. - A new file will be created. You can then edit its contents using the built-in editor or another text editor.
Now, copy a file using Midnight Commander:
- Select the file you want to copy (e.g.,
example.txt
) using the arrow keys. - Press F5 to copy the selected file.
- Provide the destination path (e.g.,
~/project/mc_demo/copied_file.txt
) and press Enter.
Finally, delete a file with Midnight Commander:
- Highlight the file you wish to remove (e.g.,
copied_file.txt
) using the arrow keys. - Press F8 to initiate file deletion.
- Confirm the removal operation by pressing Enter.
You have now successfully created, copied, and deleted files and directories using the Midnight Commander file manager. You can even perform these actions as root if needed.
Conclusion: Leveraging Midnight Commander for Efficient File Management
This tutorial covered the installation of Midnight Commander (mc) on Ubuntu 22.04, exploring its interface, and performing file and directory operations. The installation process involved updating the package index and installing the mc package. We familiarized ourselves with the Midnight Commander's user interface, utilizing its features to manage files and directories effectively, including navigating, copying, moving, and deleting files and folders. This tool is a valuable asset for any systemadmin looking to improve their workflow on Linux systems.