Create Samba Shares from Thunar

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
altair4
Level 20
Level 20
Posts: 11447
Joined: Tue Feb 03, 2009 10:27 am

Create Samba Shares from Thunar

Post by altair4 »

Note: This isn't new folks. The original was moved to the wrong subsection of the forum and subsequently locked and I cannot convince anyone to place it back where it was originally.

Create Samba Shares Directly from Thunar

Once upon a time Thunar had a plugin called thunar-shares-plugin which resembled nautilus-shares in Gnome allowing the user to create samba usershares directly from Thunar itself without using any other utility. Thunar-shares-plugin is broke. It's not offered in Xubuntu because it's broke but it is available in Debian presumably because they don't know it's broke. This is my feeble attempt to bring some of that functionality back to Thunar using "User Custom Actions".

Note: To those who are unfamiliar with this type of share it's what Samba refers to as a "Usershare". It's designed to allow any user to create a samba share of any folder he owns without becoming root. The share definition it creates is not in /etc/samba/smb.conf like Classic- shares but in /var/lib/samba/usershares. For more on userhsares: http://forums.linuxmint.com/viewtopic.php?f=42&t=23169

Remember folks Mint no longer installs the samba server package by default so you need to do that first:

Code: Select all

sudo apt-get install samba --install-recommends
Thunar Shares

Open Thunar and Select Edit > Configure Custom Actions > +

Basic Tab:
Name: Samba Public Read Only
Command:

Code: Select all

net usershare add %n %f "" Everyone:R guest_ok=y
Appearance Conditions Tab:
Make sure only Directories is enabled.

Restart Thunar and right click a directory in your home folder, say Documents, and select "Samba Public Read Only". To check if it has done it correctly run the following command to see the share definition:

Code: Select all

net usershare info --long
It should look like this if it's done it correctly:
[documents]
path=/home/altair/Documents
comment=
usershare_acl=Everyone:R,
guest_ok=y
I will list all the possible permutations here. Just use the same procedure as outlined above:

Samba Public Read Only

Code: Select all

net usershare add %n %f "" Everyone:R guest_ok=y
Samba Public Writeable

Code: Select all

net usershare add %n %f "" Everyone:F guest_ok=y && chmod 777 %f
Samba Private Read Only

Code: Select all

net usershare add %n %f "" Everyone:R guest_ok=n
Samba Private Writeable

Code: Select all

net usershare add %n %f "" Everyone:F guest_ok=n && chmod 777 %f
Samba Share Remove

Code: Select all

net usershare delete %n && chmod 755 %f
The use of User Custom Actions that I've outlined above reproduces only half of the functionality of nautilus-shares:

What it can do:
Create a samba usershare.
Change permissions on the target folder allowing write access to samba clients.

What it can't do:
Nautilus-shares and Thunar-shares had a GUI which showed you available options and those you have already selected.
Nautilus-shares but not Thunar-shares changed the folder icon to show you that the folder was shared.
Last edited by altair4 on Thu Dec 07, 2017 8:56 am, edited 1 time in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
brvcf
Level 2
Level 2
Posts: 54
Joined: Fri Sep 08, 2017 10:44 pm

Re: Create Samba Shares from Thunar

Post by brvcf »

This did not work for me in XFCE 18.2 until I did

Code: Select all

sudo apt-get install samba --install-recommends
which makes no sense because previous to trying to make a share in Mint I had no problems accessing Windows shares from Mint.
altair4
Level 20
Level 20
Posts: 11447
Joined: Tue Feb 03, 2009 10:27 am

Re: Create Samba Shares from Thunar

Post by altair4 »

Yes, I keep forgetting Mint doesn't install samba by default any more. I'll add another step to the main HowTo. Thanks.
which makes no sense because previous to trying to make a share in Mint I had no problems accessing Windows shares from Mint.
Two different sambas. The samba server package samba is no longer installed by default in Mint. I'm guessing they think no one uses Windows or MacOS. The samba client package - actaully only a samba client library not the whole thing - is installed by default most likely because it's a dependency of gvfs-backends. It's the samba client that can access your WIndows shares.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
brvcf
Level 2
Level 2
Posts: 54
Joined: Fri Sep 08, 2017 10:44 pm

