“How to Mount Windows Share on Linux using CIFS”
We hope this post helped you to find out “How to Mount Windows Share on Linux using CIFS”
On Linux and UNIX working programs, a Home windows share might be mounted on a specific mount level within the native listing tree utilizing the
cifs choice of the
The Widespread Web File System (CIFS) is a community file-sharing protocol. CIFS is a type of SMB.
On this tutorial, we’ll clarify how one can manually and routinely mount Home windows shares on Linux programs.
Installing in CIFS Utilities Packages #
To mount a Home windows share on a Linux system, first you’ll want to set up the CIFS utilities package deal.
Installing CIFS utilities on Ubuntu and Debian:
sudo apt update
sudo apt install cifs-utils
Installing CIFS utilities on CentOS and Fedora:
sudo dnf install cifs-utils
The package deal title might differ between Linux distributions.
Mounting a CIFS Home windows Share #
Mounting a distant Home windows share is just like mounting common file programs.
First, create a listing to function the mount level for the distant Home windows share:
sudo mkdir /mnt/win_share
Run the following command as root or user with sudo privileges to mount the share:
sudo mount -t cifs -o username=<win_share_user> //WIN_SHARE_IP/<share_name> /mnt/win_share
You will be prompted to enter the password:
On success, no output is produced.
To confirm that the distant Home windows share is efficiently mounted, use both the
df -h command.
As soon as the share is mounted, the mount level turns into the basis listing of the mounted file system. You’ll be able to work with the distant information as in the event that they had been native information.
The password can be offered on the command line:
sudo mount -t cifs -o username=<win_share_user>,password=<win_share_password> //WIN_SHARE_IP/<share_name> /mnt/win_share
If the user is in windows workgroup or domain you can set it as follows:
sudo mount -t cifs -o username=<win_share_user>,domain=<win_domain> //WIN_SHARE_IP/<share_name> /mnt/win_share
For higher safety it is strongly recommended to make use of a credentials file, which accommodates the share username, password and area.
The credentials file has the next format:
username = user password = password domain = domain
The file must not be readable by users. To set the correct permissions and ownership, run:
sudo chown root: /etc/win-credentials
sudo chmod 600 /etc/win-credentials
To use the credentials file, define it as follows:
sudo mount -t cifs -o credentials=/etc/win-credentials //WIN_SHARE_IP/<share_name> /mnt/win_share
By default of the mounted share is owned by root, and the permissions are set to 777.
dir_mode option to set the directory permission and
file_mode to set the file permission:
sudo mount -t cifs -o credentials=/etc/win-credentials,dir_mode=0755,file_mode=0755 //WIN_SHARE_IP/<share_name> /mnt/win_share
The default user and group ownership can be changed with the
sudo mount -t cifs -o credentials=/etc/win-credentials,uid=1000,gid=1000,dir_mode=0755,file_mode=0755 //WIN_SHARE_IP/<share_name> /mnt/win_share
To set additional options, add them as a comma-separated list after the
-o option. To get a list of all mount options type
man mount in your terminal.
Auto Mounting #
When the share is manually mounted with the
mount command, it does not persist after a reboot.
/etc/fstab file contains a list of entries that define where how and what filesystem will be mounted on system startup.
To automatically mount a Windows share when your Linux system starts up, define the mount in the
/etc/fstab file. The line must include the hostname or the IP address of the Windows PC, the share name, and the mount point on the local machine.
/etc/fstab file with your text editor:
sudo nano /etc/fstab
Add the following line to the file:
# <file system> <dir> <type> <options> <dump> <pass> //WIN_SHARE_IP/share_name /mnt/win_share cifs credentials=/etc/win-credentials,file_mode=0755,dir_mode=0755 0 0
Run the following command to mount the share:
sudo mount /mnt/win_share
mount command, will read the content of the
/etc/fstab and mount the share.
Subsequent time you reboot the system, the Home windows share can be mounted routinely.
Unmounting Home windows Share #
umount command detaches (unmounts) the mounted file system from the listing tree.
To detach a mounted Home windows share, use the
umount command adopted by both the listing the place it has been mounted or distant share:
sudo umount /mnt/win_share
If the CIFS mount has an entry in the
fstab file, remove it.
umount command will fail to detach the share when it is in use. To find out which processes are accessing the windows share, use the
fuser -m MOUNT_POINT
As soon as you discover the processes, you’ll be able to cease them with the
kill command and unmount the share.
Should you nonetheless have issues unmounting the share, use the
--lazy) choice, which lets you unmount a busy file system as quickly as it isn’t busy anymore.
sudo umount -l MOUNT_POINT
In Linux, you’ll be able to mount a Home windows shared utilizing the
mount command with the
We hope the “How to Mount Windows Share on Linux using CIFS” help you. If you have any query regarding “How to Mount Windows Share on Linux using CIFS” drop a comment below and we will get back to you at the earliest.
We hope this post helped you to find out “How to Mount Windows Share on Linux using CIFS” . You may also want to see – How to Install Git on Ubuntu 20.04