- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Host file localhost entry location
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2001 05:39 AM
тАО04-23-2001 05:39 AM
I happen to have several 10.x.x.x entries in the file and as such, the 127.0.0.1 entry gets put in numeric order with the rest of the entries. This puts the localhost entry 5th on the list. I have heard that the entry must be the first on the list.
Is this true and if so what impact would it have to place the entry elseware in the file.
Does anyone have any examples of host file sort scripts that may be better for me to use instead of just "sort hosts -o hosts.out".
Thanks,
Craig A. Sharp
Roush Industries
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2001 05:51 AM
тАО04-23-2001 05:51 AM
Re: Host file localhost entry location
I always prefer to have it as the first entry by default, but that is again my own preference/experience.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2001 06:02 AM
тАО04-23-2001 06:02 AM
Re: Host file localhost entry location
I agree with Melvyn insofar as there is no reason I know that requires the 'localhost' entry to be the first one.
I have very limited entries beyond it and the local server's hostname since use DNS services.
In an MC/ServiceGuard cluster I have, the 'localhost' entry is actually the fifth one without problems.
If you wanted to sort your /etc/hosts, you could extract the non-commentary, sort it and reinsert it:
# awk '$1 ~/[0-9]/ {print$0}' /etc/hosts|sort > /tmp/hosts
...JRF...
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2001 06:13 AM
тАО04-23-2001 06:13 AM
SolutionI supose i were make a script using awk .
awk ' NR < 5 { print $0 }' /etc/hosts > /tmp/1
awk ' NR >5 { print $0 } ' > /tmp/2
sort /tmp/2 > /tmp/3
cat /tmp/1 > /etc/hosts
cat /tmp/3 >> /etc/hosts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2001 06:21 AM
тАО04-23-2001 06:21 AM
Re: Host file localhost entry location
Thanks for the fast answers. I am starting to work in a script to do what I need. I am planning to keep the initial commented lines that hp provides and then sort and append the sorted file to the new file. I will post the script to the forum.
Thanks for your help.
Craig
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2001 03:31 PM
тАО04-25-2001 03:31 PM
Re: Host file localhost entry location
#comments
1.1.1.1 dns.server.name
1.1.1.2 hostname.of.lan0
127.0.0.1 localhost
# all others
I work with many systems, and have never had a problem using these criteria!
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2001 03:34 PM
тАО04-25-2001 03:34 PM
Re: Host file localhost entry location
Sorry,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2001 06:49 AM
тАО04-26-2001 06:49 AM
Re: Host file localhost entry location
As a suggestion, to make your maintanence easier I'd also put important hosts at the begining. Such as, DNS servers, local interfaces, gateways, nfs servers, nis servers, time servers, etc. About 90% of the entries in the hosts file I usual don't care about, and the 10% that are important to me I want to see right away at the top.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2001 03:34 AM
тАО05-09-2001 03:34 AM
Re: Host file localhost entry location
So far following the sort, all is well.
Thanks,
Craig