F9 to bring up the top menu >
Edit menu file >
User. The menu file will open. Add
+ t r
e Edit file with elevated priviledges
xterm -e 'sudo vim %f' &
to it, separated by at least one blank line from the other code blocks already present in the file. Save and close the file. Now when you want to edit a file with priviledges, just press
F2 (brings up the user menu) and then
e to select this entry.
+ t r guarantees that that entry only shows up for regular files (not for directories, sockets, etc.). See
man mc, section
Edit Menu File for more.
xterm -e 'sudo vim %f' & is the executed command. It launches a new terminal in the background with the editor — here Vim, choose the one you like best —, so that Midnight Commander does not block. The downside is that the password will be requested each time, no matter how small the interval between the sudos is. If you don't want that:
Option 1: Simply use
sudo vim %f instead, but that will take MC away from you until you close the editor.
Option 2: Make a user entry similar to the one shown above, but one that launches a new MC with root permissions with
sudo mc %d %D & (
%d %D to make the new MC open in the directories that you are!). You can use a different color scheme for root so you remember to be cautious.
I really like option 2 because it is very convenient to move files around in protected directories such as