Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command hostname

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the usage of the Linux basic command hostname". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command hostname".

Hostname

The hostname instruction is used to set or display the hostname of the system, which returns the return value of the gethostname () function without any arguments. After using the hostname instruction, the hostname is changed immediately, but it becomes invalid after rebooting the system. You can modify the configuration file / etc/sysconfig/network to make the hostname permanent.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Hostname [options]

2. List of options

Option

Description

-h |-- help

Show help documentation

-V |-- version

Show command version

-v

Show detailed execution process

-a |-- alias

Show host alias

-d |-- domain

Show host dns domain name

-F file

Read from a file

-f |-- fqdn |-- long

Display the domain name in full format

-A |-- all-fqdns

Displays all the FQDNs of the machine

-I |-- ip-address

Displays the ip address of the specified host

-I |-- all-ip-address

Show all addresses of the host

-s |-- short

Display in a short format, showing only the parts separated from the first point

-y |-- yp |-- nis

Show nis domain name

3 、 FQDN

You cannot change the FQDN (returned by hostname-fqdn) or the DNS domain name (returned by dnsdomainname) with this command. The FQDN of the system is the name returned by the resolver hostname. Technically: FQDN is the hostname returned by gethostname (2). The DNS domain name is the part after the first dot. Therefore, how to change depends on the configuration file (usually in "/ etc/host.conf"). Usually (if you parse the host file before DNS or NIS), you can change it in "/ etc/host".

If a machine has multiple network interfaces / addresses, or is used in a mobile environment, it may have multiple FQDN/ domain names, or none at all. Therefore, avoid using "hostname-fqdn", "hostname-- domain" and "dnsdomainname". The "hostname-- ip-address" address is similarly restricted and should be avoided as well.

4. Examples

1) display hostname

[root@localhost ~] # hostname / / display the full name

Localhost.localdomain

[root@localhost ~] # hostname-s / / display short format names

Localhost

[root@localhost ~] # hostname-a / / Show host alias

Localhost.localdomain localhost4 localhost4.localdomain4 localhost.localdomain localhost6 localhost6.localdomain6

2) display the host ip

[root@localhost] # hostname-I

127.0.0.1 127.0.0.1

Thank you for your reading, the above is the content of "the usage of the Linux basic command hostname". After the study of this article, I believe you have a deeper understanding of the usage of the Linux basic command hostname, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report