2.3 Install and Use Midnight Commander

One of the biggest challenges of working with a virtual server is that it does not come with a desktop environment. Rather than clicking buttons, you need to enter commands in a terminal. The problem with the terminal is that, it can be very difficult for visual learners (who make up half the population) to be constantly entering a series of complex commands into an abstract tool like the terminal. Thankfully, the Linux community also provides a graphical user interface for a server File Manager called Midnight Commander. In this article, we will learn how to install and configure Midnight Commander - first on a our Home Debian Computer and then on our Debian 11 VPS.

Why we need to learn how to use Midnight Commander
If you were only using a desktop laptop like Linux Debian, and never using a VPS, you would not need to learn how to use Midnight Commander. This is because Linux Debian comes with a great File Manager which is very easy to use. Sadly, the Debian Desktop File Manager can not be displayed on a Linux server. So installing and learning to use Midnight Commander is the next best option.

01

But there is another more important reason to that it is essential for anyone working with a VPS to learn how to use Midnight Commander. When you have a server, you will frequently need to transfer files from your home computer to your server and download files from your server to your home computer. Historically, folks used FTP (File Transfer Protocol) to transfer files using a free FTP tool called FileZilla. But FTP has security problems and FileZilla has basically turned into malware.

This led to the creation of SFTP which stands for Secure File Transfer Protocol. SFTP uses the Linux Secure Shell also known as SSH. But it requires the use of an SFTP Client. The best and easiest SFTP client is Midnight Commander. Now that we understand how important it is to learn Midnight Commander, we will install it on our Home computer to see how it works. We will then install it on our Debian 11 server to see how the server version is different from the desktop.

Install Midnight Commander
The easy way to install Midnight Commander is to go to the Linux Debian Software Manager and type Midnight Commander. Then select it and click Install. Alternately, you can open a terminal and copy paste: sudo apt-get install mc

To install Midnight Commander on a VPS, your only option is to copy paste the above commands into the Server terminal. Either way, once Midnight Commander is installed, you need to first open a terminal and then type mc. Then press Enter. Here is the initial interface when opening Midnight Commander on a Debian laptop:

02

Here is the initial interface when opening Midnight Commander on a server:

03

Both open in the User Home folders. One obvious difference is that your Desktop computer has folders called Documents, Downloads and Music while the Server only has a few hidden files. Another difference is that you can generally use your mouse on your Desktop.

On a server, you may need to navigate with the up and down arrows and select folders by pressing Enter on your keyboard. You can gain more function by using SSH to access the server from your home computer whenever the server is running. But be aware that, even when using an SSH session on your home terminal, the server version is not quite as easy to use as the desktop version is. Which is why were are starting by learning Midnight Commander on our desktop computer.

On the Desktop and the Server, Midnight Commander uses a double panel screen. The purpose of this double panel arrangement is to make it easy to copy files from one panel and paste them into the other panel. The panels are labeled Left and Right. Above the panels are a menu that applies to both panels with the menu items called File, Command and Options. Each menu item has a series of sub-menu items, some of which we will cover in this tutorial.

Configure Midnight Commander
Most server tutorials use the initials MC to stand for Midnight Commander. We will do the same in this tutorial.

Change the background to a lighter color

By default, MC comes with light letters on a dark background.

However, using dark letters on a light background is both easier to read and easier to see on screen shots. Therefore the first thing you should do after installing MC is to change the background color. To do this, click Options, Appearance.

04

The default skin is called Default. Press Enter to see more options.

05

Click Gray, Green Purple (in a server, you would need to use the up or down arrows to select it). Then press Enter. Then press OK.

06

Hide the Hint Line
There is a Hint Line at the bottom of the page telling you to press Control plus o to change the screen from MC to the Terminal and back again. Try this to see how it works. (Note: sometimes this command does not work. Another option is to use the File menu and click Exit. Then type mc to bring back the MC screen). You can focus more by getting rid of the Hint Line. To do this, click Options, Layout.

07

Uncheck the Hintbar Visible box. Then click OK.

Make MC Look Like the Debian File Manager
The Debian File Manager has a narrow column on the left with a tree menu and a bigger column on the right with normal files. We can do something similar with MC. Click Options, Layout. Then Uncheck the Equal Split box. Then use the less than arrow to reduce the left side form 40 to 30. Then click OK.

08

To save this setting, click Options, Save Setup. Then click the word Left and change the view for the Left panel from File Listing to Tree. Click on the forward slash to expand the root folder:

09

Hide the File Size Column
Click on the word Right to go to the right panel. Then click Listing Format.

10

Check User Defined. Then place your cursor to the right of the word prem (which stands for Permissions) and delete perm and size. Then type mtime (which stands for modified time).

11

Then click OK. To open a folder in the Tree view column to see the internal folders, double click on the folder. Click on the home folder in the left column. Then click on your username (in this case debian) to open the home folder. This also opens the folder in the right column.

12

Navigating between Folders
There are three hidden ways to navigate between folders. The first is to notice and click on the two dots at the top of the right panel. Then press Enter. This takes us to the Parent folder which in this case is called /debian. Then select the two dots again. Then press Enter.

13

