This is an old revision of the document!
Windows (SMB, CIFS) shares can be accessed in various ways from a modern Linux desktop, but if you want everything (such as rsync) to work (most) all of the time, it's best to just mount the Windows share to a local mountpoint. Then, regardless of the type of access you desire, you just access the filesystem as if you were browsing local files.
You can use the fstab
file and automount the SMB shares on bootup, but this method forces all access to the Windows share as a particular user regardless of which user is actually accessing the Windows share. It kind of goes against the grain…
So, sometimes it's best to just run a script as a user logs in to mount the Windows share as that user.
Ubuntu users may need to install the smbfs
package.
sudo apt-get install smbfs
Make sure the smbmnt
and smbumount
commands are setuid root.
As root:
chmod u+s /usr/bin/smbmnt chmod u+s /usr/bin/smbumount
Verify these commands are now setuid root:
ls -al /usr/bin/smbmnt ls -al /usr/bin/smbumount
These mountpoints need to be within the user's home directory to assure ease of access and the proper privileges.
As the regular user:
mkdir -p ~/mnt/sharename mkdir -p ~/mnt/sharename2
This script could be on the user's desktop, or most anywhere you want to put it. It should be owned by the regular user, have limited access and be executable.
Use your favorite editor to create a script named mymounts
(for example):
vi ~/Desktop/mymounts
Containing:
smbmount //server/sharename /home/regularusername/mnt/sharename -o dmask=0777,fmask=0777,password=smbpassword smbmount //server/sharename2 /home/regularusername/mnt/sharename2 -o dmask=0777,fmask=0777,password=smbpassword
Set the script permissions to protect your password and make it executable:
chmod 700 mymounts
If the script is on the user's desktop, they can just double-click it whenever they need access to the Windows shares. The mounts are persistent throughout the current login session.
In Gnome, you can have your script run automatically upon login like this:
System → Preferences → Sessions → Startup Programs → Add
Add the full path to the script:
/home/username/Desktop/mymounts