How To Mount a Windows File Share on Linux

1. Make sure the required packages/libraries are installed:

Debian/Ubuntu:

apt install -y cifs-utils

RHEL/clones:

dnf install -y cifs-utils

2. Create a text file in /root with your file server credentials:

sudo vim /root/.windowsShare

3. Add the following contents:

username=myuser
password=secretpassword

4. Create a mount point for your share:

sudo mkdir /mnt/my_share

5. Open /etc/fstab with your favorite text editor, e.g. vim:

sudo vim /etc/fstab

6. Add the following line at the end of the file:

//server.domain.com/share_name /mnt/my_share cifs defaults,_netdev,uid=my_unix_user,credentials=/root/.windowsShare 0 0

7. Mount the share to your system (or reboot):

sudo mount /mnt/my_share

8. You're done! Yay!