smbclient |
The smbclient program is the "Swiss army knife " of the Samba suite. Initially developed as a testing tool, it has become a command shell capable of acting as a general-purpose Unix client, with a command set very similar to that of ftp . It offers the following set of functions:
Interactive file transfer, similar to ftp
Interactive printing to shared SMB printers
Interactive tar format archiving
Sending messages on the SMB network
Batch mode tar format archiving
"What services do you have?" querying
Debugging
smbclient // server / share [ password] [options]
It is possible to run smbclient noninteractively, for use in scripts, by specifying the -c option along with a list of commands to execute. Otherwise, smbclient runs in interactive mode, prompting for commands such as this:
smb:\>
The backslash in the prompt is replaced by the current directory within the share as you change your working directory with smbclient 's cd command.
Specifies a file from which to read the username and password used for the connection. The format of the file is as follows :
username = value password = value domain = value
This is to avoid having the password prompted for or have it appear in plain text in scripts. The permissions on the file should be very restrictive (0600, for example) to prevent access by unwanted users.
Sets the size of the buffer used when transferring files. It defaults to 65520 bytes and can be changed as a tuning measure. Generally it should be quite large or set to match the size of the buffer on the remote system. It can be set smaller to work around Windows bugs : some Windows 98 systems work best with a buffer size of 1200.
Sets the broadcast address.
Passes a command string to the smbclient command interpreter. The argument consists of a semicolon-separated list of commands to be executed.
Sets the debug (logging) level, from 0 to 10, with A for all. Overrides the value in smb.conf . Debug level 0 logs only the most important messages; level 1 is normal; debug levels 3 and above are for debugging and slow smbclient considerably.
Upon starting up, causes smbclient to change its working directory to init_dir on the remote host.
Sends output from commands to stderr instead of stdout .
Prints the command-line help information (usage) for smbclient .
Sets the IP address of the server to which the client connects.
Sets a NetBIOS scope identifier.
Sends the log messages to log_file rather than to the log file specified in the Samba configuration file or the compiled-in default.
Lists services (shares) offered by the server. This can be used as a quick way to test an SMB server to see if it is working. If there is a name -service problem, use the -I option to specify the server.
Allows you to send messages using the Windows messaging protocol. Once a connection is established, you can type your message, pressing Ctrl-D to end. The -U and -I options can be used to control the "From" and "To" parts of the message.
Suppresses the password prompt. Useful when using share mode security and accessing a service that has no password.
Allows you to override the NetBIOS name by which smbclient will advertise itself.
Sets the TCP/IP socket options using the same parameters as the socket options configuration option. Often used for performance tuning and testing.
Sets the port number with which smbclient will connect.
Sets the resolve order of the name servers. This option is similar to the resolve order configuration option and can take any of the four parameters lmhosts , host , wins , and bcast , in any order. If more than one is specified, the argument is specified as a space-separated list. This option can be used to test name service by specifying only the name service to be tested .
Specifies the location of the Samba configuration file. Used for debugging.
Sets the terminal code for Asian languages.
Runs the tar archiver, which is gtar compatible. The tar file that is written to or read from is specified by tarfile . The two main commands are c (create) and x (extract), which can be followed by any of these:
Resets the archive attribute on files after they have been saved. See also the g option.
Sets the block size for writing the tar file, in 512-byte units.
Backs up only files that have their archive bit set. See also the a option.
Includes files and directories. This is the default, so specifying this is redundant. To perform pattern matching, see also the r option.
Backs up only those files newer than file .
Suppresses diagnostics.
Performs regular expression matching, which can be used along with the I or E option to include or exclude files.
Excludes files and directories.
Sets the username and, optionally , the password used for authentication when connecting to the share.
Specifies the workgroup/domain in which smbclient will claim to be a member.
With no command specified, prints a list of available commands. If a command is specified as an argument, a brief help message will be printed for it.
Shell escape. With no command specified, runs a Unix shell. If a command is specified, runs the command in a Unix shell.
Causes smbclient to request from the server and then print the old-style, 8.3-format filename for the specified file.
Causes smbclient to request the server to cancel one or more print jobs, as specified by the numeric job IDs provided as arguments. See also the queue command, which prints job IDs.
Requests that the server change the Unix file permissions on filename to octal_mode , specified in octal numeric format. Works only if the server supports Unix CIFS extensions.
Requests that the server change the owner and group of the file specified by filename to those provided as decimal numeric arguments UID and GID . Works only if the server supports Unix CIFS extensions.
With no argument, prints the current working directory on the remote system. If a directory name is supplied as an argument, changes the working directory on the remote system to that specified.
Requests that the server delete one or more files, as specified by the argument, from the current working directory. The argument can be a filename globbing pattern using the * and ? characters .
With no arguments, prints a list of files and directories in the working directory on the server. If an argument is provided, only files and directories whose names match the argument will be listed. The argument can be a filename globbing pattern using the * and ? characters.
Quits the smbclient program after terminating the SMB connection to the server.
Copies the file specified by remote_file from the server to the local system. If no local_file argument is specified, smbclient will name the local file the same as it is named on the server. If local_file is specified, it will be used as the name of the local copy. See also the lowercase command.
A synonym for the ? command.
If no argument is provided, prints the name of smbclient 's working directory on the local system. If a directory name is provided as an argument, changes smbclient 's working directory to the directory specified.
Requests that the server create a hard link to filename and name it link_name . This command works only if the server supports Unix CIFS extensions.
Toggles the boolean lowercasing setting. When this setting is on, names of files copied from the server with the get and mget commands will be changed to all lowercase. This is mainly used for accessing servers that report filenames in all uppercase only.
A synonym for dir .
Sets the filename globbing pattern for use with the mget and mput commands when recursion is turned on. (When recursion is off, the setting has no effect.) Both mget and mput accept a globbing pattern as arguments; however, those patterns apply only to the current directory. This command specifies the pattern used for all subdirectories that are recursively traversed. The pattern stays in effect until it is changed with another mask command. To return the setting to its original default, specify a globbing_pattern of an asterisk ( * ), which matches all files. See also the mget , mput , and recurse commands.
A synonym for the mkdir command.
When recursion is turned off, copies files matching the file-globbing pattern, as specified by the argument, from the current working directory on the server to the local system. When recursion is on, the pattern argument is used to match directories in the current working directory, and the pattern specified by the mask command is used for matching files within each directory and all subdirectories. See also the lowercase , mask , and recurse commands.
Prints the specified file. This requires that smbclient be connected to a print share. See also the printmode command.
Sets the mode that is used by the print command. The mode can be either text , for printing text files such as the ASCII files commonly found on Unix, or graphics , for printing binary files.
Toggles the prompting mode. When prompting is on (the default), the mget and mput commands will interactively prompt the user for permission to transfer each file. The user can answer either y (yes) or n (no), followed by a newline, to this prompt. When prompting is off, all the files will be transferred with no prompts issued.
Copies the file specified by local_file from the local to the remote system. If no remote_file argument is specified, smbclient will name the remote file the same as it is named on the local system. If remote_file is specified, it will be used as the name of the remote copy. See also the lowercase command.
Prints information on the print queue on the server. This requires that smbclient is connected to a print share.
A synonym for exit .
A synonym for rmdir .
Toggles the recursion mode, which affects the mget and mput commands. When recursion is off (the default), the mget and mput commands will copy only files from the current working directory that match the file-globbing pattern specified as an argument to the command, and the pattern set by the mask command is ignored. When recursion is turned on, the mget and mput commands recursively traverse any directories that match the pattern specified as the argument to the command, and the pattern set by the mask command is used to match files in those directories.
A synonym for del .
Requests that the server remove the specified directory.
Requests that the server assign the specified MS-DOS file attributes on the specified file. The attributes argument has the format of a leading plus sign ( + ) or minus sign ( - ) either to set or to unset the attribute(s), respectively, followed by one or more of the characters r (read), s (system), h (hidden), or a (archive).
Requests that the server create a symbolic link named link_name to filename . This command works only if the server supports Unix CIFS extensions. The server will not create a link that refers to a file not in the share to which smbclient is connected.
Performs an archiving operation using the tar format. This is the interactive form of the -T command-line operation, and the cmd_str argument is specified in the same manner. See also the tarmode command.
Sets the block size, in units of 512 bytes, for files written by the tar command.
Specifies how the tar command performs its archiving, including how it handles the archive attribute on files. Multiple mode arguments can be provided, chosen from the following:
All files will be included, regardless of whether their archive attribute is set. This is the default.
Only files that have the archive attribute set will be included in the backup.
The archive attribute will be unset by tar after the file is included in the archive.
The archive attribute will be left unchanged. This is the default.
Files with the system attribute set will be included in the archive. This is the default.
Files with the system attribute set will not be included in the archive.
Files with the hidden attribute set will be included in the archive. This is the default.
Files with the hidden attribute set will not be included in the archive.
As files are included in the archive (when creating the archive) or are read from the archive (when extracting it), the name of each file will be printed. This is the default.
This turns verbose mode off, causing tar to perform its work quietly .
An antonym for the verbose mode. When quiet is on, verbose is off, and vice versa.