Ubuntu Server Setup

assuming you got it up and running already, eventually through PXE

Quick post-install

Check what exact version you got installed

lsb_release -a

Get a lease to proceed remotely

ip addr
dhclient -v NETIF
apt update
apt install openssh-server

and eventually continue through ssh

Better networking

Switch back to the old school /etc/network/interfaces

apt update
apt install net-tools ifupdown

rmdir /etc/network/interfaces.d/
#mv /etc/network/interfaces.d/50-cloud-init.cfg /etc/network/interfaces.fuck.the.cloud-init.cfg
mv /etc/network/interfaces /etc/network/interfaces.dist

Proceed with a typical Debian network setup

vi /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address x.x.x.x/xx
    gateway x.x.x.x
    dns-nameservers x.x.x.x
    #dns-search example.local

Apply, check that your local and caching stub-resolver points to your true validating resolver

systemctl restart networking
systemd-resolve --status

and see next section for disabling netplan at boot time

GRUB & kernel arguments

cp -pi /etc/default/grub /etc/default/grub.dist
vi /etc/default/grub

GRUB_CMDLINE_LINUX="netcfg/do_not_use_netplan=true net.ifnames=0 biosdevname=0 mitigations=0"

grep netplan /boot/grub/grub.cfg

Eventually validate that networking get correctly setup at boot time by rebooting the box



apt install nvi elvis-tiny
apt purge vim vim-common vim-runtime vim-tiny
update-alternatives --config vi
update-alternatives --config editor


Clean-up the configuration file

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

Check that the repositories point against some near mirror, for example bionic/RU

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

Alternatively, you can build your own configuration with some helper

And in case you have an HTTP PROXY on your network for that purpose

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

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

apt update


Check for major release uprgade


Proceed with patch updates

apt update
apt full-upgrade

and see Ubuntu Server Operations for further maintenance

Additional steps & server specific

Time Setup

Time Setup

Environment & additional 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

Tweak your environment

Setup GNU/Screen

Fixing 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
#dpkg-reconfigure locales

==> full fix, check the current setting,


(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

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"
source /etc/bash.bashrc

Shutdown Scripts

cat > /lib/systemd/system/rc-local-shutdown.service <<-EOF
Description=/etc/rc.local_shutdown Compatibility
After=rc-local.service basic.target



vi /etc/rc.local_shutdown


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

Do not clear the screen

tested on Bionic

On a bare-metal system, prevent the system from clearing the screen after boot (equivalent of getty --noclear)

#systemctl edit getty@tty1
ls -lF /etc/systemd/system/getty.target.wants/
vi /lib/systemd/system/getty@.service


systemctl daemon-reload

Revert to the default set of packages


Revert to default installed pkgs,

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


how can I remove the clear screen before login https://askubuntu.com/questions/58097/how-can-i-remove-the-clear-screen-before-login

Prevent the console from clearing the screen? https://serverfault.com/questions/255969/prevent-the-console-from-clearing-the-screen

Configure Locales in Ubuntu https://www.thomas-krenn.com/en/wiki/Configure_Locales_in_Ubuntu

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