other languages
SMBCLIENT(1) | SMBCLIENT(1) |
NAME¶
smbclient - 类似FTP操作方式的访问SMB/CIFS服务器资源的客户端总览 SYNOPSIS¶
smbclient {servicename} [password] [-b <buffer size>] [-d debuglevel] [-D Directory] [-U username] [-W workgroup] [-M <netbios name>] [-m maxprotocol] [-A authfile] [-N] [-l logfile] [-L <netbios name>] [-I destinationIP] [-E] [-c <command string>] [-i scope] [-O <socket options>] [-p port] [-R <name resolve order>] [-s <smb config file>] [-T<c|x>IXFqgbNan] [-k]描述 DESCRIPTION¶
此程序是 Samba(7)套件的一部分。选项 OPTIONS¶
- servicename
-
- password
-
注意:有些服务器(包括OS/2和Windows for Workgroups)会强调使用大写口令,它们会拒绝小写或者大小写混合的口令。
- -R <name resolve order>
- 通过指定这个选项让Samba套件中的程序决定使用怎样的名字解析服务及其次序来解决主机名和IP的对应。这个选项以一个以空格分隔的不同的名称解析方法为选项值。
- -M NetBIOS name
- 使用这个选项可以让你以“WinPopup”
协议向其它计算机发送信息。一旦联接成功你就可以发送信息了,结束时可以按^D(Ctl-D).
- -p port
- 联接服务器所用的TCP端口号。标准(众所周知)的SMB/CIFS服务器TCP端口是139,当然也是默认值。
- -h|--help
- 打印出命令行帮助信息。
- -I IP-address
- 指定要联接的服务器IP地址。当然格式应该是“a.b.c.d”。
- -E
- 当使用了这个参数后,程序会把信息写到标准错误流(stderr)而不是标准输入流中。
- -L
- 此选项允许你查看服务器上可以获得的服务资源。使用smbclient
-L host
命令会显示一份列表。如果你的NetBIOS名与TCP/IP域名不匹配或者要在其它网络上查找主机时,
-I
选项会非常有用。
- -t terminal code
- 用这个选项告诉smbclient怎样解释从远程服务器上传来的文件名。通常,UNIX系统对亚洲多字节的语言的实现与SMB/CIFS服务器使用的字符集不同(例如用EUC代替
SJIS)。设置这个参数可以让
smbclient
在UNIX文件名与SMB文件名之间进行正确的转换。不过,这个选项还没有经过严格的测试,所以可能会有些问题。
- -b buffersize
- 在对服务器进行上/下传文件时可以用这个选项来改变传输缓冲大小。默认值是65520个字节。当从一个Win9x的服务器上进行文件传输时,把这个值设为稍小一点的值(例如1200字节)可以得到一些速度提升。
- -V
- Prints the program version number.
- -s <configuration file>
- 指定的这个文件包含服务器需要的配置详细信息。文件中的信息包含针对服务器的信息,比如使用什么printcap文件,还有所有服务器提供的服务的描述。参见smb.conf来获得更多信息。默认的配置文件名是在编译时指定的。
- -d|--debug=debuglevel
- debuglevel
调试等级是个从0到10的整数。参数未指定时默认值为0。
- -l|--logfile=logbasename
- 指定一个记录和调试的文件名。文件会被添加.client扩展名。记录文件无法被客户端删除。
- -N
- 如果指定了这个选项,就会省略通常的口令提示。当访问无需口令的服务资源时它很有用。
- -k
- Try to authenticate with kerberos. Only useful in an Active
Directory environment.
- -A|--authfile=filename
- This option allows you to specify a file from which to read
the username and password used in the connection. The format of the file
is
username = <value> password = <value> domain = <value>
- -U|--user=username[%password]
- 这个参数指定程序联接时使用的用户名或者用户名和密码
- -n <primary NetBIOS name>
- 使用这个选项让你越过机器的主机名而使用你要用的NetBIOS名。这样作和设置smb.conf文件中的netbios
name选项作用相同。但是,命令行设置比配置文件中的设置优先级高。
- -i <scope>
- 这个参数指定一个产生NetBIOS名字时nmblookup用来通信所需要的NetBIOS范围。对于NetBIOS范围这个概念,可以参见rfc1001.txt和rfc1002.txt这两个文件中的详细定义。实际上这个NetBIOS范围的概念很少被用到,仅当你作为负责整个NetBIOS通信的管理员时才要设置。
- -W|--workgroup=domain
- 设置用户名的SMB域。这个选项越过了smb.conf配置文件中的默认域。如果指定的域与服务器NetBIOS名相同,会使得用户使用服务器本地安全管理local
SAM来登录(与域SAM相反).
- -O socket options
- TCP套接字选项用来在客户端设定套接字方面的功能。参见smb.conf(5)手册页中的socket
options参数获得合法的选项列表。
- -T tar options
- 我们可以用smbclient来对位于SMB/CIFS共享资源上的所有文件建立兼容tar(1)
格式的备份。可使用的tar选项是以下这些:
- -D initial directory
- 在开始前用这个参数来改变初始目录。可能只在用tar的-T选项才用。
- -c command string
- 命令字符串串是一个以单引号(“'”)分隔的用来替换标准输入提示的一系列命令列表,这个参数意味着
-N。
操作 OPERATIONS¶
一旦运行了这个命令,就会在用户的提示行出现以下信息:- ? [command]
- 如果指定了command
,那么?命令就显示该命令的一些简单介绍信息。如果单独使用?的话,它会
给出一份给用命令的列表。
- ! [shell command]
- 如果指定了 shell
command,那么!命令会执行一个本地的命令解释器并运行指定的shell命令。如果不指定
要运行哪个shell命令,那么就只执行一个本地命令解释器。
- altname file
- The client will request that the server return the
"alternate" name (the 8.3 name) for a file or directory.
- cancel jobid0 [jobid1] ... [jobidN]
- The client will request that the server cancel the
printjobs identified by the given numeric print job ids.
- chmod file mode in octal
- This command depends on the server supporting the CIFS UNIX
extensions and will fail if the server does not. The client requests that
the server change the UNIX permissions to the given octal mode, in
standard UNIX format.
- chown file uid gid
- This command depends on the server supporting the CIFS UNIX
extensions and will fail if the server does not. The client requests that
the server change the UNIX user and group ownership to the given decimal
values. Note there is currently no way to remotely look up the UNIX uid
and gid values for a given name. This may be addressed in future versions
of the CIFS UNIX extensions.
- cd [directory name]
- 如果指定了"directory
name",那么服务器的当前工作路径就改为用户指定的路径。如果指定了任何不可访问的目录的话,该操作就失败了。
- del <mask>
- 删除所有当前工作路径中匹配mask的文件。
- dir <mask>
- 列出所有当前工作路径中匹配mask的文件。
- exit
- 终止联接并退出程序。
- get <remote file name> [local file name]
- 把服务器上名为remote
file
name的文件到拷贝到本地,名称为
local file
name。要注意的是,
smbclient所用的传送模式为二进制模式。同时参见lowercase命令。
- help [command]
- 同以上的?命令相同。
- lcd [directory name]
- 把本机目录改为directory
name指定的地点。如果要换的目录是不可访问的话,操作将会失败。
- link source destination
- This command depends on the server supporting the CIFS UNIX
extensions and will fail if the server does not. The client requests that
the server create a hard link between the source and destination files.
The source file must not exist.
- lowercase
- 在get和mget命令中选用小写字符作为文件名。
- ls <mask>
- 同以上的dir命令。
- mask <mask>
- 此命令允许用户设置在mget和mput命令的递归形式操作中使用的一个掩码(通配符)。
- md <directory name>
- 同以上的mkdir命令。
- mget <mask>
- 复制服务器上所有匹配mask
的文件到本机。
- mkdir <directory name>
- 在服务器上建立指定名称的目录(当然用户要有相应的访问权限)。
- mput <mask>
- 复制本机上当前目录内所有匹配mask
的文件到服务器当前工作目录。
- print <file name>
- 打印本机上指定的文件到服务器的可打印资源上。
- printmode <graphics or text>
- 设定打印模式以适应二进制数据(例如图形信息)或文本,这样后续的打印命令皆使用当前设好的打印模式。
- prompt
- 在执行mget和mput命令时使用对文件名的提示。
- put <local file name> [remote file name]
-
从本机拷贝名为 local file name的文件到服务器上并取名为 remote file name。与上面提到的一样, smbclient 传送用的是二进制模式。参见lowercase命令。
- queue
- 用来显示打印队列、任务标识、名称、容量大小和当前状态。
- quit
- 参见exit命令。
- rd <directory name>
- 参见rmdir命令。
- recurse
- 以目录递归方式运行mget和mput命令。
- rm <mask>
- 删除所有服务器上当前工作目录中与mask相符的文件。
- rmdir <directory name>
- 从服务器上删除指定的目录,当然了,需要一定的用户访问权限。
- setmode <filename> <perm=[+|\-]rsha>
- 与DOS命令attrib类似的东东,用来设定文件权限,例如:
- symlink source destination
- This command depends on the server supporting the CIFS UNIX
extensions and will fail if the server does not. The client requests that
the server create a symbolic hard link between the source and destination
files. The source file must not exist. Note that the server will not
create a link to any path that lies outside the currently connected share.
This is enforced by the Samba server.
- tar <c|x>[IXbgNa]
- 执行一个tar操作。参见上面的
-T
命令行选项。tarmode命令可能会影响具体的行为。还有就是g(增量方式)和N(新建方式)会改变tarmode设定。这里要注意的是
tar
x参数前加"-"可能会导致命令不执行,应当使用命令行选项方式。
- blocksize <blocksize>
- 块大小。参数后必须跟一上合法的(就是比0大的数啦)块尺寸。因为在执行命令时,tar文件要被写到一个大小为blocksize*TBLOCK(一般是512字节)的块中。
- tarmode <full|inc|reset|noreset>
- 根据归档位来改变tar的行为。当用完全备份时,tar会备份所有的内容而不管归档位是如何设置的,这正好是默认的工作模式。当为增量模式时,它只备份置有归档位的文件。而用重组模式时,tar会对所有要备份文件的归档位进行复位(同时读/写共享)。