Posted by: isaraffee | August 10, 2009

Configuring Samba in Sabayon Linux

It’s Time to Samba! – Configuring Samba in Sabayon and Windows XP

Firstly make sure that the Linux box and the Windows box are able to ping each other.

On the Samba server

Create a user account,

sabayonx86 ~ # useradd -c “Samba user” -d /home/marsita -s /bin/bash marsita

Check that the user account has been created.

sabayonx86 ~ # less /etc/passwd |grep marsita

marsita:x:1005:1008:Samba user:/home/marsita:/bin/bash

Check the Samba version

sabayonx86 ~ # smbd -V

Version 3.0.23a

Start the Samba services

But before I start the Samba services, let’s check if it is already started during boot up.

sabayonx86 ~ # ps -ef|grep mb | grep -v grep

root 12433 1 0 11:01 ? 00:00:00 /usr/sbin/smbd -D

root 12442 1 0 11:01 ? 00:00:00 /usr/sbin/nmbd -D

root 12490 12433 0 11:01 ? 00:00:00 /usr/sbin/smbd -D

Wow, the samba services have been started by default.

If your samba services were not started, you can do so by finding the files, namely smb and nmb, These scripts are responsible to start the samba services. In Mandrake, the scripts were found in /etc/init.d directory, but in Sabayon, those files were missing as shown below.

sabayonx86 ~ # cd /etc/init.d

sabayonx86 init.d # ls s*

samba shutdown.sh slpd spamd splash syndaemon

saslauthd slapd slurpd speedtouch sshd syslog-ng

serial slmodem smartd spind svnserve

In Sabayon, the Samba scripts can be found by typing:

sabayonx86 init.d # which smbd

/usr/sbin/smbd

sabayonx86 init.d # which nmbd

/usr/sbin/nmbd

To check if Samba package is installed in Sabayon, use the emerge command:

sabayonx86 init.d # emerge –search samba

Searching…

[ Results for search key : samba ]

[ Applications found : 4 ]

* app-admin/system-config-samba

Latest version available: 1.2.35

Latest version installed: [ Not Installed ]

Size of files: 184 kB

Homepage: http://fedoraproject.org/wiki/SystemConfig/samba

Description: Samba server configuration tool

License: GPL-2

* net-fs/samba

Latest version available: 3.0.33

Latest version installed: 3.0.23a

Size of files: 48,478 kB

Homepage: http://www.samba.org/

Description: A suite of SMB and CIFS client/server programs for UNIX

License: GPL-3 oav? ( GPL-2 LGPL-2.1 )

* net-misc/sambasentinel

Latest version available: 0.1

Latest version installed: [ Not Installed ]

Size of files: 18 kB

Homepage: http://kling.mine.nu/sambasentinel.htm

Description: SambaSentinel is a GTK frontend to smbstatus

License: GPL-2

* sec-policy/selinux-samba

Latest version available: 20080525

Latest version installed: [ Not Installed ]

Size of files: 328 kB

Homepage: http://www.gentoo.org/proj/en/hardened/selinux/

Description: SELinux policy for samba

License: GPL-2

Using the package name, use equery command to see the files owned by the package.

sabayonx86 init.d # equery files net-fs/samba

!!! SELinux module not found. Please verify that it was installed.

[ Searching for packages matching net-fs/samba… ]

* Contents of net-fs/samba-3.0.23a:

/etc

/etc/conf.d

/etc/conf.d/samba

/etc/init.d

/etc/init.d/samba

/etc/openldap

/etc/openldap/schema

/etc/openldap/schema/samba.schema

/etc/pam.d

/etc/pam.d/samba

/etc/samba

/etc/samba/lmhosts

/etc/samba/smb.conf.example

/etc/samba/smbusers

/etc/samba/system-auth-winbind

/etc/samba/vscan-oav.conf

/etc/xinetd.d

/etc/xinetd.d/swat

<output is truncated for brevity>

Through the output, I saw samba in the /etc directory

sabayonx86 ~ # cd /etc/conf.d/

sabayonx86 conf.d # more samba

The file, samba will show you how to start and stop samba servcices.

Configuring the Samba Configuration file

Locate the smb.conf file. In SABAYON, it is in the /etc/samba diretory

Edit the smb.conf file but it is a good practice to make a backup of the file:

sabayonx86 samba # cp -p smb.conf smb.conf.bkp

In the smb.conf, change the workgroup name to your Windows box workgroup. In my case, it is MSHOME. Save and exit the file.

My smb.conf consists of the following:

sabayonx86 samba # more smb.conf|grep -v “^#” | grep -v “;”

[global]

workgroup = MSHOME

netbios name = sabayonx86

server string = Sabayon Linux %v

printcap name = cups

load printers = yes

printing = cups

printer admin = @adm

log file = /var/log/samba3/log.%m

max log size = 50

map to guest = bad user

security = user

encrypt passwords = yes

smb passwd file = /etc/samba/private/smbpasswd

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

dns proxy = no

[homes]

comment = Home Directories

browseable = yes

writable = yes

[netlogon]

comment = Network Logon Service

path = /var/lib/samba/netlogon

guest ok = yes

writable = no

[printers]

comment = All Printers

path = /var/spool/samba

browseable = yes

guest ok = yes

