smbclient servicename [password] [-b <buffer size>] [-d debuglevel] [-D Directory] [-U username] [-W workgroup] [-M <netbios name>] [-m maxprotocol] [-A authfile] [-N] [-l logfile] [-L <netbios name>] [-I destinationIP] [-E] [-c <command string>] [-i scope] [-0 <socket options>] [-p port] [-R < name resolve order>] [-s <smb config file>] [-T<cx>IXFqgbNan] [-k]
This tool is part of the Samba(7) suite.
smbclient is a client that can 'talk' to an SMB/CIFS server. It offers an interface similar to that of the ftp program (see ftp(1)). Operations include things like getting files from the server to the local machine, putting files from the local machine to the server, retrieving directory information from the server and so on.
servicename ” servicename is the name of the service you want to use on the server. A service name takes the form //server/service where server is the NetBIOS name of the SMB/CIFS server offering the desired service and service is the name of the service offered . Thus to connect to the service "printer" on the SMB/CIFS server " smbserver ", you would use the servicename //smbserver/printer
password ” The password required to access the specified service on the specified server. If this parameter is supplied, the -N option (suppress password prompt) is assumed.
-R <name resolve order> ” This option is used by the programs in the Samba suite to determine what naming services and in what order to resolve host names to IP addresses. The option takes a space-separated string of different name resolution options.
-M NetBIOS name ” This options allows you to send messages, using the "WinPopup" protocol, to another computer. Once a connection is established you then type your message, pressing ^D (control-D) to end.
-p port ” This number is the TCP port number that will be used when making connections to the server. The standard (well-known) TCP port number for an SMB/CIFS server is 139, which is the default.
-l logfilename ” If specified, logfilename specifies a base filename into which operational data from the running client will be logged.
-h “help ” Print a summary of command line options.
-I IP-address ” IP address is the address of the server to connect to. It should be specified in standard "a.b.c.d" notation.
-E ” This parameter causes the client to write messages to the standard error stream (stderr) rather than to the standard output stream.
-L ” This option allows you to look at what services are available on a server. You use it as smbclient -L host and a list should appear. The -I option may be useful if your NetBIOS names don't match your TCP/IP DNS host names or if you are trying to reach a host on another network.
-t terminal code ” This option tells smbclient how to interpret filenames coming from the remote server. Usually Asian language multibyte UNIX implementations use different character sets than SMB/CIFS servers ( EUC instead of SJIS for example). Setting this parameter will let smbclient convert between the UNIX filenames and the SMB filenames correctly. This option has not been seriously tested and may have some problems.
-b buffersize ” This option changes the transmit/send buffer size when getting or putting a file from/to the server. The default is 65520 bytes. Setting this value smaller (to 1200 bytes) has been observed to speed up file transfers to and from a Win9x server.
-V ” Prints the program version number.
-s <configuration file> ” 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.
-d “debug=debuglevel ” debuglevel is an integer from 0 to 10. The default value if this parameter is not specified is zero.
-l “logfile=logbasename ” File name for log/debug files. The extension ".client" will be appended. The log file is never removed by the client.
-N ” If specified, this parameter suppresses the normal password prompt from the client to the user. This is useful when accessing a service that does not require a password.
-k ” Try to authenticate with kerberos. Only useful in an Active Directory environment.
-A “authfile=filename ” This option allows you to specify a file from which to read the username and password used in the connection. The format of the file is
username = <value> password = <value> domain = <value>
-U “user=username[%password ” ] Sets the SMB username and username and password.
-n <primary NetBIOS name> ” This option allows you to override the NetBIOS name that Samba uses for itself. This is identical to setting the netbios name parameter in the smb.conf file. However, a command line setting will take precedence over settings in smb.conf .
-i <scope> ” This specifies a NetBIOS scope that nmblookup will use to communicate with when generating NetBIOS names. For details on the use of NetBIOS scopes, see rfc1001.txt and rfc1002.txt. NetBIOS scopes are very rarely used, only set this parameter if you are the system administrator in charge of all the NetBIOS systems you communicate with.
-W “workgroup=domain ” Set the SMB domain of the username. This overrides the default domain which is the domain defined in smb.conf. If the domain specified is the same as the servers NetBIOS name, it causes the client to log on using the servers local SAM (as opposed to the Domain SAM).
-O socket options ” TCP socket options to set on the client socket. See the socket options parameter in the smb.conf manual page for the list of valid options.
-T tar options ” smbclient may be used to create tar(1) compatible backups of all the files on an SMB/CIFS share. The secondary tar flags that can be given to this option are:
-D initial directory ” Change to initial directory before starting. Probably only of any use with the tar -T option.
-c command string ” command string is a semicolon-separated list of commands to be executed instead of prompting from stdin. -N is implied by -c .
Once the client is running, the user is presented with a prompt :
The backslash ("\\") indicates the current working directory on the server, and will change if the current working directory is changed.
The prompt indicates that the client is ready and waiting to carry out a user command. Each command is a single word, optionally followed by parameters specific to that command. Command and parameters are space-delimited unless these notes specifically state otherwise. All commands are case-insensitive. Parameters to commands may or may not be case sensitive, depending on the command.
You can specify file names which have spaces in them by quoting the name with double quotes, for example "a long file name".
Parameters shown in square brackets (e.g., "[parameter]") are optional. If not given, the command will use suitable defaults. Parameters shown in angle brackets (e.g., "<parameter>") are required.
All commands operating on the server are actually performed by issuing a request to the server. Thus the behavior may vary from server to server, depending on how the server was implemented.
The commands available are given here in alphabetical order.
? [command ”] If command is specified, the ? command will display a brief informative message about the specified command. If no command is specified, a list of available commands will be displayed.
! [shell command ”] If shell command is specified, the ! command will execute a shell locally and run the specified shell command. If no command is specified, a local shell will be run.
altname file ” The client will request that the server return the "alternate" name (the 8.3 name) for a file or directory.
cancel jobid0 [jobid1 ... [jobidN] ”] The client will request that the server cancel the printjobs identified by the given numeric print job ids.
chmod file mode in octal ” This command depends on the server supporting the CIFS UNIX extensions and will fail if the server does not. The client requests that the server change the UNIX permissions to the given octal mode, in standard UNIX format.
chown file uid gid ” This command depends on the server supporting the CIFS UNIX extensions and will fail if the server does not. The client requests that the server change the UNIX user and group ownership to the given decimal values. There is currently no way to remotely look up the UNIX UID and GID values for a given name. This may be addressed in future versions of the CIFS UNIX extensions.
cd [directory name ”] If "directory name" is specified, the current working directory on the server will be changed to the directory specified. This operation will fail if for any reason the specified directory is inaccessible.
del <mask> ” The client will request that the server attempt to delete all files matching mask from the current working directory on the server.
dir <mask> ” A list of the files matching mask in the current working directory on the server will be retrieved from the server and displayed.
exit ” Terminate the connection with the server and exit from the program.
get <remote file name> [local file name ”] Copy the file called remote file name from the server to the machine running the client. If specified, name the local copy local file name . All transfers in smbclient are binary. See also the lowercase command.
help [command ”] See the ? command above.
lcd [directory name ”] If directory name is specified, the current working directory on the local machine will be changed to the directory specified. This operation will fail if for any reason the specified directory is inaccessible.
link source destination ” This command depends on the server supporting the CIFS UNIX extensions and will fail if the server does not. The client requests that the server create a hard link between the source and destination files. The source file must not exist.
lowercase ” Toggle lowercasing of filenames for the get and mget commands.
ls <mask> ” See the dir command above.
mask <mask> ” This command allows the user to set up a mask which will be used during recursive operation of the mget and mput commands.
md <directory name> ” See the mkdir command.
mget <mask> ” Copy all files matching mask from the server to the machine running the client.
mkdir <directory name> ” Create a new directory on the server (user access privileges permitting) with the specified name.
mput <mask> ” Copy all files matching mask in the current working directory on the local machine to the current working directory on the server.
print <file name> ” Print the specified file from the local machine through a printable service on the server.
printmode <graphics or text> ” Set the print mode to suit either binary data (such as graphical information) or text. Subsequent print commands will use the currently set print mode.
prompt ” Toggle prompting for filenames during operation of the mget and mput commands.
put <local file name> [remote file name ”] Copy the file called local file name from the machine running the client to the server. If specified, name the remote copy remote file name . All transfers in smbclient are binary. See also the lowercase command.
queue ” Displays the print queue, showing the job id, name, size and current status.
quit ” See the exit command.
rd <directory name> ” See the rmdir command.
recurse ” Toggle directory recursion for the commands mget and mput.
rm <mask> ” Remove all files matching mask from the current working directory on the server.
rmdir <directory name> ” Remove the specified directory (user access privileges permitting) from the server.
setmode <filename> <perm=[+ \- rsha> ”] A version of the DOS attrib command to set file permissions. For example:
symlink source destination ” This command depends on the server supporting the CIFS UNIX extensions and will fail if the server does not. The client requests that the server create a symbolic hard link between the source and destination files. The source file must not exist. The server will not create a link to any path that lies outside the currently connected share. This is enforced by the Samba server.
tar <c x>[IXbgNa ”] Performs a tar operation - see the -T command line option above. Behavior may be affected by the tarmode command (see below). Using g (incremental) and N (newer) will affect tarmode settings. Using the "-" option with tar x may not work - use the command line option instead.
blocksize <blocksize> ” Blocksize. Must be followed by a valid (greater than zero) blocksize. Causes tar file to be written out in blocksize *TBLOCK (usually 512 byte) blocks.
tarmode <full inc reset noreset> ” Changes tar's behavior with regard to archive bits. In full mode, tar will back up everything regardless of the archive bit setting (this is the default mode). In incremental mode, tar will only back up files with the archive bit set. In reset mode, tar will reset the archive bit on all files it backs up (implies read/write share).
Some servers are fussy about the case of supplied usernames, passwords, share names (AKA service names) and machine names. If you fail to connect try giving all parameters in uppercase.
It is often necessary to use the -n option when connecting to some types of servers. For example OS/2 LanManager insists on a valid NetBIOS name being used, so you need to supply a valid name that would be known to the server.
smbclient supports long file names where the server supports the LANMAN2 protocol or above.
The variable USER may contain the username of the person using the client. This information is used only if the protocol level is high enough to support session-level passwords.
The variable PASSWD may contain the password of the person using the client. This information is used only if the protocol level is high enough to support session-level passwords.
The variable LIBSMB_PROG may contain the path, executed with system(), which the client should connect to instead of connecting to a server. This functionality is primarily intended as a development aid, and works best when using a LMHOSTS file
The location of the client program is a matter for individual system administrators. The following are thus suggestions only.
It is recommended that the smbclient software be installed in the /usr/local/samba/bin/ or /usr/samba/bin/ directory, this directory readable by all, writeable only by root. The client program itself should be executable by all. The client should NOT be setuid or setgid!
The client log files should be put in a directory readable and writeable only by the user.
To test the client, you will need to know the name of a running SMB/CIFS server. It is possible to run smbd(8) as an ordinary user - running that server as a daemon on a user-accessible port (typically any port number over 1024) would provide a suitable test server.
Most diagnostics issued by the client are logged in a specified log file. The log file name is specified at compile time, but may be overridden on the command line.
The number and nature of diagnostics available depends on the debug level used by the client. If you have problems, set the debug level to 3 and peruse the log files.