LinuxCommandLibrary

smbclient

TLDR

Connect to a share

$ smbclient //[server]/[share]
copy
Connect with username
$ smbclient //[server]/[share] --user [username]
copy
Connect with workgroup and username
$ smbclient //[server]/[share] --workgroup [domain] --user [username]
copy
Connect with username and password
$ smbclient //[server]/[share] --user [username%password]
copy
Download a file
$ smbclient //[server]/[share] --directory [path] --command "get [file.txt]"
copy
Upload a file
$ smbclient //[server]/[share] --directory [path] --command "put [file.txt]"
copy
List shares anonymously
$ smbclient --list=[server] --no-pass
copy

SYNOPSIS

smbclient //server/share [OPTIONS]

DESCRIPTION

smbclient is an FTP-like client for accessing SMB/CIFS network shares. It connects to Windows file servers and Samba shares, enabling file transfers, directory operations, and share browsing from the command line.
The tool supports interactive sessions with FTP-style commands or batch operations via -c flag. It can create tar backups of shares and browse available network resources.

PARAMETERS

-U, --user username[%password]

Specify username and optional password
-W, --workgroup domain
Set SMB workgroup/domain
-N, --no-pass
Suppress password prompt for anonymous access
-L, --list host
List available shares on server
-D, --directory path
Change to initial directory on connection
-c, --command commands
Execute semicolon-separated commands
-I, --ip-address ip
Specify server IP directly
-p, --port port
TCP port (default: 139 or 445)
-m, --max-protocol level
Maximum SMB protocol (NT1, SMB2, SMB3)
-A, --authentication-file file
Read credentials from file
-T, --tar options
Tar backup mode with flags
-d, --debuglevel level
Debug verbosity (0-10)
-n, --netbiosname name
Override client NetBIOS name

INTERACTIVE COMMANDS

get remote [local]

Download file from share
put local [remote]
Upload file to share
ls [pattern]
List directory contents
cd directory
Change remote directory
lcd directory
Change local directory
mkdir directory
Create remote directory
rm file
Delete remote file
exit
Close connection

CAVEATS

Password on command line is visible in process listings; use -A for credentials file. Some features require specific SMB protocol versions. Firewall rules may block SMB ports (139, 445). NTLM authentication is being deprecated in favor of Kerberos.

HISTORY

smbclient is part of Samba, created by Andrew Tridgell in 1992 after reverse-engineering the SMB protocol. Samba has evolved to support modern SMB2 and SMB3 protocols. The tool remains essential for cross-platform file sharing and accessing Windows shares from Linux.

SEE ALSO

Copied to clipboard