Bridging the Windows and Linux Gap
While Linux servers natively use NFS to share files with each other, corporate networks are heavily dominated by Windows File Servers. If your Linux server (perhaps running a web application or backup script) needs to read or write data to a standard Windows shared folder, you must use the Server Message Block (SMB) protocol. The cifs-utils package provides the necessary tools for the Linux kernel to natively mount and interact with Windows file shares.
Step 1: Install the cifs-utils Package
By default, most modern Linux distributions do not include the CIFS networking tools. Open your terminal and install them using your package manager.
On Ubuntu/Debian:
sudo apt update && sudo apt install cifs-utils -y
On RHEL/CentOS:
sudo yum install cifs-utils -y
Step 2: Create a Local Mount Point
You need a local directory on the Linux server where the remote Windows files will appear. It is standard practice to create this directory inside the /mnt folder.
sudo mkdir -p /mnt/windows_share
Step 3: Create a Secure Credentials File
To mount a Windows share, you must provide a valid Active Directory (or local Windows) username and password. Writing these credentials in plain text directly in the mount command is a massive security risk. Instead, create a hidden credentials file:
sudo nano /root/.smbcredentials
Add the following lines (replacing with your actual credentials):
username=svc_backup
password=YourStrongPasswordHere
domain=corp.local
Save the file, and immediately lock its permissions so only the root user can read it:
sudo chmod 600 /root/.smbcredentials
Step 4: Manually Mount the Share
Before making the mount permanent, test it manually using the mount command. You must specify the CIFS filesystem type, the remote path, the local path, and the path to your credentials file.
sudo mount -t cifs //192.168.1.50/SharedData /mnt/windows_share -o credentials=/root/.smbcredentials,uid=1000,gid=1000
(Note: The uid and gid options map the file permissions to your specific Linux user, preventing everything from being owned by root).
Run ls -l /mnt/windows_share to verify you can see the Windows files.
Step 5: Make the Mount Persistent (Auto-Mount on Boot)
Manual mounts are lost if the Linux server reboots. To make it permanent, you must edit the filesystem table file (/etc/fstab):
sudo nano /etc/fstab
Append the following line to the bottom of the file:
//192.168.1.50/SharedData /mnt/windows_share cifs credentials=/root/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,vers=3.0 0 0
Save and close. You can test the fstab entry by unmounting the share (sudo umount /mnt/windows_share) and running sudo mount -a. If no errors appear, your Linux server will automatically map the Windows drive every time it boots up.