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.

Question for you. I thought that was the only place to make a change as well. When you read any local mail with the mail account as root, it shows root@old-hostname

Do you know how to fix that?

This is a little complicated. Are you using MTA (like Sendmail or Postfix) to send an email?