Linux系统管理.samba软件包介绍

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

你可能感兴趣的:(linux,samba,samba软件包的配置,samba软件包的安装,samba常用的客户端工具)