Search Engine

Loading

Sallar

Sallar
RedhatEnterpriseLinux Blog

Samba configuration Step by Step Part-1


Samba
Samba, which uses the CIFS/SMB protocol, is commonly brought up when you want Linux and Windows machines to be able to share files together. Aside from the file sharing uses, Samba also has some built-in functionality to run as a member server on a Windows domain, print server, or file server. Let’s get started with the setup.


Step 1. Install the required packages for Samba:
# yum install –y samba samba-common samba-client
Step 2. Verify the package installation:
# rpm -qa | grep samba
samba-client-3.5.4-68.el6.x86_64
samba-3.5.4-68.el6.x86_64
samba-winbind-clients-3.5.4-68.el6.x86_64
samba-common-3.5.4-68.el6.x86_64
Step 3. Enable the service to start during boot:
# chkconfig smb on
Step 4. Verify that the service is set to start on boot:
# chkconfig smb --list
smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Configuring Samba
If you have never worked with Samba before, the number of options can seem overwhelming. First, let’s look at the two services responsible for running Samba:

smbd              Samba server daemon
nmbd             NetBIOS service daemon

There are also a handful of config files:
/etc/samba/smb.conf Contains the main config file
/etc/samba/smbusers Maps Samba and Red Hat users
/etc/samba/smbpasswd Contains Samba user passwords

I’m sure you could have guessed by now that no service this complex comes without a group of management commands as well:

mount.cifs    Mounts a Samba resource without root privileges
smbclient      Connects to a Samba resource
smbpasswd  Configures Samba users and passwords
smbstatus     Displays the status of Samba connections
testparm       Tests the syntax of the main config file for issues
umount.cifs Unmounts a Samba resource without root privileges

Now that you are completely overwhelmed with config files and commands, let’s take a step back and see what these things are actually used for. You need to edit the main config file to set up the Samba server and directories that you’d like to make into Samba shares. Here is a sample /etc/samba/smb.conf config file you can use (just read through it for now):

# cat /etc/samba/smb.conf
### Global Data Section ###
[global]
### Define our workgroup and hostname information ###
workgroup = INET
server string = My Samba Server
netbios name = RHEL01
### Define the log file and its size ###
log file = /var/log/samba/%m.log
max log size = 50
### Use a local password file (/etc/samba/smbpasswd) ###
security = user
passdb backend = tdbsam
### Define printer settings ###
load printers = yes
printcap name = /etc/printcap
cups options = raw
### Samba Share for Company Data ###
[company_data]
### Define a comment for the share ###
comment = Directory for all employees within the company
### Allow users to access the share and define its location ###
browseable = yes
path = /opt/company_data
### Make the share writable and define access for valid users ###
valid users = user01
writable = yes
### Share for Samba printers ###
[printers]
### Define a comment for the share ###
comment = All Printers
### Allow users to access the share and define its location ###
browseable = no
path = /var/spool/samba
### Set permissions and user access ###
guest ok = no
writable = no
printable = yes
To set up the file, do the following:

Step 1. Make a backup of the main config file so you can review the comments in
it later:
# cp /etc/samba/smb.conf /etc/samba/smb.bk
Step 2. Copy the sample file provided here into a new main config file:
# nano /etc/samba/smb.conf
Step 3. Save the file and exit. Now you need to check that the config file has no
syntax errors by using the testparm command:
Syntax: testparm [options] <config file> [hostname] [host IP]
Options:
-s         Suppresses the prompt
-v        Provides verbose output (shows the default options)

Check the syntax of the config file:
# testparm
Load smb config files from /etc/samba/smb.conf
Processing section “[company_data]”
Processing section “[printers]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
workgroup = INET
netbios name = RHEL01
server string = My Samba Server
log file = /var/log/samba/%m.log
max log size = 50
printcap name = /etc/printcap
cups options = raw

[company_data]
comment = Directory for all employees within the company
path = /opt/company_data
valid users = user01
read only = No

[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No

There are no errors in the output shown here, but you can see the global options
displayed, including the different shares that are accessible to users. Before you can start connecting clients, however, you also need to create Samba users because they are separate from system users. You can use the smbpasswd command to create a new Samba user.
Syntax: smbpasswd [options] [user]
Options:

-a        Adds a user
-d        Disables a user
-e        Enables a user
-x         Deletes a user

Step 1. Create your first Samba user:
# smbpasswd -a user01
New SMB password:
Retype new SMB password:
Added user user01.
Step 2. Verify that the user was created successfully by using the pdbedit command:
# pdbedit -w -L
user01:501:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:17601CAE62CBC5D649CF7D1951C42806:[U ]:LCT-4D498DE8:

At this point, everything should be in place for your Samba server. You just need to make sure that the directories you specified to be a Samba share exist

Step 1. If you haven’t done so already, start the Samba service:
# service smb start
Starting SMB services:                                          [ OK ]
Step 2. Verify that the service is running:
# service smb status
smbd (pid 3145) is running...

1 comments:

Unknown said...

Well this is very Good Information for linux learners We Are Also Providing Linux Online Training.Linux Online Training is One of The Best Training Center

Post a Comment

Powered by Blogger.

Ads

 
Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: www.redhatenterpriselinux.blogspot.com I live in Quetta, Pakistan and work as an IT-Engineer.