#cifs #samba #linux #filesystem
Mount a CIFS/Samba share in Linux with read & write permissions
Prerequisites
Credentials
If credentials are required, create a credentials file in a secure folder
vim /secrets/domain_credsAnd populate it with your domain/host Credentials
username=<username>
password=<password>
domain=<domain or hostname>Then limit the permissions to prevent reads by other users
chmod 600 /secrets/domain_credsMount
Edit /etc/fstab and append a line to ensure the shared folder will be mounted during startup
sudo vim /etc/fstabAppend line in the format:
<remote_path> <local_path> cifs credentials=<cred_file>,uid=<uid>,gid=<gid>,vers=3.0,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0Example:
//10.0.0.4/Library /mnt/library cifs credentials=/secrets/my_server,uid=1000,gid=1000,vers=3.0,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0Save the changes and then mount:
sudo mount -a