June 27, 2018 · networking linux bug

Fixing a Linux Slow Shutdown Bug

I was installing a non-desktop version of Debian Linux on a laptop earlier this week (it's never the year of the Linux desktop) and I ran into a slow shutdown bug. The shutdown bug had to do with the networking, and would only happen if: a) my ethernet port wasn't connected and b) if I had just turned on the system within the past minute. After the system started shutting down, systemd would hang for more than a minute displaying something similar to the following message:

[ *** ] (1/8) A stop job is running for ifup for eth0 (1s/1min31s)
[ *** ] (2/8) A stop job is running for Raise Network Interfaces (1s/1min31s)

So it looks like whenever the ethernet wasn't connected, there was a delay with the ethernet initialization that blocked the entire shutdown process. My /etc/network/interfaces file had the following lines:

# /etc/network/interfaces
allow-hotplug eth0
iface eth0 inet dhcp

Removing the lines solved the shutdown bug, but I no longer was automatically connected using ethernet.

I ended up fixing it by installing NetworkManager, a program that runs in the background and manages all my network connections.

$ sudo apt install network-manager

NetworkManager is a bulky program, so I was happy to learn that instead of running it as a tray application as the default, it has a command line interface called nmcli.

Here's what I did to connect to the WiFi:

$ nmcli device wifi rescan
$ nmcli device wifi list
$ nmcli device wifi connect <WiFi-Network-Name> password <WiFi-Password>