Where to put computerdescription in linux/unix (like in windows âcomputer propertiesâ)?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Question:
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
?)
Background:
In Windows you can place a description under sysdm.cpl (system properties > computername) and you can query this information from the cmd e.g. withwmic 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?
linux administration
add a comment |Â
up vote
1
down vote
favorite
Question:
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
?)
Background:
In Windows you can place a description under sysdm.cpl (system properties > computername) and you can query this information from the cmd e.g. withwmic 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?
linux administration
How do you intend to read that information? After logging in or before deciding which host you want to login to?
â rbanffy
Jul 11 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 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 at 20:15
If you do adig TXT www-txt.banffy.com.br
you'll see a note I added to the www-txt TXT record.
â rbanffy
Jul 13 at 21:20
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Question:
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
?)
Background:
In Windows you can place a description under sysdm.cpl (system properties > computername) and you can query this information from the cmd e.g. withwmic 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?
linux administration
Question:
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
?)
Background:
In Windows you can place a description under sysdm.cpl (system properties > computername) and you can query this information from the cmd e.g. withwmic 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?
linux administration
asked Jul 11 at 14:58
eli
571514
571514
How do you intend to read that information? After logging in or before deciding which host you want to login to?
â rbanffy
Jul 11 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 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 at 20:15
If you do adig TXT www-txt.banffy.com.br
you'll see a note I added to the www-txt TXT record.
â rbanffy
Jul 13 at 21:20
add a comment |Â
How do you intend to read that information? After logging in or before deciding which host you want to login to?
â rbanffy
Jul 11 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 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 at 20:15
If you do adig TXT www-txt.banffy.com.br
you'll see a note I added to the www-txt TXT record.
â rbanffy
Jul 13 at 21:20
How do you intend to read that information? After logging in or before deciding which host you want to login to?
â rbanffy
Jul 11 at 15:21
How do you intend to read that information? After logging in or before deciding which host you want to login to?
â rbanffy
Jul 11 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 at 19:53
@rbanffy interesting questing: my first intent was when logged in. But would it be possible to get this information beforehand?
â eli
Jul 11 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 at 20:15
You can add TXT records with CNAME and notes to your DNS and query that. Then you query those records.
â rbanffy
Jul 13 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 at 21:20
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 at 21:20
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
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:
    Â
References
- Customizing your Logon with /etc/issue
- Is "/etc/issue" common for all Linux distributions?
1
I didn't know about /etc/issue, this seems to be an appropriate place, because from theman issue
page, it's intended for "system identification" (unlike the motd). thanks!
â eli
Jul 11 at 19:59
add a comment |Â
up vote
3
down vote
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
- https://unix.stackexchange.com/a/433245/5132
- Lennart Poettering et al. (2016).
machine-info
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
systemd-hostnamed.service
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
hostnamectl
. systemd manual pages. Freedesktop.org. - Jonathan de Boyne Pollard (2018). "
read-conf
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
clearenv
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
printenv
". Manual. nosh toolset. Softwares. - /etc/machine-info is missing
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 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 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 fromwin01
tothis-is-a-short-meaningful-description-of-win01
.
â sourcejedi
Jul 11 at 22:58
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
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:
    Â
References
- Customizing your Logon with /etc/issue
- Is "/etc/issue" common for all Linux distributions?
1
I didn't know about /etc/issue, this seems to be an appropriate place, because from theman issue
page, it's intended for "system identification" (unlike the motd). thanks!
â eli
Jul 11 at 19:59
add a comment |Â
up vote
4
down vote
accepted
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:
    Â
References
- Customizing your Logon with /etc/issue
- Is "/etc/issue" common for all Linux distributions?
1
I didn't know about /etc/issue, this seems to be an appropriate place, because from theman issue
page, it's intended for "system identification" (unlike the motd). thanks!
â eli
Jul 11 at 19:59
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
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:
    Â
References
- Customizing your Logon with /etc/issue
- Is "/etc/issue" common for all Linux distributions?
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:
    Â
References
- Customizing your Logon with /etc/issue
- Is "/etc/issue" common for all Linux distributions?
edited Jul 11 at 15:21
answered Jul 11 at 15:09
slmâ¦
233k65479651
233k65479651
1
I didn't know about /etc/issue, this seems to be an appropriate place, because from theman issue
page, it's intended for "system identification" (unlike the motd). thanks!
â eli
Jul 11 at 19:59
add a comment |Â
1
I didn't know about /etc/issue, this seems to be an appropriate place, because from theman issue
page, it's intended for "system identification" (unlike the motd). thanks!
â eli
Jul 11 at 19:59
1
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 at 19:59
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 at 19:59
add a comment |Â
up vote
3
down vote
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
- https://unix.stackexchange.com/a/433245/5132
- Lennart Poettering et al. (2016).
machine-info
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
systemd-hostnamed.service
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
hostnamectl
. systemd manual pages. Freedesktop.org. - Jonathan de Boyne Pollard (2018). "
read-conf
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
clearenv
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
printenv
". Manual. nosh toolset. Softwares. - /etc/machine-info is missing
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 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 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 fromwin01
tothis-is-a-short-meaningful-description-of-win01
.
â sourcejedi
Jul 11 at 22:58
add a comment |Â
up vote
3
down vote
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
- https://unix.stackexchange.com/a/433245/5132
- Lennart Poettering et al. (2016).
machine-info
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
systemd-hostnamed.service
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
hostnamectl
. systemd manual pages. Freedesktop.org. - Jonathan de Boyne Pollard (2018). "
read-conf
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
clearenv
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
printenv
". Manual. nosh toolset. Softwares. - /etc/machine-info is missing
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 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 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 fromwin01
tothis-is-a-short-meaningful-description-of-win01
.
â sourcejedi
Jul 11 at 22:58
add a comment |Â
up vote
3
down vote
up vote
3
down vote
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
- https://unix.stackexchange.com/a/433245/5132
- Lennart Poettering et al. (2016).
machine-info
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
systemd-hostnamed.service
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
hostnamectl
. systemd manual pages. Freedesktop.org. - Jonathan de Boyne Pollard (2018). "
read-conf
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
clearenv
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
printenv
". Manual. nosh toolset. Softwares. - /etc/machine-info is missing
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
- https://unix.stackexchange.com/a/433245/5132
- Lennart Poettering et al. (2016).
machine-info
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
systemd-hostnamed.service
. systemd manual pages. Freedesktop.org. - Lennart Poettering et al. (2016).
hostnamectl
. systemd manual pages. Freedesktop.org. - Jonathan de Boyne Pollard (2018). "
read-conf
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
clearenv
". Manual. nosh toolset. Softwares. - Jonathan de Boyne Pollard (2018). "
printenv
". Manual. nosh toolset. Softwares. - /etc/machine-info is missing
answered Jul 11 at 21:17
JdeBP
27.8k459133
27.8k459133
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 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 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 fromwin01
tothis-is-a-short-meaningful-description-of-win01
.
â sourcejedi
Jul 11 at 22:58
add a comment |Â
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 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 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 fromwin01
tothis-is-a-short-meaningful-description-of-win01
.
â sourcejedi
Jul 11 at 22:58
1
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 at 22:25
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 at 22:25
1
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 at 22:42
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 at 22:42
1
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 at 22:58
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 at 22:58
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454710%2fwhere-to-put-computerdescription-in-linux-unix-like-in-windows-computer-proper%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
How do you intend to read that information? After logging in or before deciding which host you want to login to?
â rbanffy
Jul 11 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 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 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 at 21:20