Ubuntu Server - usage notes

Tags: #<Tag:0x00007f332cb9f0a8> #<Tag:0x00007f332cb9ef40> #<Tag:0x00007f332cb9edb0> #<Tag:0x00007f332cb9ec48> #<Tag:0x00007f332cb9eab8>


Automated - new school

Ansible Playbook


Manual - old school

Remove potentially unneeded software

snapd is installed by default. In some cases this may actually be a useful and sane way to deploy certain software. In most cases however I have no use case for it. Snaps are related to the Ubuntu Server distribution store.

To uninstall, if not needed:

sudo apt purge snapd ubuntu-core-launcher squashfs-tools
sudo apt-get remove accountsservice

Disable potentially unneeded daemons

By default Ubuntu Server has an iSCSI daemon, unless I am completely mistaken. Unless you plan to mount an iSCSI volume, you can disable the daemon via Systemd.

sudo systemctl disable iscsid
sudo systemctl stop iscsid

Remove the Ubuntu version string from the OpenSSH greeting banner

OpenSSH on Debian and Ubuntu greets you, and reveals the Linux distribution. That’s ok, but I don’t think it’s necessary. It’s simple to change default config: add the following line to /etc/ssh/sshd_config

DebianBanner no

A proper way to search for newly added SCSI disks

When you add a new SCSI disk (via VMware, Vbox, KVM… HW) you don’t need to restart the system. Instead you can install and run the scsitools package on Ubuntu Server.

apt-get install scsitools

/boot partition is full again


For reasons I do not understand Ubuntu Server keeps a lot of kernels, and does not purge them during the upgrade process. Due to this apt-get upgrade may fail, if the /boot partition is full. Solving this isn’t super easy, because the package manager is on a strike, a partition appears to be full, and you read something about “kernel”… You can go through a lot of pain, and try to resize the partitions. Or you can just remove some kernels.

Here is some of the usual Bash Kung Fu I have in my history. Please triple-check this:

for file in $(ls -t /boot/initrd.* | grep -v $(uname -s) | tail -n 3); \
   do du -sh $file; done | \
   awk '{ print $2 }' | \
   xargs sudo rm
dpkg -l | grep linux-image | \
   awk '{ print $2 }' | grep -v extra | grep -v $(uname -s) | \
   grep -v "linux-image-generic" | head -n 3 | \
   xargs sudo apt-get -y remove

The for loop goes through the folder, and parses ls. If you see someone doing this, you know it’s bad.

The dpkg -l listing is a better way, but sometimes it may not work, depending on how apt-get got stuck.

The currently loaded kernel is kept, and only the 3 oldest kernels are supposed to be removed. I know… fun stuff.