Useful tips for Debian based distros

Useful tips for Debian based distros

Change the default editor from nano to vi


When doing visudo, vipw, vigw or systemctl edit, the default editor is nano. I want to change it to vi or vim.

solution 1

Type update-alternatives --config editor. You will get a text like below.

~] update-alternatives --config editor
There are 3 choices for the alternative editor (providing /usr/bin/editor).

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

Press <enter> to keep the current choice[*], or type selection number: 

Find vim.tiny selection number. Type it and press enter. Next time when you open visudo your editor will be vim

solution 2

Another solution is export environment variables. In man visudo or another apropriate command you can see for ENVIRONMENT

ENVIRONMENT
     The following environment variables may be consulted depending on the value of the editor and env_editor sudoers settings:

     SUDO_EDITOR      Invoked by visudo as the editor to use

     VISUAL           Used by visudo if SUDO_EDITOR is not set

     EDITOR           Used by visudo if neither SUDO_EDITOR nor VISUAL is set

As you seem to use vi general, set both VISUAL and EDITOR variable:

export VISUAL="vim"
export EDITOR="$VISUAL"

solution 3

If you never plan to use nano, you can also simply remove it. Then the system will use vi/vim as the default.

~] apt-get purge nano

Check debian version


lsb_release

install lsb-release package

~] apt-get install lsb-release

Run lsb_release command with -a parameter

~] lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

os-release command

Another way to check your linux distribution version is output from os-release file

`] cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"