Jump to content

Installing Samba on Linux


Recommended Posts

***Setting up Samba on Linux***

Samba is a Unix/Linux application that adds SMB (Server Message Block) protocol abilities.  This protocol is used by many operating systems, including Windows and OS/2.  This guide will show how to set up Samba to allow a Unix/Linux machine to share files.

As an example... I set up Samba on a Bonzai Linux machine for use as a network file server for my home network.

For this guide, I am assuming:

  • You have Debian Linux or a Debian-based Linux Distribution installed (ex. Bonzai)<br>Note: this guide can be applied to other distributions, but file locations and commands may be different.
  • Your distribution sources list is set up properly
  • You know the basics of networking and sharing files
  • You are logged in as root
  • If you do not have the apt-get command, you know how to compile and make packages (links for Samba and SWAT downloads at the bottom)

# denotes commands typed in the shell

Several Samba related tools are available, for this guide I will only be installing SWAT (Samba Web Administration Tool), a web interface for configuring Samba.

Installing Samba

Samba only:

#apt-get install samba

Samba and SWAT:

#apt-get install samba swat

It will ask you a few basic questions about the Samba configuration, enter the correct information for your needs.

Create a directory to share

The following commands are only examples

#cd /home/user

#mkdir shared

Set up the password file

#cd /etc

#vim smbpasswd

Type :wq and press enter to save and quit

Configure Samba configuration file

(If you have KDE or Gnome installed, it may be easier to edit the config files from there unless you know how to use vi or vim)

The configuration file is typically located at /etc/samba/smb.conf

Sample configuration file:

netbios name = fileserver
server string = %h server (Samba %v)
smb passwd file = /etc/smbpasswd  [i]<-- edit this line[/i]
passdb backend = tdbsam, guest
passwd program = /usr/bin/passwd %u
passwd chat = *EntersnewsUNIXspassword:* %nn *RetypesnewsUNIXspassword:* %nn .
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
load printers = no
ldap ssl = no
invalid users = root [i]<-- recommended[/i]
valid users = user
admin users = user
write list = user
hosts allow = 192.168.0.,
hosts deny
map hidden = Yes

comment = Shared Files
path = /home/user/shared
read only = no
create mask = 0755
delete readonly = Yes
guest ok = no
case sensitive = no
[/code] The above sample file allows connections only from 192.168.0.* and sets up a shared folder at /home/user/shared with read/write permissions, accessible only by user.  It disallows root from accessing shared folders (recommended for security purposes) [b]Check the config file:[/b] #testparm [b]Restart the server for changes to take effect:[/b] #/etc/init.d/samba restart [b]Now that the configuration file is set up, add users.[/b] #adduser user [size=7pt](If the user doesn't exist already)[/size] Enter the requested information. #smbpasswd -a user [size=7pt](Note: user must be an existing user on the system)[/size] Enter the password at the prompt and press enter. [b]To map a drive from Windows:[/b] Right-click on My Computer -> Map Network Drive... -> Pick a drive letter, type fileservershared -> Check Reconnect at logon if desired -> Click Finish -> enter username and password when requested. Complete! Use SWAT to change settings and manage Samba at http://fileserver:901 Log in with username and password you set up, or root for full configuration access. Links: http://www.samba.org Download Samba Samba Documentation SWAT should be installed with Samba if you compiled Samba yourself. To set up SWAT, edit /etc/inetd.conf or /etc/xinetd.conf and add:
# Swat Samba Web Admin Tool
service swat
port = 901
socket_type = stream
wait = no
only_from =
user = root
server = /usr/local/samba/sbin/swat
log_on_failure += USERID
disable = no

(Code from http://www.geekspeek.org)

Guide written by php

Link to comment
Share on other sites

  • Create New...