Mittwoch, 18. März 2009

setup Samba

If you have other Windows computers on your Lan and want to share files with them, you must setup Samba.

To setup Samba you must (1) install samba, (2) add you 'shares', (3) add users, (4) start Samba service.

1. Install Samba

It is best to have Samba installed in the installation process. If not yum users can install using: Add/Remove Software > Servers > Windows File Server. Users without yum can install the following packages from their DVD (or download): samba, samba-common, samba-client.

2. Add Shares

You must edit /etc/samba/smb.conf as root: (use nano instead of gedit if you do not have a GUI)

[mirandam@charon ~]$ sudo gedit /etc/samba/smb.conf

Set your Windows Workgroup name in [global] section.

Added shares at the end of the file. Example:

[c_drive]
path = /media/c_drive
public = yes
writable = no
[netshare]
path = /data/
public = yes
writable = yes

If 'writable' the location must be writable in Linux first. Additionally permissions must match (for example: drw-rw-rw-).

If home data (all personal files under /home/username) is to be accessible, then set 'browseable = yes' under [homes] (~line 250). This configuration file is very descriptive, read through it to get more ideas or information.

3. Add Users

To access shares, you must be a valid user. Add valid users AND passwords using the smbpasswd command.

This login name WILL be the login name and password you use from Windows to access your Linux computer. The password does NOT need to match your Linux password.

[mirandam@charon ~]$ sudo smbpasswd -a username
New SMB password:
Retype new SMB password:
account_policy_get: (warnings ignore)
Added user username.

(Note: 'username' must be a valid account on the machine)

4. Start Samba Service

Run samba and check for any errors:

[mirandam@charon ~]$ sudo /etc/init.d/smb start
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]

Use chkconfig or serviceconf to enable samba (smb) in both runlevels 3 and 5. This will make sure to run Samba each time Fedora boots.

[mirandam@charon ~]$ /sbin/chkconfig --list smb
smb 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[mirandam@charon ~]$ sudo /sbin/chkconfig --level 35 smb on
[mirandam@charon ~]$ /sbin/chkconfig --list smb
smb 0:off 1:off 2:off 3:on 4:off 5:on 6:off

Restart Samba for every change to users/passwords or 'smb.conf'

[mirandam@charon ~]$ sudo /etc/init.d/smb restart
Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]