Using basic systemd commands


Systemd recognizes that hostnames have grown more varied over the years. The hostnamectl command recognizes three types of hostname with its options: --static is the traditional hostname, used to initialize the system at bootup; --transient is the hostname assigned by a network; and --pretty is the high-level name for humans to read, which may contain many characters that static and transient hostnames are not permitted to use. Then, just to complicate matters further, hostnamectl can also adjust the hostname used in graphical interfaces. For example, set-icon-name NAME sets the hostname displayed on a desktop, and set-chassis TYPE designates a hostname as desktop, laptop, server, tablet, handset, or watch, to affect how they are displayed by some applications.

Use set-hostname NAME to change a hostname, modifying it with an option as necessary. To view the current hostname, use the command status. Add the option --host (-H) to change or view a hostname remotely. Note that a successful name change is marked only by a return to the command prompt.


Locales are the languages and settings used for conventions such as currency and time and date formats. Locales typically begin with a two-letter lowercase abbreviation for the language, followed by an underscore and a two-letter uppercase abbreviation for the variant, and ending with an extension that indicates the character encoding – generally, .utf8. For example, en_UK.utf8 stands for the English language as it is used in the United Kingdom. Keyboard maps specify the locale and the keyboard layout, such as Dvorak.

Under systemd, locales are managed by localectl. The localectl command can set the general system locale (set-locale LOCALE), the locale for the X Window system, which includes the general system locale (set-x11-keymaps-variants), and the keyboard locale (set-keymap MAP TOGGLE). If you need to look up locales, you can use the command list-locales for the display or list-keymaps for the keyboard.


To begin using loginctl, run the bare command to receive a list of current logins (Figure 3). If you want details for a session, add the sub-command session-status. Adding the session to a subcommand, you can activate a session, forcing it to replace the one currently displayed – for example, lock-session, unlock-session, terminate-session, or kill-session.

Figure 3: Loginctl controls the accounts logged in to the system.

Besides controlling logins, loginctl can also be used to read what devices are being used by each account with show-user USER and show-seat SEAT.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Command Line: Systemd

    Wondering what all the fuss is about systemd? We explain the basic concepts and capabilities of the new system management suite – coming soon to a distro near you.

  • Systemd GUIs

    Graphical frontends make it easier to take full advantage of the Systemd process manager. We examine some leading tools for the KDE environment.

  • Systemd Graphical Tools

    Systemd has won the race, as indicated by the several tools that already offer a service just a mouse click away. We look at six of these tools.

  • Professor Knopper's Lab – Removing systemd

    The systemd service manager has been widely adopted by many Linux distros, so why would you want to remove it? The professor reveals why and how.

  • Working the System

    Every major aspect of a system that runs in userland can be controlled by systemctl, a command that acts on systemd's units.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More