2

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 ~]# 

3 Answers 3

5

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.

0
yum install -y hostname

Also solves the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .