The ldapmodify command is used to create, read, update, or delete entries in the directory. There is also an ldapadd command, which is used to create new directory entries. However, this command is equivalent to invoking ldapmodify with the –a (add) option. In addition, while it is possible to enter data using standard input, most users will perform actions based on data stored in a file (after all, if you make a mistake when typing and you have to cancel the data entry, all of the input will be lost).
If we want to create a new entry for Moppet Watters in the directory, the following data should be inserted into a file called newdata.txt:
dn: cn=Moppet Watters, o=cassowary.net, c=US objectClass: person cn: Mopster Watters sn: Watters title: Mascot mail: moppet@cassowary.net uid: moppet
In order to insert this data into the directory, the following command would be used:
# ldapmodify –a –f newdata.txt
To delete this entry from the directory, we would first insert the following data into delentry.txt:
dn: cn=Moppet Watters, o=cassowary.net, c=US changetype=delete
We could then delete the entry from the directory by using the following command:
# ldapmodify –f delentry.txt