smbclient [options] \\\\[server]\\[share] [password] -U [username]
# Anonymous login
smbclient -L \\\\192.168.1.100
smbclinet -L \\\\\\\\192.168.1.100\\\\
# With valid username and password
smbclient -L \\\\192.168.1.100 -U username%password
# Access a share with a null password (only use in trusted environments)
smbclient \\\\192.168.1.100\\share$ -N
smbclient \\\\192.168.1.100\\share$ -U username%password
# Download a file from a specific share
smbclient \\\\[192.168.1.100\\share](notion://192.168.1.100/sharename)$ -U username -c "get filename.txt"
# Download a file from a specific share folder
smbclient \\\\192.168.1.100\\share$ -c 'cd folder; get desired_file_name' password -U username
# List files on a specific share
smbclient \\\\192.168.1.100\\share$ -c 'ls' password -U username
# List files on a specific share folder inside the share:
smbclient \\\\192.168.1.100\\share$ -c 'cd folder; ls' password -U username
# Copy a file to a specific share folder:
smbclient \\\\192.168.1.100\\share$ -c 'put /var/www/my_local_file.txt .\\target_folder\\target_file.txt' password -U username
# Rename a file in a specific share folder
smbclient \\\\192.168.1.100\\share$ -c 'rename current_file.txt new_file.txt' password -U username
# Create a folder in a specific share folder:
smbclient \\\\192.168.1.100\\share$ -c 'mkdir .\\target_folder\\new_folder' password -U username
| Command | Description |
|---|---|
| get [file] | Download a file from the remote share |
| put [file] | Upload a file to the remote share |
| cd [directory] | Change the current working directory on the remote share |
| ls | List files and directories in the current remote directory |
| pwd | Display the current remote working directory |
| prompt | Toggle interactive prompting for file transfers (on/off) |
| recurse | Recursively copy directories when uploading or downloading |
| rm [file] | Delete a file on the remote share |
| mkdir [directory] | Create a directory on the remote share |
| rmdir [directory] | Remove a directory on the remote share |
| mget [files] | Download multiple files matching a pattern |
| mput [files] | Upload multiple files matching a pattern |
| help | Display a list of available commands |
| Switch | Description |
|---|---|
| -L | List available shares on the server |
| -c | Execute a single command or script |
| -D | Specify a directory to use as the current directory |
| -N | Use a null password (use cautiously in trusted environments) |
| -U [username] | Specify the username for authentication |
| -W [workgroup] | Set the workgroup or domain name |
| -P [port] | Specify the port to use (default is 139) |
| -e [character_set] | Set the character set to use |
| -g | Disable graphical prompts and use only the CLI |