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
You can reinstall it:
dnf install hostname 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.
yum install -y hostnameAlso solves the issue.