Re: Create Samba Shares from Thunar

Post by brvcf »

Yes, I keep forgetting Mint doesn't install samba by default any more. ...
You know we criticize Microsoft for changing things for apparently no good reason so that some well-established procedure doesn't work any more. This is one of the things (along with the whole forced and flaky update debacle) that really ticked me off about Windows 10 and helped push me to get serious about Linux.

I think Linux developers (especially of distributions such as Mint that are promoted as replacements for Windows for the average user) have to be careful to avoid that wherever possible.

One of the things that I find most frustrating about trying to find out how to do something in Linux is that there is no comprehensive documentation for any distribution, so you have to search forums and such. You get all kinds of results which may or may not apply or be correct. You have to look very carefully at the date of the answers as well as the details of the distribution even within the same family (i.e. Mint XFCE with Thunar vs. Mint Cinnamon with nemo, etc.) and is it for 12,13,14, 15,16,17,18, ....
MtnDewManiac
Level 6
Level 6
Posts: 1491
Joined: Fri Feb 22, 2013 5:18 pm
Location: United States

Re: Create Samba Shares from Thunar

Post by MtnDewManiac »

altair4 wrote: Thu Dec 07, 2017 8:54 am Yes, I keep forgetting Mint doesn't install samba by default any more. I'll add another step to the main HowTo. Thanks.
which makes no sense because previous to trying to make a share in Mint I had no problems accessing Windows shares from Mint.
Two different sambas. The samba server package samba is no longer installed by default in Mint. I'm guessing they think no one uses Windows or MacOS.
Or perhaps Clem (et al) feels that those who do use one of those other OS do not constitute the majority of users? If so, it would make sense (IMHO) to include the package in our repositories for those who do require it, but to not install it by default on every user's system.

I have not tried to get my (Mint) system to talk to one of Microsoft's since Mint 14 was still the newest version. I would like to, at some point, if I can ever get that old computer to boot again (graphics card seems to have issues, and the power supply is very close to being dead (if that has not already happened)). I suppose that means I'll have to install - or set up some things - on both computers. I do not intend to serve TO the Windows computer; I only hope to be able to pull some files off of it, if it is not too late to do so.

Would I still need to install the Samba server stuff if I only intend to download from the Windows computer? I'd like to be able to boot the Windows machine (assuming it will, which is questionable) and leave it running for the few minutes at a time it could handle (when it booted) before overheating or whatever it was that kept causing it to die on me under use - and then return to my linux laptop and do all the file transfers (downloads) from there.

Thanks in advance! And thank you, in general, for posting this help thread.

Regards,
MDM
Mint 18 Xfce 4.12.

If guns kill people, then pencils misspell words, cars make people drive drunk, and spoons made Rosie O'Donnell fat.
altair4
Level 20
Level 20
Posts: 11447
Joined: Tue Feb 03, 2009 10:27 am

Re: Create Samba Shares from Thunar

Post by altair4 »

Would I still need to install the Samba server stuff if I only intend to download from the Windows computer?
Your question really has nothing to do with this Tutorial but ...

Like most things Samba the answer is: it depends. You do not need to install anything on Linux to access a windows box but you must create a share on the Windows box first and then connect to it from Mint. You may find it easier to install samba on your Mint box, create a share, then "push" the files from Windows to Mint rather than "pulling" the files from Windows to Mint.

Given the fragile nature of your Windows box you might want to consider something entirely different: HTTP. There is something in the repository called "droopy" that might be of interest: viewtopic.php?f=150&t=223787&p=1178942#p1178942

It sets up a baby temporary http server on the Mint box with it's own web page that allows you on Windows or any other OS to use your Internet Browser to "upload" files to Mint. The problem here is that we are talking about files not folders. In order to use Droopy with a directory you would need to archive it - zip file for example - and upload that.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
MtnDewManiac
Level 6
Level 6
Posts: 1491
Joined: Fri Feb 22, 2013 5:18 pm
Location: United States

Re: Create Samba Shares from Thunar

Post by MtnDewManiac »

altair4 wrote: Sun Mar 18, 2018 12:04 pmYour question really has nothing to do with this Tutorial but ...
In that case, thank you even more for responding. I will refrain from posting more in this thread, and will start a new one if/when I get that old desktop to power up and boot (it will probably be next month when I make the attempt).

