How to Completely Disable the ‘console-getty.service’ in Ubuntu Server

In Ubuntu Server and other systemd-based Linux distributions, the console-getty.service is responsible for providing a login prompt (getty) on the system console (usually /dev/console). While essential for physical access and recovery in many environments, this service may be unnecessary or undesirable in heavily secured headless servers, containerized environments, or embedded systems where console access is strictly prohibited and all administration is performed via SSH or serial interfaces.

This guide provides a straightforward method to completely disable and mask the console-getty.service in Ubuntu Server, preventing it from starting during boot and freeing up the associated system resources.

How to Disable the ‘console-getty.service’

To safely disable the service, you must interact with systemctl. Follow these steps carefully with root or sudo privileges:

  1. Connect to your Ubuntu Server via SSH or open a terminal window.
  2. First, stop the service if it is currently running in the active session by executing the following command:
    sudo systemctl stop console-getty.service
  3. Next, disable the service to prevent it from starting automatically on the next system boot:
    sudo systemctl disable console-getty.service
  4. To completely lock down the service and prevent any other systemd units or dependencies from inadvertently starting it, mask the service:
    sudo systemctl mask console-getty.service

Masking links the service file to /dev/null, effectively making it impossible to start manually or automatically.

Verifying the Changes

To confirm that the console-getty.service has been successfully disabled and masked, run the following verification command:

sudo systemctl status console-getty.service

The output should indicate that the service is masked and inactive (dead). You should no longer see a login prompt on the physical console display.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.