From ArchWiki
Jump to navigation Jump to search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end


Samba is a re-implementation of the SMB/CIFS networking protocol, it facilitates file and printer sharing between Linux and Windows systems or Linux to Linux systems as an alternative to Nfs. Samba is easily configured and operation is very straight-forward.


To install the Samba server, install the samba package

# pacman -S samba


As root, copy the default Samba configuration file to /etc/samba/smb.conf

# cp /etc/samba/smb.conf.default /etc/samba/smb.conf

Open the smb.conf and edit it to suit your needs. The file is well commented and provides many examples, it shouldn't be too hard to understand.

The default file creates a share for each user's home directory. It also creates a share for printers.

Starting the Daemon

Samba can be started with

# /etc/rc.d/samba start

Samba typically uses FAM to monitor the filesystem for changes. You will need to have the fam daemon started before samba. A better alternative is to use Gamin

Add samba to your DAEMONS line in rc.conf to start the daemon at boot

Adding Users

To log into a Samba share you'll need to add a user.

# smbpasswd -a <user>

The user must already have a account on the server. If the user does not exist you will recieve the error:

Failed to modify password entry for user "<user>"

You can add a new user to the system with adduser.

Accessing Samba Shares

KDE and Gnome have the ability to browse Samba shares. You therefore do not need any additional packages if using either of these DE's. If however you plan to use the share solely from a shell, you will need an additional package.

Accessing a Samba Share from Gnome

From a Nautilus window, hit Template:Keypress+Template:Keypress or go to the "Go" menu and select "Location..." - both actions will allow you to type in the "Go to:" blank. Enter smb://servername/share followed by the Template:Keypress.

Note: If you do not have your servername in your Template:Filename, you must use the IP Address of the server in place of the servername.



A variant of the above should also work in KDE.

Accessing a Samba Share from the Shell

You can also use smbclient to browse shares from the shell.

$ smbclient -L <hostname> -U%

Will list any public shares on the server.

For a GUI in the KDE SystemSettings you have to install the kdenetwork-filesharing package from Extra.

Mounting a Samba Share

To manually mount a share from the shell:

# mount.cifs //<hostname>/<share> <mount_point> -o user=<username>,password=<password>

To allow a normal user to mount and unmount a Samba share you can add setuid root to /sbin/mount.cifs. An alternative is to use the smbnetfs package.

Adding a Share to fstab

You can add a line to fstab like this:

//<hostname>/<share> <mount_point> cifs credentials=<credentials_file>,rw,user,noauto 0 0

Since fstab is readable by all users, we don't want to put our Samba password in this file. In this case we can use a credentials file that is only readable by you. This is a simple text file that contains:


The user option of the fstab line allows the owner of the <mount_point> to mount and unmount the share. The noauto option disables mounting at boot.

If you are adding a Samba share to fstab, you should also add the netfs daemon to rc.conf, somewhere after the network daemon. The netfs daemon will mount network partitions at boot and, more importantly, unmount network partitions at shutdown. Even if you are using the noauto option in fstab you should add the netfs daemon. Without it any network share that is mounted when you shutdown will cause the network daemon to wait for the connection to time out, consideribly extending your shutdown time.

Share files for your LAN without user and password

Edit default /etc/samba/smb.conf on the following lines:

security = user


security = share

If you want to restrict the shares data to a specific interface replace

;   interfaces =

to (replace eth0 to local network you want share to)

interfaces = lo eth0
bind interfaces only = true

if you want to edit the account that access the shares, edit the following line:

;   guest account = nobody

The last step is to create share directory (for write access make writable = yes):

[Public Share]
path = /path/to/public/share
available = yes
browsable = yes
public = yes
writable = no

Sample configuration file

The configuration that worked for me:

workgroup = WORKGROUP
server string = Samba Server
netbios name = PC_NAME
security = share
; the line below is important! If you have permission issues make sure the user here is the same as the user of the folder you want to share
guest account = mark
username map = /etc/samba/smbusers
name resolve order = hosts wins bcast
wins support = no
[public] comment = Public Share path = /path/to/public/share available = yes browsable = yes public = yes writable = no


If you are having trouble accessing a password protected share from Windows, try adding this to the /etc/samba/smb.conf Suggestion found here

client lanman auth = yes
client ntlmv2 auth = no

Getting a dialog box up takes a long time

I had a problem that it took ~30 seconds to get a password dialog box up when trying to connect from both Windows XP/Windows 7. Analyzing the error.log on the server I saw:

[2009/11/11 06:20:12,  0] printing/print_cups.c:cups_connect(103)
Unable to connect to CUPS server localhost:631 - Interrupted system call

I don't have any printer connected to this server, so I added this to the global section:

load printers = no
printing = bsd
disable spoolss = yes
printcap name = /dev/null

Not sure if all of them are necessary, but at least it works now.


See Also

More Resources