Complete the goal:
Modify the host name of the CentOS 7 system
Use the command:
Hostnamectl
[Email protected] ~]# Hostnamectl--Helphostnamectl [OPTIONS ...] COMMAND ... Query or change system hostname. -H--help Show This Help--version Show package version--no-ask-password do not prompt forPassword-H--host=[[Email protected]]host Operate on remote HOST-M--machine=CONTAINER Operate on local CONTAINER--transient onlySettransient hostname--StaticOnlySet Statichostname--pretty onlySetpretty hostnamecommands:status Show current hostname settingsSet-hostname NAME SET system hostnameSet-icon-name name Set icon Name forHostSet-chassis NAME Set Chassis type forHostSet-deployment NAME Set Deployment Environment forHostSet-location NAME Set Location forHost
To permanently modify the hostname, you need to modify the static host name:
[Email protected] ~]# Hostnamectl--staticset-hostname ossec-server
or execute the command.
Set-hostname ossec-server
Finally, reboot a bit.
How to modify the Linux system host name