Is there an equivalent on MacOS to the Linux hostnamectl command?
1 Answer
Yes, it's scutil.
From the documentation:
scutil Manage system configuration parameters. (...) --get <pref> Retrieves the specified preference. The current value will be reported on standard output. Supported preferences include: ComputerName The user-friendly name for the system. LocalHostName The local (Bonjour) host name. HostName The name associated with hostname(1) and gethostname(3). --set <pref> [newval] Updates the specified preference with the new value. If the new value is not specified on the command line then it will be read from standard input. Supported preferences include: ComputerName LocalHostName HostName The --set option requires super-user access. Related question on Apple SE: https://apple.stackexchange.com/questions/287760/set-the-hostname-computer-name-for-macos (thanks to @MarcusMüller for the comment).
hostnamectlis not a Linux command. It is a SystemD-HostnameD command. There are many Linux distributions which do not use SystemD, and thus do not havehostnamectl. And while I don't know of the existence of such a system, it would theoretically be possible to implement the Freedesktop specification and SystemD on a non-Linux system.