天天看点

samba安装和基本命令

下载完成后tar xvzf samba*.tar.gz

然后执行cd source/;./configure && make && make install && make installbin && make installman

安装完成以后我们就可以看windows的共享目录了,我们首先查看目标我们输入

[root@localhost /]# smbtree

Password:

WORKGROUP

这里就可以看到了共享的机器CNBIRD了,

找到了共享了目录以后我们输入

[root@localhost /]# nmblookup CNBIRD

querying CNBIRD on 192.168.0.255

192.168.0.1 CNBIRD<00>

192.168.1.1 CNBIRD<00>

192.168.234.1 CNBIRD<00>

[root@localhost /]#

我们就可以得到CNBIRD这台机器的IP地址了,这里IP很多,主要是安装了Vmware的原因。

我们下面就来具体的查看我们目录中有什么东西了,

[root@localhost /]# smbclient -L 192.168.0.1 -Uredhat%redhat

Domain=[CNBIRD] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

        Sharename       Type      Comment

        ---------       ----      -------

        IPC$            IPC       ÈÂ│╠ IPC

        hacker          Disk

        cnbird          Disk

session request to 192.168.0.1 failed (Called name not present)

session request to 192 failed (Called name not present)

        Server               Comment

        ---------            -------

        Workgroup            Master

我们用redhat和密码redhat来进行查看共享。

下面就是我们需要看共享里面的内容了,我们输入

[root@localhost /]# smbclient //192.168.0.1/hacker -U redhat%redhat

smb: />

这个时候我们就入了smb里面了,我们输入help来查看一下具体的命令,

smb: /> help

?              altname        archive        blocksize      cancel

case_sensitive cd             chmod          chown          del

dir            du             exit           get            hardlink

help           history        lcd            link           lowercase

ls             mask           md             mget           mkdir

more           mput           newer          open           print

printmode      prompt         put            pwd            q

queue          quit           rd             recurse        reget

rename         reput          rm             rmdir          setmode

stat           symlink        tar            tarmode        translate

vuid           logon          !

命令不少,但是看上去和ftp有很多的相同的地方,我们输入ls就可以查看共享文件了,同时也可以使用cd来切换目录,同时可以用get命令下载文件put上传文件等等的操作了,具体的就不操作了。

下面就是共享目录的备份了,我们输入命令

[root@localhost /]# smbtar

Usage: smbtar [<options>] [<include/exclude files>]

Function: backup/restore a Windows PC directories to a local tape file

Options:         (Description)                 (Default)

  -r             Restore from tape file to PC  Save from PC to tapefile

  -i             Incremental mode              Full backup mode

  -a             Reset archive bit mode        Don't reset archive bit

  -v             Verbose mode: echo command    Don't echo anything

  -s <server>    Specify PC Server

  -p <password>  Specify PC Password

  -x <share>     Specify PC Share              backup

  -X             Exclude mode                  Include

  -N <newer>     File for date comparison

  -b <blocksize> Specify tape's blocksize

  -d <dir>       Specify a directory in share  /

  -l <log>       Specify a Samba Log Level     2

  -u <user>      Specify User Name             root

  -t <tape>      Specify Tape device           tar.out

Please enter a command line parameter!

具体的使用是smbtar -s 192.168.0.1 -u redhat -p redhat -x cnbird -t cnbird.tar

本来以为结束了,但是一看没有成功,后来查看资料发现是smbtar这个工具有问题的,我们来看一下解决方法

[root@localhost /]# locate smbtar

warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old

/usr/share/man/man1/smbtar.1.gz

/usr/share/doc/samba-3.0.10/htmldocs/smbtar.1.html

/usr/bin/smbtar

[root@localhost /]# file /usr/bin/smbtar

/usr/bin/smbtar: Bourne shell script text executable

smbtar是一个脚本文件,我们最后一行的内容

eval $SMBCLIENT "'////$server//$service'" "'$password'" -U "'$username'" /

-E $log -D "'$cdcmd'" ${clientargs} /

哈哈我下载的最新的版本已经修改过这个Bug了,以前的是把-N的命令去掉。

继续阅读