On Unix-like operating systems, the smbclient command launches an ftp-like client to access SMB/CIFS resources on servers.

Description

smbclient is a client that is part of the Samba software suite. It communicates with a LAN Manager server, offering an interface similar to that of the ftp program. 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.

  • Description
  • Syntax
  • Examples
  • Related commands
  • Linux commands help

Syntax

smbclient servicename [ password ] [ -A ] [ -E ] [ -L host ] [ -M host ] [ -I IP number ] [ -N ] [ -P ] [ -U username ] [ -d debuglevel ] [ -l log basename ] [ -n netbios name ] [ -W workgroup ] [ -O socket options ] [ -p port number ] [ -c command string ] [ -T tar options ] [ -D initial directory ]

Options

Operations

Once the client is running, the user is presented with a prompt, “smb: >”. The backslash ("") indicates the current working directory on the server, and changes if the current working directory is changed.

smbclient -L ftp -I ftp.microsoft.com

smbclient ‘\server\share’ -TcxIXbgNa [ blocksize ] [ newer-file ] tarfile [ file names…. ]

smbclient ‘\mypc\myshare’ "" -N -Tx backup.tar

smbclient ‘\mypc\myshare’ "" -N -TXx backup.tar users/docs

smbclient ‘\mypc\myshare’ "" -N -Tc backup.tar users/docs

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 (eg., “[parameter]”) are optional. If not given, the command uses suitable defaults. Parameters shown in angle brackets (eg., “”) are required.

Note that 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.

Notes

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.

setmode myfile +r

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.

Environment Variables

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.

Examples

smbclient -L host

Lists available shares on host. Using this command would display information similar to the below output:

Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51] Server=[HOPE] User=[] Workgroup=[WORKGROUP] Domain=[] Sharename type Comment


ADMIN$ Disk Remote Admin C$ Disk Default share IPC$ IPC Remote IPC

smbclient ‘\hope\ch’ password

Connects to the ch share on the networked computer hope using the login password “password”.

findsmb — List information about machines networked with the Samba protocol.