Using basic systemd commands
Hostnamectl
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.
Localectl
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.
Loginctl
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
.
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
.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
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.
News
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.