Setting up Samba

From ArchWiki

Jump to: navigation, search
i18n
Dansk
German
English
Czech
Romanian
简体中文
正體中文
Italiano

NOTE:This is more of what I have done to get SAMBA working on my machine. I am not going to guarantee that it will work for you.

First of all - make sure you have the workgroup of the home network you wish to share over. This will come into play later.

Next install samba.

pacman -Sy samba


Now - to share the actual data. Still as root, change to the directory which holds the smb.conf file (This file holds samba's configuration settings as well as the share information)

cd /etc/samba

During the Samba installation a default configuration file is saved. Make a copy of this file. The configuration file smb.conf will be used by Samba.

cp smb.conf.default smb.conf

Now begin editing the file

nano smb.conf

The first section is the Global Parameters section. This refers to the "blanketing" options for Samba - much of your editing will be done here. Here is my smb.conf's Global Parameters Section for reference:

#Global Parameters
workgroup = HOME
netbios name = Bennett-DSLIN
encrypt passwords = yes

The workgroup name is what it says it is, what workgroup you want this machine to be a part of. (The default in Windows XP is MSHOME and WORKGROUP.)
The "encrypt passwords" option should be kept at "yes". This may change if your other machine runs Windows 95 or Windows 98, as their earlier builds use unencrypted passwords,
The "netbios name" is how you want this machine to appear in the "Network Neighborhood" (or "My Network Places" in Windows XP).

Now to set up the shares. The simplest share would be one in which the user can access and write his own home folder.

[homes]
browseable = no
read only = no

If you want everyone to see the files, but only certain groups to be able to write (say everyone can view, but only the staff group can write) then the section would look like this:

[homes]
public = yes
writable = yes
write list = @staff

If you want regular Windows users to see a "clean" home page (and not be confused by all those dot files (e.g. ~/.bashrc), then the section would look something like this:

[homes]
path = /home/%u/smb
browseable = no
read only = no

Be sure to add 'smb' to everyone's home directory. Also add 'smb' to the /etc/skel folder so all new users get an 'smb' added to their home directory, automatically:

 mkdir /etc/skel/smb

Moving on to shares other than the home directory isn't much harder, as there are really only two more commands that did not apply to the homes. These are the path command and the valid users. Looks like this:

[music]
path = /mnt/windows/Music/
browseable = yes
read only = yes
valid users = Bryan, Michael, David, Jane

The Path is obviously where on the harddrive the share is. Pretty simple, no?
The valid user command lets Samba know which users have the ability to even log in to the share. Again - pretty simple, although this creates a bit more work for us. Please keep in mind that these user names MUST coincide with users on the linux box and SHOULD coincide with users on the Windows box.


Once the smb.conf file is set up as you want it, save and exit the editor. (This is Ctrl+O in nano, followed by Ctrl+X)
Next We have to add the "valid users" to samba's user list. Do this by issuing

smbpasswd -a <username>

Follow its instructions, creating the password to be the same as the Windows password, and the user name the same as the Linux user. Once you have finished adding users, You are done (mostly).

If you have not done so - start (or restart) the samba daemon by issuing the following as root:

/etc/rc.d/samba stop
/etc/rc.d/samba start

Now - run upstairs to the other computer (or wherever it is ) and reboot. When it boots back up, login as one of the "valid users" and attempt to access your shares. You will need the password from the smbpasswd step to do so.

If everything worked out you can add samba to your DAEMONS in /etc/rc.conf

 DAEMONS=(syslog-ng network ... samba ...)

[edit] Links

  • Samba Samba (German) (archlinux.de)
Personal tools