Thursday, December 15, 2011

Sharing files

Sharing files should be a piece of cake?  Right click, select sharing, enable, done.

Well almost. First off, samba is not installed by default with my distro (Ubuntu 11.10), but Ubuntu kindly offers to install samba the first time you click file sharing. And if you are the only user on the box, then that's it. Piece of cake.Hooray!

However, if you have another user, then you enter into the murky CLI territory for which Linux is so famous. But in this case the command is easy. All you have to do is add the user to the sambashare group using the usermod command. As always read the man pages completely before trying any hack (man usermodman sudo), then hit ctrl-alt-T and presto, a terminal window will appear. Then enter the following command, if you dare.

$ sudo usermod -a -G sambashare

I've used the sudo command many times blindly following the directions posted online, without really appreciating how powerful this command is. Even more power is the su command (man su) which can seriously mess up your system if you're like me and don't know what you're doing. In this case sudo just says run the following commands as root, and prompts you for your password before running the command. Therefore you must be logged in as an administrator for this to work. Then the usermod command modifies the user. In this case I used the -a option with the -G option to append the user to a supplementary group. I don't wan't the user to be removed from it's current groups so that's why I have to use the -a option. If I only used the -G option, the user would be removed from any group it was currently a member of that was not listed following the -G option. I know, tricky, right?

When I first tried to share the public folder in the other users home I get a warning message, that I do not own the file and so I can't share it. But if I wanted I could edit the global smb.conf file to force sharing even if I don't own it. Really, that's way too much work. Logging in as the other user, who is not an administrator, gave me another clue about what to do. It says can't enable file sharing because the user was not a member of the sambashare group. Ubuntu actually said to ask the administrator to add me to the group. Then of course, as you are doing now, I went to the internet, and tried to find out how to do this. But first I managed to totally mess up my system by running su without the -c option for commands. How I have managed to not totally brick my Android is beyond me. Luckily there is a file system checker that fixed my errors. Again friendly Ubuntu tells you what to do, but I'll save that for another post.

No comments:

Post a Comment

Fork me on GitHub