Using SAMBA
From MEPIS Documentation Wiki
Contents |
Introduction
If you haven't already, please read the Samba introduction in the File sharing page.
Method 1: Dolphin ( or Konqueror)
Dolphin can browse Samba shares in your network neighborhood directly. To browse the network, click the blue globe Network Icon on the Places Panel on the left side of the Dolphin window and then click "Samba Shares"; or type this into the address bar:
smb:/
To see the shares (i.e., shared resources) available on "workgroup", type this:
smb://workgroup
To get to a share called "share1" on the "workgroup" network, type this:
smb://workgroup/share1
To access the share as a particular user, type this:
smb://myUser@workgroup/share1
You can use the "create shortcut to URL" option in the KDE desktop right-click menu to make desktop shortcuts to Samba shares using URLs in this format.
CAVEAT: Some non-KDE programs, notably OpenOffice, do not do file management using kio URLs like smb://. In other words, you probably won't be able to directly open some kinds of files if you're browsing shares like this, you'll have to copy them down to your desktop first. Or use one of the other two methods that actually mount the share to a folder.
Method 2: Command line / Script
You can mount a remote share to any empty folder anywhere on your system (provided you have the appropriate permissions on the folder). This is useful to know if you want to create a "logon script" that will mount remote shares automatically, for example (You could put such a script in ~/.kde/Autostart/ to automount folders on logon). To mount the share "share2" on server "server2" to a folder in your home directory called "sambaShare" is:
smbmount //server2/share2 ~/sambaShare
NOTE: the tilde (~) is a placeholder that always means your home directory. If you have to use a username and password on the remote machine, you can specify username and password:
smbmount //server2/share2 ~/sambaShare -o username=myUser password=myPassword
Method 3: Start with a sample Script and modify it
You could use this along with method 3 to auto mount it - remember to test and use it in a non-production environment. Copy and Paste as needed. Note that this method only works if you logged into SimplyMEPIS with your User name and Password, if you bypass login with an automatic login then you need to use sudo for any commands that require root privileges in the script.
This is a sample script to mount a share
# The following line is the script interpreter we are using #! /bin/sh # # filename - mount-Public.sh # # a sample script to share resources located on Windows Vista #+ by David Rodriguez - mycomputerfixer.com # # freely distribute - this works in Linux SimplyMepis 6.5 # # this is a sample SMB mount script to mount a share #+ in Windows Vista onto a directory in Mepis #+ the (~) tilde symbol designates your home directory #+ so interpreted it would be as an example /home/David # # place this file in your Mepis home directory then click on it #+ or run it in the shell (terminal) from your Home Directory #+ by entering "./mount-Public.sh" without the quotes #+ - note - make sure you make it executable! # # to make it executable read the next line #+ do the following in konqueror: #+ set permissions by right clicking on the filename #+ - click the Permissions tab - then checkmarking the "is executable" checkbox # # use at your own risk #+ need more help - i charge 125.00 US per hour otherwise use of this script is free #+ for more information on scripting please refer to http://tldp.org/LDP/abs/html/ # # variables follow homedirectory=~/ # Don't change this one!, it points to your real Home Directory (Folder). targetdirectory=~/sambaShare4VistaPublic # change the targetdirectory here to whatever you like sourcedirectory=//VISTADEMO-PC/public # change the sourcedirectory here to whatever you like # end of variables # #code follows cd $targetdirectory # now let's see if this directory does not exist if [ "$PWD" != "$targetdirectory" ] # if the target directory does not exist then ... then sleep 1 # wait a second clear # Clear the screen echo " " # type this to the screen echo " The Target Directory $targetdirectory was not found." # type this to the screen echo " I will create it for you..." # type this to the screen cd $homedirectory # change directory to the home directory mkdir $targetdirectory # and create the local directory echo " " # type this to the screen echo " Directory creation is now complete." # type this to the screen cd $homedirectory # let's move to the home directory sleep 1 # wait a second # # Next we'll get the share and mount it to the target directory smbmount $sourcedirectory $targetdirectory -o username=Yourusername,password=yourpassword # change your username and password here # echo " " # type this to the screen echo " Please wait while I load the Target Directory." # type this to the screen # wait again cause you surely won't see an instant load - This time can optionally be increased for a slooooow computer sleep 3 # wait 3 seconds echo " " # type this to the screen echo " $targetdirectory should be open now" # type this to the screen echo " if not, then please be patient while I load it" # type this to the screen echo " some computers or networks are slower than others..." # type this to the screen kfmclient openURL $targetdirectory # now we can finally open the Share in Mepis else cd $homedirectory # let's move to the home directory sleep 1 # wait a second # # Get the share and mount it to the target directory smbmount $sourcedirectory $targetdirectory -o username=Yourusername,password=yourpassword # change your username and password here # # wait again cause you surely won't see an instant load - This time can optionally be increased for a slooooow computer # finally open the Share in Mepis echo " " # type this to the screen echo " Please wait while I load the Target Directory." # type this to the screen sleep 3 # wait 3 seconds echo " " echo " $targetdirectory should be open now" # type this to the screen echo " if not, then please be patient while I load it" # type this to the screen echo " some computers or networks are slower than others..." # type this to the screen echo " " # type this to the screen kfmclient openURL $targetdirectory # now open the target directory in konqueror fi # end of condition # end of code # there's no sense in going further so let's exit now exit 0 # end of script
This is a sample script to unmount a share
# The following line is the script interpreter we are using #! /bin/sh # # filename - unmount-Public.sh # # a sample script to share resources located on Windows Vista #+ by David Rodriguez - mycomputerfixer.com # # freely distribute - this works in Linux SimplyMepis 6.5 # # this is a sample SMB unmount script to unmount a share #+ in Windows Vista onto a directory in Mepis #+ the (~) tilde symbol designates your home directory #+ so interpreted it would be as an example /home/David # # place this file in your Mepis home directory then click on it #+ or run it in the shell (terminal) from your Home Directory #+ by entering "./unmount-Public.sh" without the quotes #+ - note - make sure you make it executable! # # to make it executable read the next line #+ do the following in konqueror: #+ set permissions by right clicking on the filename #+ - click the Permissions tab - then check marking the "is executable" check box # # use at your own risk #+ need more help - i charge 125.00 US per hour otherwise use of this script is free #+ for more information on scripting please refer to http://tldp.org/LDP/abs/html/ # # variables follow rootdirectory=/ # Don't change this one!, it points to your real root Directory homedirectory=~/ # Don't change this one!, it points to your real Home Directory targetdirectory=~/sambaShare4VistaPublic # change the targetdirectory here to whatever you like # end of variables # #code follows cd $targetdirectory # let's see if this directory exists if [ "$PWD" = "$targetdirectory" ] # if the target directory exists then... then cd $rootdirectory # go to the root directory so that the target directory can be unmounted sleep 1 # wait a second clear # Clear the screen echo " " # type this to the screen echo " The Target Directory exists..." # type this to the screen echo " Please wait while I unmount it." # type this to the screen echo " If you want to mount (open) this resource run 'mount-Public.sh'." # type this to the screen if [ "$(pidof konqueror)" ];then kill $(pidof konqueror) # if konqueror is running then kill it (unload) konqueror #+ - since the stupid share tab remains in konqueror even if the directory is removed fi # end of this condition smbumount $targetdirectory # unmount the local share sleep 5 # wait 5 seconds while the share is unmounted - the time can optionally be decreased rm -r $targetdirectory # remove the directory to avoid clutter # echo " Please wait while I load your Home Directory." # type this to the screen sleep 3 # wait 3 seconds kfmclient openURL # this line will load your home directory in konqueror clear # Clear the screen echo " " # type this to the screen echo " Your Home Directory $homedirectory should be open now" # type this to the screen echo " if not, then please be patient while I load it" # type this to the screen echo " some computers are slower than others..." # type this to the screen echo " " # type this to the screen else clear # Clear the screen echo " " # type this to the screen echo " Sorry $targetdirectory does not exist!" # type this to the screen echo " " # type this to the screen echo " If you want to mount (open) this resource please run 'mount-Public.sh'." # type this to the screen fi # end of condition # end of code # there's no sense in going further so let's exit now exit 0 # end of script
Method 4: SMB4K
SMB4K is a package designed to enable you to mount (and unmount) a share on a network drive.
See Smb4K wiki page for full details.