16

I have downloaded BASH for Windows 10. How would I navigate to a network address as I would in a Windows environment? I have seen SAMBA mentioned and have downloaded smbclient.

I have tried:

smbclient \\localhost\

I receive the error

ERROR: Could not determine network interfaces, you must use a interfaces config file

I am a novice user of BASH, and see this as an opportunity to be more efficient.

As a bonus please show how I could accomplish some common tasks such as copying files across a network, as well as how to authenticate since this would likely be required for such operations.

22

In the latest Windows release "Fall Creators Update" it is possible to mount UNC paths, or any other filesystem that Windows can access, from within WSL.

You can do this with the mount command as usual, with the filesystem "drvfs" provided by WSL:

sudo mount -t drvfs '\\server\share' /mnt/share

Single quotes are useful around the UNC path so that you don't have to escape the backslashes. You can mount on an arbitrary directory; I've used /mnt/share as an example here, but any empty directory will do.

All files will show up with full a+rwx 777 permissions. The real access rights will be checked when you try to access a file, and you can get an error at that point even if it looks like the operation should succeed. Every readable file will be treated as executable.


For locations that require credentials you have three options:

  1. Prior to mounting, navigate to the location using Windows' File Explorer and authenticate. WSL will inherit your credentials and permissions. This is the easiest way for a one-off.
  2. Use the net use command from a cmd prompt, or net.exe use from inside WSL (cd /mnt/c first to suppress a warning). You'll need something like net.exe use \\server\share <PASSWORD> /USER:<USERNAME>. You can use '*' for the password to be prompted instead. Other configurations are shown with net.exe help use.
  3. Use the Windows Credential Manager to set up a stored credential. I've never done this one.

I understand that Samba proper can be made to work under WSL as well, but since the host provides the same functionality I would use the built-in version from Windows when it's available. smbclient is primarily for FTP-style access to SMB servers and retrieving/putting individual files, and it should work when appropriately configured as usual.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.