SAMBA
Samba is way a Linux computer communicates with Windows.
So we can make Linux system as a part of windows network.
Samba service works on SMB protocol.
SMB:(Server Message Block)
Windows uses a protocol called SMB to communicate with each other to share services)
Samba server daemons:
NMBD: Network Message Block Daemon- handles all UDP-based protocols-NetBIOS
It responsible for all name registration and resolution requests.
SMBD:Server Message Block daemon - handles all TCP/IP-based connection services.
It responsible for file and print-share operations, etc.
Packages : Samba
Samba-common
Samba-client
Port numbers : 137 Net bios name service
138 Net bios session service
139 Net bios datagram service
Script : /etc/samba/smb.conf
Services : smb
Daemon : nmbd and smbd.
Configuration of Samba Server
It is used to share the files/folders between Linux/Unix to Windows and vice versa.
Step 1) CHECK & INSTALL PACKAGES
[root@smb ~]# rpm -qa | grep samba
OR
[root@smb ~]# yum list installed | grep samba
[root@smb ~]# yum remove samba* -y
[root@smb ~]# rm -r /etc/samba*
[root@smb ~]# yum install samba* -y
Step 2) Create the resources on Samba server (file/folders & users)
[root@smb ~]# useradd tom
[root@smb ~]# useradd joy
[root@smb ~]# passwd tom
[root@smb ~]# passwd joy
Create or Copy some files inside /var/zoom
[root@smb ~]# mkdir /var/zoom
[root@smb ~]# chmod 777 /var/zoom [root@smb ~]# cd /var/zoom
[root@smb zoom ]# touch fa.txt fb.txt music.mp3 [root@smb zoom ]# ls
Step 3) Edit the Main Configuration File
[root@smb ~]# vi /etc/samba/smb.conf
# Go to end of file copy last 8 lines 8yy and press p to paste
[salesshare]
comment = This share is for sales dept path = /var/zoom
valid users = tom joy public = no
writable = yes
printable = no
create mask = 0765
:wq!
Step 4) Provide a separate samba password for samba users.
[root@smb ~]# smbpasswd -a tom
[root@smb ~]# smbpasswd -a joy
Step 5 ) Check the syntax of configuration file
[root@smb ~]# testparm
Step 6 ) Start the services
[root@smb ~]# service smb restart
Client Side Configuration
Scenario 1) Windows as client for Linux Samba Server
Login to windows pc from Linux by using rdesktop command where windows ip is 192.168.0.16 and samba server's ip is 192.168.0.253
[root@smb ~]# rdesktop 192.168.0.16 &
Scenario 2) Linux as client for Linux Samba Server
To see the list linux Samba Server in network
[root@client ~]# findsmb
To see the list of Shares on Samba Server
[root@client ~]# smbclient -L //192.168.0.253
Method 1) By mounting
[root@client ~]# mount //192.168.0.253/salesshare /mnt -o
username=tom
Password:
[root@client ~]# mount
[root@client ~]# cd /mnt
[root@client mnt]# ls
Method 2) By smbclient method
Use put and get commands to upload and download respectively.
[root@client ~]# smbclient //192.168.0.253/salesshare -U tom Password:
Domain=[SMB] OS=[Unix] Server=[Samba 3.0.23c-2]
smb: \> ls
D 0 Sat Jul 12 03:29:30
2008
D 0 Sat Jul 12 03:28:54
2008
fa.txt 0 Sat Jul 12 03:29:30
2008
music.mp3 0 Sat Jul 12 03:29:30
2008
fb.txt 0 Sat Jul 12 03:29:30
2008
61755 blocks of size 16384. 52294 blocks available
smb: \> exit
[root@client ~]#
Scenario 3) Linux as client for Windows [ IP=192.168.0.16 ]
In windows the shared folders are windir1 windir2 and the users are winu1 winu2
Method 1) By mounting
[root@client ~]# mount //192.168.0.16/windir1 /mnt -o username=winu1 Password:
[root@client ~]# mount
[root@client ~]# cd /mnt
[root@client mnt]# ls
Method 2) By smbclient method
Use put and get commands to upload and download respectively.
[root@client ~]# smbclient //192.168.0.16/windir2 -U winu1 Password:
smb: \> ls
smb: \> help
smb: \> exit
[root@client ~]#