Is there a place in linux (e.g. debian/ubuntu) to put the computer description?
Meaning: are there directives or best practices (I didn't see it in the FHS)?
(Maybe a file /etc/hostinfo?)


In Windows you can place a description under sysdm.cpl (system properties > computername) and you can query this information from the cmd e.g. with
wmic path win32_operatingsystem get descriptiong

So even if I named all machines in a network win01 to win25 I could give them a short meaningful description that I can read without searching the documentation.

At the moment I have this info in the /etc/profile, but I would rather want to read it from a separate place. If there are no guidelines I would think that /etc/hostinfo could be a good place, but I don't know if this would clash with some other program/common use.
Or are there better strategies?

  • How do you intend to read that information? After logging in or before deciding which host you want to login to? – rbanffy Jul 11 '18 at 15:21
  • @rbanffy interesting questing: my first intent was when logged in. But would it be possible to get this information beforehand? – eli Jul 11 '18 at 19:53
  • You can add TXT records with CNAME and notes to your DNS and query that. Then you query those records. – rbanffy Jul 13 '18 at 20:15
  • If you do a dig TXT www-txt.banffy.com.br you'll see a note I added to the www-txt TXT record. – rbanffy Jul 13 '18 at 21:20

The typical place to do this in Unix/Linux is in the /etc/motd or /etc/issue & /etc/issue.net files. When people log into the system either on the console or via SSH they'll be presented with the contents of these files.

Beyond this it's generally the case that external systems are used to managed any metadata regarding the system's purpose. This category of software is called asset and inventory management.

The one that I'm most familiar with is Solarwinds (commercial). I'm not recommending it or anything, just giving an example. There are others as listed on alternative.to. NOTE: Take that list with a grain of salt, not all of them are feature for feature identical.

/etc/motd example

$ cat /etc/motd
Company X Ltd. CentOS 7 Build 1805.02

When you log in you'll see it displayed like so:

$ vagrant ssh box-101

Last login: Mon Jul  9 19:32:36 2018 from gateway
Company X Ltd. CentOS 7 Build 1805.02
[vagrant@centos7 ~]$

/etc/issue example

$ cat /etc/issue
This system is the property of Company Ltd.

Then when you log into the system:

     ss of login


  • 1
    I didn't know about /etc/issue, this seems to be an appropriate place, because from the man issue page, it's intended for "system identification" (unlike the motd). thanks! – eli Jul 11 '18 at 19:59

The systemd answer.

Debian and Ubuntu are nowadays systemd operating systems, and the systemd people invented a mechanism for this. (It applies to other systemd operating systems too; but you won't find it on any Linux non-systemd operating systems, or on the BSDs, MacOS, or the various commercial Unices.) It is the /etc/machine-info file, which contains amongst other things a "prettified" version of the hostname.

This does not have to be the same as the actual dynamic hostname that is returned by the gethostname() C library function (and printed by the hostname and uname -n commands), which the systemd people call the "transient" hostname. You can take advantage of that to give your machines "prettified" hostnames that are as informative as you like.

The systemd people expect you to query and set this "prettified" hostname through the hostnamectl command:

# hostnamectl --pretty set-hostname "I am JdeBP's 4o machine."
# hostnamectl --pretty
I am JdeBP's 4o machine.

However, this command does not read the file directly. Rather, it needs two system dæmons running, the system-wide Desktop Bus dæmon and the hostnamed dæmon. The command talks to the first dæmon using a complex internal protocol, which then talks to the second dæmon, which in turn just reads (and writes) the file directly.

I just read the file directly, myself.

$ clearenv read-conf --oknofile /etc/machine-info printenv PRETTY_HOSTNAME
I am JdeBP's 4o machine.

Further reading

  • 1
    afaics reading the file is encouraged; "you may" does not necessarily mean "are expected to". nice nosh command. from the horses mouth these daemons were very much designed for existing gui app(s). dbus provides a method to subscribe changes, which is suited to GUI needs. maybe used by a total of one app in this case :). hostnamectl also supports the authenticated writes (polkit), which are again used by the gui app. hence it is simplest to implement reads through dbus as well. think of hostnamectl as a stub to exercise the gui backend, which might or might not also be a useful cli utility. – sourcejedi Jul 11 '18 at 22:25
  • 1
    imo it's relatively uncommon to have a scriptable cli to edit a specific config file in the first place. it's a pretty simple text file. if you don't want to use a text editor, there's generic configuration management software, and that would also prefer to control the config file directly. e.g. Ansible will like to use lineinfile or a template, because Ansible likes to detect whether there will be a change or not, as well as being able to implement the change. – sourcejedi Jul 11 '18 at 22:42
  • 1
    Thinking about it, "take advantage" here has the sense of "exploit" or "(ab)use". If something ever round-tripped the hostname... i-am-jdebps-4o-machine might not be what you want in your system logs, or dhcp requests and local dns / you probably don't want the hostname to get changed from win01 to this-is-a-short-meaningful-description-of-win01. – sourcejedi Jul 11 '18 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.