❚

7–10 minutes

reading

·

Installing Samba Server on Ubuntu

I’m putting this here almost for my own reference, but hopefully to help others.

I’ve installed Ubuntu on an old netbook that was too slow. All I want to do is set it up as a file server on my wireless network. This is proving most challenging, but I’m learning a lot. The biggest problem I’m having is not understanding tutorials, because they often skip steps that they take for granted.

I don’t know ANYTHING. I’m battling through this with no knowledge or experience.

By adding to another tutorial I found, hopefully this will be literally a dummy’s guide for installing Samba on Ubuntu. The original tutorial is on How-To Geek. Their steps are in the bullet points; my notes are in [square brackets].

  • If you want to share files between your Ubuntu and Windows computers, your best option is to use Samba file sharing.
  • To install, first open a terminal window and enter the following command:

[To open a terminal window, press Ctrl-Alt-T or search for the application “Terminal”. Once you’re running it, a window will pop up that’s black with a blinking white cursor. This is where you write the stuff they suggest.]

sudo apt-get install samba smbfs

[Now apparently this sudo thing is like some sort of “I’m doing something serious now” command and the apt-get install thing is the action – samba smbfs would be the application itself (I’m guessing). Sometimes it will ask you for a password so it can get on with its “something serious”. If that happens, you just type in your system password and it happily keeps processing.]

  • We’ve got Samba installed, but now we’ll need to configure it to make it accessible. Run the following command to open the configuration file, substituting your editor of choice:

[For some reason the damn thing isn’t finished or something and needs to be configured manually. By you. When you put in the following command (straight after the last one in the black window with the white cursor) it will open a new window. This new window will just be code for configuration. Luckily, they’ve put in lots of explanations on how the configuration works. Unfortunately they’ve written it in Nerd. This whole “substituting your editor of choice” is unknown to me, but when I typed in the following command everything seemed to work.]

sudo gedit /etc/samba/smb.conf
  • Find this section in the file:

[Okay, there’s going to be a hell of a lot of code. The key is looking for the “####### Authentication #######” bit. There will be heaps of sections in the config file (the pop-up with code) and each one is like a box with hashes around it. Find the box with the Authentication heading and the text below. It will be somewhere near the top, so it shouldn’t take too long.]

####### Authentication #######

# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
# in the samba-doc package for details.
;  security = user
  • Uncomment the security line, and add another line to make it look like this:

[Alright, now, because the boxes I was talking about above are not part of the code, they need a way to be distinguished from code lines. This is the hash. Wherever a hash starts a line, it means it’s a comment and can be ignored. In fact, putting a hash in front of a line is called “commenting”. So where you are asked to “uncomment”, it means to remove the hash – or in this case a semi-colon. Once the semi-colon is removed and the extra line is added beneath, it will look like this:]

security = user
username map = /etc/samba/smbusers

[When you’ve added these lines, you then have to save the file. I found an icon in the top bar of the pop-up window that said Save, so I went with that. After it’s saved, I closed the box (X in the corner) and it went straight back to the prompt and the white cursor.]

  • This will set Samba to use the smbusers file for looking up the user list.

[Samba works out who can use it based on a table that is a user list. In this command, I think what you’re doing is telling Samba to use the table you have provided for the users.]

Create a Samba user

  • There are two steps to creating a user. First we’ll run the smbpasswd utility to create a Samba password for the user.
sudo smbpasswd -a <username>

[This is where I came off the rails. So, you’re using the sudo thing again, that’s fine. I think it’s trying to run the “smbpasswd” utility and adding someone called <username>. I found out the hard way that the name in the “<>” should be replaced by your actual username. So here’s what I did.

I went into the search and typed in “user”. It showed me an app called “User Accounts” and I clicked on it. When the new screen opened, it had my user on it (me). So I used the same username.

For example, if my username was Jerry, I would type “sudo smbpasswd -a Jerry” and then hit enter.

When I did this, it first asked me for my sudo password, which I put in (as discussed above).

Then it asked me for my “New SMB password:” – I used the same password as the system password. I hope this doesn’t cause problems. It seemed to accept it. It then asked me to “Retype new SMB password:” so I typed the same password again. It then gave me a message saying it had “Added user Jerry.” (if I had used Jerry as my username).]

  • Next, we’ll add that username to the smbusers file.
sudo gedit /etc/samba/smbusers

[Remembering from before that the smbusers file is the table that has the users in it, I kind of got where this was going. The sudo I’m now familiar with, but I don’t know what gedit is – I think it allows you to edit a file, because a new window opens that looks like a text box.]

  • Add in the following line, substituting the username with the one you want to give access to. The format is <ubuntuusername> = “<samba username>”. You can use a different Samba username to map to an Ubuntu account, but that’s not really necessary right now.
<username> = "<username>"

[This blows my mind. Since the file is empty, you’re creating the first line. There’s no need to do anything apart from type the one line, save it and close the pop-up window. Then you can head back to the prompt and the white cursor for the next command.

What to write is the hard thing. If you did what I did and used the system username for the Samba username, this gets kind of easy. Using my previous example, you would type: Jerry = Jerry

If you used different usernames, then the system username (ubuntuusername) goes first and the proposed Samba username goes on the other side of the equals sign: Jerry = SambaJerry]

  • Now you can create Samba shares and give access to the users that you listed here.

[And that’s the end of the tutorial! Apparently that’s all you need to do.

Next, though, is the next step of the process – sharing files. That original tutorial is also on How-To Geek.

Hopefully you’ve left your Terminal window up – you’ll still be using that.]

  • To share the home directories, open up smb.conf with the following command:

[The command below will open up the configuration file (pop-up window). It’s the same one you opened before with all the code in it.]

sudo gedit /etc/samba/smb.conf
  • Find this section of the file, and make it match the following:

[This time, instead of looking for “Authentication”, you’re looking for “Share Definitions”. It’s the very last one, so it’s right at the bottom.]

#======================= Share Definitions =======================

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
[homes]
comment = Home Directories
browseable = yes

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server. Un-comment the following parameter
# to make sure that only "username" can connect to \\server\username
valid users = %S

# By default, the home directories are exported read-only. Change next
# parameter to 'yes' if you want to be able to write to them.
writable = yes

[The “uncommenting” is done by removing the semi-colon against “[homes]”, “comment = Home Directories” and “browseable = yes”. You’ll also need to change the no to yes on the browseable one.

On mine, instead of “writable = yes”, I had “read only = yes”, so I changed it to “no” and I assume it means the same thing. Maybe it’s a version thing. The read only section still had the same comment in front of it, though. I just removed the semi-colon and changed it to “no”.

A bit further down I found the valid users thing and took out the semi-colon in front of it as well. That was the last change, so I saved the file and closed the pop-up window.]

[Once the above is complete, you can shut down the Terminal window. I also restarted my machine just in case. (Don’t know if that helps or not.)]

  • Now you should be able to map a drive on Windows using the following share format:
\\ubuntumachine\username

And that’s how the tutorial goes. However, it didn’t work for me. I still can’t get Samba to run.

I’m actually going to try other things now – I’ll see how it goes.

This post was originally published on the Myriad Projects blog and has been brought across to Kraken Shift to preserve it.

Comments

Leave a Reply