Skip to main content
The Smb2Client tool connects to SMB2 servers and lets you list directory contents, transfer files, manage directories and symbolic links, create junctions, watch for changes, and enumerate server-level information including shares, sessions, open files, network interfaces, snapshots, and alternate data streams.

UNC path syntax

All SMB commands that take a <UncPath> use the format:
\\<server>[:<port>]\<share>[\<path>]
Where <port> is an optional integer overriding the default SMB port. The <server> name is used within the SMB2 protocol for negotiation (for example, as the SPN host when using Kerberos). To connect through a SOCKS proxy or to a server at a different IP address, use -HostAddress to specify the actual network address while keeping the original <server> name in the UNC path.

Subcommands

CommandDescription
lsList the contents of a directory
getDownload a file or directory tree
putUpload a file to the server
rmDelete a file
rmdirDelete a directory
mkdirCreate a directory
mklinkCreate a symbolic link
mountCreate a mount point or junction
umountUnmount a mount point
touchUpdate timestamps or attributes on a file or directory
watchWatch a directory or subtree for changes
enumsharesList shares on the server
enumsessionsList active sessions on the server
enumopenfilesList files open on the server
enumnicsQuery the server for its network interfaces
enumsnapshotsList available snapshots for a file or directory
enumstreamsList data streams of a file or directory
For help on any subcommand, run Smb2Client <subcommand> -h.

Common options

Most subcommands share these authentication and connection options:
-UserName (-u)
UserPrincipalName
User name to authenticate with (not including the domain).
-UserDomain (-ud)
string
Domain of the authenticating user.
-Password (-p)
string
Password to authenticate with.
-NtlmHash
hexadecimal hash
NTLM hash for pass-the-hash authentication.
-Anonymous
boolean
Use anonymous login.
-Kdc (-K)
host:port
KDC endpoint. Required to enable Kerberos.
-Tgt
string
Path to a TGT file (.kirbi or ccache).
-Tickets
string[]
Path to service ticket files (.kirbi or ccache).
-TicketCache
string
Ticket cache file.
-AesKey
HexString
AES-128 or AES-256 Kerberos key.
-S4UserName
UserPrincipalName
User to impersonate with S4U2self.
-HostAddress (-ha)
string[]
Override the network address used to connect. Useful when routing through a SOCKS proxy where the server name in the UNC path cannot be resolved directly.
-UseTcp4Only (-4)
boolean
Use TCP over IPv4 only.
-UseTcp6Only (-6)
boolean
Use TCP over IPv6 only.
-EncryptSmb
boolean
Require an encrypted SMB connection.
-EncryptShare
boolean
Encrypt PDUs for the target share.
-RequireSigning (-signreq)
boolean
Require signed packets.
-Dialects
Smb2Dialect[]
SMB2 dialects to negotiate. Possible values: Smb2_0_2, Smb2_1, Smb3_0, Smb3_0_2, Smb3_1_1.
-FollowDfs (-F)
boolean
Follow DFS referrals (default: true).
-Socks5
host:port
SOCKS5 proxy endpoint.

ls

Lists the contents of a directory. Can also display named pipes (via the IPC$ share) and retrieve detailed file metadata including security descriptors, link targets, and timestamps.
Smb2Client ls [options] <UncPath>
UncPath
UNC path
required
Directory to list. Accepts wildcard patterns to filter results.
-Depth
integer
Depth limit for recursive listing. 0 = no recursion (default); -1 = unlimited.
-QueryBufferSize (-Q)
integer
Buffer size for the directory listing query.
-TimeWarpToken
TimeWarpToken
Snapshot version — date/time or @GMT token.
-OutputFields
string[]
Fields to display. Available: RelativePath, Size, SizeOnDisk, FileAttributes, CreationTime, LastAccessTime, LastWriteTime, LastChangeTime, LinkTarget, SecurityDescriptorSddl, Owner, Group, Dacl, Sacl, MaxAccess, ShortName, FileId, FileIndex, EaSize, ReparseTag.
-UseBackupSemantics
boolean
Open files with backup semantics.

Examples

# List a share
Smb2Client ls \\\\SERVER\\Share -u User -ud DOMAIN -p password

