Linux Server won’t restart

Not too long ago I ran into a problem where a server with systemd would not shutdown or reboot through normal means.

When executing  sudo shutdown -r now I would get a weird message back as output:

Failed to start Connection timed out
See system logs and 'systemctl status' for details.
Failed to open /dev/initctl: No such device or address
Failed to talk to init daemon.

I’m still not entirely certain what caused the problem and the suggestion of running  systemctl status to troubleshoot simply resulted in the same message being displayed.

However, if you run into this problem and you just need to get your services back up and running you can force a reboot like this:

Try this first:

systemctl --force reboot

If that doesn’t work, which it didn’t for me, add another –force but know that this will unceremoniously kill all running process.

systemctl --force --force reboot

This of course assumes that you can still gain access to the terminal via ssh. This operation is essentially the same as holding down the power button on a physical machine or hitting the reset button on a VM.

According to the man page this can dangerous if you have a process running that is trying to save data so be certain that you want to forcibly kill off every process on your server before running this command. Try it with only a single –force first.

RPM package queries

This post is just a quick walk-through of some basic commands to help you find information about rpm packages. These commands will work for any rpm based distribution (Red Hat, Centos, Suse, Mageia) Debian based distributions like Ubuntu or Mint use dpkg instead of rpm and I’ll cover those in a different post.

Query the rpm database

You can query the rpm database to find a particular installed package using the -q option. With rpm -q you must also pass a package name. For example, to find out what version of the httpd server we have installed we can use rpm -q httpd

rpm -q httpd

List all installed packages

To get a quick list of every installed package on an rpm based Linux distribution you can use -qa. In this case you do not need to pass any specific package into the command. Often times you will use this to find a package when you are not sure of the exact name. For example, you might grep for “ruby” to find all the installed ruby libraries.

rpm -qa

Running rpm -qa | grep ruby will produce output similar to this on a Centos 7 server.

rpm -qa | grep ruby

Find associated files

Using rpm -ql and rpm -qc will help you to locate files associated with a particular package. This is a great tool to help you find your way around a newly installed application. For example, how could you find out that the configuration file for Apache can be found at “/etc/httpd/conf/httpd.conf”, without searching the interwebs?

rpm -qc <package name> will list all of the configuration files.

 rpm -qc httpd

Similarly running rpm -ql will give you a list not only of configuration files but also every file that was installed on your server with its location.

Identify vendors

In some cases, you may need more information about a package. Who is the vendor? When was it installed? etc… Getting this type of information with rpm packages is easy.

rpm -qi <package name>

rpm -qi httpd
Name        : httpd
Version     : 2.4.6
Release     : 45.el7.centos.4
Architecture: x86_64
Install Date: Mon 12 Jun 2017 09:37:04 PM UTC
Group       : System Environment/Daemons
Size        : 9823677
License     : ASL 2.0
Signature   : RSA/SHA256, Thu 13 Apr 2017 01:04:44 AM UTC, Key ID 24c6a8a7f4a80eb5
Source RPM  : httpd-2.4.6-45.el7.centos.4.src.rpm
Build Date  : Wed 12 Apr 2017 09:05:23 PM UTC
Build Host  :
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <>
Vendor      : CentOS
URL         :
Summary     : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.

Finding documentation

You can also quickly find where documentation for a package can be found on your system using rpm -qd

rpm -qd httpd

This documentation will include listing man pages that migt be available. As well as example configuration files. In this case you can see that “/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf” is an example of a virtual host file…. Maybe something that would come in handy as a template for virtual hosts you might have to set up.

As you can see there is quite a lot of information that can be extracted from the rpm database. In my humble opinion, this is one of the big advanatages that rpm has over dpkg (though you can get this information from dpkg, it’s just not as straight forward), rpm makes it easy to query the database and quickly find the information you need.

All of this really only scratches the surface of what you can do as well. There are many ways to modify these commands to help you discover information about the packages you have installed on your system. I encourage you to read the full man page for rpm if you are interested in learning more in-depth capabilities for rpm packages.

Find services that require a restart

Ubuntu offers a live patching utility that allows kernel patches to be installed without requiring a system restart to be applied. Read more about online patching in this post about patching. That said, in many cases other services or processes on your system may need to be restarted after an upgrade. Continue reading “Find services that require a restart”