1)、samba samba服務器軟件包
2)、samba-client samba客戶端工具
3)、samba-common samba通用工具和庫文件
1、安裝rpmdb庫文件
2、rpm –ivh rpmdb-***.rpm
3、rpm –ivh –-aid samba*.rpm
[root@localhost root]# rpm -qa |grep samba
samba-2.2.7a-7.9.0
samba-common-2.2.7a-7.9.0
samba-client-2.2.7a-7.9.0 <可能還需要安裝cups-lib*.rpm>
安裝過程如下:
[root@localhost RPMS]# cp samba*.rpm /home/test/
[root@localhost RPMS]# ls /home/test
samba-2.2.7a-7.9.0.i386.rpm samba-client-2.2.7a-7.9.0.i386.rpm samba-common-2.2.7a-7.9.0.i386.rpm
[root@localhost RPMS]# rpm -ivh rpmdb-redhat-9-0.20030313.i386.rpm
warning: rpmdb-redhat-9-0.20030313.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing… ########################################### [100%]
1:rpmdb-redhat ########################################### [100%]
[root@localhost RPMS]# cd /home/test/
[root@localhost test]# rpm -ivh –aid samba*
warning: samba-2.2.7a-7.9.0.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: open of cups-libs-1.1.17-13.i386.rpm failed: No such file or directory
error: Failed dependencies:
libcups.so.2 is needed by samba-2.2.7a-7.9.0
libcups.so.2 is needed by samba-client-2.2.7a-7.9.0
libcups.so.2 is needed by samba-common-2.2.7a-7.9.0
[root@localhost root]# umount /dev/cdrom
[root@localhost root]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost root]# cd /mnt/cdrom/RedHat/RPMS/
[root@localhost RPMS]# ls |grep cup
cups-1.1.17-13.i386.rpm
cups-libs-1.1.17-13.i386.rpm
[root@localhost RPMS]# rpm -ivh cups-libs-1.1.17-13.i386.rpm
warning: cups-libs-1.1.17-13.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing… ########################################### [100%]
1:cups-libs ########################################### [100%]
[root@localhost RPMS]# cd /home/test/
[root@localhost test]# rpm -ivh samba*
warning: samba-2.2.7a-7.9.0.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing… ########################################### [100%]
1:samba-common ########################################### [ 33%]
2:samba ########################################### [ 67%]
3:samba-client ########################################### [100%]
[root@localhost root]# rpm –ql samba |more
/etc/logrotate.d/samba
/etc/pam.d/samba
/etc/rc.d/init.d/smb
/etc/samba/smbusers
/etc/sysconfig/samba
/lib/security/pam_smbpass.so
/usr/bin/make_unicodemap
/usr/bin/mksmbpasswd.sh
/usr/bin/smbadduser
/usr/bin/smbcontrol
/usr/bin/smbstatus
/usr/bin/tdbbackup
/usr/include/libsmbclient.h
/usr/lib/libsmbclient.a
/usr/lib/samba/vfs
/usr/lib/samba/vfs/recycle.so
/usr/sbin/nmbd
/usr/sbin/smbd
/usr/share/doc/samba-2.2.7a
…………中間有很多文檔資料…………
/usr/share/man/man1/make_unicodemap.1.gz
/usr/share/man/man1/smbcontrol.1.gz
/usr/share/man/man1/smbstatus.1.gz
/usr/share/man/man5/smbpasswd.5.gz
/usr/share/man/man7/samba.7.gz
/usr/share/man/man8/nmbd.8.gz
/usr/share/man/man8/pdbedit.8.gz
/usr/share/man/man8/smbd.8.gz
/var/cache/samba
/var/log/samba
/var/run/samba
/var/spool/samba
Samba常用客戶端工具
1.smbtree(用當前用戶登錄局域網主機)
作用:顯示局域網中的所有共享主機和目錄列表
用法:smbtree [-b][-D][-U usrname%password]
2.nmblookup
作用:顯示一臺主機的netbios主機名
3.smbclient
作用:顯示登錄局域網中的共享文件夾
用法:smbclient –L host
smbclient //host/share
4.smbtar
作用:遠程備份網上鄰居中的文件(需要稍做修改再使用)
用法:smbtar –s server –u user –P password –x sharename –t output
例:smbtar –s win2000 –u redhat –P redhat –x chinaitlab –t itlab.tar
實例: #smbtree –b <———發送廣播查詢
#smbtree –D <—————-向工作組、域查詢,並顯示
#smbtree –b –D –u redhat%redhat < -u username%password >
#nmblookup win2000 <———由主機名查詢IP地址
#nmblookup \* <———–查詢局域網中的所有活動主機
#smbclient –L 主機名(或IP地址)
#smbclient –L 192.168.0.254
#smbclient –L 192.168.0.254 –U redhat%redhat
#smbclient //192.168.0.254/lab –U redhat%redhat
smb:>help
smb:> <——————-smb提示符說明登陸成功
#smbmount //192.168.0.254/lab /mnt/dir
#smbmount //192.168.0.254/lab /mnt/dir –o username=redhat%redhat
#smbmount 掛載smb文件
#umount /mnt/dir
Smbtar備份遠程的文件和目錄
#smbtar –s 192.168.0.254 –U redhat –P redhat –x lab –t lab.tar
#vi /usr/bin/smbtar
找到-N <———(-N的意思是不使用密碼,此選項取消,然後保存退出)
#tar tvf lab.tar
Smb服務器配置
一、修改配置文件:/etc/samba/smb.conf
Workgroup = workgroup (加入工作組)
security = share (安全級別)
[docs]
path = /usr/share/doc
comment = share documents
public = yes
二、重新啓動服務器: #service smb restart
#chkconfig smb on
三、測試:#smbclient –L host (IP地址)
實例:
[root@localhost local]# smbclient -L 192.168.0.153 -U guest
added interface ip=192.168.0.254 bcast=192.168.0.255 nmask=255.255.255.0
session request to 192.168.0.153 failed (Called name not present)
session request to 192 failed (Called name not present)
Password:
Domain=[WORKGROUP] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
——— —- ——-
Error returning browse list: NT_STATUS_OK
Server Comment
——— ——-
Workgroup Master
——— ——-
[root@localhost local]# smbclient -L 192.168.0.153 -U administrator%leekwen
added interface ip=192.168.0.254 bcast=192.168.0.255 nmask=255.255.255.0
session request to 192.168.0.153 failed (Called name not present)
session request to 192 failed (Called name not present)
Domain=[WORKGROUP] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
——— —- ——-
IPC$ IPC Ô¶³Ì IPC
share Disk share document on 192.168.0.153
Server Comment
——— ——-
Workgroup Master
——— ——-
[root@localhost local]# smbclient //192.168.0.153/share -U administrator%leekwen
added interface ip=192.168.0.254 bcast=192.168.0.255 nmask=255.255.255.0
session request to 192.168.0.153 failed (Called name not present)
session request to 192 failed (Called name not present)
Domain=[WORKGROUP] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: \> ls
. D 0 Sun May 31 11:21:34 2009
.. D 0 Sun May 31 11:21:34 2009
test.txt A 16 Sun May 31 11:26:40 2009
38135 blocks of size 524288. 13137 blocks available
smb: \> pwd
Current directory is \\192.168.0.153\share\
smb: \> ls
. D 0 Sun May 31 11:21:34 2009
.. D 0 Sun May 31 11:21:34 2009
test.txt A 16 Sun May 31 11:26:40 2009
38135 blocks of size 524288. 13137 blocks available
smb: \> dir
. D 0 Sun May 31 11:21:34 2009
.. D 0 Sun May 31 11:21:34 2009
test.txt A 16 Sun May 31 11:26:40 2009
38135 blocks of size 524288. 13137 blocks available
smb: \> cp test.txt /home
cp: command not found
smb: \> ls
. D 0 Sun May 31 11:21:34 2009
.. D 0 Sun May 31 11:21:34 2009
test.txt A 16 Sun May 31 11:26:40 2009
38135 blocks of size 524288. 13137 blocks available
smb: \> pwd
Current directory is \\192.168.0.153\share\
smb: \> help
? altname archive blocksize cancel
cd chmod chown del dir
du exit get help history
lcd link lowercase ls mask
md mget mkdir more mput
newer open print printmode prompt
put pwd q queue quit
rd recurse rename rm rmdir
setmode symlink tar tarmode translate
!
smb: \> quit
[root@localhost root]# smbmount //192.168.0.153/share /mnt/ -o username=administrator
9074: session request to 192.168.0.153 failed (Called name not present)
9074: session request to 192 failed (Called name not present)
Password: <————-輸入密碼
[root@localhost root]# ls /mnt/
test.txt
[root@localhost root]# cp /mnt/test.txt /home/test/
[root@localhost root]# ls /home/test/
rpmdb-redhat-9-0.20030313.i386.rpm
samba-2.2.7a-7.9.0.i386.rpm
samba-client-2.2.7a-7.9.0.i386.rpm
samba-common-2.2.7a-7.9.0.i386.rpm
test.txt
[root@localhost root]# umount /mnt/floppy/
[root@localhost root]# mount
/dev/sda1 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
/dev/sdc1 on /mnt/sdc1 type ext3 (ro)
/dev/sdb1 on /mnt/sd1 type ext3 (rw)
[root@localhost root]# service smb restart
Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
[root@localhost root]# smbmount //192.168.0.153/share /mnt/ -o username=administrator
9113: session request to 192.168.0.153 failed (Called name not present)
9113: session request to 192 failed (Called name not present)
lPassword:
[root@localhost root]# ls /mnt
test.txt
[root@localhost root]# cp /home/test/test.txt /mnt/
cp: overwrite `/mnt/test.txt’? y
[root@localhost root]# vi /mnt/test.txt
[root@localhost root]# rm /mnt/test.txt
rm: remove regular file `/mnt/test.txt’? y
[root@localhost local]# chkconfig smb on
[root@localhost local]# chkconfig smb –list
smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost local]# smbclient -L localhost -N
added interface ip=192.168.0.254 bcast=192.168.0.255 nmask=255.255.255.0
Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 2.2.7a]
Sharename Type Comment
——— —- ——-
IPC$ IPC IPC Service (linux)
ADMIN$ Disk IPC Service (linux)
Server Comment
——— ——-
LOCALHOST linux <———-samba虛擬機的名稱
WWW-AC332FC77F7
Workgroup Master
——— ——-
WORKGROUP WWW-AC332FC77F7