Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On my Fedora 19 system, I am able to change the system hostname with hostnamectl. This allows me to set several things, such as the static (normal) hostname, as well as a "pretty" hostname.

Is there a simple command that retrieves the pretty hostname, from a bash prompt?

hostname returns the static hostname, and the man page shows no options to recover the pretty one.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

As per man hostnamectl:

The static host name is stored in /etc/hostname, see hostname(5) for more information. The pretty host name, chassis type and icon name are stored in /etc/machine-info, see machine-id(5).

Therefore, if you have set a pretty hostname using the command

hostnamectl set-hostname --pretty YourHostname

you can retrieve it using a tool like awk:

awk -F= '/PRETTY/ {print $2}' /etc/machine-info
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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