Skip to content

How to edit files via console

Daniel Speichert edited this page Dec 19, 2015 · 4 revisions

You do not always need to download files to your machine via WinSCP, edit the and upload them back!

There is an easy way to edit files directly on the server with one of many command-line files editors. Many people use nano, vi or vim. However, we recommending trying mcedit, which is part of mc - a great command-line file browser.

The syntax to edit a file directly from command prompt is as follows:

[otsmanager@host ~]# mcedit /path/to/file

Then you can simply edit the file and use one of many hotkeys you see at the bottom of the screen:

Other tricks:

  • Select text with mouse - copy to clipboard
  • Shit+Insert - paste from windows clipboard

The file editor looks like that:
mcedit

File browser: mc

In case you want to browser directories and files easily, you can simply run mc:

[otsmanager@host ~]# mc

It will look like this:
mc

Useful hotkeys:

  • TAB - switch from left to right panel
  • Insert - select file
  • F2 - open menu - useful to compress directories
  • F5 - copy selected file(s) from one side to another
  • F6 - move selected file(s) from one side to another
  • F7 - create directory
  • F8 - delete file
  • F10 - quit
  • CTRL+O - open shell in current directory
  • CTRL+S and start typing - search for a filename in current directory
  • Alt+C and type path - go to directory
    See reference: https://www.midnight-commander.org/wiki/doc/filePanels/hotkeys
Clone this wiki locally