Skip to content

Instantly share code, notes, and snippets.

@cmbaughman
Created January 18, 2023 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmbaughman/92806109779b0a137aef956150dcc61e to your computer and use it in GitHub Desktop.
Save cmbaughman/92806109779b0a137aef956150dcc61e to your computer and use it in GitHub Desktop.
Mounting Windows Shares With CIFS

How To Use Windows Network Shares From Linux

This is the fastest way to set up Windows network (AD) shares with Linux using cifs-utils

Setup

  1. sudo apt update && sudo apt install cifs-utils -y
  2. sudo mkdir /mnt/win_share_name
  3. Create a credentials file: sudo nano /etc/win-credentials and enter the following contents:
username=user
password=password
domain=domain
  1. sudo chown root: /etc/win-credentials
  2. sudo chmod 600 /etc/win-credentials
  3. 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
  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment