0

I read here about how to safely edit a file using sudo, I do use sudoedit most of the time, however I would be interested to know if there is something similar on Ubuntu to rvim which is mentioned there.

I am running Ubuntu GNOME 16.04 with GNOME 3.20 and as I can't find anything in the repositories with the same or a similar name I was wondering if rvim or a similar restrictive text editor exists in Ubuntu?

5
  • Well, according to the vim man page, rvim Can also be done with the "-Z" argument. – steeldriver Aug 17 '16 at 14:52
  • @steeldriver: Oh, please post that as an answer then so that I can accept it! – user364819 Aug 17 '16 at 15:13
  • There's no separate package for rvim, but installing vim does install a /usr/bin/rvim executable. Check your dir. I have it on my system. (But it doesn't show up in the list of installed files for vim, which I can't explain.) You can call it with rvim as you would expect. According to the man file, the -Z works like the executable [that] starts with "r", so its the functional equivalent of rvim but is not literally calling the rvim executable. – chaskes Aug 17 '16 at 15:45
  • @chaskes: Strange! I could have sworn it wasn't finding rvim before when just running it like that. – user364819 Aug 17 '16 at 16:23
  • @ParanoidPanda We've all had things like that happen. :) – chaskes Aug 17 '16 at 16:26
2

There appears to be no independent rvim binary, however installing the vim package creates a symbolic link using the update-alternatives mechanism:

Setting up vim (2:7.4.1689-3ubuntu1.1) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode

Following the link, we find that the link eventually resolves to vim.basic

$ readlink -f $(which rvim)
/usr/bin/vim.basic

Presumably there's some argv[0] magic inside vim.basic that causes it to run it in restricted mode when invoked as rvim.

According to the vim manpage you can also use the -Z option:

rvim rview rgvim rgview
          Like the above, but with restrictions.  It will not be possi‐
          ble to start shell commands, or suspend  Vim.   Can  also  be
          done with the "-Z" argument.

Which provides the same functionality in vim as rvim, but is not literally calling rvim.

3
  • Perhaps you should add it to your answer, I just tried running rvim with vim installed and I'm pretty sure I got it! Seems to be as said here. – user364819 Aug 17 '16 at 16:18
  • I edited your answer with my suggestion, please do edit it though as you wish. I just wanted to quickly get the information in there. – user364819 Aug 17 '16 at 16:22
  • @ParanoidPanda it appears to be some update-alternatives magic – steeldriver Aug 17 '16 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy