Setup Debian / Ubuntu Server

Time Setup

Time Setup

Setup sources.list

Clean-up your package sources configuration,

cd /etc/apt/
mv sources.list sources.list.dist
sed '/^[[:space:]]*$/d; /^[[:space:]]*#/d' sources.list.dist > sources.list

and in case you told the installer you are in the US while you are, say in Russia,

mv -i /etc/apt/sources.list /etc/apt/sources.list.tmp
#country=fr
country=ru
sed "
    s/http:\/\/us\./http:\/\/$country./g;
    /^#/d;/^$/d
" /etc/apt/sources.list.tmp > /etc/apt/sources.list
cat /etc/apt/sources.list
rm -f /etc/apt/sources.list.tmp
unset country

for example Debian

... main contrib non-free

for example xenial/FR

deb http://fr.archive.ubuntu.com/ubuntu/ xenial main restricted universe
deb http://fr.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe
deb http://fr.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe
#deb http://fr.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe
#deb http://fr.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe

for example xenial/RU

deb http://ru.archive.ubuntu.com/ubuntu/ xenial main restricted universe 
deb http://ru.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe
deb http://ru.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe
#deb http://ru.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe
#deb http://ru.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe
#multiverse

Alternatively, you can build your own sources list with this helper: https://repogen.simplylinux.ch/

APT Proxy

In case you are using an APT/HTTP proxy,

#nmap -p 3142 x.x.x.x
vi /etc/apt/apt.conf.d/02proxy

Acquire::http { Proxy "http://x.x.x.x:3142"; };

Environment & Packages

Install a few more packages. Starting with packages that are not for Docker containers,

cd ~/
wget https://github.com/pbraun9/doc/raw/master/ubuntu.hw.lst
list=`sed '/^#/d' ubuntu.hw.lst`
export DEBIAN_FRONTEND=noninteractive
apt install `echo $list` # w.o double quote
rm -f ubuntu.hw.lst
unset list

and continuing with the list that is shared with some troubleshooting-enabled Docker containers,

wget https://github.com/pbraun9/doc/raw/master/ubuntu.server.lst
list=`sed '/^#/d; /^$/d' ubuntu.server.lst`
export DEBIAN_FRONTEND=noninteractive
apt install `echo $list` # w.o double quote
rm -f ubuntu.server.lst
unset list

systemctl status postfix
systemctl stop postfix
systemctl disable postfix

systemctl get-default
systemctl set-default multi-user.target
update-alternatives --config editor
==> elvis-tiny

Tweak your environment

Setup GNU/Screen

Fixing the Locales

warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Quick fix,

locale-gen en_US.UTF-8
#update-locale LANG=en_US.UTF-8

Long fix, check the current setting,

locale

(Re-)Generate the locale,

apt install language-pack-en-base
locale-gen en_US.UTF-8
update-locale en_US.UTF-8
dpkg-reconfigure locales
cat /etc/default/locale
locale

LANGUAGE and LC_ALL are still missing. Add those the brutal way,

cat >> /etc/bash.bashrc <<EOF
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
EOF
source /etc/bash.bashrc

Shutdown Scripts

cat > /lib/systemd/system/rc-local-shutdown.service <<-EOF
[Unit]
Description=/etc/rc.local_shutdown Compatibility
ConditionFileIsExecutable=/etc/rc.local_shutdown
DefaultDependencies=no
After=rc-local.service basic.target
Before=shutdown.target

[Service]
ExecStop=/etc/rc.local_shutdown
StandardInput=tty
RemainAfterExit=yes

[Install]
WantedBy=shutdown.target
EOF

vi /etc/rc.local_shutdown

#!/bin/bash
...

chmod +x /etc/rc.local_shutdown
systemctl daemon-reload 
systemctl enable rc-local-shutdown.service

Miscellaneous

Do not clear the screen

On a bare-metal system, prevent the system from clearing the screen after boot (tested on Bionic)

systemctl edit getty@tty1

[Service]
TTYVTDisallocate=no

systemctl daemon-reload

Revert to the default set of packages

draft/untested

Revert to default installed pkgs,

dpkg --get-selections >output
dpkg --set-selections <output
apt-get dselect-upgrade

Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml