How To Mount Windows Share On Ubuntu 22.04 LTS

How To Mount Windows Share On Ubuntu 22.04 LTS Operating System.

A network filesystem technology called Common Internet File System (CIFS) is used to allow shared access to printers and files amongst connected devices. With the help of this, You can read, write or delete files on the distant server. The CIFS protocol was created at IBM in the 1980s by Barry Feigenbaum, as Wikipedia states. Formerly referred to as Server Message Block (SMB). In order to adjust local file access to network file systems, SMB was once intended to operate on top of the NetBIOS / NetBEUI API (which is commonly implemented with NBF, NetBIOS over IPX/SPX, or NBT).

Here, To access mount point on a Window Share we will be using CIFS. This tutorial post will go through the required steps of installing and mounting the Windows Share on Ubuntu .

How To Mount Windows Share On Ubuntu 22.04 LTS

Install CIFS on Ubuntu operating system

Run the following commands in Ubuntu to install a CIFS or common internet file system:

sudo apt-get update
sudo apt-get install cifs-utils

Manually Or Automatically mounting windows share on Linux.

Run the following command to create a directory on your Ubuntu by the name winshared under /mnt

sudo mkdir /mnt/winshared

Note: /mnt/winshared is the mount point of the remote windows share in your network.

Now you can easily mount the Windows share on your Ubuntu with the following CIFS option of the mount command.

sudo mount -t cifs -o username=$windows_username,password=$windows_username_password //WIN_SHARE_IPAddressofthewindows/$shared_name /mnt/winshared

If the $windows_username is in a windows domain, you need to specify the domain, and run the following command to do that.

sudo mount -t cifs -o username=$windows_username,password=$windows_username_password,domain=$windows_domain_name //WIN_SHARE_IPaddressofthewindows/$shared_name /mnt/winshared

Once the windows share is successfully mounted, you can use command df -h to verify the mounting windows share in Linux.

df -h
Filesystem                 Size  Used Avail Use% Mounted on
udev                       4,2G     0  4,2G   0% /dev
tmpfs                      777M  2,2M  705M   1% /run
/dev/sda2                  350G   23G  305G   6% /
tmpfs                      4,2G  705M  2,2G  18% /dev/shm
tmpfs                      5,0M  4,0K  5,0M   1% /run/lock
tmpfs                      4,2G     0  4,2G   0% /sys/fs/cgroup
//  400G  4,7G  396G   2% /mnt/winshared

Now you need to create a CIFS credentials file: /etc/cifs-credentials now with the following commands:

username = $windows_username
password = $windows_username_password
domain = $windows_domain_name

Don’t forget to grant the permission to read and write to the credentials file:

sudo chmod +rw /etc/cifs-credentials

Mount the share using credentials with commands as follows:

sudo mount -t cifs -o credentials=/etc/cifs-credentials //WIN_SHARE_IP/$shared_name /mnt/winshared

Note: In manual mount , when you reboot your Linux machine, the shares will be lost.

If dont want to lose it, You need to configure the file /etc/fstab that contains the necessary configuration that allows automatically mount cifs permanently in Linux.

sudo vim /etc/fstab

Add the following line to the file.

//WIN_SHARE_IPaddress/$shared_name /mnt/winshared cifs credentials=/etc/cifs-credentials,file_mode=0755,dir_node=0755 0 0

Run the command to mount all the entries listed in /etc/fstab

sudo mount -a

Just in case if you want to unmount a share, run the following command :

sudo umount /mnt/winshare

Leave a Comment