Are there scenarios where vi
is the only option to create, edit or modify a file in an Ubuntu environment?
My question is basically to really know if there is such a case where I would be forced to use vi
because it would be the only option available in a particular case in the Ubuntu ecosystem.
Could a particular case exist where I somehow would not have access to other options like nano
, pico
or simply sending the information with tools like cat
, sed
, tee
and more?
I would assume this is more of a server or cloud side since on the Desktop there are many more options, but from anybody that uses the terminal a lot I ask:
Is there such a case?
Inside the Ubuntu ecosystem, I do not think this case can even exist, as
vi
would at least be a vim-tiny, which is already a “realvim
” far from “realvi
.”In the context of resource limited embedded systems, which are not normally Ubuntu, you may just have a
vi
that turns out to be a link tobusybox
. And not space left. Then,vi
is the only option.Apart from that, I think situations where
vi
the only option are not very common at all today, even outside the Linux world.But there can easily be situations where
vi
is the only option you can plan for, the only option that certaily will exist in some future situation — which will happen inside a customer’s over-chilled server room, most probably.Imagine you are called by a customer:
No problem, by now, you know there will be
vi
!Vi is never the only option; you can always use
ed
instead.Well, there is one case where you need the
vi
editor, lets assume:*nix
systemAs you can see there is no numerical keypad. With the old
vi
(and I mean the original traditionalvi
, notvim
,vim.tiny
, orvim.basic
) you can edit a file with this keyboard. Without arrow keys? Yes, when you're in command mode you moved through the file with h, j, k and l, like a pro. h was left, j was down, k was up and l was right.Fact of the matter is that, in many distributions editors like
nano
andpico
just aren't standard while other packages, namelyvim-tiny
are. See here for the package list of ubuntu-minimal,vim-tiny
is the only editor. According to this answer, it seems to be the case for Ubuntu server, as well. I know this is the case for base Debian, Fedora as well.That being said, given that if you have
nano
on your system I've yet to see a case where you'd HAVE to usevi
instead, but, playing off @Volker's answer, if you're working for a customer and don't have root access?apt-get install nano
isn't going to do you much good (if it even has access to the outside internet!).There are a number of cases where
vi
(and by that I naturally meanvim.tiny
because that's what we ship) could be the only interactive editor. If we ignore butterflies and cosmic-rays, these seem like the most likely occasions where this could happen:You're only using the
ubuntu-minimal
base meta-package. This depends onvim-tiny
but no other editors. I can't currently find a way to install Ubuntu without thestandard^
task but you can remove it after installation with:I have personal experience where I've been handed a system image without the
standard^
task installed. If I hadn't had network accessvi
would have been my only option.Chrooting into an environment that only mapped
vi
throughManually nuking all the other editors (and disabling the means to reinstall them)
Manually breaking the shell to stop known editors except
vi
being launched.A true-minimal install will be the most likely reason but those are fairly rare these days. Some VPS and cloud hosting companies use them (to save disk space as much as anything else) but I would suggest that they are definitely not the norm.
In cases where you are not able to install emacs, or in cases where you need to modify a configuration file in order to enable you to install emacs. :-p
Many (most?) Busy-Box installations only have
vi
.It's not ubuntu specific, but it is true of many embedded devices.
There's always cat, head, tail ... so I am not sure there is system where you do not have any alternative, but it's possible to find systems where there is not a better alternative even if you prefer emacs.
My example was a system I once administered, that was either so slow (or the line was slow and lossy), that when navigating with cursor keys, it often suddenly switched to insert and injected garbage into the edited file, and using HJKL for movement was the only reliable option.
Here's the case where vim is the only option within Ubuntu ecosystem:
Ubuntu Snappy
doesn't come with any text editor other thanvim-tiny
. Perhaps in future there will be one, but not as of 2015-16. If you are going to be using Ubuntu Snappy over serial console or ssh, you better be prepared to usevim
.I got myself into a situation once where only vi's linemode was working. Something having to do with having really screwed up terminal definitions. Basically only vi in linemode (this behaves like normal vi if you pretend you have a 1 line terminal), ex, and ed were going to work because the only terminal definition was "dumb".