How to Permanently Mount Windows Network Shares on Linux Using CIFS
This step‑by‑step guide shows how to install the required CIFS utilities, configure host name resolution, create a credentials file, edit /etc/fstab, and mount a Windows network share so it remains available after Linux reboots.
Before you start
Interacting with a Windows network from Linux can be challenging, but with the right tools you can map Windows network drives and keep them mounted after reboot.
This guide assumes Samba is already working and you can manually mount the share.
Create a mount point
First create a directory that will serve as the mount point, e.g., /media/share:
sudo mkdir /media/shareInstall required utilities
Install the CIFS utilities package: sudo apt-get install cifs-utils This also installs all dependencies.
Then edit /etc/nsswitch.conf and change the hosts line to include wins:
hosts: files mdns4_minimal [NOTFOUND=return] wins dnsInstall winbind
Install winbind to resolve Windows hostnames in a DHCP network: sudo apt-get install libnss-windbind windbind Restart the networking service:
sudo service networking restartMount the network drive
Backup /etc/fstab before editing: sudo cp /etc/fstab /etc/fstab.old To restore later: sudo mv /etc/fstab.old /etc/fstab Create a credentials file ~/.smbcredentials with your Windows username and password:
username=USER password=PASSWORDFind your UID and GID: id USER Typical output: uid=1000(USER) gid=1000(GROUP) Add a line to /etc/fstab (replace placeholders with actual values and the remote IP):
//192.168.1.10/SHARE /media/share cifs credentials=/home/USER/.smbcredentials,iocharset=utf8,gid=GID,uid=UID,file_mode=0777,dir_mode=0777 0 0Save the file and run: sudo mount -a The share should now be accessible at /media/share.
Conclusion
With cifs-utils and Samba installed, mapping a Windows network share on Linux becomes straightforward and persists across reboots.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
