Samba on Linux is A Mess
ฝัง
- เผยแพร่เมื่อ 26 ก.พ. 2023
- Today I talk about Samba and file sharing on Linux and why it kinda sucks.
👇 PULL IT DOWN FOR THE GOOD STUFF 👇
Patreon - / thelinuxcast
Liberapay - liberapay.com/...
TH-cam - / @thelinuxcast
===== Follow us 🐧🐧 ======
Discord - / discord
Odysee - odysee.com/$/i...
TILvids - tilvids.com/c/...
Mastodon- fosstodon.org/...
gitlab.com/the...
Subscribe at thelinuxcast.org
Contact us email@thelinuxcast.org
Telegram Group - t.me/+9lYoIuLh...
Amazon Wishlist - www.amazon.com...
Merch Store - zaney.creator-...
Logo Courtesy of - pedropaulo.net
==== Special Thanks to Our Patrons! ====
thelinuxcast.o...
#rant #linux #thelinuxcast - วิทยาศาสตร์และเทคโนโลยี
Want more Linux Content? Follow me on Mastodon! fosstodon.org/@thelinuxcast
I'm a long term Linux user, but perpetually a noob. I always thought my samba woes were unique to me! Thank you for this video!
I'm glad you said "hard" and not "broken". "Broken" seems to be the Linux TH-cam title word to use nowadays for anything that isn't working properly or has an issue.
What is wrong about calling things what they are?
The only valid question IMHO could be is if it's really Samba's fault or the users'. But in such an important matter and after so many years of development a software still not being even remotely user friendly, I think it's very justified to blame the issue for the biggest part on the software.
I first encountered SAMBA in OpenSUSE and found it quite nice 💪😎
I will give it a shot on other distros and make a general tutorial 🙏
Could be quite interesting
Using SMB/Samba was NEVER meant to be for Linux users among themselves. Samba is an attempt to provide a way for Linux to interact with a proprietary, patent encumbered, secret not full documented system used by Microsoft Windows. I think Linux users should be using NFS or SSHFS between systems.
I can appreciate that this may be the case, but what if users have little choice in dealing with a mixed environment, where not all systems are Linux?
@@curtdawe NFSv4 is vastly superior to SMB in every way. There are clients for windows.
@@milohoffman274 I am going to check that out. I spent a few hours wrestling with smb when I set up Debian as a NAS. It was out of habit. After a couple of hours of trying to configure the server and all of my machines it dawned on me that nothing I own is running Windows anymore. I had an nfs share up and secured in the time it took me to read where exports file was and how to secure based on IP range. I run windows 10 in KVM now and don't really want to run a samba server to easily share a directory with it....
samba has historically been so complex .. there's a lot of story about the development , I think initially was reverse engineered and then MS openned the specs.
I definitely understand about Samba and the complications of it. I authored how to set up Samba to work with Active Directory in 2003. I did this because people insisted it couldn't be done. The long and short, it took me 6 hours to even get the Samba part working. I got it to work and I published how to do it via the Gentoo forums. I haven't looked at Samba and Active Directory in years. If I ever lose my mind and decide to do it again, I would be starting from scratch.
Nemo! Good one!
Never used Linux until Feb 2021 with Ubuntu 20.04 on an Odroid XU4.
It took me about 1 hour EVERY day, watching YT tutorials and reading online articles, up to Feb 2024 to get a Samba share to work that I can access from Windows 10 (it works connecting from an old Vista PC too).
Still trying to connect from Mac 10.8.5 doesn't work (kept saying SMB not supported). Using VFS Fruit it now says share doesn't exist, even though I select it in the list of available shares.
So I think I'm nearly there, it must just be the fruit settings.
So yes, fully agree, there has to be a better way of doing it.
Setting up Samba is always a bit of a hassle - you would think this is something your distro could easily automate for you. But once you are done with the initial setup, the option to manage Samba shares through your file manager is something that has actually been available for a long time. Chances are good that there is already a plugin for this available for your favorite file manager, it's just that most distributions don't include it. On my computer, I can right-click on any folder in Nemo, choose 'Sharing Options' from the menu, and I get a friendly GUI pop-up where all I need to do is check a box for 'Share this folder', and I get a couple options for what access level I want to grant.
Even this does usually not work. There's not even the needed usershares directory created by many distributions and the needed permissiions/groups don'T exist.
This was very helpful, as I had no idea. Some of the comments are informative so you've certainly done me a favor. I've been intending to migrate from Windows since 2000 but it only became truly critical with the dreaded W10 and 11. Patience has its limits. 😉
Linux permissions are incredibly easy to understand if you just set everything to 777, security be damned
SFTP is the way to go. SAMBA is for sharing compatibility with Windows.
Great vid! As a recent convert from Windows to Ubuntu, it's ridiculous how many steps it takes to share a file between two computers on a LAN, that both run Ubuntu!
The 777 kind of permissions is not that hard. If you have used binary (which most programmers do/did) it's actually very easy.
Each of the three is a number which codifies the 3 flags: read, write and execute. This is called a bit field. In binary, that is, if you write a number in base two, the 7 is written as 111. A 6 is written 110. 5 is 101, 4 is 100, 3 is 011, 2 is 010, 1 is 001 and 0 is 000 (shocking, I know).
Now, basically each "digit" of that binary represents a flag, in our case, the first one is the read flag, the second one is the write and the last one is the execute. This order matters.
So, if you have read and execute, we have the 1st bit and the 3rd bit on, while the 2nd is off. So we write that 101. 101 in binary is 5. All flags on - that's a 7.
Also, you can simply remember that each bit, each flag, is a power of 2. The rightmost one is 2^0=1. Then the second rightmost one is 2^1=2. Then 4, then 8, 16 and so on.
In order to quickly compute, realize that any permission number is a unique sum of 1, 2 and 4 when you can use each only once. Or 0, if there's no permission at all. You see a 5 ? That's 4+1. 6 ? That's 4+2.
And here's the other part: read is 4, write is 2 and execute is 1.
And you have 3 numbers, because you have permission for user (owner of file), group (any user who's in the group specified by that file) and others (all other users which do not fit the owner or group matching). So 755 is 7 for owner, 5 for group and others. 7 is 4+2+1 which means the user has read, write and execute permissions. 5 is 4+1 which is read and execute.
An extra "shortcut": if it's bigger than 4, it has read permission. If it's odd (aka not even) it has execute permissions.
Hope this helps. If you do this mental math several times, I think, I hope that it will stay with you and you'll be able to instantly know the permissions. And knowing the binary part and the math might help you in other situations where there's bit fields, especially if they're longer. Though it's never required to know this properly if you don't do coding.
Edit: if it helps some more, here's the full table:
7 = 4 + 2 + 1 = read + write + execute
6 = 4 + 2 = read + write (no execute)
5 = 4 + 1 = read + execute (no write)
4 = 4 = read only (no write, no execute)
3 = 2 + 1 = write + execute (kind of weird, no read)
2 = 2 = write only (no read, no execute)
1 = 1 = execute only (no read, no write)
0 = no permissions.
In practice, only 0, 4, 5, 6 and 7 are used. Folders need to have the execute flag in order to "enter" them and see their contents, that's why folders usually have 755 or 775 permissions. For files (not folders) the execute flag is required if you want to run that file as an executable. Like "./muh_script.sh" . Though if it lacks that, it can be used as an argument, and sometimes that's enough. For example, with php, you can run "php whatever.php" without whatever.php having an execute flag
Exactly what I think and exactly my experience ("normal people don't want to deal with configuration files"), with file sharing on Linux. I can deal with Samba configuration, but why do I have to? Even though I know how to configure Samba, I'm still having problems. It shouldn't be that hard to get file sharing to work. I hate to admit that Microsoft has been doing it right, for decades, but that's the truth. It's super easy on Windows. Why can't it be like that on Linux? Great video.
Yeah remember setting samba up some months ago, it was quite unintuitive and frustrating, but somehow it all worked in the end and now I use it everyday
Some of the reason for its complexity is smb is a windows file sharing system. Samba is trying to convert permissions and users into a system that windows can understand. If you have no windows systems on your network then look into nfs. Nfs is the linux native file sharing protocol.
I’m so glad I found this video I thought I was a dummy having such a hard time getting samba to work
the permissions of Linux is easy if you know binary, 1 is executable(x), 2 is writable(w) and 4 is readable(r), so 644 is 6 = 4 and 2 so R,W and 4 = R so on. and then each number is a permission, owner, group, all users, so here owner got 6 and group 4 and all users 4.
Tiny correction. 4=R not W so 644 is RW for the owner, R for the group and R for everyone else. And as an aside X (execute permission) on a directory is for access to a directory. Without it you can't change into that directory.
By now at least in KDE Plasma file sharing with Samba works fairly well with Dolphin for users who want to use a GUI.
The whole permission thing with Samba is the absolute WORST!!! I really ran out of patience dealing with this. I wanted to setup an old laptop with a ~1TB HDD as a "simple server" on my network to use to exchange files between the multiple machines in my home (which - of course - use multiple different OSes), but I JUST CAN'T GET THE F###ING PERMISSIONS TO WORK OUT AS I WANT!!! Even though I'm 99.9% sure I did everything correctly - it's still a mess, and I don't get write access!!!
Now I just added a DAVFS share on it and I have basically a network share for my Linux machines - but my iPhone, my wife's Android and our Windows devices can't really access it. You can imagine how pissed I am.
There is an alternative but only for Linux networks: Good ol' NFS. But another part of the file sharing hot mess is tutorials of wildly varying quality. Also, like you mention, no two distros set up Samba the same. Indeed, no two PEOPLE set it (or NFS) alike. A prime example is my own NFS setup on openWRT. I was not able to have it auto-mount on startup, so I found a workaround. What I did was add a line to the /etc/init.d/rc.local file to run a script to get it going in the form of "/etc/autoexec.bat" containing:
sleep 5
mount /dev/sda1 -t ext4 /mnt/nfs
sleep 5
exportfs
The two "sleep 5" lines are to get it to make sure all the other config files are done first and then to make sure the mounting is done. I found the "exportfs" clue in an unlikely place: a rant posting about Samba explaining NFS is easier. NONE of the tutorials had THAT vital clue! The /etc/audoexec.bat (don't forget to chmod +x it!) is my own idea.
Samba is so easy to configure that i don't even use it for ages /s
I only use sftp (ftp over ssh) for file transfer, but also i don't use windows... My main issue is transfer speed, no mater what configuration option i do, it will always be downgraded: if i have a 100Mb network it will behave as if it is 10Mb, if it a 1Gb it will behave as if it was 100Mb... i lost all my geek patience trying to solve samba issues...
Lol you had me in the beginning
Just found this vid in mid-2024. The SMB struggles are still real. Dolphin and Nautilus have no issue connecting but the rest of the apps in Linux can’t access what the file managers see because they don’t mount the shares to local folders. So Davinci Resolve, KDEnlive and OBS become useless for my workflow. 😭
Linux permissions are dirt simple if you understand them. This was one of the things that I learned early on in my Linux journey. Linux uses something called additive permissions. All you have to remember is the numbers 4 2 1. Those are the numbers that represent read write and execute. When you're changing permissions on a file or a folder with chmod you always get a three-digit number. Those numbers refer to the permission's for the owner the group and everyone else. So the way you decipher the permissions such as 777 you look at each number individually and ask yourself what combination of 4 2 1 do you have to add together in order to get 7. And it's pretty cool the way it works out because there's only ever one combination no matter what. There's only one combination of read writing execute to get each number all the way up to seven. 0 means that there are no RWX permissions. 1 would mean that there are only X permissions. 2 would mean that there is only W permissions. 3 would mean that there are WX permissions. etc. there's literally only one combination of 4 2 1 to get any permissions. And you usually only see certain combinations because they're the only ones that really make sense in a usability standpoint. Like you usually will see 755 which means everyone has read and execute permissions but only the owner has write permissions. Because the 5s are an additive permission of read and execute and the 7 is a combination of read right and execute the 4 2 1 that we talked about earlier. But there are also permissions that you will never see because they make absolutely no sense for usability standpoint like 111 for example would probably make no sense at all because that just gives everyone execute permissions but how can you execute something if you have no way of reading it.
What about ACLs?
copied files from a windows share and they got padded with zeros up to 256kB on raspberry pi os arm32. i don't understand how that is possible. this happens when using the GVFS API but not when using the GVFS FUSE mountpoint.
tried the same with a fresh installed manjaro arm64 kde plasma and the downloaded files were zero padded again, but instead to 256kB they had 64kB now using the KIO API in dolphin.
can someone try to reproduce the zero-padding bug? is cifs or smb broken in general or just on ARM? that bug drives me nuts
Currently going thorough that myself.
I remember setting up small local shares on samba/ubuntu back around 2008 and it was not complicated.
Attempting the same today in a mixed environment due to the need to take my old win-svr offline and deciding to go with ubuntu samba.
Setting up a multi-share, multi-user mixed access privileges is proving to be a real pain. I would do NFS but can't due to being in a mx environment. But I may give it a try.
Sshfs might help you too.
Still can not conect to the shared folder on my Synology NAS.
Ive been using linux for more then 10 year and still have issues with SMB. I mostly stick with the Debian family of branches, mostly linux mint and ubuntu but i know that this is probably a smb issue and not linux issue. But thanks to these issues i've learnt to use the terrminal, smb.conf & fstab files like a boss
Man, I feel a lot better after watching this and checking the comments. I've been beating my head against a wall, for a couple of days, trying to get a basic filesharing VM spun up and working. Better take another look at the permissions:)
Samba is not a protocol, it's a Linux implementation for file / print services for the SMB/CIFS protocols (Windows). I, personally, will never have a use case for sharing file/print services with any M$ product (I've used Linux exclusively since 2003).
I use NFS, which (as anything new), has a learning curve. While not perfect, it's better than SMB/CIFS.
It uses the SMB Protocol.
I have only seen easy SAMBA on Puppy Linux but cannot find a GUI tool that comes close.
skip samba and mount over ssh with sshfs. It is much faster and (imo) more secure.
As much as I like Linux, Samba management is a massive cluster f**k. This is something that Windows does right, right-click folder->properties->share, done.
Great video bud, it's so confusing. I recently jumped on Fedora 37, set up samba as I have done so for years, including 35,36 Fedora, Ubuntu, arch. But for some reason I couldn't get it working under 37. Turns out that on 37 they changed the permissions with selinux. Anyway I disabled it and everything is working fine. But took ages because Fedora didn't mention any changes. But windows has become so much worse over the years.
Thanks. You hit the nail squarely on the head, pointing out the superiority of Windows over Linux for LAN sharing. I mirror your experience but not nearly as extensive as your's.
Hi, after many years with Windows 10, a few months ago I assembled my first computer with ryzen 5700x CPU and installed Debian testing and steam. On my laptops I have Devuan chimaera and Devuan Daedalus. I would like to use an old netbook to create a file server with samba.
I just set up samba on Debian using a config file chatgpt made and add a issue where I didn't make the user and then I asked chatgpt to fix it and it give a terminal command to add a user and then it worked for me
LMAO
Agree 100%. Samba is bad. NFS can be easy but security and id mapping is like voodoo. SFTP is ok to transfer files, not remotely work on them. I am certified in both Linux and Windows Server management and the permissions on Windows are also not the most user friendly.
I tried it on Fedora 39 and gave up. FreeBSD would in theory be nice because everything is uniform but tutorials for cerain niche configurations are few and far between because the userbase is so small.
Would there be a market for someone to write an install-time app that configured file-sharing? Like, set up Samba, ask you what you want to share, fix all the permissions, and so on? If so, who would write it (because I've got a day job!)...?
sftp works well, either from the command line or via Thunar and Nemo sharing files between computers running Mint, EndeavourOS, and Void OS. What's missing besides Windows compatibility?
Well friend, your missing is a major, major gulf for a typical mixed environment.
I’ve never used samba. I have three machines and I run syncthing which works fine so long as your hard drive isn’t encrypted. I sync between Arch and Debian with very little fuss.
I can see your argument for Samba but file sharing without Samba is actually quite easy using rsync, SCP or SFTP. If you wanna share files without the hassel than just make a script which sends files with rsync over ssh to the other machine and put it on a Cron job. I know you already use rsync for backups so it's way easier.
I should have been more specific, but I don't want to store the files in both places. I think that's the only way rsync would work.
@@TheLinuxCast actually I just remembered that sshfs exists, this might be what your looking for, it allows you to mount remote filesystems through ssh without duplication like rsync.
@@the_linux_legend6199 Not only that. I use SFTP with my filenamanger (worked in Dolphin previously and now Thunar). I have access to the file structure just like any other filesystem on my host through SFTP. There is no need for rsync and is my preferred way to access Steam Decks system.
The good thing is, SSH is standard and setting up should not differ from every distro. So yes, I highly recommend looking into SFTP / SSHFS. Plus I have remote access through SSH too as a bonus. Meaning I can use pacman or flatpak commands on the device remotely in example.
Thanks Matt
I hate setting up SAMBA, and the Linux permission system being a nightmare for newer users. It's far more secure than Windows's defaults, but it's not user-friendly. It's got to the point where I have a text document with a bunch of SAMBA and permission commands, because I can't remember them all.
i was almost understanding samba in Debian, and then i wanted to swap my server to RHEL... and then the nightmare started..
Samba seems to be just as broken on Windows, to be honest...
I tried samba a few days ago between Garuda and windows 11 and I couldn't figure it out. I tried several sites that said how and I did what they said but couldn't figure it out. I said f it. Maybe use a data/ethernet cable between my two laptops. I'm gonna try to get that working.
I use Samba because I need Windows and macOS to have access to the file server, and Samba is the easiest way to do so, at least for me.
Which Linux distro. did you go with?
@@curtdawe I'm a long time Slackware user, been using it for 17-18 years. Edit: I'm not doing the "try a different distro" challenge. I have several others in VMs.
In the past I used Samba and it worked well. On my Steam Deck Samba is not installed and it just did not work. But I found other ways through SFTP in the graphical filemanager.
what is the point of samba? isn't ssh better
Well, I have used the same smb.config from my Windows NT server days and adapted it with a Linux one I found and still use to today. In the last few years I have modified it a bit to work with Linux and windows but not all that much. Sure it is a pain to get Samba to play nice in Linux and Windows but not so much for me as I don't have Window running on my network. Sure all the comments say rsync, ssh, SFTP, with NFS and all that hooy but It can be done in SMB once you get it set up.
Sure setting up the permissions is a pain too. I (my chose) never use a fair wall with samba. It does nothing but cause issues and every distro 's fire wall is a beast of its own as you pointed out in your video!
Install the file share plugin for your file manager is a must.
Now don't expect to use that cute little "Network" in your file manager which kinda works with IP6 but IP6 is something else.
Instead when setting up your router's (what ever you use) use DHCP service it assigns a 192.268.1.xxx to all your computers right?
Just type that (192.268.1.xxx) into your file manager address bar to access that computer. Assuming you have Samba installed and a config on all the systems. Then save that link as a bookmark in your file manager. Samba and your config will manage the passwords etc in the background.
I may try to make a video on how I do it soon, maybe... Lol
LLAP 🖖
Matt - take a look at Warpinator. Easy-peasy.
Really the best solution is to just not use SAMBA. I user SSH/FTP/SFTP between my devices and those protocols are solid.
100% agree with you on that one.
Linux permissions are not a mess. Your difficulty to grasp them is a different thing. Also I am confused why you insist on using samba. Using ssh is super easy. Sending over sftp or mounting remote locations so you can use it in your file manager is easy with sshfs. You can use rsync with ssh...
No coding knowledge is needed for any of this...
Yes, because ssh is also very user friendly. People wonder why Linux has a reputation for only being used by nerds and people stuck in a terminal.
Edit: sorry, I've been very snappy today. Shouldn't have taken it out on you. but the point mostly stands.
@@TheLinuxCast No worries. I am an AH when writing comments myself so I do not mind it. But try focusing on ssh. It is now built in into windows, you can use it even with androids... Setting up ssh keys an making a config allows you to say: sshfs networkDevice:/ local/dir and that is it
Above sshfs command would mount it to your file system like a usb flash. Also about permissions. Separate the numbers to three parts. First digit is for yourself, second is for the group and third is for others. Then just learn how actions add up their values. You have shorthands like chmod +x to add execution permissions or -w to remove writing permission
@@TheLinuxCast Your point lands true for many of us. :)
You should tryout Syncthing or Resilio Sync.
Don't use Samba. Problem solved. SMB is for legacy MiscroSoft networks.
Have you tried NFS?
i just use syncthing
I don't want to store the files in two places.
@@TheLinuxCast yeah that makes sense, i use it for my cellphone and for that it's perfect.
NFS worked fine for me already a decade ago.
I find Warpinator to be quite sufficient.
Set up a nextcloud server and fileshare that way. Samba is aweful.
You just have to deal with linux permissions.
Openmediavault on a raspberry pi works great
Samba is the reason Linux is a no go for me. Windows is the far superior OS in regards to file sharing hands down. Linux could be good but in 2 years of working with it I've never once gotten Samba to work for shit. It's amazing how horrible a community can be at functionally explaining samba in the slightest. Linux permissions are another reason to NEVER touch Linux - it's what keeps it as a "hobbiest" OS
There are other options for file sharing on Linux that are far superior that I discovered after this video was made. SSHFS, which I've made a video on, is great. NFS too. scp for individual transfers works wonders, and there are a few others. All work WAY better than Samba even on its best day.
I use Samba to share files between Linux. Android and Windows (VM). Never had any issue and it was super simple to configure .
Which distro?
You are lucky so far.
Just don't use Samba tbh.
I only use samba for sharing with a Windows VM, so I can install games from stores that don't run on Linux (tho I run the games themselves on Linux).
For file sharing, I use NextCloud. Auto-sync between my devices and send a download link to others if they want the file.
Don't have to worry about weird Samba configs or permissions.
FileZilla anyone?
is not a mess, JUST USE KDE CONNECT....
I'd love to do this as a person with multiple devices, but yeah, it seems way too hard. Someday I might pony up the money to get an NAS.
Use warpinator to share files between devices
It’s called BitTorrent.
This conversation is like trying to convince these idiots that I am not in entertainment