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 links end
- 1 Introduction
- 2 Installation
- 3 Configuration
- 4 Accessing Samba Shares
- 5 Share files for your LAN without user and password
- 6 Troubleshooting
- 7 See Also
- 8 More Resources
Samba is a re-implementation of the SMB/CIFS networking protocol, it facilitates file and printer sharing between Linux and Windows systems.
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
Add samba to your DAEMONS line in rc.conf to start the daemon at boot
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.
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.
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.
A variant of the above should also work in KDE.
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.
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.
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.
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 = 192.168.12.2/24 192.168.13.2/24
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:
[global] 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
[global] # THE LANMAN FIX client lanman auth = yes client ntlmv2 auth = no