How To Use Windows Network Shares From Linux
Image credit: Gabriel Heinzer https://unsplash.com/@6heinz3r
This is the fastest way to set up Windows network (AD) shares with Linux using cifs-utils
Setup
sudo apt update && sudo apt install cifs-utils -y
sudo mkdir /mnt/win_share_name
- Create a credentials file:
sudo nano /etc/win-credentials
and enter the following contents:
username=user
password=password
domain=domain
sudo chown root: /etc/win-credentials
sudo chmod 600 /etc/win-credentials
- Now you should be able to test with:
sudo mount -t cifs -o credentials=/etc/win-credentials,uid=1000,gid=1000,dir_mode=0755,file_mode=0755 //machineNameOrIP/share_name /mnt/win_share_name
- When you are done testing, unmout with:
sudo umount /mnt/win_share_name
Set Up Auto Mounting
Add the following to your /etc/fstab with sudo nano /etc/fstab
:
//machineNameOrIP/share_name /mnt/win_share_name cifs credentials=/etc/win-credentials,file_mode=0755,dir_mode=0755 0 0
After a reboot, you should be able to simply run:
sudo mount /mnt/win_share_name
To unmount of course, use:
sudo umount /mnt/win_share_name