Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Mount Windows Share on Linux using CIFS - DesignLinux

Sep 27 2020
designlinux 0 Comments
How to Mount Windows Share on Linux using CIFS

On Linux or UNIX OS, you can mount a Windows share on a specific point in the local directory tree using mount command with the cifs option. The Common Internet File System (CIFS) is a network file-sharing protocol. CIFS is a form of SMB. This tutorial explains how to mount Windows share on Linux systems.

Install CIFS Packages#

You need to install the CIFS utilities package to mount a Windows share on a Linux systems.

Install 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

For different Linux distributions, the package name might be differ.

Mount a CIFS Windows Share#

It is a simple to mount the remote Windows share.

First of all, you should create a directory to serve as the mount point for the remote Windows share:

sudo mkdir /mnt/Windows_Share

After that, run the below command to mount the share as root or user with sudo privileges:

sudo mount -t cifs -o username= //WIN_SHARE_IP/ /mnt/WIN_SHARE

It will ask to enter the password:

Password:

On success authentication, it will not show any output.

You can verify using the mount or df -h command that Windows share is mounted properly.

Auto Mounting#

If you mounted share manually using mount command, it will not persist after a reboot. The /etc/fstab file contains a list of entries that define where how and what filesystem will be mounted on system startup.

You should define the mount in the /etc/fstab file to mount a Windows share automatically on your Linux system start up. 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

Edit the /etc/fstab file with your text editor :

sudo nano /etc/fstab

Now add the following line to it:

# <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

The mount command, will read the content of the /etc/fstab and mount the share.

Now once you reboot the system, the Windows share will be mounted automatically.

Unmounting Windows Share#

You can detaches the mounted file system from the directory tree using the umount command:

sudo umount /mnt/WIN_SHARE

Check the fstab file that if the CIFS mount has an entry and remove it.

Make sure the umount command will failed to detach when the share is in use. Use the fuser command to find out which processes are accessing the windows share:

fuser -m MOUNT_POINT

After finding the processes, you can stop those using the kill command and umount the share.

Even if the umount failed, you can use the -l (--lazy) option to umount busy file system:

sudo umount -l MOUNT_POINT

Conclusion#

This guide shows you how to mount a Windows shared using the mount command with the cifs option.

If you have any questions or feedback, please leave a comment below.

Related

Tags: mount, terminal

How to Add or Remove a User from a Group in Linux

Prev Post

How to Find the Length of a List in Python

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 486
  • 612,665

DesignLinux.com © All rights reserved

Go to mobile version