You have given me some additional ideas. You also ended up reminding me of a little thing called tiny server, simple server, something like that which Steve Gibson (IIRC) wrote years ago for the Microsoft OS environment, and I may end up looking for that and running it on the Windows box. Ideally, I'd like to "open up" everything - the "C" drive along with some additional internal hard drives installed in that computer - for sharing, but (obviously) only to the other computer accessing the same router. And then to be able to do everything from the (Mint) laptop.

Again, thank you. I hope you leave your reply to me in this thread up, in case the additional information you've provided can help others (even though it isn't directly related to your original tutorial post).

Kind regards,
MDM
Mint 18 Xfce 4.12.

If guns kill people, then pencils misspell words, cars make people drive drunk, and spoons made Rosie O'Donnell fat.
PromZA
Level 1
Level 1
Posts: 3
Joined: Fri Jun 16, 2023 2:02 pm

Re: Create Samba Shares from Thunar

Post by PromZA »

This does not work with drives. I'm not sure if that's correct as it gives the option but does nothing.
altair4
Level 20
Level 20
Posts: 11447
Joined: Tue Feb 03, 2009 10:27 am

Re: Create Samba Shares from Thunar

Post by altair4 »

To be honest I'm surprised after all this time that it works at all - which it does.

Anyhoo, you know the drill: Please post the output of the following commands:

Code: Select all

testparm -s

Code: Select all

net usershare info --long

Code: Select all

hostname
And in your original post what does this mean:
This does not work with drives.
What's a "drive"?
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
PromZA
Level 1
Level 1
Posts: 3
Joined: Fri Jun 16, 2023 2:02 pm

Re: Create Samba Shares from Thunar

Post by PromZA »

A drive like the root folder of a harddrive or flashdrive. Yes it works, sort of. Seems you have to run Thunar as root. But I get access is denied and need permission errors from the windows side even when mapping as writable. But I can live with that for now as long as I have access to my stuff. :)

EDIT: Seems this only works with removable media mounted at /media/a. Anything above I can't access at all.

Code: Select all

Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
WARNING: The "syslog" option is deprecated
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
Server role: ROLE_STANDALONE

# Global parameters
[global]
	dns proxy = No
	log file = /var/log/samba/log.%m
	map to guest = Bad User
	max log size = 1000
	obey pam restrictions = Yes
	pam password change = Yes
	panic action = /usr/share/samba/panic-action %d
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
	passwd program = /usr/bin/passwd %u
	server role = standalone server
	server string = %h server (Samba, Ubuntu)
	syslog = 0
	unix password sync = Yes
	usershare allow guests = Yes
	idmap config * : backend = tdb


[printers]
	browseable = No
	comment = All Printers
	create mask = 0700
	path = /var/spool/samba
	printable = Yes


[print$]
	comment = Printer Drivers
	path = /var/lib/samba/printers

Code: Select all

[E6C9-CBC3]
path=/media/a/E6C9-CBC3
comment=
usershare_acl=Everyone:F,
guest_ok=y

Code: Select all

a
Last edited by PromZA on Fri Jun 16, 2023 3:58 pm, edited 1 time in total.
altair4
Level 20
Level 20
Posts: 11447
Joined: Tue Feb 03, 2009 10:27 am

Re: Create Samba Shares from Thunar

Post by altair4 »

A lot has happened in 6 years.

Your partition is mounted at /media/a/E6C9-CBC3 I'm going to guess that your Mint user name is "a".

The system creates special permissions to the /media/$USER ( in your case /media/a ) folder such that only "a" will get past it.

Your share is set up as a guest accessible share. "guest" is not "a" so it will never get to the E6C9-CBC3 folder.

But you can force it to:

Edit /etc/samba/smb.conf and right under the workgroup = WORKGROUP line add this one:

Code: Select all

force user = a
THen restart samba:

Code: Select all

sudo service smbd restart
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
PromZA
Level 1
Level 1
Posts: 3
Joined: Fri Jun 16, 2023 2:02 pm

Re: Create Samba Shares from Thunar

Post by PromZA »

This does work thank you.
And thanks for the tutorial. :)
Post Reply

Return to “Tutorials”