dscl(1) BSD General Commands Manual dscl(1)
NAME
dscl -- Directory Service command line utility
SYNOPSIS
dscl [options] [datasource [command]
options:
-p prompt for password
-u user authenticate as user
-P password authentication password
-raw don't strip off prefix from DirectoryService API
constants
-url print record attribute values in URL-style encod-
ing
-q quiet - no interactive prompt
commands:
-read [path [key ...]
-list path [key]
-search path key val
-create recordpath [key [val ...]
-append recordpath key val ...
-merge recordpath key val ...
-delete path [key [val ...]
-change recordpath key oldval newval
-changei recordpath key valindex newval
-passwd userpath [newpassword oldpassword newpassword]
available only in interactive mode:
-cd dir
-pushd [dir]
-popd
-auth [user [password]
-authonly [user [password]
-quit
DESCRIPTION
dscl is a general-purpose utility for operating on Directory Service
directory nodes. Its commands allow one to create, read, and manage
Directory Service data. If invoked without any commands, dscl runs in an
interactive mode, reading commands from standard input. Interactive pro-
cessing is terminated by the quit command. Leading dashes ("-") are
optional for all commands.
dscl operates on a datasource specified on the command line. This may be
a node name or a Mac OS X Server (10.2 or later) host specified by DNS
hostname or IP address. Node names may be absolute paths beginning with
a slash ("/"), or relative domain paths beginning with a dot (".") char-
acter, which specifies the local domain, or "..", specifying the local
domain's parent. If the hostname or IP address form is used then the
user must specify the -u option and either the -P of -p options to spec-
ify an administrative user and password on the remote host to authenti-
cate with to the remote host. The exception to this is if "localhost" is
specified. Passing passwords on the command line is inherently insecure
and can cause password exposure. For better security do not provide the
password as part of the command and you will be securely prompted.
PATH SPECIFICATION
There are two modes of operation when specifying paths to operate on. The
two modes correspond to whether the datasource is a node or a host. In
the case of specifying a node, the top level of paths will be record
types. Example top level paths would be:
/Users/alice
/Groups/admin
In the case of specifying a host as a data source, the top level of paths
correspond to Open Directory plug-ins and Search Paths. One can specify
the plug-in to traverse to a node name, after which the paths are equiva-
lent to the former usage. The following might be the equivalent paths as
the above paths:
/NetInfo/root/Users/alice
/LDAPv3/10.0.1.42/Groups/admin
If path components contain keys or values with embedded slash characters,
the slash characters must be escaped with a leading backslash character.
Since the shell also processes escape characters, an extra backslash is
required to correctly specify an escape. For example, to read a mount
record with the name "ldapserver:/Users" in the "/Mounts" path, the fol-
lowing path would be used:
dscl . -read /Mounts/ldaphost:\\/Users
All pathnames are case-sensitive.
NOTE: You must use double quotes to combine text into a single value. If
you use single quotes then they will actually become part of the value.
Please see the given append example below.
COMANDS
The action of each command is described below. Some commands have
aliases. For example, "cat" and "." are aliases for "read". Command
aliases are listed in parentheses.
read (cat .)
Usage: read [path [key ...]
Prints a directory. Each of the properties are printed one per line.
The property key is followed by a colon, then a space-separated list of
the values for that property. Note that a value which contains embedded
spaces will appear identical to a pair of values.
If The -raw flag for raw output has been given, then read prints the full
DirectoryService API constant for record and attribute types.
If the -url flag has been specified then printed record path attribute
values are encoded in the style of URLs. This is useful if a script or
program is trying to process the output since values will not have any
spaces or other control characters.
list (ls)
Usage: list path
Lists the subdirectories of the given directory. Subdirectories are
listed one per line. In the case of listing a search path, the names are
preceded by an index number that can act as a shortcut and used in place
of the name when specifying a path.
When used in interactive mode, the path is optional. With no path given,
the current directory will be used.
search
path key val
Searches for records that match a pattern. The search is rooted at the
given path. The path may be a node path or a record type path. Valid
keys are Directory Service record attribute types.
create (mk)
Usage: create recordpath [key [val ...]
Creates a record, property, or value. If only a record path is given,
the create command will create the record if it does not exist. If a key
is given, then a property with that key will be created.
WARNING - If a property with the given key already exists, it will be
destroyed and a new property will be created in its place. To add values
to an existing property, use the append or merge commands.
If values are included in the command, these values will be set for the
given key.
NOTE - Not all directory nodes support a property without a value. An
error will be given if you attempt to create a property with no value in
such a directory node.
append
Usage: append recordpath key val ...
Appends one or more values to a property in a given record. The property
is created if it does not exist.
merge
Usage: merge recordpath key val ...
Appends one or more values to a property in a given directory if the
property does not already have those values. The property is created if
it does not exist.
change
Usage: change recordpath key oldval newval
Replaces the given old value in the list of values of the given key with
the new value in the specified record.
changei
Usage: changei path key index val
Replaces the value at the given index in the list of values of the given
key with the new value in the specified record. index is an integer
value. An index of 1 specifies the first value. An index greater than
the number of values in the list will result in an error.
delete (rm)
Usage: delete path [key [val ...]
Delete a directory, property, or value. If a directory path is given,
the delete command will delete the directory. This can only be used on
record type and record paths. If a key is given, then a property with
that key will be deleted. If one or more values are given, those values
will be removed from the property with the given key.
passwd
Usage: passwd userpath [newpasword oldpassword newpasword]
Changes a password for a user. The user must be specified by full path,
not just a username. If you are authenticated to the node (either by
specifying the -u and -P flags or by using the auth command when in
interactive node) then you can simply specify a new password. If you are
not authenticated then the user's old password must be specified. If
passwords are not specified while in interactive mode, you will be
prompted for them. Passing these passwords on the command line is inher-
ently insecure and can cause password exposure. For better security do
not provide the password as part of the command and you will be securely
prompted.
INTERACTIVE COMANDS
cd
Usage: cd dir
Sets the current directory. Path names for other dscl commands may be
relative to the current directory.
pushd (pd)
Usage: pushd path
Similar to the pushd command commonly found in Unix shells. When a path
is specified it sets the current directory while pushing the previous
directory on to the directory stack. If no path is specified it
exchanges the top two elements of the directory stack. It will also
print the final directory stack.
popd
Usage: popd
Pops the directory stack and returns to the new top directory. It will
also print the final directory stack.
auth (su)
Usage: auth [user [password]
Authenticate as the named user, or as "root" if no user is specified. If
a password is supplied, then that password is used for authentication,
otherwise the command prompts for a password.
If dscl is run in host mode, then when this command is run the current
directory must be in the subdirectories of a node.
authonly
Usage: authonly [user [password]
Used to verify the password of a named user, or of "root" if no user is
specified. If a password is supplied, then that password is used for
authentication, otherwise the command prompts for a password.
If dscl is run in host mode, then when this command is run the current
directory must be in the subdirectories of a node.
quit (q)
Usage: quit
Ends processing of interactive commands and terminates the program.
command history
The up and down arrow keys will scan through the command history.
tab completion
When pathnames are being typed, pressing the tab key will result in a
search to auto-complete the typed partial subdirectory name. It will also
attempt to correct capitilization in the process.
EXAMPLES
-view a record in the local directory node
dscl . -read /Users/www
-create or replace the UserShell attribute value for the www user record
dscl . -create /Users/www UserShell /usr/bin/false
-list the uniqueID values for all user records on a given node
dscl /LDAPv3/ldap.company.com -list /Users UniqueID
-append a value that has spaces in it
dscl . -append /Users/www Comment "This is a comment"
SEE ALSO
DirectoryService(8), DirectoryServiceAttributes(7)
MacOSX August 25, 2003 MacOSX
|