smbclient
smbclient
is a command-line tool in Samba that allows users to interact with Windows network shares and printers. It provides an FTP-like interface to access and manage files on SMB/CIFS servers, including Windows machines and other Samba servers. This tool is useful for transferring files, accessing shared directories, and testing SMB connections.
General Usage
Common Options
-L host
: List shares available on a host.-U user
: Specify the username for authentication.-W workgroup
: Specify the workgroup or domain.-I ip_address
: Specify the IP address of the host.-c command
: Execute a command immediately after connecting.
Basic Usage Examples
List Shares on a Server
This command lists all available shares on the specified server.
Example:
Output:
Connecting to a Share
This command connects to a specific share on the server.
Example:
Output:
Uploading a File
Once connected to a share, you can upload files using the
put
command.Example:
Output:
Downloading a File
Similarly, you can download files using the
get
command.Example:
Output:
Listing Files in a Directory
Example:
Output:
Creating a Directory
Example:
Output:
Deleting a File
Example:
Output:
Executing Multiple Commands
You can execute multiple commands by using the
-c
option.Example:
Output:
Advanced Usage
Authenticating with a Password File
Instead of entering a password interactively, you can use a credentials file.
Create a Credentials File
Use the Credentials File
Example:
Using Kerberos Authentication
If your network uses Kerberos for authentication, you can connect using your Kerberos ticket.
Obtain a Kerberos Ticket
Connect with Kerberos Authentication
Example:
Summary
Conclusion
smbclient
is a powerful tool for interacting with SMB/CIFS shares from the command line. It provides a wide range of options and commands for accessing, managing, and transferring files on network shares. Whether you need to list available shares, connect to a specific share, or perform file operations, smbclient
offers the functionality needed for effective network file management in a Samba environment. Understanding its options and commands is essential for system administrators and users working with network shares.
Last updated