How to configure the hostname in Oracle Linux7?

Source: Internet
Author: User

How to configure the hostname in Oracle Linux7?

How to configure the hostname in Oracle Linux7?
Source:
How to Configure hostname in Oracle Linux 7 (Document ID 2049221.1)

Applicable:
Linux OS-Version Oracle Linux 7.0 and later
Linux x86
Linux x86-64

Objectives:
This document describes how to modify the hostname in Oracle Linux7.
Note: manually APPEND "HOSTNAME = xxxxx" to/etc/sysconfig/network and restart OS. This method does not take effect in Oracle Linux7.

Solution:
Use either of the following three methods to modify the host name in Oracle Linux7:

1. use hostname control utility: hsotnamectl2. use NetworkManager command line tool: nmcli3. edit /etc/hostname file directly (a reboot afterwards is required)

 

1. Use hsotnamectl which is a command-line client to Use EMD-hostnamed service

Get current hostname status:

[[email protected] ~]# hostnamectl status   Static hostname: localhost.localdomain         Icon name: computer           Chassis: n/a        Machine ID: ed264df49f3f42b7b64ca75f763ad117           Boot ID: 3ec1705218b9499b9619e1bdca7be737    Virtualization: oracle  Operating System: Oracle Linux Server 7.1       CPE OS Name: cpe:/o:oracle:linux:7:1            Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64      Architecture: x86_64


Set hostname:

[[email protected] ~]# hostnamectl set-hostname oraclelinux.oracle.com[[email protected] ~]#


Re-login terminal session:

[[email protected] ~]# hostnamectl status   Static hostname: oraclelinux.oracle.com         Icon name: computer           Chassis: n/a        Machine ID: ed264df49f3f42b7b64ca75f763ad117           Boot ID: 3ec1705218b9499b9619e1bdca7be737    Virtualization: oracle  Operating System: Oracle Linux Server 7.1       CPE OS Name: cpe:/o:oracle:linux:7:1            Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64      Architecture: x86_64
2. nmcli

Check current hostname:

[[email protected] ~]# nmcli general hostnamelocalhost.localdomain

 

Modify hostname and restart ystemd-hostnamed service:

[[email protected] ~]# nmcli general hostname oraclelinux.oracle.com[[email protected] ~]# systemctl restart systemd-hostnamed


Re-login terminal session:

[[email protected] ~]# hostnameoraclelinux.oracle.com

 

3. Edit/etc/hostname

View current content:

[[email protected] ~]# cat /etc/hostnamelocalhost.localdomain


Replace file content with new hostname:

[[email protected] ~]# echo "oraclelinux.oracle.com" > /etc/hostname[[email protected] ~]# cat /etc/hostnameoraclelinux.oracle.com


Restart system and verify:

[[email protected] ~]# hostnameoraclelinux.oracle.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.