Console environment configuration for a testing workstation

Configuring the console on our example Debian testing workstation/desktop machine

Author: Francesco Poli
Contact: invernomuto@paranoici.org
Version: 0.58
Copyright: Expat license
Notice:

Copyright (c) 2007-2026 Francesco Poli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About this document
Web form HyperText Markup Language
Source form reStructuredText
Web stylesheet Cascading StyleSheets
Build directives Makefile

Contents

Summary of previous episodes

In another document (HTML, reST) you saw some initial tuning for our example Debian testing workstation/desktop box. Now that the new system is up-to-date and reasonably hardened, you can customize it in order to fit your needs. If your tastes for the console environment are similar to mine, go on reading...

Shell customization

The default shell in a Debian system is GNU Bash. Let's customize the shell environment for root and for the regular user, as well.

For the root user, edit /root/.bashrc. Add the following lines:

# store 1000 commands in history, but don't put duplicate lines
export HISTCONTROL=ignoredups
export HISTSIZE=1000
export HISTFILESIZE=1000

# append to the history file, don't overwrite it
shopt -s histappend

Modify the prompt line so that it looks like:

PS1='\[\e[1m\]\u@\h \W \$ \[\e[0m\]'

and uncomment the lines that set safer aliases for potentially dangerous commands:

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

Then, add the following lines:

# set editor for fc builtin
export FCEDIT="vim"

You can also add the following two lines, in order to get more data in the status line of less and to make color escape sequences work:

# default options for less
export LESS="-MR"

For the regular user, edit ~/.bashrc. Change the history configuration into:

# store 1000 commands in history, but don't put duplicate lines
export HISTCONTROL=ignoredups
export HISTSIZE=1000
export HISTFILESIZE=1000

# append to the history file, don't overwrite it
shopt -s histappend

Uncomment the following line:

