Skip to content

Debian

Debian administration tasks: check the release, update packages, set the locale and time zone, purge removed packages and boot to text mode.

2 min readUpdated

Everyday administration tasks on a Debian system. Run the commands as root, or prefix them with sudo.

Check the Debian version

Show the distribution, release number and code name:

Terminal window
lsb_release -a

lsb_release comes from the lsb-release package, which minimal installations and containers often lack. These two files are always present:

Terminal window
cat /etc/os-release
cat /etc/debian_version

Update the system

Refresh the package lists, then install the newer versions of the installed packages:

Terminal window
# update the list of available packages and their versions; installs nothing
apt update
# install newer versions of the installed packages
apt upgrade

Or both in one line:

Terminal window
apt update && apt upgrade

apt is the interactive front end. Scripts often use apt-get update && apt-get upgrade, whose output format stays stable between releases.

Change the locale

Uncomment the locales you need in /etc/locale.gen, for example tr_TR.UTF-8 UTF-8:

Terminal window
nano /etc/locale.gen

Then generate them:

Terminal window
locale-gen

Alternatively, dpkg-reconfigure locales shows the list as a menu, generates the selected locales and asks which one should be the system default. Log out and back in for programs to pick up the new setting.

Change the time zone

Choose the time zone from a menu:

Terminal window
dpkg-reconfigure tzdata

This updates both the /etc/localtime link and the Debian-specific /etc/timezone file. The Debian wiki recommends it over timedatectl set-timezone, which does not update /etc/timezone.

Purge removed packages

When a package is removed without purging, its configuration files stay on disk and dpkg marks it as deinstall.

List the selection state of every package:

Terminal window
dpkg --get-selections

Count the packages in the deinstall state:

Terminal window
dpkg --get-selections | grep deinstall | wc -l

Purge all of them at once. The pipeline changes each deinstall mark to purge, feeds the list back to dpkg, and dpkg -Pa then purges every package marked for purging:

Terminal window
dpkg --get-selections | grep deinstall | sed 's/deinstall/purge/' | dpkg --set-selections; dpkg -Pa

On current releases (apt 2.0 and later), an apt search pattern does the same in one command and shows the list before acting:

Terminal window
apt purge '~c'

~c (long form ?config-files) matches packages of which only configuration files are left.

Boot to text mode instead of the desktop

Make the system start without the graphical login manager:

Terminal window
systemctl set-default multi-user.target

To start the desktop once from the text console, without changing the default:

Terminal window
systemctl isolate graphical.target

To boot to the desktop again by default:

Terminal window
systemctl set-default graphical.target

Before systemd (Debian 7 and earlier), the same was done by removing the display manager’s init script links with update-rc.d -f gdm remove and restoring them with update-rc.d gdm defaults.

References

Related notes

1 min read

GNOME

Make the GNOME login screen (GDM) ask for a username instead of showing the list of users.

  • Linux & Systems
4 min read

Jitsi Meet

Self-host Jitsi Meet on Debian: install from the Jitsi repository, add a Let's Encrypt certificate, open the firewall, require login and check the services.

  • Linux & Systems
4 min read

SSH keys

Create and manage SSH keys: generate a key pair, set a passphrase, copy the public key, test Git hosts and recover a server you are locked out of.

  • Security
  • Linux & Systems

Type to search the whole site.