Samba: Practical Introduction to Linux Usershares on openSUSE 10.2, 10.3
There are two classes of Samba shares. This HowTo is about creating Usershares in openSUSE. Usershares are made by ordinary users on-the-fly without a need for root privileges. Classical shares have tailored security and are created by root.
Introduction: Usershares were introduced in Samba v3.0.23; In the openSUSE series usershares commence from openSUSE 10.2. Usershares allow non-root users to add, modify and delete their own shares. These on-the-fly actions require only one command in a non-root terminal. Or you can use the excellent and very simple GUI that has been designed into the Nautilus file manager to allow sharing by right-click. KDE's Konqueror does not have a similar facility to date in openSUSE. Usershares made in Nautilus are a low security share so if security is an issue for you, it's best to turn them on and off as required.
Installing Usershare Functionality in the Samba Configuration File: Samba's config file is a text file located at /etc/samba/smb.conf. It's made up of various paragraphs and the first paragraph, headed [global], contains the following code if you've got, e.g. a openSUSE 10.2, 10.3a default installation:
In openSUSE only some of the entries required for easy userhares are installed by default. Make sure you edit all of the following into the [global] paragraph of smb.conf:
Back up your smb.conf file before editing it: Make a quick&easy backup before you begin. Here's a one-line command in a non-root terminal to copy the file smb.conf from directory /etc/samba to a file e.g. smb.bak on your desktop for safe keeping:
It's a good idea to create a "backup" mentality.
Edit smb.conf with a text editor (e.g. Kwrite or Gedit): The Samba configuration file is a text file. In Windows files like these are edited with text editors, e.g. Notepad. In Linux it's the same. If you're using KDE you can use the "Kwrite" editor to open the file with this command in a terminal:
And if you're using Gnome you can use the "Gedit" editor like so:
When the file opens in your editor you simply inspect the [global] section (which will look like the first code-box above) to see which of the five necessary lines listed second above are missing - and type them in at the bottom of the [global] paragraph. Then save the file and exit.
Install the Usershare Working Directory: A separate configuration file is generated for each share that is created with usershare technology. In openSUSE, these configuration files are stored in the folder /var/lib/samba/usershares. This folder must have permissions 1770. You can create it in a root console like so:
Alternatively you can browse to /var/lib/samba in a superuser file manager and create the folder in a GUI. Here's a screenshot:
Do I Add Allowed Users to the Samba User Database? You can log on as a non samba user and browse and even create some usershares. But the experience will be frustrating and unproductive. The real answer is that you should be a member of the Samba user database, just as for classical shares. For more on Samba accounts see Appendix I in my tutorial on classical shares.
Creating a Usershare in the Nautilus File Manager/Browser: This Gnome tool is really easy. You can install it and use it in KDE too (Install nautilus and nutilus-share from Yast Software Management). You create usershares with a right click --> "sharing options" in Nautilus. Here are the self-explanatory pics:
The two Nautilus pics, one each for read-only and read-write reproduce the on-the-fly sharing that Windows offers. But remember that just like Windows, usershares are not secure so you might like to use Nautilus to switch them on and off as needs dictate.
I've done this research in openSUSE 10.2 and 10.3a. For both of those the premissions for the desktop (located at /home/username/Desktop) are drwx------, i.e. all guests and members of the group users other than the owner forbidden. This prevents you from making usershares on a desktop with the Nautilus facility. You can however make shares on the desktop with a simple non-root terminal command. See next section.
Tip: You need the package "nautilus-share" installed, the 4-line tweak to the [global] section of smb.conf mentioned earlier, and the folder /var/lib/samba/usershares installed with appropriate permissions before usershares can be created with Nautilus.
Creating a Usershare in a Terminal: That's really simple. Suppose you have a folder e.g. "folder" located at /home/username/folder and you want to share it. You want it to appear as "share_1" in network browsers. Just enter this into a non-root terminal to create the read-write share:
That's all there is to it! If you want the share to be read-only, instead of the term username:F use username:R. Windows clients can browse as guests if guest_ok is set to yes. Linux clients need to authenticate.
Removing/Switching-off a Usershare from the CLI: Enter this into a non-root terminal to remove a usershare from the network:
The on-the-fly ability to switch usershares on and off is useful for non-root users who are security conscious.
Can KDE & Konqueror Create a Usershare? THE SIMPLE ANSWER IS "NOT IN openSUSE 10.2 or 10.3". But Konqueror does have a right-click, on-the-fly sharing facility. The share that's generated is a classical Samba share, not the new technology usershare. Refer to tutorial: HowTo Configure Shares on a Linux File Server in a SOHO LAN.
That's all folks. Take it easy.
Swerdna: 24 February 2007