LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

systemd-firstboot

Initialize basic system settings

TLDR

Configure a mounted image or chroot rather than the running host
$ sudo systemd-firstboot --root=[/mnt]
copy
Set locale and keyboard in one pass
$ sudo systemd-firstboot --root=[/mnt] --locale=[en_US.UTF-8] --keymap=[us]
copy
Set the hostname and timezone
$ sudo systemd-firstboot --root=[/mnt] --hostname=[myhost] --timezone=[Europe/Berlin]
copy
Set the root password from a hash rather than plaintext
$ sudo systemd-firstboot --root=[/mnt] --root-password-hashed=[hash]
copy
Read the root password from a file
$ sudo systemd-firstboot --root=[/mnt] --root-password-file=[path/to/password]
copy
Choose the root account's shell
$ sudo systemd-firstboot --root=[/mnt] --root-shell=[/bin/bash]
copy
Copy the host's locale, keymap, timezone and root password into the image
$ sudo systemd-firstboot --root=[/mnt] --copy
copy
Generate a machine ID for the image
$ sudo systemd-firstboot --root=[/mnt] --setup-machine-id
copy
Ask interactively for anything not already configured
$ sudo systemd-firstboot --prompt
copy
Overwrite settings that are already present
$ sudo systemd-firstboot --root=[/mnt] --force --hostname=[myhost]
copy
Clear every setting systemd-firstboot manages
$ sudo systemd-firstboot --root=[/mnt] --reset
copy
Leave the root account with an empty password
$ sudo systemd-firstboot --root=[/mnt] --delete-root-password
copy

SYNOPSIS

systemd-firstboot [options]

DESCRIPTION

systemd-firstboot initializes basic system settings on or before the first boot of a system. It is typically used when preparing OS images or system installations.The tool can set hostname, locale, timezone, keyboard layout, and root password. When run without options on a live system, it interactively prompts for unconfigured settings.

PARAMETERS

--root _path_

Operate on specified root directory
--hostname _name_
Set the system hostname
--keymap _map_
Set the keyboard layout
--timezone _tz_
Set the system timezone
--locale _locale_
Set the system locale
--root-password _password_
Set root's password
--root-shell _shell_
Set root's login shell
--prompt
Prompt interactively for settings
--force
Overwrite existing configuration
--reset
Remove all firstboot configuration files
--delete-root-password
Remove root password

INSTALL

sudo apt install systemd
copy
sudo dnf install systemd
copy
sudo pacman -S systemd
copy
sudo zypper install systemd
copy
brew install systemd
copy
nix profile install nixpkgs#systemd
copy

CAVEATS

Some settings require the --force flag to overwrite existing configuration. The --root option is essential when preparing disk images. Passwords should be provided securely. Part of the systemd suite.

SEE ALSO

Copied to clipboard
Kai