0

On CentOS 8 the hostname command was removed. With seemingly no way to get it back. No documented way at least Duckduckgo tells me.

The problem with this approach is that the whole world expects the command to remain. For example the Ansible community has thousands of roles that depend on the hostname being available. Effectively cutting off any migration / upgrade path to CentOS 8. For the foreseeable future.

Is there a way to get hostname back?

[root@centos8]# hostname
-bash: hostname: command not found
[root@centos8 ~]# 
1

You can reinstall it:

dnf install hostname
0

If hostname command is available, then there are other ways to manage host name as well. You can alternatively use 'hostnamectl' command as well.

You can also refer to following tutorial, 5 ways to change hostname

Alternatively, you can also install hostname command,

dnf install hostname 

Hope this helps.

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.