This article explains options to access your Samba share from a Windows client.

In article Run your own home file server / NAS with Samba (SMB) we covered the installation and configuration of Samba (SMB) on Ubuntu. Now with having your Samba server running, you may want to access  Samba shares from your system running Windows 10, Windows 11, or earlier.

Connect to Samba share using Windows Explorer

You can connect to a Samba share using Windows Explorer or on the command line with command NET USE. The section covers the steps for Windows Explorer, a bit further down you find the details about NET USE.

1) To connect within Windows Explorer, make a right-click on This PC: 

Samba connection in Windows Explorer: Add Network Connection

2) Select Add a network location and the Network Location Wizard shows up. Click on Next:

Samba connection in Windows Explorer: Network Connection Wizzard

3) Click on Choose a custom network location (the only option available):

Samba connection in Windows Explorer: Custom Network Connection

4) Specify the network connection and share in the format \\servername\share or \\IP-address\share:

Samba connection in Windows Explorer: Specify Location

5) Next, you can enter a name for the location (or just confirm the default):

Samba connection in Windows Explorer: Name the Location

6) Everything is set now and you can confirm with Finalize:

Samba connection in Windows Explorer: Finalize

That's it. The new network connection is now available and ready for use.

Connect to Samba share with command NET USE

NET USE Overview and Options

The NET USE command is used to connect to, remove, and configure connections to shared resources, like mapped drives and network printers on the Windows command line.

NET USE Options
Option Explanation
net use

NET USE connects a computer to a shared resource or disconnects a
computer from a shared resource.

When used without options, it lists the computer's connections, i.e. the currently mapped drives and devices.

devicename

Assigns a name to connect to the resource or specifies the device to be disconnected. 
There are two kinds of devicenames: Disk drives (D: through Z:) and printers (LPT1: through LPT3:).

Type an asterisk instead of a specific devicename to assign the next available devicename.

\\computername\sharename

Is the name of the computer controlling the shared resource. If the computername contains blank characters, enclose the double backslash (\\) and the computername in quotation marks (" "). The computername may be from 1 to 15 characters long.

As an alternative you may use the IP address instead, such as \\192.168.1.10.

sharename is the network name of the shared resource.

password

This is the password needed to access the shared resource on computername.

You can choose to enter the password during the execution of the net use command by typing * instead of the actual password.

/user

Use this net command option to specify a username to connect to the resource with. If you don't use /user, net use will attempt to connect to the network share or printer with your current username.

You can shorten this switch to /u.

domainname

Specify a different domain than the one you're on, assuming you're on one, with this option.

Skip domainname if you're not on a domain or you want net use to use the one you're already on.

username Use this option with /user (or /u) to specify the username with which to logon.
/home This net use command option maps the current user's home directory to either the devicename drive letter or the next available drive letter with *.
/persistent:{yes | no}

Use this option to control the persistence of connections created with the net use command. Choose yes to automatically restore created connections at the next login or choose no to limit the life of this connection to this session.

The default is the setting used last.

You can shorten this switch to /p.

/smartcard Specifies that the connection is to use credentials on a smart card.
/savecred Specifies that the username and password are to be saved. It stores the password and user4 information for this session or in all future sessions when used in conjunction with /persistent:yes.
/delete

Cancels a network connection and removes the connection from the list of persistent connections.

Use /delete with devicename to remove a specified connection or with * to remove all mapped drives and devices.

This option can be shortened to /d.

/help Use this option, or the shortened /h, to display detailed help information for the net use command. Using this switch is the same as using the net help command with net use: net help use.
/REQUIREINTEGRITY Requires a signed connection to the share. The operation will fail if the provider does not support signed connections.
/REQUIREPRIVACY Requires an encrypted connection to the share. The operation will fail if the provider does not support encrypted connections.
/? The standard help switch also works with the net use command but only displays the command syntax, not any detailed information about the command's options.

NET USE Examples

Persistently map a drive

net use M: \\computername\devicename /u:username password /p:yes

Example:

net use M: \\AIRIX01\media /u:media secret /p:yes

Connects the Samba share media on server AIRIX01 with user media and password secret to drive M: and make it persistent.

Temporarily map a drive

net use * \\computername\devicename /u:username /p:no

Connects the next available drive letter to \\computername\devicename with user username.

List all connections

net use

Unmap a drive

net use M: /delete

Unmaps drive M:

Unmap all connections

net use * /delete