DbAppWeb.com

Menu
  • Home
  • Linux
  • HP-UX
  • macOS
  • Windows
  • Web Servers
  • App Servers
  • Storage

How to get a list of enabled entries in Linux hosts file

September 8, 2023 DbAppWeb Admin

Problem

How to get a list of enabled entries in Linux hosts file?

Sometimes, as system administrators, you need to check the list of enabled entries in a Linux system’s /etc/hosts file. Generally, we check the list of enabled host entries by checking the /etc/hosts file using the cat command and then verify the enabled entries.

[root@dbappweb ~]# cat /etc/hosts
127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1       localhost localhost.localdomain localhost6 localhost6.localdomain6
#10.20.2.10     server1.dbappweb.com
10.40.1.11      server2.dbappweb.com
#10.40.1.12     server3.dbappweb.com
10.30.2.30	server4.dbappweb.com


Solution

You can list out the only enabled entries in the /etc/hosts file using the getent command as shown below:

[root@dbappweb ~]# getent hosts
127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1       localhost localhost.localdomain localhost6 localhost6.localdomain6
10.40.1.11      server2.dbappweb.com
10.30.2.30	server4.dbappweb.com

 

Related Posts

  • Whitelist a Range of IP Addresses in Linux
  • chroot SFTP User and Bind Mount in Linux
  • Linux: Count number of files inside a directory including its subdirectories
  • Disable SSH Weak Algorithms Supported in Linux

 

Last Updated: September 07, 2023

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
Prev Article
Next Article
Tags:Linux RedHat Linux RHEL Sys Admin

Leave a Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Popular
  • Recent

Categories

  • Android (2)
  • Blogger (16)
  • Domain and Hosting (1)
  • Hardware Issues (7)
  • HP-UX (55)
  • HPE Data Protector (9)
  • IBM Lotus Notes (2)
  • IBM WebSphere Application Server (16)
  • Internet Tips & Tricks (15)
  • iOS (8)
  • JBoss/WildFly Application Server (2)
  • Linux (76)
  • macOS (15)
  • Microsoft Windows (31)
  • News and Updates (11)
  • Oracle Database (5)
  • SSL/TLS (1)
  • Storage Servers (23)
  • Tools/Softwares (1)
  • VMware ESXi (17)
  • Web Servers (14)
  • WordPress (5)

Archives

DbAppWeb.com

Solution of Database, Application and Web Server Problems

About DbAppWeb.com

One Stop Solution for Database Server, Application Server and Web Server Problems.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

DbAppWeb on Social Media

Copyright © 2026 DbAppWeb.com
Terms and Conditions   Theme by MyThemeShop.com