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會對所有要備份檔案的歸檔位進行復位(同時讀/寫共享)。