- Open the file manager by clicking on the file manager icon or by pressing the Super key (also known as the Windows key) and typing “Files” and pressing Enter.
- In the file manager, click on “File” in the top menu and select “Connect to Server” or press Ctrl + L
- In the Server Address field, enter the UNC path to the network drive you want to connect to (e.g. smb://server/share)
- If the network drive requires a username and password to connect, enter the necessary information.
- Click on “Connect”
- The network drive should now appear in the left pane of the file manager and can be accessed like any other drive on your computer.
- To map the network drive to a drive letter, Open terminal by pressing Ctrl+Alt+T and type the following command :
sudo mount -t cifs -o username=<username>,password=<password> //<server-ip>/<share-name> <mount-point>
Replace the <username>,<password>,<server-ip> and <share-name> with your respective details and <mount-point> is the directory where you want to mount your network drive.
For example :
sudo mount -t cifs -o username=johndoe,password=password //192.168.1.100/data /mnt/data
Note: You have to create the mount point directory before running the command. This command will mount the network drive to ‘/mnt/data’ directory.
To make the network drive to persist after reboot , you can add the command in the fstab file. Open the file by running
sudo nano /etc/fstab
Add the following line at the end of the file:
//192.168.1.100/data /mnt/data cifs username=johndoe,password=password 0 0
And that’s it! You should now be able to access the network UNC drive from Ubuntu Linux using the mapped drive letter or the folder you have chosen to mount your network drive.
Here is a one-click script for connecting to a network UNC drive and mapping it to a drive letter in Ubuntu Linux:
#!/bin/bash
# Variables
username=””
password=””
server=””
share=””
mount_point=””# Mount network drive
sudo mount -t cifs -o username=$username,password=$password //$server/$share $mount_point# Add mount command to fstab to persist after reboot
echo “//$server/$share $mount_point cifs username=$username,password=$password 0 0” | sudo tee -a /etc/fstab
You will need to edit the script and replace the values of the variables username, password, server, share, and mount_point with the appropriate values for your network UNC drive and the desired mount point.
You can save this script as a file with a .sh extension and make it executable by running the command :
chmod +x <filename>.sh
To run the script, open terminal and navigate to the directory where the script is located, then type:
./<filename>.sh
After running the script, the network UNC drive should be mounted at the specified mount_point location and the mount command will be added to the /etc/fstab file to persist after reboot.
Please note that this script is a basic example and may not work in all cases. It is always recommended to test the script in a safe environment before using it in production.