CentOS 8 Change Hostname (computer name) command

Originally published at: https://www.cyberciti.biz/faq/centos-8-change-hostname-computer-name-command/

I am a new CentOS 8 Linux user and setup a server. They setup my server name to ‘li2025-143’ during deployment but now I would like to change the computer name to something else. How can I remove old name and set it to ‘nixcraft-centos8’ on CentOS Enterprise Linux? Can you tell me how do I change the CentOS 8 computer name? How do I assign a static hostname to server running CentOS 8?

Under Centos 7 it would be “hostnamectl set-hostname nixcraft-centos8”. I would think that it still works under Centos 8.

yes, it is just an example. you can replace nixcraft-centos8 with anything you want.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki