13

Anyone know what is the default text editor for Ubuntu Server 22.04 LTS with minimal installation?

I tried vim, nano, editor, gedit. none of the above is working.

muru
  • 207,970
dhg
  • 139
  • 1
    gedit is the GNOME editor, so unless you added GNOME (ubuntu-desktop) to your system, why would it be there? I'd expect vi to be included; ie. the basic editor & not vim (VI improved). If you don't have an editor you like; why not just add one? – guiverc Jun 22 '22 at 06:24
  • I believe you could find the network configuration file for that specific distro, modify it and pipe that text into a file, then replace the original file, for example echo "here you should copy the configuration file contents and modify it" > /etc/netplan/nameOfConfigFile This way you could set up your network and then install a text editor. – Locros Nov 29 '22 at 12:14

5 Answers5

9

You can use cat in a pinch (I needed to fix my netplan.yaml in order to connect to the internet, and thus couldn't install another editor)

cat - > /path/to/file then just ctrl+c to exit

19wolf
  • 375
  • 1
  • 5
  • 11
7

you can also use 'sed' for simple changes. For example if you want to replace the ip address:

sed -i s/192.0.2.0/192.0.2.1/ /etc/netplan/00-installer-config.yaml

In Ubuntu 22.04 the minimal installation is for machines where no human is logging in. And they really mean it! You are not supposed to ever login. Only automated tools are expected, which of course do not use visual text editors. Indeed, it was quite surprising because in previous Ubuntu versions the minimal installation meant that no regular users are logging in but a few interactive programs were still installed for sysadmins. Not for 22.04.

Abbreviations:

  • sed: stream editor
  • -i: edit file in-place (instead of only printing the result)
  • s: substitute
5

I had the same question, and I'm a little scared to report that it appears there isn't an editor installed with the Ubuntu 22.04 LTS minimal server install...

Ubuntu (including the minimal server install) ships with a utility to set the default editor (aptly named select-editor; see the Ubuntu select-editor Manpage). Honestly, it's kind of ironic, given the following, but... *shrugs*

I ran select-editor on my fresh minimal server install and got:

user@server:/$ select-editor
update-alternatives: error: no alternatives for editor
user@server:/$

So I installed nano, and ran it again to see what would happen:

user@server:/$ select-editor
user@server:/$

It seems that, now that there's only one editor installed, it ran without any further input and threw no errors.

To sate my growing curiosity, I installed vim as well and ran select-editor again:

user@server:/$ select-editor
Select an editor.  To change later, run 'select-editor'.
  1. /bin/nano        <---- easiest
  2. /usr/bin/vim.basic

Choose 1-2 [1]:

So all I can conclude from this is that the Ubuntu 22.04 LTS minimal server install does not ship with a text editor. *shrugs again; shakes head in disbelief*

claypooj
  • 181
  • 1
    This is unfortunate, I need a text editor to fix my internet so I can install a text editor Edit: cat - > /path/to/file was a usable solution – 19wolf Sep 20 '22 at 15:25
4

If you have internet access:

Try vi or vim.tiny instead of vim or you could install nano using the following commands:

sudo apt update
sudo apt install nano

If you don't have internet access, of course you have two options.

  1. write your config file from scratch using cat (it's really not much different than a regular text editor but you can't edit in place, only create new files).
  2. and/or use sed to edit in place.

and the secret third option is to not use the minimized install option if you need more user friendly tools before accessing the internet.

According to the list of installed packages posted here, there is no other text editor. As far as I understand, the minimized setup was originally intended for cloud instances, in which they have internet access by default. So if you want a text editor, they would expect you to install it yourself.

I usually use the mini.iso which is similar. Although it's set up to install over the internet so it obviously assumes you have network access.

Normally, I'll set up a virtual AP from a separate router with a fairly easy password to use during the installation process.

Nothing fancy:

  • automatic DHCP
  • super easy to remember password

Once everything is installed using apt and/or tasksel, I'll do the full configuration for networking and disable the virtual AP on the router.

So I guess the 4th option would be to make the network easier to connect to using the installer options so that writing a configuration file isn't necessary to access the internet.

mchid
  • 45,159
  • This requires network, and network seems hard to configure without an editor. Is there an easy way? – hey Jul 22 '22 at 04:26
  • 1
    @hey vi doesn't require network. – mchid Jul 22 '22 at 18:15
  • @mchid vi is not available in Ubuntu Server 22.04 LTS minimal installation, and to install it you need network – Ron Apr 27 '23 at 10:05
  • @Ron Yes, I guess they use vim.tiny now. I will update the answer. – mchid Apr 29 '23 at 01:49
  • 1
    Alternatively, type vi and then press TAB twice and it should either autocomplete or it will show you a list of available commands. – mchid Apr 29 '23 at 01:52
  • As I mentioned there's no vi, vim, nano, joe, pico or vim.tiny in the minimal installation... there's no single editor available, as surprising as that might sound. – Ron Apr 29 '23 at 01:54
  • @Ron You can't/didn't connect to the internet during installation? I assume you're using the mini.iso which is a network installer so it installs Ubuntu over the internet. After installation, you usually just run sudo tasksel first thing after you boot up for the first time to install the server and you can choose whatever other suites you'd like to install as well and it should use the same internet connection used during the prior installation process. Just remember to never use tasksel to uninstall any packages because it will basically uninstall your entire system. – mchid Apr 29 '23 at 02:13
  • No, we are talking about using the current ubuntu 22.04 standard server.iso, and throughout the process of installation you choose "Minimal setup" instead of the default "Standard setup", and you do not add anything additional , and you have no internet connection, no dhcp.. That is how I understand the question of the OP.. That installation does not contain vim.tiny nor any of the editors I mentioned above.. Thus the question being asked here. – Ron Apr 29 '23 at 02:21
  • @Ron Okay so this thread shows all the packages installed. sed is installed if you need to make edits in place. You can use cat for creating a new file from scratch like in the other answer shown. – mchid Apr 29 '23 at 02:57
  • is the Q about standard server or minimal installation?? cat and sed can be used, but they are not text editor. You could've tested, as I did, instead of guessing, assuming, twisting or keep commenting NOT relevant points... – Ron Apr 29 '23 at 03:11
  • "Minimal installation" typically refers to the mini.iso or Ubuntu minimal and what you're referring to is usually referred to as minimized. Maybe use the right language and don't look a gift horse in the mouth when someone tries to help you even though you're not using the right language for your question ;) – mchid Apr 29 '23 at 03:17
  • You're asking an XY question where your problem is that you need to edit a file but you're suggesting a solution instead of asking for a solution to your problem. The answer to fix your problem, use sed and cat as text editors. Sorry you don't like the solution but it is what it is. – mchid Apr 29 '23 at 03:20
  • It's usually way faster to edit using sed anyhow. – mchid Apr 29 '23 at 03:25
1

I have checked :

apt list --installed| grep -i vim

result after installation of vim-doc

vim-common/jammy-updates,jammy-updates,jammy-security,jammy-security,now 
2:8.2.3995-1ubuntu2.3 all [installed,automatic]
vim-doc/jammy-updates,jammy-updates,jammy-security,jammy-security,now 2:8.2.3995-1ubuntu2.3 all [installed]
vim-tiny/jammy-updates,jammy-security,now 2:8.2.3995-1ubuntu2.3 amd64 [installed,automatic]

It is: VIM - Vi IMproved version 8.2.4919

Adam
  • 379
  • According to dpkg -L vim-tiny (vim-common doesn't show an executable vim) the command is vim.tiny – mchid Apr 29 '23 at 01:49