Ubuntu Server Operations

req

we want to receive notif by email

date | mailx -s `hostname` root
mailq

install

make sure auto-updates are enabled

apt install unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades
systemctl list-unit-files | grep unatt
pgrep -a unatt

setup

and tune it further more

cd /etc/apt/apt.conf.d/

mv -i 50unattended-upgrades ~/50unattended-upgrades.dist
grep -vE '^[[:space:]]*//|^$' ~/50unattended-upgrades.dist > ~/50unattended-upgrades.dist.clean
grep -vE '^[[:space:]]*//|^$' ~/50unattended-upgrades.dist > 50unattended-upgrades

check what repos you are pointing to

cat ../sources.list

# rel + rel-updates + rel-security

vi 50unattended-upgrades
Unattended-Upgrade::Mail "root";
systemctl status unattended-upgrades
systemctl restart unattended-upgrades

Purge old kernels

Do you have disk space problems on /boot/?

df -hT

see what you have now

uname -r
ls -lhF /boot/vmlinuz*

select the kernels you wanna get rid of and e.g.

dpkg -l | grep 5.4.0-37 | awk '{print $2}'
dpkg -l | grep 5.4.0-37 | awk '{print $2}' | xargs dpkg --purge

double-check

dpkg -l | grep kernel | awk '{print $2}'
dpkg -l | grep linux | awk '{print $2}'

obsolete

#dpkg -l | grep -E 'linux-(image|headers|extra)' | grep ^i

#apt install byobu
#purge-old-kernels

Cleaning-up

deal with left-over configurations once in a while

apt autoremove --purge
dpkg -l | grep ^rc

New Ubuntu release

lsb_release -a
df -hT
dpkg -l | grep ^ rc
apt update
apt full-upgrade
apt autoremove
dpkg -l | grep ^ rc
do-release-upgrade

iptables -I INPUT -p tcp --dport 1022 -j ACCEPT

make sure grub is in place,

update-grub2

make sure there’s a few bytes left for the system to start fine,

df -hT

and reboot,

reboot

Additional notes

clearing-up unwanted package repos

find the repo you don’t want

ls -lF /etc/apt/sources.list.d/ | grep -v ubuntu_dists
ls -lF /usr/share/keyrings/ | grep -v ubuntu-
ls -lhF /var/lib/apt/lists/ | grep -v ubuntu_dists

find packages which belong to a repo and get rid of those

grep ^Package /var/lib/apt/lists/dl.jami.net_nightly_ubuntu*
apt purge ...
apt autoremove --purge

e.g. for riot.im and jitsi

grep ^Package /var/lib/apt/lists/packages.riot.im_debian_dists_default_* | awk '{print $NF}' | sort -u | xargs apt -y purge
grep ^Package /var/lib/apt/lists/download.jitsi.org_stable_* | awk '{print $NF}' | sort -u | xargs apt -y purge

get rid of the now-unused repos here e.g. jami

rm -f /etc/apt/sources.list.d/jami.list*
rm -f /usr/share/keyrings/jami-archive-keyring.gpg
rm -f /var/lib/apt/lists/dl.jami.net_nightly_ubuntu*

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

Resources

AutomaticSecurityUpdates https://help.ubuntu.com/community/AutomaticSecurityUpdates

UnattendedUpgrades https://wiki.debian.org/UnattendedUpgrades

Ubuntu 16.04: Auto apt update and apt upgrade https://www.hiroom2.com/2016/05/18/ubuntu-16-04-auto-apt-update-and-apt-upgrade/

Ubuntu 18.04 remove all unused old kernels https://www.cyberciti.biz/faq/ubuntu-18-04-remove-all-unused-old-kernels/


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun