الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

hostname

Show the host name (and its FQDN, domain or IP addresses), or set it until the next reboot.

المستوى
امتحان RHCSA
المجموعة
الشبكة
يحتاج root
للتغييرات
الحزمة
hostname
يُسمّى أيضًا
dnsdomainname, domainname

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

hostname prints the current host name. Options show the FQDN, the DNS domain or all IP addresses.

Setting a name with hostname NAME lasts only until reboot. To set it for good on RHEL, use hostnamectl set-hostname NAME (writes /etc/hostname).

طريقة الكتابة

hostname [OPTION]
hostname [-b] [-F FILE] [NAME]

الخيارات 12

الأكثر استخدامًا

-s, --short
Short name (until the first dot).
-f, --fqdn, --long
Fully qualified domain name (from DNS or /etc/hosts).
-d, --domain
The DNS domain part.
-i, --ip-address
Addresses of the host name (by name lookup).
-I, --all-ip-addresses
All addresses of all interfaces (no lookup).
-a, --alias
Alias names (old, not recommended).
-A, --all-fqdns
All FQDNs of the host addresses.
-y, --yp, --nis
The NIS domain name.
-b, --boot
When setting: use a default name if none is given.
-F, --file FILE
Read the name from a file.
-h, --help
Show help.
-V, --version
Show the version.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Show the host name

    hostname
    server1.example.com

    RHEL often uses the full name as host name.

  2. 2Short name and FQDN

    hostname -s; hostname -f
    server1
    server1.example.com

    -f needs /etc/hosts or DNS to know the full name.

  3. 3All IP addresses

    hostname -I
    192.168.122.10 fe80::5054:ff:fe12:3456

    Quick way to find the IP of a fresh VM.

  4. 4Domain part

    hostname -d
    example.com

    Same as dnsdomainname.

  5. 5Set a name until reboot

    hostname test1

    For a quick test only.

  6. 6Set the name for good

    hostnamectl set-hostname server1.example.com

    Writes /etc/hostname (the RHCSA way).

  7. 7Use the name in a prompt or file name

    tar -czf /backup/$(hostname -s)-etc-$(date +%F).tgz /etc

    Each server makes a different file name.

  8. 8Check the name for certificates

    hostname -f; getent hosts $(hostname -f)

    The FQDN must resolve to the server IP before you request a TLS certificate.

  9. 9Find wrong FQDN settings

    hostname -f
    hostname: Name or service not known

    Add the name to /etc/hosts or DNS.

  10. 10Show the domain of NIS

    hostname -y

    Only for old NIS setups.

الملفات

/etc/hostname
The static host name.
/etc/hosts
Local name to address list.

رموز الخروج

0Done.
1Error.