hosts2ldif Command

Purpose

Creates an LDAP Data Interchange Format (LDIF) file from a hosts file.

Syntax

hosts2ldif [ -i InputFile ] [ -o OutputFile ] [ -s SearchBase ]

Description

The /usr/sbin/hosts2ldif command creates a LDAP Data Interchange Format (LDIF) file from /etc/hosts or another file that looks like /etc/hosts. With no flags, the /etc/hosts file is used to create the /tmp/hosts.ldif LDIF file using cn=hosts as the baseDN.

The LDIF file created by this command is compliant with SecureWay Directory Schema and is used for setting up the ldap mechanism. The ldap mechanism is supported, but the use of the nis_ldap mechanism rather than the ldap mechanism is recommended.

Flags

Item Description
-i InputFile Specifies the hosts file used for input.
-o OutputFile Specifies the LDIF file used for output.
-s SearchBase Specifies the baseDN of the host table on the LDAP server.

Examples

  1. To create /home/ldifhosts from the /etc/hosts file, type:
    hosts2ldif -o /home/ldifhosts
  2. To create /tmp/hosts.ldif from the /home/hosts.bak file, type:
    hosts2ldif -i /home/hosts.bak
  3. To create /home/ldifhosts from the /etc/hosts file using cn=hosttab as the baseDN, type:
    hosts2ldif -o /home/ldifhosts -s cn=hosttab

Files

Item Description
/etc/hosts Contains the Internet Protocol (IP) name and addresses of hosts on the local network.