0

Operating System: Debian GNU/Linux 10 (buster) Kernel: Linux 4.19.0-17-amd64 Architecture: x86-64

I am studying behavior of crontab -e. Are following assumptions correct?

  1. crontab -e edits the crontab file in "default editor"
  2. Such "default editor" is selected by sudo update-alternatives --config editor
  3. If printenv EDITOR returns blank, the above "default editor" is used
  4. But if $EDITOR is defined, it takes precedence over the "default editor"

Also, after selecting "default editor", where is that selection stored? Many online resource explains how to select "default editor", but I couldn't find answer to location of configuration file.

1
  • You have to add this setting into your personal .profile file (then logout and relog) or .bashrc. Oct 8, 2021 at 5:35

1 Answer 1

1

man crontab answers most of your questions; if you’re using Vixie Cron:

The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically. If neither of the environment variables is defined, then the default editor /usr/bin/editor is used.

So the editor is determined by the VISUAL variable, or if it’s not set, the EDITOR variable, and if that’s not set, /usr/bin/editor. The latter is an alternative, i.e. a symlink to /etc/alternatives/editor, which is itself a symlink to the chosen editor, configurable as you say by running update-alternatives.

That’s how the chosen alternative is stored: the corresponding symlink is updated. Information about alternatives is also stored in /var/lib/dpkg/alternatives. See man update-alternatives for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .