net — Tool for administration of Samba and remote CIFS servers.
net
{<ads|rap|rpc>} [-h] [-w workgroup] [-W myworkgroup] [-U user] [-I ip-address] [-p port] [-n myname] [-s conffile] [-S server] [-l] [-P] [-d debuglevel] [-V] [--request-timeout seconds]
This tool is part of the samba(7) suite.
The Samba net utility is meant to work just like the net utility available for windows and DOS. The first argument should be used to specify the protocol to use when executing a certain command. ADS is used for ActiveDirectory, RAP is using for old (Win9x/NT3) clients and RPC can be used for NT4 and Windows 2000. If this argument is omitted, net will try to determine it automatically. Not all commands are available on all protocols.
Print a summary of command line options.
Try to authenticate with kerberos. Only useful in an Active Directory environment.
Sets target workgroup or domain. You have to specify either this option or the IP address or the name of a server.
Sets client workgroup or domain
User name to use
IP address of target server to use. You have to specify either this option or a target workgroup or a target server.
Port on the target server to connect to (usually 139 or 445). Defaults to trying 445 first, then 139.
This option allows you to override
the NetBIOS name that Samba uses for itself. This is identical
to setting the parameter in the smb.conf
file.
However, a command
line setting will take precedence over settings in
smb.conf
.
The file specified contains the
configuration details required by the server. The
information in this file includes server-specific
information such as what printcap file to use, as well
as descriptions of all the services that the server is
to provide. See smb.conf
for more information.
The default configuration file name is determined at
compile time.
Name of target server. You should specify either this option or a target workgroup or a target IP address.
When listing data, give more information on each item.
Make queries to the external server using the machine account of the local server.
Let client requests timeout after 30 seconds the default is 10 seconds.
level
is an integer
from 0 to 10. The default value if this parameter is
not specified is 0.
The higher this value, the more detail will be logged to the log files about the activities of the server. At level 0, only critical errors and serious warnings will be logged. Level 1 is a reasonable level for day-to-day running - it generates a small amount of information about operations carried out.
Levels above 1 will generate considerable amounts of log data, and should only be used when investigating a problem. Levels above 3 are designed for use only by developers and generate HUGE amounts of log data, most of which is extremely cryptic.
Note that specifying this parameter here will
override the parameter
in the smb.conf
file.
This command allows the Samba machine account password to be set from an external application to a machine account password that has already been stored in Active Directory. DO NOT USE this command unless you know exactly what you are doing. The use of this command requires that the force flag (-f) be used also. There will be NO command prompt. Whatever information is piped into stdin, either by typing at the command line or otherwise, will be stored as the literal machine password. Do NOT use this without care and attention as it will overwrite a legitimate machine password without warning. YOU HAVE BEEN WARNED.
The NET TIME
command allows you to view the time on a remote server
or synchronise the time on the local server with the time on the remote server.
Join a domain. If the account already exists on the server, and [TYPE] is MEMBER, the machine will attempt to join automatically. (Assuming that the machine has been created in server manager) Otherwise, a password will be prompted for, and a new account may be created.
[TYPE] may be PDC, BDC or MEMBER to specify the type of server joining the domain.
[UPN] (ADS only) set the principalname attribute during the join. The default format is host/netbiosname@REALM.
[OU] (ADS only) Precreate the computer account in a specific OU. The OU string reads from top to bottom without RDNs, and is delimited by a '/'. Please note that '\' is used for escape by both the shell and ldap, so it may need to be doubled or quadrupled to pass through, and it is not used as a delimiter.
Join a domain. Use the OLDJOIN option to join the domain using the old style of domain joining - you need to create a trust account in server manager first.
Enumerates all exported resources (network shares) on target server.
user
[password
]Validate whether the specified user can log in to the remote server. If the password is not specified on the commandline, it will be prompted.
Currently NOT implemented.
command
Execute the specified command
on
the remote server. Only works with OS/2 servers.
Currently NOT implemented.
Samba uses a general caching interface called 'gencache'. It can be controlled using 'NET CACHE'.
All the timeout parameters support the suffixes:
s - Seconds |
m - Minutes |
h - Hours |
d - Days |
w - Weeks |
Prints the SID of the specified domain, or if the parameter is omitted, the SID of the local server.
Manage the mappings between Windows group SIDs and UNIX groups. Common options include:
unixgroup - Name of the UNIX group
ntgroup - Name of the Windows NT group (must be resolvable to a SID
rid - Unsigned 32-bit integer
sid - Full SID in the form of "S-1-..."
type - Type of the group; either 'domain', 'local', or 'builtin'
comment - Freeform text description of the group
Add a new group mapping entry:
net groupmap add {rid=int|sid=string} unixgroup=string \ [type={domain|local}] [ntgroup=string] [comment=string]
Delete a group mapping entry. If more than one group name matches, the first entry found is deleted.
net groupmap delete {ntgroup=string|sid=SID}
Prints out the highest RID currently in use on the local server (by the active 'passdb backend').
Print information about the domain of the remote server, such as domain name, domain sid and number of users and groups.
DOMAIN
Add a interdomain trust account for DOMAIN
.
This is in fact a Samba account named DOMAIN$
with the account flag 'I'
(interdomain trust account).
This is required for incoming trusts to work. It makes Samba be a
trusted domain of the foreign (trusting) domain.
Users of the Samba domain will be made available in the foreign domain.
If the command is used against localhost it has the same effect as
smbpasswd -a -i DOMAIN
. Please note that both commands
expect a appropriate UNIX account.
DOMAIN
Remove interdomain trust account for
DOMAIN
. If it is used against localhost
it has the same effect as smbpasswd -x DOMAIN$
.
DOMAIN
Establish a trust relationship to a trusted domain. Interdomain account must already be created on the remote PDC. This is required for outgoing trusts to work. It makes Samba be a trusting domain of a foreign (trusted) domain. Users of the foreign domain will be made available in our domain. You'll need winbind and a working idmap config to make them appear in your system.
Create a trust trust object by calling lsaCreateTrustedDomainEx2. The can be done on a single server or on two servers at once with the possibility to use a random trust password.
Options:
Domain controller of the second domain
Admin user in the second domain
SID of the second domain
NetBIOS (short) name of the second domain
DNS (full) name of the second domain
Trust password
Examples:
net rpc trust create \
otherdomainsid=S-x-x-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx \
other_netbios_domain=dom2 \
otherdomain=dom2.dom \
trustpw=12345678 \
-S srv1.dom1.dom
net rpc trust create \
otherserver=srv2.dom2.test \
otheruser=dom2adm \
-S srv1.dom1.dom
Delete a trust trust object by calling lsaDeleteTrustedDomain. The can be done on a single server or on two servers at once.
Options:
Domain controller of the second domain
Admin user in the second domain
SID of the second domain
Examples:
net rpc trust delete \
otherdomainsid=S-x-x-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx \
-S srv1.dom1.dom
net rpc trust delete \
otherserver=srv2.dom2.test \
otheruser=dom2adm \
-S srv1.dom1.dom
Shut down the remote server.
Reboot after shutdown.
Force shutting down all applications.
Timeout before system will be shut down. An interactive user of the system can use this time to cancel the shutdown.
Display the specified message on the screen to announce the shutdown.
Print out sam database of remote server. You need to run this against the PDC, from a Samba machine joined as a BDC.
Export users, aliases and groups from remote server to local server. You need to run this against the PDC, from a Samba machine joined as a BDC.
Print out status of machine account of the local machine in ADS.
Prints out quite some debug info. Aimed at developers, regular
users should use NET ADS TESTJOIN
.
EXPRESSION
ATTRIBUTES...
Perform a raw LDAP search on a ADS server and dump the results. The expression is a standard LDAP search expression, and the attributes are a list of LDAP fields to show in the results.
Example: net ads search '(objectCategory=group)' sAMAccountName
DN
(attributes)
Perform a raw LDAP search on a ADS server and dump the results. The DN standard LDAP DN, and the attributes are a list of LDAP fields to show in the result.
Example: net ads dn 'CN=administrator,CN=Users,DC=my,DC=domain' SAMAccountName
(Re)Create a BUILTIN group. Only a wellknown set of BUILTIN groups can be created with this command. This is the list of currently recognized group names: Administrators, Users, Guests, Power Users, Account Operators, Server Operators, Print Operators, Backup Operators, Replicator, RAS Servers, Pre-Windows 2000 compatible Access. This command requires a running Winbindd with idmap allocation properly configured. The group gid will be allocated out of the winbindd range.
Create a LOCAL group (also known as Alias). This command requires a running Winbindd with idmap allocation properly configured. The group gid will be allocated out of the winbindd range.
Map an existing Unix group and make it a Domain Group, the domain group will have the same name.
Add a member to a Local group. The group can be specified only by name, the member can be specified by name or SID.
Remove a member from a Local group. The group and the member must be specified by name.
List the specified set of accounts by name. If verbose is specified, the rid and description is also provided for each account.
Set the workstations a user account is allowed to log in from.
Set or unset the "password must change" flag for a user account.
Set a value for the account policy. Valid values can be: "forever", "never", "off", or a number.
Only available if ldapsam:editposix is set and winbindd is running. Properly populates the ldap tree with the basic accounts (Administrator) and groups (Domain Users, Domain Admins, Domain Guests) on the ldap tree.
Dumps the mappings contained in the local tdb file specified. This command is useful to dump only the mappings produced by the idmap_tdb backend.
Store a secret for the specified domain, used primarily for domains that use idmap_ldap as a backend. In this case the secret is used as the password for the user DN used to bind to the ldap server.
Delete a mapping sid <-> gid or sid <-> uid from the IDMAP database. The mapping is given by <ID> which may either be a sid: S-x-..., a gid: "GID number" or a uid: "UID number". Use -f to delete an invalid partial mapping <ID> -> xx
Use "smbcontrol all idmap ..." to notify running smbd instances. See the smbcontrol(1) manpage for details.
Check and repair the IDMAP database. If no option is given a read only check of the database is done. Among others an interactive or automatic repair mode may be chosen with one of the following options:
Interactive repair mode, ask a lot of questions.
Noninteractive repair mode, use default answers.
Produce more output.
Try to apply changes, even if they do not apply cleanly.
Dry run, show what changes would be made but don't touch anything.
Lock the database while doing the check.
Check the specified database.
It reports about the finding of the following errors:
A record with mapping A->B where there is no B->A. Default action in repair mode is to "fix" this by adding the reverse mapping.
A record with mapping A->B where B->C. Default action is to "delete" this record.
A high water mark is not at least equal to the largest ID in the database. Default action is to "fix" this by setting it to the largest ID found +1.
Something we failed to parse. Default action is to "edit" it in interactive and "delete" it in automatic mode.
Starting with version 3.0.23, a Samba server now supports the ability for non-root users to add user defined shares to be exported using the "net usershare" commands.
To set this up, first set up your smb.conf by adding to the [global] section: usershare path = /usr/local/samba/lib/usershares Next create the directory /usr/local/samba/lib/usershares, change the owner to root and set the group owner to the UNIX group who should have the ability to create usershares, for example a group called "serverops". Set the permissions on /usr/local/samba/lib/usershares to 01770. (Owner and group all access, no access for others, plus the sticky bit, which means that a file in that directory can be renamed or deleted only by the owner of the file). Finally, tell smbd how many usershares you will allow by adding to the [global] section of smb.conf a line such as : usershare max shares = 100. To allow 100 usershare definitions. Now, members of the UNIX group "serverops" can create user defined shares on demand using the commands below.
The usershare commands are:
net usershare add sharename path [comment [acl] [guest_ok=[y|n]]] - to add or change a user defined share. |
net usershare delete sharename - to delete a user defined share. |
net usershare info [-l|--long] [wildcard sharename] - to print info about a user defined share. |
net usershare list [-l|--long] [wildcard sharename] - to list user defined shares. |
sharename
path
[comment]
[acl]
[guest_ok=[y|n]]
Add or replace a new user defined share, with name "sharename".
"path" specifies the absolute pathname on the system to be exported. Restrictions may be put on this, see the global smb.conf parameters: "usershare owner only", "usershare prefix allow list", and "usershare prefix deny list".
The optional "comment" parameter is the comment that will appear on the share when browsed to by a client.
The optional "acl" field specifies which users have read and write access to the entire share. Note that guest connections are not allowed unless the smb.conf parameter "usershare allow guests" has been set. The definition of a user defined share acl is: "user:permission", where user is a valid username on the system and permission can be "F", "R", or "D". "F" stands for "full permissions", ie. read and write permissions. "D" stands for "deny" for a user, ie. prevent this user from accessing this share. "R" stands for "read only", ie. only allow read access to this share (no creation of new files or directories or writing to files).
The default if no "acl" is given is "Everyone:R", which means any authenticated user has read-only access.
The optional "guest_ok" has the same effect as the parameter of the same name in smb.conf, in that it allows guest access to this user defined share. This parameter is only allowed if the global parameter "usershare allow guests" has been set to true in the smb.conf.
There is no separate command to modify an existing user defined share, just use the "net usershare add [sharename]" command using the same sharename as the one you wish to modify and specify the new options you wish. The Samba smbd daemon notices user defined share modifications at connect time so will see the change immediately, there is no need to restart smbd on adding, deleting or changing a user defined share.sharename
Deletes the user defined share by name. The Samba smbd daemon immediately notices this change, although it will not disconnect any users currently connected to the deleted share.
[-l|--long]
[wildcard sharename]
Get info on user defined shares owned by the current user matching the given pattern, or all users.
net usershare info on its own dumps out info on the user defined shares that were created by the current user, or restricts them to share names that match the given wildcard pattern ('*' matches one or more characters, '?' matches only one character). If the '-l' or '--long' option is also given, it prints out info on user defined shares created by other users.
The information given about a share looks like: [foobar] path=/home/jeremy comment=testme usershare_acl=Everyone:F guest_ok=n And is a list of the current settings of the user defined share that can be modified by the "net usershare add" command.
[-l|--long]
wildcard sharename
List all the user defined shares owned by the current user matching the given pattern, or all users.
net usershare list on its own list out the names of the user defined shares that were created by the current user, or restricts the list to share names that match the given wildcard pattern ('*' matches one or more characters, '?' matches only one character). If the '-l' or '--long' option is also given, it includes the names of user defined shares created by other users.
Starting with version 3.2.0, a Samba server can be configured by data stored in registry. This configuration data can be edited with the new "net conf" commands.
The deployment of this configuration data can be activated in two levels from the
smb.conf file: Share definitions from registry are
activated by setting registry shares
to
“yes” in the [global] section and global configuration options are
activated by setting include = registry in
the [global] section for a mixed configuration or by setting
config backend = registry in the [global]
section for a registry-only configuration.
See the smb.conf(5) manpage for details.
The conf commands are:
net conf list - Dump the complete configuration in smb.conf like format. |
net conf import - Import configuration from file in smb.conf format. |
net conf listshares - List the registry shares. |
net conf drop - Delete the complete configuration from registry. |
net conf showshare - Show the definition of a registry share. |
net conf addshare - Create a new registry share. |
net conf delshare - Delete a registry share. |
net conf setparm - Store a parameter. |
net conf getparm - Retrieve the value of a parameter. |
net conf delparm - Delete a parameter. |
net conf getincludes - Show the includes of a share definition. |
net conf setincludes - Set includes for a share. |
net conf delincludes - Delete includes from a share definition. |
Print the configuration data stored in the registry in a smb.conf-like format to standard output.
[--test|-T]
filename
[section]
This command imports configuration from a file in smb.conf format. If a section encountered in the input file is present in registry, its contents is replaced. Sections of registry configuration that have no counterpart in the input file are not affected. If you want to delete these, you will have to use the "net conf drop" or "net conf delshare" commands. Optionally, a section may be specified to restrict the effect of the import command to that specific section. A test mode is enabled by specifying the parameter "-T" on the commandline. In test mode, no changes are made to the registry, and the resulting configuration is printed to standard output instead.
sharename
Show the definition of the share or section specified. It is valid to specify "global" as sharename to retrieve the global configuration options from registry.
sharename
path
[writeable={y|N}
[guest_ok={y|N}
[comment
]]] Create a new share definition in registry. The sharename and path have to be given. The share name may not be "global". Optionally, values for the very common options "writeable", "guest ok" and a "comment" may be specified. The same result may be obtained by a sequence of "net conf setparm" commands.
section
parameter
value
Store a parameter in registry. The section may be global or a sharename. The section is created if it does not exist yet.
section
Get the list of includes for the provided section (global or share).
Note that due to the nature of the registry database and the nature of include directives, the includes need special treatment: Parameters are stored in registry by the parameter name as valuename, so there is only ever one instance of a parameter per share. Also, a specific order like in a text file is not guaranteed. For all real parameters, this is perfectly ok, but the include directive is rather a meta parameter, for which, in the smb.conf text file, the place where it is specified between the other parameters is very important. This can not be achieved by the simple registry smbconf data model, so there is one ordered list of includes per share, and this list is evaluated after all the parameters of the share.
Further note that currently, only files can be included from registry configuration. In the future, there will be the ability to include configuration data from other registry keys.
Manipulate Samba's registry.
The registry commands are:
net registry enumerate - Enumerate registry keys and values. |
net registry enumerate_recursive - Enumerate registry key and its subkeys. |
net registry createkey - Create a new registry key. |
net registry deletekey - Delete a registry key. |
net registry deletekey_recursive - Delete a registry key with subkeys. |
net registry getvalue - Print a registry value. |
net registry getvalueraw - Print a registry value (raw format). |
net registry setvalue - Set a new registry value. |
net registry increment - Increment a DWORD registry value under a lock. |
net registry deletevalue - Delete a registry value. |
net registry getsd - Get security descriptor. |
net registry getsd_sdd1 - Get security descriptor in sddl format. |
net registry setsd_sdd1 - Set security descriptor from sddl format string. |
net registry import - Import a registration entries (.reg) file. |
net registry export - Export a registration entries (.reg) file. |
net registry convert - Convert a registration entries (.reg) file. |
key
Delete the given key and all of its subkeys and values from the registry.
key
name
type
value
...Set the value name
of an existing key.
type may be one of
sz, multi_sz or
dword.
In case of multi_sz value
may
be given multiple times.
key
name
[inc]
Increment the DWORD value name
of key by inc
while holding a g_lock.
inc defaults to 1.
key
Get the security descriptor of the given key as a Security Descriptor Definition Language (SDDL) string.
Starting with version 3.4.0 net can read, dump, import and export native win32 eventlog files (usually *.evt). evt files are used by the native Windows eventviewer tools.
The import and export of evt files can only succeed when eventlog list
is used in
smb.conf file.
See the smb.conf(5) manpage for details.
The eventlog commands are:
net eventlog dump - Dump a eventlog *.evt file on the screen. |
net eventlog import - Import a eventlog *.evt into the samba internal tdb based representation of eventlogs. |
net eventlog export - Export the samba internal tdb based representation of eventlogs into an eventlog *.evt file. |
filename
eventlog
Imports a eventlog *.evt file defined by filename
into the
samba internal tdb representation of eventlog defined by eventlog
.
eventlog
needs to part of the eventlog list
defined in smb.conf.
See the smb.conf(5) manpage for details.
filename
eventlog
Exports the samba internal tdb representation of eventlog defined by eventlog
to a eventlog *.evt file defined by filename
.
eventlog
needs to part of the eventlog list
defined in smb.conf.
See the smb.conf(5) manpage for details.
Starting with version 3.2.0 Samba has support for remote join and unjoin APIs, both client and server-side. Windows supports remote join capabilities since Windows 2000.
In order for Samba to be joined or unjoined remotely an account must be used that is either member of the Domain Admins group, a member of the local Administrators group or a user that is granted the SeMachineAccountPrivilege privilege.
The client side support for remote join is implemented in the net dom commands which are:
net dom join - Join a remote computer into a domain. |
net dom unjoin - Unjoin a remote computer from a domain. |
net dom renamecomputer - Renames a remote computer joined to a domain. |
domain=DOMAIN
ou=OU
account=ACCOUNT
password=PASSWORD
reboot
Joins a computer into a domain. This command supports the following additional parameters:
DOMAIN
can be a NetBIOS domain name (also known as short domain name) or a DNS domain name for Active Directory Domains. As in Windows, it is also possible to control which Domain Controller to use. This can be achieved by appending the DC name using the \ separator character. Example: MYDOM\MYDC. The DOMAIN
parameter cannot be NULL.
OU
can be set to a RFC 1779 LDAP DN, like ou=mymachines,cn=Users,dc=example,dc=com in order to create the machine account in a non-default LDAP container. This optional parameter is only supported when joining Active Directory Domains.
ACCOUNT
defines a domain account that will be used to join the machine to the domain. This domain account needs to have sufficient privileges to join machines.
PASSWORD
defines the password for the domain account defined with ACCOUNT
.
REBOOT
is an optional parameter that can be set to reboot the remote machine after successful join to the domain.
Note that you also need to use standard net parameters to connect and authenticate to the remote machine that you want to join. These additional parameters include: -S computer and -U user.
Example: net dom join -S xp -U XP\\administrator%secret domain=MYDOM account=MYDOM\\administrator password=topsecret reboot.
This example would connect to a computer named XP as the local administrator using password secret, and join the computer into a domain called MYDOM using the MYDOM domain administrator account and password topsecret. After successful join, the computer would reboot.
account=ACCOUNT
password=PASSWORD
reboot
Unjoins a computer from a domain. This command supports the following additional parameters:
ACCOUNT
defines a domain account that will be used to unjoin the machine from the domain. This domain account needs to have sufficient privileges to unjoin machines.
PASSWORD
defines the password for the domain account defined with ACCOUNT
.
REBOOT
is an optional parameter that can be set to reboot the remote machine after successful unjoin from the domain.
Note that you also need to use standard net parameters to connect and authenticate to the remote machine that you want to unjoin. These additional parameters include: -S computer and -U user.
Example: net dom unjoin -S xp -U XP\\administrator%secret account=MYDOM\\administrator password=topsecret reboot.
This example would connect to a computer named XP as the local administrator using password secret, and unjoin the computer from the domain using the MYDOM domain administrator account and password topsecret. After successful unjoin, the computer would reboot.
newname=NEWNAME
account=ACCOUNT
password=PASSWORD
reboot
Renames a computer that is joined to a domain. This command supports the following additional parameters:
NEWNAME
defines the new name of the machine in the domain.
ACCOUNT
defines a domain account that will be used to rename the machine in the domain. This domain account needs to have sufficient privileges to rename machines.
PASSWORD
defines the password for the domain account defined with ACCOUNT
.
REBOOT
is an optional parameter that can be set to reboot the remote machine after successful rename in the domain.
Note that you also need to use standard net parameters to connect and authenticate to the remote machine that you want to rename in the domain. These additional parameters include: -S computer and -U user.
Example: net dom renamecomputer -S xp -U XP\\administrator%secret newname=XPNEW account=MYDOM\\administrator password=topsecret reboot.
This example would connect to a computer named XP as the local administrator using password secret, and rename the joined computer to XPNEW using the MYDOM domain administrator account and password topsecret. After successful rename, the computer would reboot.
Manage global locks.
lockname
timeout
command
Execute a shell command under a global lock. This might be useful to define the
order in which several shell commands will be executed. The locking information
is stored in a file called g_lock.tdb
. In setups with CTDB
running, the locking information will be available on all cluster nodes.
LOCKNAME
defines the name of the global lock.
TIMEOUT
defines the timeout.
COMMAND
defines the shell command to execute.