[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

Change the prompt settings into comments and set the following prompt:

# set a fancy prompt
PS1='${debian_chroot:+($debian_chroot) }\[\e[1m\]\u@\h \W \$ \[\e[0m\]'

If, like me, you do not like ls coloring, change the line:

alias ls='ls --color=auto'

into a comment:

#alias ls='ls --color=auto'

Finally add the following lines:

# set editor for fc builtin
export FCEDIT="vim"

# default options for less
export LESS="-MR"

Customizing locale settings

Install the locale data package:

# aptitude install locales

If it was already installed, mark it as manually installed:

# aptitude unmarkauto locales

Configure the default system-wide locale:

# update-locale LANG="en_US.UTF-8" LANGUAGE="en_US:en"

Now you should have:

$ cat /etc/locale.conf
#  File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"

and:

$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Customizing text editors

You can set up a good configuration file for VIM:

$ cat ~/.vimrc
" Use Vim defaults
set nocompatible

" Trust no one...
set secure

" set UTF-8 encoding
set encoding=utf-8

" Load plugin files for specific file types
filetype plugin on

" Syntax highlighting
set background=dark
syntax on

" Normally I want 8 spaces instead of a TAB
" (but an actual TAB may be obtained with CTRL+v,TAB)
set expandtab

" Indentation preferences (mainly for C and the like)
set autoindent
autocmd BufEnter *.c,*.h,*.cpp,*.hpp :set cindent
autocmd BufLeave *.c,*.h,*.cpp,*.hpp :set nocindent
set sw=4
set cino=n-2,{2,t0,+4,(0

" Highlight searched items
set hlsearch

" Indent when pasting by default
" (but <F11> toggles auto-indentation for pastes)
set nopaste
set pastetoggle=<F11>

" Enable mouse and have fun!
set mouse=a
:nmap <LocalLeader>p i<S-MiddleMouse><ESC>
:imap <S-Insert> <S-MiddleMouse>
:cmap <S-Insert> <S-MiddleMouse>
:map <MouseMiddle> <esc>"*p

" Speedup long file processing
autocmd BufEnter * :syntax sync minlines=100

" Do *not* autowrap text!
autocmd BufEnter * :set fo-=tc

" Set shell-like tab completion
set wildmode=longest,list:longest,list:full

The above quoted .vimrc can be used for your regular user and for root, as well.

Then, install a useful VIM plugin:

# aptitude install vim-vimoutliner

If you want to enable the vimoutliner plugin for your regular user, issue the following command:

$ vim-addons install vimoutliner

You should also tweak its configuration:

$ cat ~/.vimoutlinerrc
let g:vo_modules_load = "checkbox"
if !exists("otl_autocmds_loaded")
  let otl_autocmds_loaded = 1
  autocmd BufWinEnter *.otl :set foldlevel=0
  autocmd BufUnload *.otl :silent !savelog -q -n -p -c 8 <afile>
  autocmd BufUnload *.otl :silent !cp -af <afile>.0 <afile>
endif

In order to enhance the markdown syntax highlighting support, until bug #885936 is fixed, you may want to add the following configuration tweak for your regular user:

$ cat ~/.vim/after/syntax/markdown.vim
unlet! b:current_syntax

syn include @tex syntax/tex.vim
syn region inlmath start="\\\@<!\$ \@!" end=" \@<!\$" skip="\\\$" keepend contains=@tex
syn region dismath start="\\\@<!\$\$" end="\$\$" keepend contains=@tex

unlet! b:current_syntax

syn include @yamlTop syntax/yaml.vim
syn region yamlmetadata start="\%^---$\|^\s*\_^---$" end="^---$\|^\.\.\.$" keepend contains=@yamlTop

let b:current_syntax = "markdown"

Obviously, you want VIM to be your regular user's selected editor, when invoking sensible-editor (from package sensible-utils):

$ select-editor
Select an editor.  To change later, run select-editor again.
  1. /bin/nano        <---- easiest
  2. /usr/bin/vim.basic
  3. /usr/bin/vim.tiny

Choose 1-3 [1]: 2
$ cat ~/.selected_editor
# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/usr/bin/vim.basic"

Please note that, in case you're not familiar at all with VIM, and you want to start learning how to use it, you may issue the following command:

$ vimtutor

and read through the nice interactive tutorial.

Utilities

Install a nice command to visualize directory subtrees:

# aptitude install tree

Also, install a little program to check the freeness of your system:

# aptitude install check-dfsg-status

Then, install a useful command scheduler:

# aptitude install at

Sometimes you need to measure CPU time used by a command; the following is a feature richer replacement for the corresponding GNU Bash builtin:

# aptitude install time

Just in case you come into contact with non-UTF-8 filenames:

# aptitude install convmv

A powerful command to mass-rename files:

# aptitude install rename

If it was already installed, mark it as manually installed:

# aptitude unmarkauto rename

A tool to monitor hardware health:

# aptitude install lm-sensors

In order to access more sensors, load the following kernel module:

# modprobe nct6775

In order to have this module automatically loaded at boot, create the following file:

# echo nct6775 > /etc/modules-load.d/lm-sensors_local.conf

Other tools that could be useful to get information about the CPU and other hardware of the workstation is:

# aptitude install cpuid hwinfo

Then, install a helper tool for locales:

# aptitude install localehelper

and a calendar display program:

# aptitude install ncal

Dictionaries and spell checking

Install a useful command-line online dictionary client:

# aptitude install dict

Moreover, install a spell checker (if it is not already installed):

# aptitude install ispell

Then install some other appropriate dictionaries:

# aptitude install iamerican ibritish iitalian ingerman

Finally, install some wordlists (some of which should be already installed for cracklib):

# aptitude install wamerican wbritish witalian wngerman

Console mouse support

Activate mouse support for the console environment:

# aptitude install gpm

Calculators

Install some useful text interface calculators:

# aptitude install dc calc

and a unit converter:

# aptitude install units

Fortune

Install the well-known fortune program, which displays epigrams on demand (it may be useful when you feel a bit sad or bored...):

# aptitude install fortunes

With this, you have the basic fortune cookie database. Install some additional collections:

# aptitude install fortunes-bofh-excuses fortunes-debian-hints

You can also install some non-english fortune collections:

# aptitude install fortunes-it

and even offensive fortunes:

# aptitude install fortunes-it-off

Debian documentation

Some documents which is good having always handy:

# aptitude install doc-debian

File comparison and conversion

Install the following word-by-word text file comparison tool:

# aptitude install wdiff

and the following new line delimiter conversion tools:

# aptitude install tofrodos

Moreover, you may want to install the following in-depth file/archive/directory comparison tool:

# aptitude --without-recommends install diffoscope python3-tlsh+M

Archive file management

Mark as manually installed the following .zip compressed archive creation and extraction tool:

# aptitude unmarkauto zip unzip

Install the following multi-format archive extraction tool:

# aptitude install unar

and the following compression tool:

# aptitude install bzip2

Large text display

Install the following package:

# aptitude --without-recommends install toilet

Message of the day

Prepare a little script to customize the banner that is shown when a user logs in to the console:

$ mkdir -p ~/bin
$ cat ~/bin/create-motd.sh
#!/bin/sh

dts()
{
    # drop trailing spaces
    sed -e 's/ *$//'
}

N_DASHES=76
DASHES=$(for _ in $(seq $N_DASHES) ; do printf '-' ; done)

printf '\n'
toilet -f term -c -- "$DASHES"                 | dts

printf '\n'

MYHOSTNAME=$(hostname)
toilet -f future -c "$MYHOSTNAME"              | dts

printf '\n'
toilet -f term -c "Welcome to $MYHOSTNAME"     | dts
toilet -f term -c "Debian GNU/Linux"           | dts

printf '\n'
toilet -f term -c -- "$DASHES"                 | dts
printf '\n'

and set proper permissions:

$ chmod +x ~/bin/create-motd.sh

You can use this script to create a customized MOTD:

$ create-motd.sh > /tmp/motd

If you are satisfied with the result, you can use it as /etc/motd:

# cat /tmp/motd > /etc/motd

Text colorizing

Install the following simple and useful package:

# aptitude install clog

Serial console connection

If you need to connect to a serial console through a serial null-modem cable, you may want to install the following package:

# aptitude install picocom

The users that need to connect to a serial console have to be added to the dialout group:

# adduser $USER dialout

where $USER should be substituted with the actual username.

Socket connection

If you need to handle sockets and the like, you may want to install the following package:

# aptitude install socat

Configuration file parsing

Install an INI-style configuration file parser:

# aptitude install confget

Conclusions

Now the system has a reasonably comfortable console. Next step is configuring the desktop environment. More details in a separate document (HTML, reST).