Useful tips for Debian based distros

Useful tips for Debian based distros

Debian bookworm - behavior of more utility has changed

I've just ran apt upgrade and apt dist-upgrade and noticed the behavior of more utility has changed. In particular I have to supply -e option in my scripts otherwise it currently presents me with (END) prompt in console.
Or when I have alias with more utility, example: alias lf="ls -alFh|more", the output end with (END) prompt in console.

Manual says the following:

-e, --exit-on-eof Exit on End-Of-File, enabled by default if not executed on terminal.

The changelog for 2.38 version in util linux repository says:

POSIX compliance patch preventing exit on EOF without -e [Ian Jones]

solution:

So, the default behaviour would be replicated using more -e .... You can use an alias to always call it with -e by adding this to your ~/.bashrc if you're using bash:

alias more="more -e"

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/"

SUBSCRIBE FOR NEW ARTICLES

@
comments powered by Disqus