sudo mount -t cifs -o username=peter,password=xxxxxxxxxxxxxxxxxxxx,uid=peter,gid=peter,forceuid,forcegid,vers=2.1 //192.168.1.5/Docs /home/peter/Documents/nas_docs
The most basic mount options is:
mount -t cifs -o username=USERNAME,password=PASSWD //192.168.1.88/shares /mnt/share
If the basic mount does not work, you may need to use extended features
mount -t cifs -o username=USERNAME,password=PASSWD,iocharset=utf8,file_mode=0777,dir_mode=0777 //192.168.1.88/shares /mnt/share
where:
FURTHER INFORMATION:
USERNAME: By default all the files and directories will be owned by the uid of the process or by root. You can force it otherwise.
sudo id user_name
If, for example, the user id is 1000 then you can use the following…
uid=1000(user_name) gid=1000(user_name) groups=...
dir_mode / file_mode
Setting the uid or gid is fine if you are the only user of the system.
On a multiuser system this is problematic as other users will still be denied.
Therefore use dir_mode / file_mode to give everyone access:
dir_mode=0777,file_mode=0666
sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g),forceuid,forcegid, //server-address/folder /mount/path/on/ubuntu
Permanently mount the shares so that they will be available after reboot.
Edit your /etc/hosts file and add the hostname and IP address of the windows share or file server.
... 192.168.1.5 NAS ...
Create mount points for each windows share. For example:
mkdir /mnt/public mkdir /mnt/media mkdir /mnt/video
Edit /etc/fstab and add a line for each windows share. For example:
//remote_machine/public/ /mnt/public cifs username=peter,password=mypassword,iocharset=utf8,sec=ntlm 0 0 //remote_machine/media/ /mnt/media cifs username=peter,password=mypassword,iocharset=utf8,sec=ntlm 0 0 //remote_machine/video/ /mnt/video cifs username=peter,password=mypassword,iocharset=utf8,sec=ntlm 0 0
NOTE: If the system complains add the 'noauto' parameter.
sudo mount -a
or Reboot.
Make the following entry in your /etc/fstab file :
//server_name/share_name /mount_path cifs defaults,uid=1000,gid=1000 0 0
Now when the share is mounted all files and folders will appear as the user with uid 1000.
FURTHER INFORMATION:
dir_mode / file_mode
Setting the uid or gid is fine if you are the only user of the system.
On a multiuser system this is problematic as other users will still be denied.
Therefore use dir_mode / file_mode to give everyone access:
//server_name/share_name /mount_path cifs defaults,dir_mode=0777,file_mode=0666 0 0
Add these lines to /etc/smb.conf on the server:
... create mask = 0666 force create mode = 0666 directory mask = 0777 force directory mode = 0777 ...
This gives 0777 permission to every samba users in the write list for new created directory or files.
Setup a credentials file so you don't need to enter your password in the command; causing it to be stored in your command history in plain-text) or at the prompt (a nuisance).
sudo mount -t cifs //nas/docs /media/peter/nas_docs -o vers=3.11,credentials=/home/peter/.ssh/.smb_nas
Note the credentials option
username=peter password=[REAL PASSWORD] domain=WORKGROUP