More MX encounters

Does anyone use view to look at files?
It is an alternative to more or less.
It is the same as vi -R ie vi in readonly mode.
I like it because I can scroll and search easier, and it is safe for system files.

So try view filename in MX , and I get a strange looking terminal window with tabs at the bottom, which turns out to be the Midnight Commander Editor., found at /usr/bin/mcview.

So we have a name clash of commands. Not a good mark for MX.
It turns out this is managed by update-alternatives.
We can inspect the situation with

$ update-alternatives --display view
view - auto mode
  link best version is /usr/bin/mcview
  link currently points to /usr/bin/mcview
  link view is /usr/bin/view
  slave view.1.gz is /usr/share/man/man1/view.1.gz
  slave view.da.1.gz is /usr/share/man/da/man1/view.1.gz
  slave view.de.1.gz is /usr/share/man/de/man1/view.1.gz
  slave view.fr.1.gz is /usr/share/man/fr/man1/view.1.gz
  slave view.it.1.gz is /usr/share/man/it/man1/view.1.gz
  slave view.ja.1.gz is /usr/share/man/ja/man1/view.1.gz
  slave view.pl.1.gz is /usr/share/man/pl/man1/view.1.gz
  slave view.ru.1.gz is /usr/share/man/ru/man1/view.1.gz
/usr/bin/mcview - priority 25
  slave view.1.gz: /usr/share/man/man1/mcview.1.gz
/usr/bin/vim.tiny - priority 15
  slave view.1.gz: /usr/share/man/man1/vim.1.gz
  slave view.da.1.gz: /usr/share/man/da/man1/vim.1.gz
  slave view.de.1.gz: /usr/share/man/de/man1/vim.1.gz
  slave view.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz
  slave view.it.1.gz: /usr/share/man/it/man1/vim.1.gz
  slave view.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz
  slave view.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz
  slave view.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz

This says that there is a link in /etc/alternatives called view and that it currently points to /usr/bin/mcview, but there is an option to point it to /usr/bin/vim.tiny instead.
So lets do that

$ su
Password: 
root@trinity:/etc/alternatives# cd
root@trinity:~# update-alternatives --config view
There are 2 choices for the alternative view (providing /usr/bin/view).

  Selection    Path               Priority   Status
------------------------------------------------------------
* 0            /usr/bin/mcview     25        auto mode
  1            /usr/bin/mcview     25        manual mode
  2            /usr/bin/vim.tiny   15        manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/view (view) in manual mode
root@trinity:~# exit
exit
nevj@trinity:/etc/alternatives

So it offered me 3 choices (0,1,2) and I took No. 2.

That seems to fix the problem. Now when I do
view filename
I get vi in readonly mode.

I have previously fixed this sort of thing by deleting the command I did not want, but learning to use update-alternatives seems a better way, because it will keep the package system happy.

2 Likes