This post shows students and new users the steps to mount Windows shares on Ubuntu Linux. For this tutorial, I will be using Windows 11 and Ubuntu Linux.

A Windows share can be mounted to a particular mount point on Ubuntu Linux using the cifs option when using mount command. The mount command can be used to mount shares to a particular mount point identified in a Linux directory.

When mounting a Windows share, a suitable protocol to use is the Common Internet File System (CIFS), which is a network file-sharing protocol. It is part of the SMB protocol that allows file and printer sharing on Windows systems.

Next, we will show you how to configure a Windows 11 machine to allow the exchange file and allow Ubuntu to mount Windows shares.

To get started mounting Windows shares on Ubuntu Linux, follow the steps below.

Enable network discovery in Windows 11

As we mentioned earlier, shares need to be advertised so that other devices can see or access them. On Windows, Network Discovery must be turned on so that stock ads can be viewed from other devices.

If your Windows devices cannot see or detect each other on your private network, Network Discovery is probably disabled.

To enable Network Discovery, continue below.

Windows 11 has a centralized location for most of its settings. From system settings to creating new users and updating Windows, everything can be done from your System settings crystal.

To access the System Settings, you can use the Windows key + i shortcut or click Start ==> Settings as shown in the following picture:

windows 11 startup settings

Alternatively, you can use the search box on the taskbar and find Settings. Then select to open it.

The Windows settings panel should look similar to the image below. In Windows settings, click Network and Internet, then select Ethernet on the right panel of the screen shown in the image below.

YOU CAN ALSO READ:   How to change the MAC address in Windows 11
windows 11 internet network

In the Ethernet configuration panel, under Network Profile Type, choose Private. This profile will allow devices to be discovered on your network. This profile must also be selected if you need to share files or use applications that communicate over this network.

The private profile is suitable for home, workplaces, and trusted networks.

network discovery in windows 11 profile

If you have other networks such as Wi-Fi (if you are connected to a wireless network) or Ethernet (if you are connected to a network using a network cable), you can also configure the profile type to be Private.

When you’re done, egress and network discovery should be enabled.

Turn on public folder sharing in Windows 11

Follow the steps below to set up file sharing.

Windows 11 has a centralized location for most of its settings. From system settings to creating new users and updating Windows, everything can be done from your System settings crystal.

However, the account username change is still done in the old Control Panel. To access the Control Panel, you can click Start and start writing Control Panel as shown in the following picture:

windows 11 control panel

In the Control Panel, select Network and Internet as highlighted in the image below.

windows 11 control panel network and internet

In the next panel, select Networks and shared resources as highlighted below.

Windows 11 Network and Sharing Center

Then select Change advanced sharing settings as highlighted below.

Windows 11 change advanced sharing settings

In the Advanced Sharing Center, select Private (current profile) and Turn on file and printer sharing.

windows 11 advanced sharing center 1

Save your changes and exit.

On the same page of advanced sharing options, scroll down All networks.

There you should see the settings for public folder sharing, media streaming, file sharing connections, and password protected sharing. Windows should automatically enable file and printer sharing on private networks. However, in some cases, this will not be enabled.

If you cannot automatically find printers and shares on your private network, file sharing may be disabled.

If you enable password-protected sharing, only people who have accounts on the local computer or in the domain environment will be able to access the shared files and printers.

Windows disables password-protected sharing

Make your changes and save, then exit.

YOU CAN ALSO READ:   How to disable the firewall in Windows 11

The above configuration can be easily done using the commands below when running as administrator.

netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes

You must open the command prompt as an administrator to run the above commands.

How to create Windows shares

You cannot mount a Windows share if you do not share a folder or directory. To learn how to create a share in Windows, read the post below.

You will need to complete the steps in the post below to create a share before mounting it on Ubuntu Linux.

How to create Windows 11 shares

Now that you have created a share on Windows, proceed below to mount it on Ubuntu Linux.

How to mount Windows shares on Ubuntu Linux

Now that network discovery and file sharing are enabled, you can now log into Ubuntu Linux and start mounting Windows shares

To mount a Windows share on Ubuntu Linux, you must first install the CIFS utility package. The following commands will install it.

sudo apt update
sudo apt install cifs-utils

After running the above commands, you can start mounting shares using the mount commands with the cifs File System. Mounting a remote Windows share is similar to mounting normal file systems.

A simple mount command below will mount a Windows share on the / mnt / Windows_Share directory on Ubuntu Linux. Make sure the directory or folder already exists on Ubuntu Linux.

sudo mount -t cifs -o username=<Windows_UserName> //WindowsPC_IP/<ShareName> /mnt/Windows_Share

The above commands are detailed below:

  • mount -t cifs = filesystem type (protocol)
  • Username = Windows account username
  • // WindowsPC_IP / ShareName = the share name of the Windows PC
  • / mnt / Windows_Share = the mount point in Ubuntu

For example, if my Windows username is Richard, I would run the following commands:

sudo mount -t cifs -o username=richard //10.0.2.18/Ubuntu /mnt/windows

When you run the above commands, it should ask you for your Windows account password to mount the share.

After the share is mounted, the mount point becomes the root directory of the mounted file system. You can work with remote files as if they were local files.

YOU CAN ALSO READ:   How to create a hard drive partition in Windows 11

If you want to include the password with the mount command, just add the password file option as shown below:

sudo mount -t cifs -o username=<Windows_UserName>,password=<Windows_Password> //WindowsPC_IP/<ShareName> /mnt/Windows_Share

By default, the mounted share is owned by root and the permissions are set to 777. If you want to set custom permissions, you can use dir_mode option to set directory permission and file_mode to set the file’s permission.

An example format would be:

sudo mount -t cifs -o dir_mode=0755,file_mode=0755 //WidnowsPC_IP/<ShareName> /mnt/Windows_Share

For security reasons, it is recommended to use a file for the account credentials so that it is not exposed with the mount commands.

You can create a file and type the username, password, and domain details, then reference the file in the mount command.

The format of the credentials should be entered as follows:

username=user
password=password
domain=domain

Then check in the file using the following commands if the file is located in / etc / credentials.

sudo chown root: /etc/credentials
sudo chmod 600 /etc/credentials

Then you can use the mount commands below with options for credentials as shown below:

sudo mount -t cifs -o credentials=/etc/credentials //WindowsPC_IP/<ShareName> /mnt/Windows_Share

How to auto mount Windows shares in Ubuntu

If you don’t want to always type the mount commands to mount Windows shares, you can use the / etc / fstab file to automatically mount the shares.

The file contains a list of entries that define where and how the file system will be mounted at system startup.

Run the following commands to open the file:

sudo nano /etc/fstab

Then enter the mount commands at the bottom of the file and save.

//WindowsPC_IP/ShareName  /mnt/Widows_Share  cifs  credentials=/etc/credentials,file_mode=0755,dir_mode=0755 0   0

Now every time Ubuntu Linux starts, the share should do it automatically.

If you want to unmount, run the following commands to disconnect the mounted share.

sudo umount /mnt/win_share

You should do that!

Conclusion:

In this tutorial we have seen how to mount Windows shares on Ubuntu Linux. If you find any errors above or have something to add, use the comment form below.

Write A Comment