Mount Windows Shared Folders

This section provides a tutorial example on how to mount Windows shared folders on Linux systems. 'cifs-utils' device driver is needed.

If you have a Windows computer on the local network, you can share a folder with your Linux computer. Here is what I did to share a folder on my Windows 10 with my CentOS 8 computer.

1. On my Windows 10 computer, create share folder and make it available for sharing:

2. On my CentOS 8 computer, install cifs-utils device drive and mount the shared folder. Note that "" is the IP address of my Windows 10 computer. "herong" is the username on Windows 10 computer.

herong$ sudo dnf install cifs-utils

herong$ sudo mkdir /mnt/share

herong$ sudo mount -t cifs -o username=herong // /mnt/share
Password for herong@//  ********

3. Verify the shared folder. It works as expected!

herong$ sudo touch /mnt/share/junk

herong$ sudo ls -l /mnt/share/junk
-rwxr-xr-x. 1 root root 0 Oct 10 22:31 /mnt/share/junk

4. To mount it under a private user and group, you need to specify additional options on the "mount" command. For example, the following command mounts the shared folder for me to access only:

herong$ sudo mount -t cifs \
  -o username=herong,uid=herong,gid=herong,dir_mode=0700,file_mode=0700 \
  // /mnt/share

herong$ ls -l /mnt
drwx------. 2 herong herong     78 Oct 10 22:49 share

Cool. This is perfect for me to transfer files between my Windows 10 and CentOS 8 computer!

5. To mount it for the Apache Web server to use, you need to give "read/execute" permission and override its SELinux context type from "cifs_t" to "tmp_t":

[herong@mail ~]$ ls -lZ /mnt
drwx------.  2 herong herong unconfined_u:object_r:cifs_t:s0 share

herong$ sudo mount -t cifs \
  -o username=herong,uid=herong,gid=herong,dir_mode=0755,file_mode=0755,\
  context=unconfined_u:object_r:tmp_t:s0 // /mnt/share

drwxr-xr-x.  2 herong herong unconfined_u:object_r:tmp_t:s0 share

By the way, if you try to mount CIFS file system without installing "cifs-utils", you will get a "cannot mount ... read-only" error message, which is very misleading:

(Mount without cifs-utils installed)
herong$ sudo mount -t cifs -o username=herong // /mnt/share
mount: /mnt/share: cannot mount // read-only.

For more information on "cifs-utils" device driver, run "man mount.cifs" command to read its man page.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

File Systems

 "df" - Display Free Space of File System

 Mount USB Drive as File System

 "dd" - Copy Data from/to Storage Devices

 Use "dd" Command to Test I/O Speed

 "du" - Display Disk Usage of Directories

 Mount Windows NTFS File System

 Access Persmissions on "ntfs-3g" File System

Mount Windows Shared Folders

 W95 Ext'd (LBA) Partition

 Reformat NTFS Partition into EXT4 Partition

 NFS (Network File System)

 Mount NFS (Network File System) on macOS

 /etc/mtab and /etc/fstab Files

 Unreachable Remote File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks


 Full Version in PDF/EPUB