# List named pipes
Smb2Client ls \\\\SERVER\\IPC$ -u User -ud DOMAIN -p password

# Connect via IP to avoid DNS (useful behind a SOCKS proxy)
Smb2Client ls \\\\SERVER\\Share -ha 10.0.0.1 -u User -ud DOMAIN -p password

# Pass the hash
Smb2Client ls \\\\SERVER\\Share -u User -ud DOMAIN -NtlmHash 8846F7EAEE8FB117AD06BDD830B7586C

# Use Kerberos
Smb2Client ls \\\\SERVER\\Share -u User -ud DOMAIN -p password -Kdc 10.0.0.10

get

Downloads a file or directory tree from an SMB share to the local filesystem. The UNC path accepts wildcard patterns (* and ?). When downloading a single file, specifying <DestinationFileName> is optional — omit it to print the file to the console. When downloading a directory, <DestinationFileName> must be a local directory that either exists or will be created. The default chunk size is 32,768 bytes.
Smb2Client get [options] <UncPath> [<DestinationFileName>]
UncPath
UNC path
required
Source file or directory on the server. Accepts wildcards.
DestinationFileName
string
Local file or directory to write to. Omit to print the file to the console.
-Depth
integer
Directory traversal depth. 0 = current directory only (default); -1 = unlimited.
-ChunkSize
integer
Read chunk size in bytes. Must not exceed the server’s MaxReadSize. Default: 32768.
-TreeOnly
boolean
Copy directory structure without copying files.
-Overwrite
boolean
Overwrite existing local files.
-ContinueOnError
boolean
Continue copying after encountering an error.
-Unbuffered
boolean
Read data directly from storage.
-Compress
boolean
Request the server compress the data.
-TimeWarpToken
TimeWarpToken
Snapshot version — date/time or @GMT token for reading from a shadow copy.
-QueryBufferSize (-Q)
integer
Buffer size for directory listing queries during recursive operations.

Examples

# Print a file to the terminal
Smb2Client get \\\\SERVER\\Share\\File.txt -u DOMAIN\\User -p Password

# Download a file
Smb2Client get \\\\SERVER\\Share\\File.txt LocalFile.txt -u DOMAIN\\User -p Password

# Download all .txt files up to depth 20
Smb2Client get '\\\\SERVER\\Share\\*.txt' LocalTextFiles -depth 20 -u DOMAIN\\User -p Password

# Copy only the directory tree structure, not files
Smb2Client get \\\\SERVER\\Share\\Departments Departments -depth -1 -TreeOnly -u DOMAIN\\User -p Password

put

Uploads a local file to the SMB share.
Smb2Client put [options] <UncPath> [<SourceFileName>]
UncPath
UNC path
required
Destination path on the server.
SourceFileName
string
Local file to upload. Reads from stdin if not specified.

rm

Deletes a file on the SMB share.
Smb2Client rm [options] <UncPath>
UncPath
UNC path
required
Path of the file to delete.

rmdir

Deletes a directory on the SMB share.
Smb2Client rmdir [options] <UncPath>
UncPath
UNC path
required
Path of the directory to delete.

mkdir

Creates a directory on the SMB share. By default, parent directories are not created. If a parent directory does not exist, the server returns STATUS_OBJECT_PATH_NOT_FOUND. Use -Parents to create the full path. With this flag, Smb2Client mkdir walks the path from the root, creating each level as needed. If the directory already exists with -Parents, no error is generated.
Smb2Client mkdir [options] <UncPath>
UncPath
UNC path
required
Path of the directory to create.
-Parents
boolean
Create parent directories as needed.

Creates a symbolic link on the SMB share. By default the target path is treated as an absolute path and \??\ is prepended automatically. Use -Relative for a relative link. Use -Directory to create a directory symlink. A symlink contains a substitution path (the actual target) and a print path (what directory listings display). By default both paths are identical. Use -PrintPath to set them independently.
Smb2Client mklink [options] <UncPath> <TargetPath>
UncPath
UNC path
required
Path where the symlink will be created.
TargetPath
string
required
Path the symlink points to.
-Directory
boolean
Create a directory symlink.
-Relative
boolean
Treat the target path as relative.
-PrintPath
string
Path to display in directory listings (defaults to <TargetPath>).

