7 CONTENT="Modular DocBook HTML Stylesheet Version 1.57"></HEAD
27 >smbclient -- ftp-like client to access SMB/CIFS resources
30 CLASS="REFSYNOPSISDIV"
40 > {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 <terminal code>] [-c <command string>] [-i scope] [-O <socket options>] [-p port] [-R <name resolve order>] [-s <smb config file>] [-T<c|x>IXFqgbNan]</P
50 >This tool is part of the <A
59 > is a client that can
60 'talk' to an SMB/CIFS server. It offers an interface
61 similar to that of the ftp program (see <B
65 Operations include things like getting files from the server
66 to the local machine, putting files from the local machine to
67 the server, retrieving directory information from the server
86 >servicename is the name of the service
87 you want to use on the server. A service name takes the form
97 > is the NetBIOS name of the SMB/CIFS server
98 offering the desired service and <TT
104 is the name of the service offered. Thus to connect to
105 the service "printer" on the SMB/CIFS server "smbserver",
106 you would use the servicename <TT
112 >Note that the server name required is NOT necessarily
113 the IP (DNS) host name of the server ! The name required is
114 a NetBIOS server name, which may or may not be the
115 same as the IP hostname of the machine running the server.
118 >The server name is looked up according to either
128 using the name resolve order parameter in the <TT
132 allowing an administrator to change the order and methods
133 by which server names are looked up. </P
139 >The password required to access the specified
140 service on the specified server. If this parameter is
147 password prompt) is assumed. </P
149 >There is no default password. If no password is supplied
150 on the command line (either by using this parameter or adding
151 a password to the <TT
163 specified, the client will prompt for a password, even if
164 the desired service does not require one. (If no password is
165 required, simply press ENTER to provide a null password.)
168 >Note: Some servers (including OS/2 and Windows for
169 Workgroups) insist on an uppercase password. Lowercase
170 or mixed case passwords may be rejected by these servers.
173 >Be cautious about including passwords in scripts.
180 >Specifies the location of the all important
187 >-O socket options</DT
190 >TCP socket options to set on the client
191 socket. See the socket options parameter in the <TT
194 > manpage for the list of valid
198 >-R <name resolve order></DT
201 >This option is used by the programs in the Samba
202 suite to determine what naming services and in what order to resolve
203 host names to IP addresses. The option takes a space-separated
204 string of different name resolution options.</P
206 >The options are :"lmhosts", "host", "wins" and "bcast". They
207 cause names to be resolved as follows :</P
217 address in the Samba lmhosts file. If the line in lmhosts has
218 no name type attached to the NetBIOS name (see the <A
219 HREF="lmhosts.5.html"
223 any name type matches for lookup.</P
230 > : Do a standard host
231 name to IP address resolution, using the system <TT
235 >, NIS, or DNS lookups. This method of name resolution
236 is operating system dependent, for instance on IRIX or Solaris this
237 may be controlled by the <TT
239 >/etc/nsswitch.conf</TT
241 file). Note that this method is only used if the NetBIOS name
242 type being queried is the 0x20 (server) name type, otherwise
250 > : Query a name with
251 the IP address listed in the <TT
257 parameter. If no WINS server has
258 been specified this method will be ignored.</P
265 > : Do a broadcast on
266 each of the known local interfaces listed in the
273 parameter. This is the least reliable of the name resolution
274 methods as it depends on the target host being on a locally
279 >If this parameter is not set then the name resolve order
284 (name resolve order) will be used. </P
286 >The default order is lmhosts, host, wins, bcast and without
287 this parameter or any entry in the <TT
293 > parameter of the <TT
296 > file the name resolution
297 methods will be attempted in this order. </P
303 >This options allows you to send messages, using
304 the "WinPopup" protocol, to another computer. Once a connection is
305 established you then type your message, pressing ^D (control-D) to
308 >If the receiving computer is running WinPopup the user will
309 receive the message and probably a beep. If they are not running
310 WinPopup the message will be lost, and no error message will
313 >The message is also automatically truncated if the message
314 is over 1600 bytes, as this is the limit of the protocol.
317 >One useful trick is to cat the message through
323 > cat mymessage.txt | smbclient -M FRED </B
325 send the message in the file <TT
329 to the machine FRED. </P
331 >You may also find the <TT
342 > options useful, as they allow you to
343 control the FROM and TO parts of the message. </P
345 >See the message command parameter in the <TT
348 > for a description of how to handle incoming
349 WinPopup messages in Samba. </P
353 >: Copy WinPopup into the startup group
354 on your WfWg PCs if you want them to always be able to receive
361 >This specifies a NetBIOS scope that smbclient will
362 use to communicate with when generating NetBIOS names. For details
363 on the use of NetBIOS scopes, see <TT
371 NetBIOS scopes are <EM
373 > rarely used, only set
374 this parameter if you are the system administrator in charge of all
375 the NetBIOS systems you communicate with. </P
381 >If specified, this parameter suppresses the normal
382 password prompt from the client to the user. This is useful when
383 accessing a service that does not require a password. </P
385 >Unless a password is specified on the command line or
386 this parameter is specified, the client will request a
393 >By default, the client will use the local
394 machine's hostname (in uppercase) as its NetBIOS name. This parameter
395 allows you to override the host name and use whatever NetBIOS
407 > is an integer from 0 to 10, or
410 >The default value if this parameter is not specified
413 >The higher this value, the more detail will be logged to
414 the log files about the activities of the
415 client. At level 0, only critical errors and serious warnings will
416 be logged. Level 1 is a reasonable level for day to day running -
417 it generates a small amount of information about operations
420 >Levels above 1 will generate considerable amounts of log
421 data, and should only be used when investigating a problem.
422 Levels above 3 are designed for use only by developers and
423 generate HUGE amounts of log data, most of which is extremely
429 > is set to the letter 'A', then <EM
432 > debug messages will be printed. This setting
433 is for developers only (and people who <EM
436 to know how the code works internally). </P
438 >Note that specifying this parameter here will override
439 the log level parameter in the <TT
449 >This number is the TCP port number that will be used
450 when making connections to the server. The standard (well-known)
451 TCP port number for an SMB/CIFS server is 139, which is the
463 > specifies a base filename
464 into which operational data from the running client will be
467 >The default base name is specified at compile time.</P
469 >The base name is used to generate actual log file names.
470 For example, if the name specified was "log", the debug file
476 >The log file generated is never removed by the client.
483 >Print the usage message for the client. </P
494 > is the address of the server to connect to.
495 It should be specified in standard "a.b.c.d" notation. </P
497 >Normally the client would attempt to locate a named
498 SMB/CIFS server by looking it up via the NetBIOS name resolution
499 mechanism described above in the <TT
502 >name resolve order</I
505 parameter above. Using this parameter will force the client
506 to assume that the server is on the machine with the specified IP
507 address and the NetBIOS name component of the resource being
508 connected to will be ignored. </P
510 >There is no default for this parameter. If not supplied,
511 it will be determined automatically by the client as described
518 >This parameter causes the client to write messages
519 to the standard error stream (stderr) rather than to the standard
522 >By default, the client writes messages to standard output
523 - typically the user's tty. </P
526 >-U username[%pass]</DT
529 >Sets the SMB username or username and password.
530 If %pass is not specified, The user will be prompted. The client
531 will first check the <TT
534 > environment variable, then the
538 > variable and if either exists, the
539 string is uppercased. Anything in these variables following a '%'
540 sign will be treated as the password. If these environment
541 variables are not found, the username <TT
547 >If the password is not included in these environment
548 variables (using the %pass syntax), <B
555 > environment variable from which
556 to read the password. </P
558 >A third option is to use a credentials file which
559 contains the plaintext of the domain name, username and password. This
560 option is mainly provided for scripts where the admin doesn't
561 wish to pass the credentials on the command line or via environment
562 variables. If this method is used, make certain that the permissions
563 on the file restrict access from unwanted users. See the
569 > for more details. </P
571 >Be cautious about including passwords in scripts or in
575 > environment variable. Also, on
576 many systems the command line of a running process may be seen
580 > command to be safe always allow
584 > to prompt for a password and type
592 you to specify a file from which to read the username, domain name, and
593 password used in the connection. The format of the file is
603 CLASS="PROGRAMLISTING"
604 >username = <value>
605 password = <value>
606 domain = <value>
613 >If the domain parameter is missing the current workgroup name
614 is used instead. Make certain that the permissions on the file restrict
615 access from unwanted users. </P
621 >This option allows you to look at what services
622 are available on a server. You use it as <B
626 > and a list should appear. The <TT
632 > option may be useful if your NetBIOS names don't
633 match your TCP/IP DNS host names or if you are trying to reach a
634 host on another network. </P
637 >-t terminal code</DT
640 >This option tells <B
644 filenames coming from the remote server. Usually Asian language
645 multibyte UNIX implementations use different character sets than
646 SMB/CIFS servers (<EM
650 > for example). Setting this parameter will let
654 > convert between the UNIX filenames and
655 the SMB filenames correctly. This option has not been seriously tested
656 and may have some problems. </P
658 >The terminal codes include CWsjis, CWeuc, CWjis7, CWjis8,
659 CWjunet, CWhex, CWcap. This is not a complete list, check the Samba
660 source code for the complete list. </P
666 >This option changes the transmit/send buffer
667 size when getting or putting a file from/to the server. The default
668 is 65520 bytes. Setting this value smaller (to 1200 bytes) has been
669 observed to speed up file transfers to and from a Win9x server.
676 >Override the default workgroup (domain) specified
677 in the workgroup parameter of the <TT
681 file for this connection. This may be needed to connect to some
688 >smbclient may be used to create <B
692 > compatible backups of all the files on an SMB/CIFS
693 share. The secondary tar flags that can be given to this option
705 > - Create a tar file on UNIX.
706 Must be followed by the name of a tar file, tape device
707 or "-" for standard output. If using standard output you must
708 turn the log level to its lowest value -d0 to avoid corrupting
709 your tar file. This flag is mutually exclusive with the
724 > - Extract (restore) a local
725 tar file back to a share. Unless the -D option is given, the tar
726 files will be restored from the top level of the share. Must be
727 followed by the name of the tar file, device or "-" for standard
728 input. Mutually exclusive with the <TT
734 Restored files have their creation times (mtime) set to the
735 date saved in the tar file. Directories currently do not get
736 their creation dates restored properly. </P
745 > - Include files and directories.
746 Is the default behavior when filenames are specified above. Causes
747 tar files to be included in an extract or create (and therefore
748 everything else to be excluded). See example below. Filename globbing
749 works in one of two ways. See r below. </P
758 > - Exclude files and directories.
759 Causes tar files to be excluded from an extract or create. See
760 example below. Filename globbing works in one of two ways now.
775 > - Blocksize. Must be followed
776 by a valid (greater than zero) blocksize. Causes tar file to be
777 written out in blocksize*TBLOCK (usually 512 byte) blocks.
787 > - Incremental. Only back up
788 files that have the archive bit set. Useful only with the
803 > - Quiet. Keeps tar from printing
804 diagnostics as it works. This is the same as tarmode quiet.
814 > - Regular expression include
815 or exclude. Uses regular expression matching for
816 excluding or excluding files if compiled with HAVE_REGEX_H.
817 However this mode can be very slow. If not compiled with
818 HAVE_REGEX_H, does a limited wildcard match on '*' and '?'.
828 > - Newer than. Must be followed
829 by the name of a file whose date is compared against files found
830 on the share during a create. Only files newer than the file
831 specified are backed up to the tar file. Useful only with the
846 > - Set archive bit. Causes the
847 archive bit to be reset when a file is backed up. Useful with the
864 >Tar Long File Names</EM
870 >'s tar option now supports long
871 file names both on backup and restore. However, the full path
872 name of the file must be less than 1024 bytes. Also, when
873 a tar archive is created, <B
876 >'s tar option places all
877 files in the archive with relative names, not absolute names.
884 >All file names can be given as DOS path names (with '\'
885 as the component separator) or as UNIX path names (with '/' as
886 the component separator). </P
892 >Restore from tar file <TT
895 > into myshare on mypc
896 (no password on share). </P
900 >smbclient //mypc/yshare "" -N -Tx backup.tar
904 >Restore everything except <TT
912 >smbclient //mypc/myshare "" -N -TXx backup.tar
916 >Create a tar file of the files beneath <TT
923 >smbclient //mypc/myshare "" -N -Tc
924 backup.tar users/docs </B
927 >Create the same tar file as above, but now use
932 >smbclient //mypc/myshare "" -N -tc backup.tar
936 >Create a tar file of all the files and directories in
941 >smbclient //mypc/myshare "" -N -Tc backup.tar *
946 >-D initial directory</DT
949 >Change to initial directory before starting. Probably
950 only of any use with the tar -T option. </P
953 >-c command string</DT
956 >command string is a semicolon-separated list of
957 commands to be executed instead of prompting from stdin. <TT
969 >This is particularly useful in scripts and for printing stdin
970 to the server, e.g. <B
986 >Once the client is running, the user is presented with
994 >The backslash ("\") indicates the current working directory
995 on the server, and will change if the current working directory
998 >The prompt indicates that the client is ready and waiting to
999 carry out a user command. Each command is a single word, optionally
1000 followed by parameters specific to that command. Command and parameters
1001 are space-delimited unless these notes specifically
1002 state otherwise. All commands are case-insensitive. Parameters to
1003 commands may or may not be case sensitive, depending on the command.
1006 >You can specify file names which have spaces in them by quoting
1007 the name with double quotes, for example "a long file name". </P
1009 >Parameters shown in square brackets (e.g., "[parameter]") are
1010 optional. If not given, the command will use suitable defaults. Parameters
1011 shown in angle brackets (e.g., "<parameter>") are required.
1014 >Note that all commands operating on the server are actually
1015 performed by issuing a request to the server. Thus the behavior may
1016 vary from server to server, depending on how the server was implemented.
1019 >The commands available are given here in alphabetical order. </P
1023 CLASS="VARIABLELIST"
1034 > is specified, the ? command will display
1035 a brief informative message about the specified command. If no
1036 command is specified, a list of available commands will
1040 >! [shell command]</DT
1048 > is specified, the !
1049 command will execute a shell locally and run the specified shell
1050 command. If no command is specified, a local shell will be run.
1057 >The client will request that the server return
1058 the "alternate" name (the 8.3 name) for a file or directory.
1062 >cancel jobid0 [jobid1] ... [jobidN]</DT
1065 >The client will request that the server cancel
1066 the printjobs identified by the given numeric print job ids.
1070 >chmod file mode in octal</DT
1073 >This command depends on the server supporting the CIFS
1074 UNIX extensions and will fail if the server does not. The client requests that the server
1075 change the UNIX permissions to the given octal mode, in standard UNIX format.
1079 >chown file uid gid</DT
1082 >This command depends on the server supporting the CIFS
1083 UNIX extensions and will fail if the server does not. The client requests that the server
1084 change the UNIX user and group ownership to the given decimal values. Note there is
1085 currently no way to remotely look up the UNIX uid and gid values for a given name.
1086 This may be addressed in future versions of the CIFS UNIX extensions.
1090 >cd [directory name]</DT
1093 >If "directory name" is specified, the current
1094 working directory on the server will be changed to the directory
1095 specified. This operation will fail if for any reason the specified
1096 directory is inaccessible. </P
1098 >If no directory name is specified, the current working
1099 directory on the server will be reported. </P
1102 >del <mask></DT
1105 >The client will request that the server attempt
1106 to delete all files matching <TT
1111 > from the current working
1112 directory on the server. </P
1115 >dir <mask></DT
1118 >A list of the files matching <TT
1124 working directory on the server will be retrieved from the server
1131 >Terminate the connection with the server and exit
1132 from the program. </P
1135 >get <remote file name> [local file name]</DT
1138 >Copy the file called <TT
1140 >remote file name</TT
1142 the server to the machine running the client. If specified, name
1145 >local file name</TT
1146 >. Note that all transfers in
1150 > are binary. See also the
1151 lowercase command. </P
1157 >See the ? command above. </P
1160 >lcd [directory name]</DT
1168 > is specified, the current
1169 working directory on the local machine will be changed to
1170 the directory specified. This operation will fail if for any
1171 reason the specified directory is inaccessible. </P
1173 >If no directory name is specified, the name of the
1174 current working directory on the local machine will be reported.
1178 >link source destination</DT
1181 >This command depends on the server supporting the CIFS
1182 UNIX extensions and will fail if the server does not. The client requests that the server
1183 create a hard link between the source and destination files. The source file
1191 >Toggle lowercasing of filenames for the get and
1194 >When lowercasing is toggled ON, local filenames are converted
1195 to lowercase when using the get and mget commands. This is
1196 often useful when copying (say) MSDOS files from a server, because
1197 lowercase filenames are the norm on UNIX systems. </P
1200 >ls <mask></DT
1203 >See the dir command above. </P
1206 >mask <mask></DT
1209 >This command allows the user to set up a mask
1210 which will be used during recursive operation of the mget and
1213 >The masks specified to the mget and mput commands act as
1214 filters for directories rather than files when recursion is
1217 >The mask specified with the mask command is necessary
1218 to filter files within those directories. For example, if the
1219 mask specified in an mget command is "source*" and the mask
1220 specified with the mask command is "*.c" and recursion is
1221 toggled ON, the mget command will retrieve all files matching
1222 "*.c" in all directories below and including all directories
1223 matching "source*" in the current working directory. </P
1225 >Note that the value for mask defaults to blank (equivalent
1226 to "*") and remains so until the mask command is used to change it.
1227 It retains the most recently specified value indefinitely. To
1228 avoid unexpected results it would be wise to change the value of
1229 mask back to "*" after using the mget or mput commands. </P
1232 >md <directory name></DT
1235 >See the mkdir command. </P
1238 >mget <mask></DT
1241 >Copy all files matching <TT
1246 > from the server to
1247 the machine running the client. </P
1254 > is interpreted differently during recursive
1255 operation and non-recursive operation - refer to the recurse and
1256 mask commands for more information. Note that all transfers in
1260 > are binary. See also the lowercase command. </P
1263 >mkdir <directory name></DT
1266 >Create a new directory on the server (user access
1267 privileges permitting) with the specified name. </P
1270 >mput <mask></DT
1273 >Copy all files matching <TT
1278 > in the current working
1279 directory on the local machine to the current working directory on
1287 > is interpreted differently during recursive
1288 operation and non-recursive operation - refer to the recurse and mask
1289 commands for more information. Note that all transfers in <B
1296 >print <file name></DT
1299 >Print the specified file from the local machine
1300 through a printable service on the server. </P
1302 >See also the printmode command.</P
1305 >printmode <graphics or text></DT
1308 >Set the print mode to suit either binary data
1309 (such as graphical information) or text. Subsequent print
1310 commands will use the currently set print mode. </P
1316 >Toggle prompting for filenames during operation
1317 of the mget and mput commands. </P
1319 >When toggled ON, the user will be prompted to confirm
1320 the transfer of each file during these commands. When toggled
1321 OFF, all specified files will be transferred without prompting.
1325 >put <local file name> [remote file name]</DT
1328 >Copy the file called <TT
1330 >local file name</TT
1332 machine running the client to the server. If specified,
1333 name the remote copy <TT
1335 >remote file name</TT
1336 >. Note that all transfers
1340 > are binary. See also the lowercase command.
1347 >Displays the print queue, showing the job id,
1348 name, size and current status. </P
1354 >See the exit command. </P
1357 >rd <directory name></DT
1360 >See the rmdir command. </P
1366 >Toggle directory recursion for the commands mget
1369 >When toggled ON, these commands will process all directories
1370 in the source directory (i.e., the directory they are copying
1371 from ) and will recurse into any that match the mask specified
1372 to the command. Only files that match the mask specified using
1373 the mask command will be retrieved. See also the mask command.
1376 >When recursion is toggled OFF, only files from the current
1377 working directory on the source machine that match the mask specified
1378 to the mget or mput commands will be copied, and any mask specified
1379 using the mask command will be ignored. </P
1382 >rm <mask></DT
1385 >Remove all files matching <TT
1391 working directory on the server. </P
1394 >rmdir <directory name></DT
1397 >Remove the specified directory (user access
1398 privileges permitting) from the server. </P
1401 >setmode <filename> <perm=[+|\-]rsha></DT
1404 >A version of the DOS attrib command to set
1405 file permissions. For example: </P
1409 >setmode myfile +r </B
1412 >would make myfile read only. </P
1415 >symlink source destination</DT
1418 >This command depends on the server supporting the CIFS
1419 UNIX extensions and will fail if the server does not. The client requests that the server
1420 create a symbolic hard link between the source and destination files. The source file
1421 must not exist. Note that the server will not create a link to any path that lies
1422 outside the currently connected share. This is enforced by the Samba server.
1426 >tar <c|x>[IXbgNa]</DT
1429 >Performs a tar operation - see the <TT
1435 > command line option above. Behavior may be affected
1436 by the tarmode command (see below). Using g (incremental) and N
1437 (newer) will affect tarmode settings. Note that using the "-" option
1438 with tar x may not work - use the command line option instead.
1442 >blocksize <blocksize></DT
1445 >Blocksize. Must be followed by a valid (greater
1446 than zero) blocksize. Causes tar file to be written out in
1452 >*TBLOCK (usually 512 byte) blocks. </P
1455 >tarmode <full|inc|reset|noreset></DT
1458 >Changes tar's behavior with regard to archive
1459 bits. In full mode, tar will back up everything regardless of the
1460 archive bit setting (this is the default mode). In incremental mode,
1461 tar will only back up files with the archive bit set. In reset mode,
1462 tar will reset the archive bit on all files it backs up (implies
1463 read/write share). </P
1476 >Some servers are fussy about the case of supplied usernames,
1477 passwords, share names (AKA service names) and machine names.
1478 If you fail to connect try giving all parameters in uppercase.
1481 >It is often necessary to use the -n option when connecting
1482 to some types of servers. For example OS/2 LanManager insists
1483 on a valid NetBIOS name being used, so you need to supply a valid
1484 name that would be known to the server.</P
1486 >smbclient supports long file names where the server
1487 supports the LANMAN2 protocol or above. </P
1495 >ENVIRONMENT VARIABLES</H2
1501 username of the person using the client. This information is
1502 used only if the protocol level is high enough to support
1503 session-level passwords.</P
1509 the password of the person using the client. This information is
1510 used only if the protocol level is high enough to support
1511 session-level passwords. </P
1517 the path, executed with system(), which the client should connect
1518 to instead of connecting to a server. This functionality is primarily
1519 intended as a development aid, and works best when using a LMHOSTS
1530 >The location of the client program is a matter for
1531 individual system administrators. The following are thus
1532 suggestions only. </P
1534 >It is recommended that the smbclient software be installed
1537 >/usr/local/samba/bin/</TT
1540 > /usr/samba/bin/</TT
1541 > directory, this directory readable
1542 by all, writeable only by root. The client program itself should
1543 be executable by all. The client should <EM
1546 setuid or setgid! </P
1548 >The client log files should be put in a directory readable
1549 and writeable only by the user. </P
1551 >To test the client, you will need to know the name of a
1552 running SMB/CIFS server. It is possible to run <B
1556 > as an ordinary user - running that server as a daemon
1557 on a user-accessible port (typically any port number over 1024)
1558 would provide a suitable test server. </P
1568 >Most diagnostics issued by the client are logged in a
1569 specified log file. The log file name is specified at compile time,
1570 but may be overridden on the command line. </P
1572 >The number and nature of diagnostics available depends
1573 on the debug level used by the client. If you have problems,
1574 set the debug level to 3 and peruse the log files. </P
1584 >This man page is correct for version 2.2 of
1595 >The original Samba software and related utilities
1596 were created by Andrew Tridgell. Samba is now developed
1597 by the Samba Team as an Open Source project similar
1598 to the way the Linux kernel is developed.</P
1600 >The original Samba man pages were written by Karl Auer.
1601 The man page sources were converted to YODL format (another
1602 excellent piece of Open Source software, available at
1604 HREF="ftp://ftp.icce.rug.nl/pub/unix/"
1606 > ftp://ftp.icce.rug.nl/pub/unix/</A
1607 >) and updated for the Samba 2.0
1608 release by Jeremy Allison. The conversion to DocBook for
1609 Samba 2.2 was done by Gerald Carter</P