This brief tutorial shows students and new users how to mount Windows shares on Ubuntu 18.04 | 16.04 for all users..
Recently we showed you how to create a public share on Windows system for everyone to access.. If you want to Linux users to access the public shares you created, follow the steps below.
For students or new users looking for a Linux system to start learning on, the easiest place to start is Ubuntu Linux OS…. It’s a great Linux operating system for beginners..
Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices…
When learning Ubuntu, you will find that Linux isn’t so different than Windows and other operating systems in so many ways, especially when it comes to using Ubuntu to get work done.…
Both Ubuntu and Windows systems allow you to be productive, easy to use, reliable and enable you to install and run thousands of programs from gaming to productivity suite software for individuals and businesses..
To mount Windows shares on Ubuntu, use the steps below;
Step 1: Create Windows Shares
Before you can share a resource, that resource needs to be created and sharing enabled.. This is true for any system. If you don’t enable resource sharing, there can be no sharing.
The first step to share a Windows folder it to create it and share it.. The link below shows you how to do that.
Step 2: Install CIFS Utilities on Ubuntu
Now that you have created a Windows 10 folder and have shared it, go to the Ubuntu computer you wish to access to share from… Then run the commands below to install the CIFS utilities that will enable sharing..
sudo apt update sudo apt-get install cifs-utils
After installing, continue below to create a location on the Ubuntu machine to mount the Windows share..
For this tutorial, we’ll be mounting the share at /mnt/winshare
Step 3: Create a Mount Point on Ubuntu
After installing the Ubuntu packages that allow for sharing, run the commands below to create a location to mount the Windows share.
This location will be linked to the Windows share on Ubuntu where anyone with access can mount to..
The folder we’ll want to create for the Windows share will be called winshare.
sudo mkdir /mnt/winshare
Next, run the commands below on the mount point to give everyone access
sudo chown -R nobody:nogroup /mnt/winshare sudo chmod -R 0755 /mnt/winshare
Step 4: Mount the Windows Share
Now with sudo privileges, you can simply run the commands below to mount the share manually at the /mnt/winshare location on Ubuntu..
The windows share name created previously on the Windows 10 machine is PublicShares
sudo mount -t cifs -o username=windows_user_account_here //WIN_MACHINE_IP/PublicShares /mnt/winshare
You will be prompted for the Windows account password.
Once the file is mounted, you can use the mount command to view the mount activities or df -h command..
Use the df -h command to list the mount:
df -h /mnt/winshare
You should see similar output as below:
Output: Filesystem Size Used Avail Use% Mounted on //10.0.2.15/PublicShares 50G 16G 35G 31% /mnt/winshare
The mount point turns to a directory of the mounted file system for the root account.. You will be able to work with shared files as if they were local to the Ubuntu machine..
Step 5: Automatically Mount the Share on Ubuntu
If you want to automatically mount the shared resource everytime Ubuntu starts up, then you’ll want to add the mount point using the system’s fstab file..
For better security you should use a credentials file with the share username, password and domain for the Windows system.. Do to that, simply run the commands below to created one..
sudo nano /etc/win_cred
Then copy and paste the lines updating with the Windows user accounts with access to the share..
username = windows_user_account_name password = windows_user_password domain = windows workgroup name
Save the file and exit.
Secure the file using the commands below:
sudo chown root: /etc/win_cred sudo chmod 600 /etc/win_cred
You can then mount the file manually using the credential file created..
sudo mount -t cifs -o credentials=/etc/win_cred //WIN_MACHINE_IP/PublicShares /mnt/winshare
Finally, to mount the share automatically, run the command below to open the system’s fstab file…
sudo nano /etc/fstab
Then add the line below into the file and save.
//WIN_MACHINE_IP/PublicShares /mnt/winshare cifs credentials=/etc/win_cred,file_mode=0755,dir_mode=0755 0 0
Save the file and exit.
By default, mounted shares are owned by root since you use the sudo command to mount, and the permissions are set to 777.
Use the dir_mode option to set the directory permissions and file_mode to set the file permissions..
The line details:
credentials=/etc/win_cred file contents the windows account username and password to access the Windows share.
file_mode=0755 provides read/write/execute and write/execute for others for files
dir_mode=0755 provides the same rights as above for folders
Now all you have to do to mount the file is run the commands below:
sudo mount /mnt/winshare
If you’re using Ubuntu desktop, browse to the mount directory and the Windows share should be mounted there..
To un-mount the share, run the commands below:
sudo umount /mnt/winshare
If the file system is being used the umount command will fail… make sure no one is currently accessing the mount point before unmounting…
You have learn how to create Windows 10 shares and how to mount them in Ubuntu.. If you find errors, please comment below:
You may also like the post below: