1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.77"></HEAD
28 >smbclient -- ftp-like client to access SMB/CIFS resources
31 CLASS="REFSYNOPSISDIV"
41 > {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] [-O <socket options>] [-p port] [-R <name resolve order>] [-s <smb config file>] [-T<c|x>IXFqgbNan]</P
51 >This tool is part of the <A
60 > is a client that can
61 'talk' to an SMB/CIFS server. It offers an interface
62 similar to that of the ftp program (see <B
66 Operations include things like getting files from the server
67 to the local machine, putting files from the local machine to
68 the server, retrieving directory information from the server
87 >servicename is the name of the service
88 you want to use on the server. A service name takes the form
98 > is the NetBIOS name of the SMB/CIFS server
99 offering the desired service and <TT
105 is the name of the service offered. Thus to connect to
106 the service "printer" on the SMB/CIFS server "smbserver",
107 you would use the servicename <TT
113 >Note that the server name required is NOT necessarily
114 the IP (DNS) host name of the server ! The name required is
115 a NetBIOS server name, which may or may not be the
116 same as the IP hostname of the machine running the server.
119 >The server name is looked up according to either
129 using the name resolve order parameter in the <TT
133 allowing an administrator to change the order and methods
134 by which server names are looked up. </P
140 >The password required to access the specified
141 service on the specified server. If this parameter is
148 password prompt) is assumed. </P
150 >There is no default password. If no password is supplied
151 on the command line (either by using this parameter or adding
152 a password to the <TT
164 specified, the client will prompt for a password, even if
165 the desired service does not require one. (If no password is
166 required, simply press ENTER to provide a null password.)
169 >Note: Some servers (including OS/2 and Windows for
170 Workgroups) insist on an uppercase password. Lowercase
171 or mixed case passwords may be rejected by these servers.
174 >Be cautious about including passwords in scripts.
181 >Specifies the location of the all important
188 >-O socket options</DT
191 >TCP socket options to set on the client
192 socket. See the socket options parameter in the <TT
195 > manpage for the list of valid
199 >-R <name resolve order></DT
202 >This option is used by the programs in the Samba
203 suite to determine what naming services and in what order to resolve
204 host names to IP addresses. The option takes a space-separated
205 string of different name resolution options.</P
207 >The options are :"lmhosts", "host", "wins" and "bcast". They
208 cause names to be resolved as follows :</P
218 address in the Samba lmhosts file. If the line in lmhosts has
219 no name type attached to the NetBIOS name (see the <A
220 HREF="lmhosts.5.html"
224 any name type matches for lookup.</P
231 > : Do a standard host
232 name to IP address resolution, using the system <TT
236 >, NIS, or DNS lookups. This method of name resolution
237 is operating system dependent, for instance on IRIX or Solaris this
238 may be controlled by the <TT
240 >/etc/nsswitch.conf</TT
242 file). Note that this method is only used if the NetBIOS name
243 type being queried is the 0x20 (server) name type, otherwise
251 > : Query a name with
252 the IP address listed in the <TT
258 parameter. If no WINS server has
259 been specified this method will be ignored.</P
266 > : Do a broadcast on
267 each of the known local interfaces listed in the
274 parameter. This is the least reliable of the name resolution
275 methods as it depends on the target host being on a locally
280 >If this parameter is not set then the name resolve order
285 (name resolve order) will be used. </P
287 >The default order is lmhosts, host, wins, bcast and without
288 this parameter or any entry in the <TT
294 > parameter of the <TT
297 > file the name resolution
298 methods will be attempted in this order. </P
304 >This options allows you to send messages, using
305 the "WinPopup" protocol, to another computer. Once a connection is
306 established you then type your message, pressing ^D (control-D) to
309 >If the receiving computer is running WinPopup the user will
310 receive the message and probably a beep. If they are not running
311 WinPopup the message will be lost, and no error message will
314 >The message is also automatically truncated if the message
315 is over 1600 bytes, as this is the limit of the protocol.
318 >One useful trick is to cat the message through
324 > cat mymessage.txt | smbclient -M FRED </B
326 send the message in the file <TT
330 to the machine FRED. </P
332 >You may also find the <TT
343 > options useful, as they allow you to
344 control the FROM and TO parts of the message. </P
346 >See the message command parameter in the <TT
349 > for a description of how to handle incoming
350 WinPopup messages in Samba. </P
358 >: Copy WinPopup into the startup group
359 on your WfWg PCs if you want them to always be able to receive
366 >This specifies a NetBIOS scope that smbclient will
367 use to communicate with when generating NetBIOS names. For details
368 on the use of NetBIOS scopes, see <TT
376 NetBIOS scopes are <SPAN
382 > rarely used, only set
383 this parameter if you are the system administrator in charge of all
384 the NetBIOS systems you communicate with. </P
390 >If specified, this parameter suppresses the normal
391 password prompt from the client to the user. This is useful when
392 accessing a service that does not require a password. </P
394 >Unless a password is specified on the command line or
395 this parameter is specified, the client will request a
402 >By default, the client will use the local
403 machine's hostname (in uppercase) as its NetBIOS name. This parameter
404 allows you to override the host name and use whatever NetBIOS
416 > is an integer from 0 to 10, or
419 >The default value if this parameter is not specified
422 >The higher this value, the more detail will be logged to
423 the log files about the activities of the
424 client. At level 0, only critical errors and serious warnings will
425 be logged. Level 1 is a reasonable level for day to day running -
426 it generates a small amount of information about operations
429 >Levels above 1 will generate considerable amounts of log
430 data, and should only be used when investigating a problem.
431 Levels above 3 are designed for use only by developers and
432 generate HUGE amounts of log data, most of which is extremely
438 > is set to the letter 'A', then <SPAN
445 > debug messages will be printed. This setting
446 is for developers only (and people who <SPAN
453 to know how the code works internally). </P
455 >Note that specifying this parameter here will override
456 the log level parameter in the <TT
466 >This number is the TCP port number that will be used
467 when making connections to the server. The standard (well-known)
468 TCP port number for an SMB/CIFS server is 139, which is the
480 > specifies a base filename
481 into which operational data from the running client will be
484 >The default base name is specified at compile time.</P
486 >The base name is used to generate actual log file names.
487 For example, if the name specified was "log", the debug file
493 >The log file generated is never removed by the client.
500 >Print the usage message for the client. </P
511 > is the address of the server to connect to.
512 It should be specified in standard "a.b.c.d" notation. </P
514 >Normally the client would attempt to locate a named
515 SMB/CIFS server by looking it up via the NetBIOS name resolution
516 mechanism described above in the <TT
519 >name resolve order</I
522 parameter above. Using this parameter will force the client
523 to assume that the server is on the machine with the specified IP
524 address and the NetBIOS name component of the resource being
525 connected to will be ignored. </P
527 >There is no default for this parameter. If not supplied,
528 it will be determined automatically by the client as described
535 >This parameter causes the client to write messages
536 to the standard error stream (stderr) rather than to the standard
539 >By default, the client writes messages to standard output
540 - typically the user's tty. </P
543 >-U username[%pass]</DT
546 >Sets the SMB username or username and password.
547 If %pass is not specified, The user will be prompted. The client
548 will first check the <TT
551 > environment variable, then the
555 > variable and if either exists, the
556 string is uppercased. Anything in these variables following a '%'
557 sign will be treated as the password. If these environment
558 variables are not found, the username <TT
564 >If the password is not included in these environment
565 variables (using the %pass syntax), <B
572 > environment variable from which
573 to read the password. </P
575 >A third option is to use a credentials file which
576 contains the plaintext of the domain name, username and password. This
577 option is mainly provided for scripts where the admin doesn't
578 wish to pass the credentials on the command line or via environment
579 variables. If this method is used, make certain that the permissions
580 on the file restrict access from unwanted users. See the
586 > for more details. </P
588 >Be cautious about including passwords in scripts or in
592 > environment variable. Also, on
593 many systems the command line of a running process may be seen
597 > command to be safe always allow
601 > to prompt for a password and type
609 you to specify a file from which to read the username, domain name, and
610 password used in the connection. The format of the file is
614 CLASS="PROGRAMLISTING"
615 >username = <value>
616 password = <value>
617 domain = <value>
621 >If the domain parameter is missing the current workgroup name
622 is used instead. Make certain that the permissions on the file restrict
623 access from unwanted users. </P
629 >This option allows you to look at what services
630 are available on a server. You use it as <B
634 > and a list should appear. The <TT
640 > option may be useful if your NetBIOS names don't
641 match your TCP/IP DNS host names or if you are trying to reach a
642 host on another network. </P
645 >-t terminal code</DT
648 >This option tells <B
652 filenames coming from the remote server. Usually Asian language
653 multibyte UNIX implementations use different character sets than
654 SMB/CIFS servers (<SPAN
666 > for example). Setting this parameter will let
670 > convert between the UNIX filenames and
671 the SMB filenames correctly. This option has not been seriously tested
672 and may have some problems. </P
674 >The terminal codes include CWsjis, CWeuc, CWjis7, CWjis8,
675 CWjunet, CWhex, CWcap. This is not a complete list, check the Samba
676 source code for the complete list. </P
682 >This option changes the transmit/send buffer
683 size when getting or putting a file from/to the server. The default
684 is 65520 bytes. Setting this value smaller (to 1200 bytes) has been
685 observed to speed up file transfers to and from a Win9x server.
692 >Override the default workgroup (domain) specified
693 in the workgroup parameter of the <TT
697 file for this connection. This may be needed to connect to some
704 >smbclient may be used to create <B
708 > compatible backups of all the files on an SMB/CIFS
709 share. The secondary tar flags that can be given to this option
721 > - Create a tar file on UNIX.
722 Must be followed by the name of a tar file, tape device
723 or "-" for standard output. If using standard output you must
724 turn the log level to its lowest value -d0 to avoid corrupting
725 your tar file. This flag is mutually exclusive with the
740 > - Extract (restore) a local
741 tar file back to a share. Unless the -D option is given, the tar
742 files will be restored from the top level of the share. Must be
743 followed by the name of the tar file, device or "-" for standard
744 input. Mutually exclusive with the <TT
750 Restored files have their creation times (mtime) set to the
751 date saved in the tar file. Directories currently do not get
752 their creation dates restored properly. </P
761 > - Include files and directories.
762 Is the default behavior when filenames are specified above. Causes
763 tar files to be included in an extract or create (and therefore
764 everything else to be excluded). See example below. Filename globbing
765 works in one of two ways. See r below. </P
774 > - Exclude files and directories.
775 Causes tar files to be excluded from an extract or create. See
776 example below. Filename globbing works in one of two ways now.
791 > - Blocksize. Must be followed
792 by a valid (greater than zero) blocksize. Causes tar file to be
793 written out in blocksize*TBLOCK (usually 512 byte) blocks.
803 > - Incremental. Only back up
804 files that have the archive bit set. Useful only with the
819 > - Quiet. Keeps tar from printing
820 diagnostics as it works. This is the same as tarmode quiet.
830 > - Regular expression include
831 or exclude. Uses regular expression matching for
832 excluding or excluding files if compiled with HAVE_REGEX_H.
833 However this mode can be very slow. If not compiled with
834 HAVE_REGEX_H, does a limited wildcard match on '*' and '?'.
844 > - Newer than. Must be followed
845 by the name of a file whose date is compared against files found
846 on the share during a create. Only files newer than the file
847 specified are backed up to the tar file. Useful only with the
862 > - Set archive bit. Causes the
863 archive bit to be reset when a file is backed up. Useful with the
883 >Tar Long File Names</I
890 >'s tar option now supports long
891 file names both on backup and restore. However, the full path
892 name of the file must be less than 1024 bytes. Also, when
893 a tar archive is created, <B
896 >'s tar option places all
897 files in the archive with relative names, not absolute names.
908 >All file names can be given as DOS path names (with '\'
909 as the component separator) or as UNIX path names (with '/' as
910 the component separator). </P
920 >Restore from tar file <TT
923 > into myshare on mypc
924 (no password on share). </P
928 >smbclient //mypc/yshare "" -N -Tx backup.tar
932 >Restore everything except <TT
940 >smbclient //mypc/myshare "" -N -TXx backup.tar
944 >Create a tar file of the files beneath <TT
951 >smbclient //mypc/myshare "" -N -Tc
952 backup.tar users/docs </B
955 >Create the same tar file as above, but now use
960 >smbclient //mypc/myshare "" -N -tc backup.tar
964 >Create a tar file of all the files and directories in
969 >smbclient //mypc/myshare "" -N -Tc backup.tar *
974 >-D initial directory</DT
977 >Change to initial directory before starting. Probably
978 only of any use with the tar -T option. </P
981 >-c command string</DT
984 >command string is a semicolon-separated list of
985 commands to be executed instead of prompting from stdin. <TT
997 >This is particularly useful in scripts and for printing stdin
998 to the server, e.g. <B
1014 >Once the client is running, the user is presented with
1022 >The backslash ("\") indicates the current working directory
1023 on the server, and will change if the current working directory
1026 >The prompt indicates that the client is ready and waiting to
1027 carry out a user command. Each command is a single word, optionally
1028 followed by parameters specific to that command. Command and parameters
1029 are space-delimited unless these notes specifically
1030 state otherwise. All commands are case-insensitive. Parameters to
1031 commands may or may not be case sensitive, depending on the command.
1034 >You can specify file names which have spaces in them by quoting
1035 the name with double quotes, for example "a long file name". </P
1037 >Parameters shown in square brackets (e.g., "[parameter]") are
1038 optional. If not given, the command will use suitable defaults. Parameters
1039 shown in angle brackets (e.g., "<parameter>") are required.
1042 >Note that all commands operating on the server are actually
1043 performed by issuing a request to the server. Thus the behavior may
1044 vary from server to server, depending on how the server was implemented.
1047 >The commands available are given here in alphabetical order. </P
1051 CLASS="VARIABLELIST"
1062 > is specified, the ? command will display
1063 a brief informative message about the specified command. If no
1064 command is specified, a list of available commands will
1068 >! [shell command]</DT
1076 > is specified, the !
1077 command will execute a shell locally and run the specified shell
1078 command. If no command is specified, a local shell will be run.
1085 >The client will request that the server return
1086 the "alternate" name (the 8.3 name) for a file or directory.
1090 >cancel jobid0 [jobid1] ... [jobidN]</DT
1093 >The client will request that the server cancel
1094 the printjobs identified by the given numeric print job ids.
1098 >chmod file mode in octal</DT
1101 >This command depends on the server supporting the CIFS
1102 UNIX extensions and will fail if the server does not. The client requests that the server
1103 change the UNIX permissions to the given octal mode, in standard UNIX format.
1107 >chown file uid gid</DT
1110 >This command depends on the server supporting the CIFS
1111 UNIX extensions and will fail if the server does not. The client requests that the server
1112 change the UNIX user and group ownership to the given decimal values. Note there is
1113 currently no way to remotely look up the UNIX uid and gid values for a given name.
1114 This may be addressed in future versions of the CIFS UNIX extensions.
1118 >cd [directory name]</DT
1121 >If "directory name" is specified, the current
1122 working directory on the server will be changed to the directory
1123 specified. This operation will fail if for any reason the specified
1124 directory is inaccessible. </P
1126 >If no directory name is specified, the current working
1127 directory on the server will be reported. </P
1130 >del <mask></DT
1133 >The client will request that the server attempt
1134 to delete all files matching <TT
1139 > from the current working
1140 directory on the server. </P
1143 >dir <mask></DT
1146 >A list of the files matching <TT
1152 working directory on the server will be retrieved from the server
1159 >Terminate the connection with the server and exit
1160 from the program. </P
1163 >get <remote file name> [local file name]</DT
1166 >Copy the file called <TT
1168 >remote file name</TT
1170 the server to the machine running the client. If specified, name
1173 >local file name</TT
1174 >. Note that all transfers in
1178 > are binary. See also the
1179 lowercase command. </P
1185 >See the ? command above. </P
1188 >lcd [directory name]</DT
1196 > is specified, the current
1197 working directory on the local machine will be changed to
1198 the directory specified. This operation will fail if for any
1199 reason the specified directory is inaccessible. </P
1201 >If no directory name is specified, the name of the
1202 current working directory on the local machine will be reported.
1206 >link source destination</DT
1209 >This command depends on the server supporting the CIFS
1210 UNIX extensions and will fail if the server does not. The client requests that the server
1211 create a hard link between the source and destination files. The source file
1219 >Toggle lowercasing of filenames for the get and
1222 >When lowercasing is toggled ON, local filenames are converted
1223 to lowercase when using the get and mget commands. This is
1224 often useful when copying (say) MSDOS files from a server, because
1225 lowercase filenames are the norm on UNIX systems. </P
1228 >ls <mask></DT
1231 >See the dir command above. </P
1234 >mask <mask></DT
1237 >This command allows the user to set up a mask
1238 which will be used during recursive operation of the mget and
1241 >The masks specified to the mget and mput commands act as
1242 filters for directories rather than files when recursion is
1245 >The mask specified with the mask command is necessary
1246 to filter files within those directories. For example, if the
1247 mask specified in an mget command is "source*" and the mask
1248 specified with the mask command is "*.c" and recursion is
1249 toggled ON, the mget command will retrieve all files matching
1250 "*.c" in all directories below and including all directories
1251 matching "source*" in the current working directory. </P
1253 >Note that the value for mask defaults to blank (equivalent
1254 to "*") and remains so until the mask command is used to change it.
1255 It retains the most recently specified value indefinitely. To
1256 avoid unexpected results it would be wise to change the value of
1257 mask back to "*" after using the mget or mput commands. </P
1260 >md <directory name></DT
1263 >See the mkdir command. </P
1266 >mget <mask></DT
1269 >Copy all files matching <TT
1274 > from the server to
1275 the machine running the client. </P
1282 > is interpreted differently during recursive
1283 operation and non-recursive operation - refer to the recurse and
1284 mask commands for more information. Note that all transfers in
1288 > are binary. See also the lowercase command. </P
1291 >mkdir <directory name></DT
1294 >Create a new directory on the server (user access
1295 privileges permitting) with the specified name. </P
1298 >mput <mask></DT
1301 >Copy all files matching <TT
1306 > in the current working
1307 directory on the local machine to the current working directory on
1315 > is interpreted differently during recursive
1316 operation and non-recursive operation - refer to the recurse and mask
1317 commands for more information. Note that all transfers in <B
1324 >print <file name></DT
1327 >Print the specified file from the local machine
1328 through a printable service on the server. </P
1330 >See also the printmode command.</P
1333 >printmode <graphics or text></DT
1336 >Set the print mode to suit either binary data
1337 (such as graphical information) or text. Subsequent print
1338 commands will use the currently set print mode. </P
1344 >Toggle prompting for filenames during operation
1345 of the mget and mput commands. </P
1347 >When toggled ON, the user will be prompted to confirm
1348 the transfer of each file during these commands. When toggled
1349 OFF, all specified files will be transferred without prompting.
1353 >put <local file name> [remote file name]</DT
1356 >Copy the file called <TT
1358 >local file name</TT
1360 machine running the client to the server. If specified,
1361 name the remote copy <TT
1363 >remote file name</TT
1364 >. Note that all transfers
1368 > are binary. See also the lowercase command.
1375 >Displays the print queue, showing the job id,
1376 name, size and current status. </P
1382 >See the exit command. </P
1385 >rd <directory name></DT
1388 >See the rmdir command. </P
1394 >Toggle directory recursion for the commands mget
1397 >When toggled ON, these commands will process all directories
1398 in the source directory (i.e., the directory they are copying
1399 from ) and will recurse into any that match the mask specified
1400 to the command. Only files that match the mask specified using
1401 the mask command will be retrieved. See also the mask command.
1404 >When recursion is toggled OFF, only files from the current
1405 working directory on the source machine that match the mask specified
1406 to the mget or mput commands will be copied, and any mask specified
1407 using the mask command will be ignored. </P
1410 >rm <mask></DT
1413 >Remove all files matching <TT
1419 working directory on the server. </P
1422 >rmdir <directory name></DT
1425 >Remove the specified directory (user access
1426 privileges permitting) from the server. </P
1429 >setmode <filename> <perm=[+|\-]rsha></DT
1432 >A version of the DOS attrib command to set
1433 file permissions. For example: </P
1437 >setmode myfile +r </B
1440 >would make myfile read only. </P
1443 >symlink source destination</DT
1446 >This command depends on the server supporting the CIFS
1447 UNIX extensions and will fail if the server does not. The client requests that the server
1448 create a symbolic hard link between the source and destination files. The source file
1449 must not exist. Note that the server will not create a link to any path that lies
1450 outside the currently connected share. This is enforced by the Samba server.
1454 >tar <c|x>[IXbgNa]</DT
1457 >Performs a tar operation - see the <TT
1463 > command line option above. Behavior may be affected
1464 by the tarmode command (see below). Using g (incremental) and N
1465 (newer) will affect tarmode settings. Note that using the "-" option
1466 with tar x may not work - use the command line option instead.
1470 >blocksize <blocksize></DT
1473 >Blocksize. Must be followed by a valid (greater
1474 than zero) blocksize. Causes tar file to be written out in
1480 >*TBLOCK (usually 512 byte) blocks. </P
1483 >tarmode <full|inc|reset|noreset></DT
1486 >Changes tar's behavior with regard to archive
1487 bits. In full mode, tar will back up everything regardless of the
1488 archive bit setting (this is the default mode). In incremental mode,
1489 tar will only back up files with the archive bit set. In reset mode,
1490 tar will reset the archive bit on all files it backs up (implies
1491 read/write share). </P
1504 >Some servers are fussy about the case of supplied usernames,
1505 passwords, share names (AKA service names) and machine names.
1506 If you fail to connect try giving all parameters in uppercase.
1509 >It is often necessary to use the -n option when connecting
1510 to some types of servers. For example OS/2 LanManager insists
1511 on a valid NetBIOS name being used, so you need to supply a valid
1512 name that would be known to the server.</P
1514 >smbclient supports long file names where the server
1515 supports the LANMAN2 protocol or above. </P
1523 >ENVIRONMENT VARIABLES</H2
1529 username of the person using the client. This information is
1530 used only if the protocol level is high enough to support
1531 session-level passwords.</P
1537 the password of the person using the client. This information is
1538 used only if the protocol level is high enough to support
1539 session-level passwords. </P
1545 the path, executed with system(), which the client should connect
1546 to instead of connecting to a server. This functionality is primarily
1547 intended as a development aid, and works best when using a LMHOSTS
1558 >The location of the client program is a matter for
1559 individual system administrators. The following are thus
1560 suggestions only. </P
1562 >It is recommended that the smbclient software be installed
1565 >/usr/local/samba/bin/</TT
1568 > /usr/samba/bin/</TT
1569 > directory, this directory readable
1570 by all, writeable only by root. The client program itself should
1571 be executable by all. The client should <SPAN
1578 setuid or setgid! </P
1580 >The client log files should be put in a directory readable
1581 and writeable only by the user. </P
1583 >To test the client, you will need to know the name of a
1584 running SMB/CIFS server. It is possible to run <B
1588 > as an ordinary user - running that server as a daemon
1589 on a user-accessible port (typically any port number over 1024)
1590 would provide a suitable test server. </P
1600 >Most diagnostics issued by the client are logged in a
1601 specified log file. The log file name is specified at compile time,
1602 but may be overridden on the command line. </P
1604 >The number and nature of diagnostics available depends
1605 on the debug level used by the client. If you have problems,
1606 set the debug level to 3 and peruse the log files. </P
1616 >This man page is correct for version 2.2 of
1627 >The original Samba software and related utilities
1628 were created by Andrew Tridgell. Samba is now developed
1629 by the Samba Team as an Open Source project similar
1630 to the way the Linux kernel is developed.</P
1632 >The original Samba man pages were written by Karl Auer.
1633 The man page sources were converted to YODL format (another
1634 excellent piece of Open Source software, available at
1636 HREF="ftp://ftp.icce.rug.nl/pub/unix/"
1638 > ftp://ftp.icce.rug.nl/pub/unix/</A
1639 >) and updated for the Samba 2.0
1640 release by Jeremy Allison. The conversion to DocBook for
1641 Samba 2.2 was done by Gerald Carter</P