ubuntu:samba:mount_a_windows_share
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:samba:mount_a_windows_share [2019/12/08 20:17] – peter | ubuntu:samba:mount_a_windows_share [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Ubuntu - Samba - Mount a Windows Share ====== | ====== Ubuntu - Samba - Mount a Windows Share ====== | ||
+ | |||
+ | |||
+ | ===== Quick Example ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo mount -t cifs -o username=peter, | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
===== Command line basic syntax ===== | ===== Command line basic syntax ===== | ||
Line 8: | Line 18: | ||
mount -t cifs -o username=USERNAME, | mount -t cifs -o username=USERNAME, | ||
</ | </ | ||
+ | |||
---- | ---- | ||
Line 41: | Line 52: | ||
</ | </ | ||
- | ---- | ||
- | |||
- | Make the following entry in your /etc/fstab file : | ||
- | |||
- | <file bash / | ||
- | // | ||
- | </ | ||
- | |||
- | Now when the share is mounted all files and folders will appear as the user with uid 1000. | ||
---- | ---- | ||
Line 64: | Line 66: | ||
dir_mode=0777, | dir_mode=0777, | ||
</ | </ | ||
- | |||
- | which will look like: | ||
- | |||
- | <file bash / | ||
- | // | ||
- | </ | ||
</ | </ | ||
Line 75: | Line 71: | ||
---- | ---- | ||
- | ===== Command line mount ===== | ||
<code bash> | <code bash> | ||
- | sudo mount -t cifs -o username=peter,password=xxxxxxxxxxxxxxxxxxxx,uid=peter,gid=peter, | + | sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g), |
</ | </ | ||
+ | |||
---- | ---- | ||
+ | |||
Line 88: | Line 85: | ||
===== fstab persistent mount ===== | ===== fstab persistent mount ===== | ||
- | Quick basic example of a cfis mount entry in fstab to connect to shares | + | Permanently |
- | Permanently mount the shares so that they will be available after reboot. | + | ==== Edit the host file ==== |
Edit your **/ | Edit your **/ | ||
Line 100: | Line 97: | ||
</ | </ | ||
- | Next create | + | ---- |
+ | |||
+ | ==== Create mount points ==== | ||
+ | |||
+ | Create | ||
<code bash> | <code bash> | ||
Line 108: | Line 109: | ||
</ | </ | ||
- | Make sure you have cifs installed. | + | ---- |
- | Edit **/ | + | ==== Edit /etc/fstab ==== |
+ | |||
+ | Edit **/ | ||
<file bash / | <file bash / | ||
Line 117: | Line 120: | ||
// | // | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | ** NOTE:** If the system complains add the ' | ||
+ | </ | ||
---- | ---- | ||
- | ==== Mount the shares | + | === Mount the shares === |
<code bash> | <code bash> | ||
sudo mount -a | sudo mount -a | ||
</ | </ | ||
+ | |||
+ | or Reboot. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Extended fstab settings ===== | ||
+ | |||
+ | Make the following entry in your /etc/fstab file : | ||
+ | |||
+ | <file bash / | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | Now when the share is mounted all files and folders will appear as the user with uid 1000. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <WRAP info> | ||
+ | **__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: | ||
+ | |||
+ | |||
+ | <file bash / | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Extende fstab to assign full permissions to newly created files and directories ===== | ||
+ | |||
+ | Add these lines to / | ||
+ | |||
+ | <file bash / | ||
+ | ... | ||
+ | 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. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Hide Credentials ===== | ||
+ | |||
+ | 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). | ||
+ | |||
+ | <code bash> | ||
+ | sudo mount -t cifs //nas/docs / | ||
+ | </ | ||
+ | |||
+ | Note the **credentials option** | ||
+ | |||
+ | <file bash / | ||
+ | username=peter | ||
+ | password=[REAL PASSWORD] | ||
+ | domain=WORKGROUP | ||
+ | </ | ||
ubuntu/samba/mount_a_windows_share.1575836278.txt.gz · Last modified: 2020/07/15 09:30 (external edit)