Examples

# Create a relative file symlink
Smb2Client mklink \\\\SERVER\\Share\\Symlink -Relative ActualFile.txt

mount

Creates a mount point or junction on the SMB share.
Smb2Client mount [options] <UncPath> <TargetPath>
UncPath
UNC path
required
Path where the mount point will be created.
TargetPath
string
required
Target path for the junction.

umount

Unmounts a mount point or junction on the SMB share.
Smb2Client umount [options] <UncPath>
UncPath
UNC path
required
Path of the mount point to remove.

touch

Updates the timestamps and/or file attributes of a file or directory on the SMB share. Use this command to timestomp files or create empty files.
Smb2Client touch [options] <UncPath>
UncPath
UNC path
required
Path of the file or directory to update.

watch

Watches a directory or subtree for modifications and prints a notification each time a change is detected.
Smb2Client watch [options] <UncPath>
UncPath
UNC path
required
Directory to watch.

enumshares

Lists shares on the server using the RPC Server Service interface.
Smb2Client enumshares [options] <ServerName>
ServerName
string
required
RPC server to interact with.
-Level
ShareInfoLevel
Level of detail to query. Possible values: Level1, Level2, Level501, Level502, Level503.
-BufferSize (-B)
integer
Maximum response buffer size.
-OutputFields
string[]
Fields to display. Available: ShareName, ServerName, ShareType, Remark, Permissions, MaxUses, CurrentUses, Path, SecurityDescriptorSddl, Flags.

enumsessions

Lists active sessions on the server using the RPC Server Service interface. Use -ClientUserName to filter by the user name (without domain). Use -ClientComputer to filter by computer name — Smb2Client enumsessions automatically prepends \\ if you omit it.
Smb2Client enumsessions [options] <ServerName>
ServerName
string
required
RPC server to interact with.
-Level
SessionInfoLevel
Level of detail. Possible values: Level0, Level1, Level2, Level10, Level502.
-ClientComputer
string
Filter sessions by client computer name.
-ClientUserName
string
Filter sessions by user name (without domain).
-BufferSize (-B)
integer
Maximum response buffer size.
-OutputFields
string[]
Fields to display. Available: ClientName, UserName, NumberOfOpens, ConnectedTime, IdleTime, UserFlags, ClientType, Transport.

enumopenfiles

Lists files currently open on the server. Use -OpenBy to filter by the user name (without domain). Use -BasePath to filter by path prefix — this must be an absolute path. For regular files it begins with a drive letter (e.g. C:\Windows); for named pipes it begins with \ (e.g. \srvsvc). Wildcards are not supported in -BasePath.
Smb2Client enumopenfiles [options] <ServerName>
ServerName
string
required
RPC server to interact with.
-Level
OpenFileInfoLevel
Level of detail. Possible values: Level2, Level3.
-OpenBy
string
Filter files open by this user name (without domain).
-BasePath
string
Filter files whose path starts with this prefix.
-BufferSize
integer
Maximum response buffer size.
-OutputFields
string[]
Fields to display. Available: Id, Permissions, LockCount, Path, UserName.

enumnics

Queries the server for its network interfaces. Clients typically use this to discover additional channels for multi-channel SMB sessions.
Smb2Client enumnics [options] <UncPath>
UncPath
UNC path
required
UNC path targeting the server.
-OutputFields
string[]
Fields to display. Available: InterfaceIndex, Capabilities, LinkSpeed, AddressFamily, EndPoint.

enumsnapshots

Lists the available volume shadow copy (VSS) snapshots for a file or directory.
Smb2Client enumsnapshots [options] <UncPath>
UncPath
UNC path
required
Path of the file or directory to query snapshots for.
-OutputFields
string[]
Fields to display. Available: Token, Timestamp.

enumstreams

Lists the alternate data streams (ADS) of a file or directory.
Smb2Client enumstreams [options] <UncPath>
UncPath
UNC path
required
Path of the file or directory to query streams for.
-OutputFields
string[]
Fields to display. Available: Name, Size, AllocationSize.

  • Kerb — request Kerberos tickets for SMB authentication
  • Lsa — look up account SIDs and names
  • Scm — manage services on remote Windows systems

Build docs developers (and LLMs) love