writable = no

printable = yes

create mode = 0700

print command = lpr-cups -P %p -o raw %s -r # using client side printer drivers.

[print$]

path = /var/lib/samba/printers

browseable = yes

read only = yes

write list = @adm root

guest ok = yes

You will need to restart samba services. Go to /etc/init.d directory and run:

sabayonx86 init.d # ./samba stop

* samba -> stop: smbd … [ ok ]

* samba -> stop: nmbd … [ ok ]

sabayonx86 init.d # ps -ef|grep mb

root 14775 14209 0 12:05 pts/2 00:00:00 grep mb

I aslo check that the services have been stopped. Now start the services by typing:

sabayonx86 init.d # ./samba start

* samba -> start: smbd … [ ok ]

* samba -> start: nmbd … [ ok ]

sabayonx86 init.d # ps -ef|grep mb

root 14877 1 0 12:08 ? 00:00:00 /usr/sbin/smbd -D

root 14883 14877 0 12:08 ? 00:00:00 /usr/sbin/smbd -D

root 14887 1 0 12:08 ? 00:00:00 /usr/sbin/nmbd -D

The samba services have been started successfully.

On the Samba client, i.e. Windows box

On your Windows box, click My Network Places–>Entire Network–>Microsoft Windows Network

You will see Mshome and Sabayondomain domains

samba1

Figure 1 – Accessing the Mshome domain from the Windows XP, the Samba client

But this is as far as you can go. This is because we need to set the password for the samba user, marsita in the Samba server. Now backto the Samba server.

On the Samba server

To set the password for the Samba user type:

sabayonx86 init.d # smbpasswd -a marsita

New SMB password:

Retype new SMB password:

Added user marsita.

Now you need to restart the samba services again. So in the /etc/init.d directory, do this:

sabayonx86 init.d # ./samba stop

* samba -> stop: smbd … [ ok ]

* samba -> stop: nmbd … [ ok ]

sabayonx86 init.d # ./samba start

* samba -> start: smbd … [ ok ]

  • samba -> start: nmbd … [ ok ]

Now let’s go to the Windows box to see if we can see the Linux files belong to marsita from Windows.

On the Samba client, i.e. Windows box

When I clicked on the icon Sabayon Linux 3 icon, I was prompted for the password. This is the password that we created earlier in the Samba server.

samba2

Figure 2 – Accessing the Sabayon Samba server from Windows XP

Yes I can see marsita’s folders e.g. homes, marsita, netlogon and Printers and Faxes folders

samba3

Figure 3 – Accessing the User’s folder in the Samba server

When I clicked on any of the folders, an error message was displayed suggesting that I do not have right to access the folders. This is due to permissions of the folders that were set in the Samba server.

On the Samba server

I realised that when I created the user account, marsita, it did not create the home directory. So let’s create the /home/marsita directory

sabayonx86 ~ # cd /home

sabayonx86 home # mkdir marsita

List the files and you notice that the marsita folder belongs to root user and root group.

Now change the permissions of the marsita folder so that it belongs to marsita and the users group.

sabayonx86 home # chown marsita:users marsita

sabayonx86 home # ll -rt

total 32

drwxr-xr-x 2 root root 4096 2005-09-12 22:08 ftp

drwxr-xr-x 27 khadijah khadijah 4096 2009-03-05 04:10 khadijah

drwxr-xr-x 27 idris users 4096 2009-03-16 01:02 idris

drwxr-xr-x 43 ismail users 4096 2009-03-31 11:05 ismail

drwxr-xr-x 2 marsita users 4096 2009-03-31 12:28 marsita

It’s better to restart the Samba services again

After you have started the Samba services, go to the Windows box.

On the Samba client, i.e. Windows box

Go to the Mshome domain and select the Sabayon Linux computer icon. Access the marsita folder and now you will see that there will be no error messages being displayed. You also see that the folder is empty. This is because we have not create any files in the marsita folder.

Go to the Samba server and in the the /home/marsita directory, create a file by typing:

sabayonx86 marsita # touch samba_works.txt

Go back to the Windows box and refresh the marsita folder. You will see that the samba_works.txt file, but it is read only. To make the file read and write, you will need to go back to the samba server and change the permissions to the file. (This is because when I first create the file, I was a root user!Silly me!)

So now let’s go back to the Samba server, remove the file, samba_works.txt

sabayonx86 marsita # rm samba_works.txt

Now switch user to marsita and create the file again.

sabayonx86 marsita # su – marsita

marsita@sabayonx86 ~ $

marsita@sabayonx86 ~ $ pwd

/home/marsita

marsita@sabayonx86 ~ $ ls

marsita@sabayonx86 ~ $ touch samba_works.txt

marsita@sabayonx86 ~ $ ls -l

total 0

-rw-r–r– 1 marsita marsita 0 2009-03-31 12:58 samba_works.txt

This time with the correct permission settings on the file, yo should be able to edit the samba_works,txt file in the Windows box. In Windows edit the file and save it.

You will see that you are able to make changes to the file. Now view it in the Samba server.

marsita@sabayonx86 ~ $ more samba_works.txt

hello

Yes it work perfectly! This is how Samba works and users can access their files that are stored in Linux boxes from Windows. This conclude the section on Samba configuration.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: