SMBClient Cheat Sheet

smbclient is a command-line utility for interacting with Samba (SMB/CIFS) servers. This cheat sheet provides a quick reference for common tasks.

Basic Usage

The fundamental smbclient command follows this structure:

smbclient //<server_ip_or_hostname>/<share_name> [options]
  • <server_ip_or_hostname>: The IP address or hostname of the Samba server.

  • <share_name>: The name of the shared folder on the server.

  • [options]: Various options to customize the connection and actions.

Common Commands and Options

Option/Command
Description
Example

-U <username>

Specifies the username for authentication.

smbclient //server/share -U john.doe

-P <password>

Specifies the password for authentication (Avoid using this for security reasons; use a keytab or keyring instead).

smbclient //server/share -U john.doe -P mypassword

-N

Disables password prompting. Useful with -U and secure password management methods.

smbclient //server/share -N -U john.doe

-I <ip_address>

Specifies the IP address to use when connecting. Useful if resolving hostnames is problematic.

smbclient //192.168.1.100/share -U john.doe

get <file>

Downloads a file from the share.

get important_document.txt

put <file>

Uploads a file to the share.

put my_report.pdf

lcd <directory>

Changes the local directory.

lcd /home/user/documents

cd <directory>

Changes the remote directory (on the share).

cd project_files

ls

Lists files and directories on the share.

ls

mkdir <directory>

Creates a directory on the share.

mkdir new_folder

rmdir <directory>

Removes an empty directory on the share.

rmdir empty_folder

pwd

Prints the current remote working directory.

pwd

lpwd

Prints the current local working directory.

lpwd

bye

Closes the connection to the server.

bye

quit

Closes the connection to the server (same as bye).

quit

Last updated