When working on our server, we are mostly concerned about files in our etc folder. Click on it in the right column to select it. Then press Enter to open it.

14

A few folders appear at the top of the list and are not in alphabetical order. These include Network Manager. But most of the folders (and there are many in the etc folder) do appear in alphabetical order.

All folders have a slash in front of their name. There are two additional hidden ways to navigate between folders. First, click the small left pointing arrow in the upper left corner to return to the previous folder.

15

Second, click on the very small down pointing arrow in the upper right corner. This will bring up a history popup where you can click and select any recent previous folder.

16

Click on the /etc folder to open it again.

How to Open and Edit Files
Use the down arrow to scroll down the list. Below the folders are a series of files all of which are in alphabetically order. The most important (and oldest) file is called etc/hosts. Scroll down and select this file. If you press Enter, you will notice that files do not open in MC the way they do with the Debian File Manager. MC uses a different process to open files. If you simply want to view the file, then Press F3 on your keyboard.

17

You can use etc/hosts to force your browser to display local websites that do not actually exist on the real public Internet. This is a very useful trick for local development. To close a file opened with F3, press F3 again on your keyboard.

Recall that to edit the /etc/hosts file with our terminal, we use the command sudo nano /etc/hosts With MC, we edit a file by pressing F4 (or click File, Edit). The first time we edit a file, MC will ask us what editor we want to use.

18

Type 1, then press Enter to use the Nano editor. The ect/hosts file will appear. However, at the bottom it will say "File is unwritable" because this file is owned by root and we did not open the file as root. To edit files on our server, make sure our VPS has a root password. Then start an SSH session with 

ssh root at 123.456.789.123

Then enter your root password. We have already installed Midnight Commander with the following command: sudo apt-get install mc

Open Midnight Commander by typing mc. Then press Enter. It will open in the VPS home folder:

19

To change the background color, click Options, Appearance. Then press Enter to choose the Gray skin. Then press Enter and OK. Then click Options, Save Settings to save the settings.

20

Navigate to the root folder by pressing the two dots. Then press Enter. Then use the up arrow to select the etc folder and press Enter.

Use Midnight Commander to Configure PHP Settings
The step only needs to be done once on your server. However, it should be done before you install your first Joomla website.

We need to edit the PHP ini file which is in the following path: /etc/php/7.4/fpm/php.ini

Note: As of 2022, new Hestia installations are using PHP 8 by default. Therefore the path will be /etc/php/8.x/fpm/php.ini Also note that the Line numbers in PHP 8 are slightly different than the line numbers on PHP 7.4.

Click on etc to open your etc folder. Then click on the php folder to open it. Then click on the 7.4 folder (or the 8.x folder) to open it. Then click on the fpm folder to open it. Select the file called php.ini

21

After selecting php.ini, click File Edit to open the php.ini file. Type 1 to select the Nano editor. Then press Enter. Note that there are 1947 lines in this file. To add line numbers to the Midnight Commander edit screen, press Alt plus c to show the line numbers.

Use the down arrow to scroll down to line 215 which does not have a semi-colon in front of it and is therefore active. Change output_buffering = 4096 to output_buffering = Off.

Fix other bad PHP INI default settings
The PHP INI file also has several other truly ridiculous default settings that should have been updated years ago. Thankfully, these only need to be fixed once – when you are first setting up your VPS. Here are three important settings to change:

#1 Use the down arrow to scroll down to line 388. Change the max_execution_time from 30 to 300 (seconds).

#2 Scroll down to line 398 and change the max_input_time from 60 seconds to 600.

#3 Scroll down to line 409 and change the memory_limit from 128M to 256M.

#4 Scroll down to line 694 and increase post max size from 8M to 128M: post_max_size = 128M

#5 Scroll down to line 846. Increase upload max file size from 2M to 100M. (this will allow us to upload short videos).

#6 At line 849. Increase max file uploads from 20 to 40. This will allow us to upload up to 40 images at a time instead of the current 20.

#7 Then scroll down to line 874. Change default_socket_timeout from 60 to 600 (seconds).

Note that some values are related to other values. The order from biggest to smallest should be: memory_limit 256 > post_max_size 128 > upload_max_filesize 100

Then save the PHP INI file with Control plus o followed by Enter. Then close the file with Control plus x. Then click on the two dots a couple of times to go back to the etc folder.

Next open the /etc/apache2/apache2.conf file and change:

In the Global configuration section, Timeout increase from 30 to 300. Then save the file with Control plus o followed by Enter. Then close the file with Control plus x.

Open the /etc/nginx/nginx.conf file and change:

fastcgi_connect_timeout from 30 to 180s

fastcgi_read_timeout increase to 300s

proxy_connect_timeout from 30 to 600s
Then save the file with Control plus o followed by Enter. Then close the file with Control plus x. Then type the word exit and press Enter to close Midnight Commander without turning off your server. Then type exit and press Enter to close ssh session without turning off server. Then close the terminal.

Restart several Hestia Services for changes to take effect
Back at the Hestia Admin screen, click on Server settings, Configuration and restart apache, mariah db, nginx and php7.4-fpm (or php8.x-fpm). You are now ready to add as many Joomla websites as you want!

What’s Next?
In the next article, we will use Hestia to install Joomla.