Text Editing in Ubuntu Cloud Environment Within a Powershell Environment


Sorry about the headline; it's mostly a bunch of keywords to help it be found when I need it again.

The Problem

I have an Ubuntu container in a cloud environment managed by Virtuozzo (on Reclaim Cloud). I access it either using the built-in SSH Console or by using ssh within PowerShell. I need to set the crontab, which means I need to use the built-in editor in the Ubuntu environment.

The problem is that the Ubuntu has minimal text-editing capabilities, and when I try to edit either way I just get a blank or janky screen in which nothing appears to work. I tried changing the editor using 'select-editor' but it displayed nothing. So I couldn't edit crontab.

The Solution

Rebuilding terminal editing support in the Ubuntu container.

First, logged in as root, I installed vim, using the following commands:

    apt-get update

    apt-get install vim

The first refreshed the apt-get function, and the second does the actual install. Instructions here.

Then, I ran select-editor:

    select-editor

and this time it gave me options. I selected vim.basic. Instructions here.

The other option is nano. Maybe there's a way to configure nano so it also works, but I don't know what it is. This wasn't enough, however. It opens the file OK, but the arrow keys don't work at all. I need to set the terminal type. 

I go to my home directory - for me, working as root, it was /root but for you it will be your user home directory. Change to your home directory, whatever it is:

    cd /~

Then create a .vimrc file

    touch .vimrc

Then open the editor to that file:

    vi .vimrc

Now you're editing the file. But your editor doesn't work! We'll set the terminal inside the editor:

         press 'escape'

type:

    :set term=builtin_ansi

and hit enter. You should see the display of your file change. Instructions here.

Now you can edit your .vimrc file. 

type 

        i

to insert text (here are all the instructions for using vi, in case it's new to you). Then insert the following text:

    set term=builtin_ansi

and press enter.

To save the file in vi, type 'escape', then:

    :wq

which writes and quits. Instructions here.

Now vi will work properly and you can edit the crontab. Use your arrow keys to move your cursor, the i command to insert text, and esc when you're done and want to save or move the cursor again.

While I'm here, here's a great set of instructions for testing and setting up cron.


 

Comments

Post a Comment

Your comments will be moderated. Sorry, but it's not a nice world out there.

Popular Posts