2、經常使用的爲上傳下載sql
1)、getshell
從遠程服務器上下載一個文件存放到本地,以下:windows
先經過lcd切換到本地那個目錄下,而後經過get file服務器
>> lcd d:\ #表示切換到本地的d盤下ide
>> get ./test.sql #這樣就將當前文件下載本地的d盤下ui
2)、putspa
是將本地的文件上傳到遠程服務器上,以下:命令行
>> put #在windows下彈出選擇文件的窗口code
3)、lcdrem
先經過lcd切換到本地那個目錄下
>> lcd c:\ #表示切換到本地的c盤下
4)、lls
#顯示當前目錄下的全部文件
5)、pwd
#顯示當前目錄
3、各個用法實例詳解
實例1、從服務器下載文件到本機
Xshell 5 (Build 0806)
Copyright (c) 2002-2015NetSarang Computer, Inc. All rights reserved.
Type `help' to learn howto use Xshell prompt.
[c:\~]$
Connecting to192.168.56.101:22...
Connection established.
To escape to local shell,press 'Ctrl+Alt+]'.
Your current localdirectory is
C:\Users\FieldYang\Documents\NetSarang\Xshell\Sessions
Type `help' to browseavailable commnands.
sftp:/root> cd /mnt/share
#遠程路徑切換爲/mnt/share
sftp:/mnt/share> ls –lt
drwxrwxrwx 1 1000 users 4096 Jun 16 13:39 .
drwxr-xr-x 7 root root 4096 Jun 15 14:06 ..
-rwxrwxrwx 1 1000 users 220151 Jun 15 14:26.goutputstream-ZHJ8IY
-rwxrwxrwx 1 1000 users 19362 Jun 16 12:270.jpg
-rwxrwxrwx 1 1000 users 16157 Jun 16 13:39Auth Server and SOAP proxy.docx
-rwxrwxrwx 1 1000 users 63952 Jun 16 12:29bamquickinstall.pdf
-rwxrwxrwx 1 1000 users 7277 Jun 16 13:33DNSmmmS.txt
-rwxrwxrwx 1 1000 users 7277 May 12 10:43DNSS.txt
-rwxrwxrwx 1 1000 users 111395 Jun 15 15:46libpcap-0.9.4-15.el5.x86_64.rpm
-rwxrwxrwx 1 1000 users 363677 Jun 15 14:59ppp-2.4.4-14.1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 48430 Jun 15 14:57ppp-devel-2.4.4-14.1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 86211 Jun 15 15:38pptpd-1.4.0-1.rhel4.x86_64.rpm
-rwxrwxrwx 1 1000 users 86509 Jun 15 14:46pptpd-1.4.0-1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 220151 Jun 15 13:22Screenshot.png
-rwxrwxrwx 1 1000 users 21789 Jun 16 13:39Traffic Usage System alarm handling - Gateway, RadiusGWProxy, RadiusProxyServer.docx
sftp:/mnt/share> lcd d:\Field\test_sftp
#切換到本地的d盤下Field文件夾的test_sftp文件夾
Local directory is nowd:\Field\test_sftp
sftp:/mnt/share> lpwd
Local directory isd:\Field\test_sftp
#打印本地文件夾路徑
sftp:/mnt/share> lls
06/16/2016 05:44¤W <DIR> .
06/16/2016 05:44¤W <DIR> ..
#查看本地文件夾d:\Field\test_sftp內容
sftp:/mnt/share>get ./0.jpg ./DNSmmmS.txt./pptpd-1.4.0-1.rhel5.x86_64.rpm
#下載遠程服務器/mnt/share上的0.jpg、DNSmmmS.txt、#pptpd-1.4.0-1.rhel5.x86_64.rpm到本地文件夾d:\Field\test_sftp中
Fetching/mnt/share/./pptpd-1.4.0-1.rhel5.x86_64.rpm to pptpd-1.4.0-1.rhel5.x86_64.rpm
sftp: received 84.4 KB in0.64 seconds
Fetching/mnt/share/./DNSmmmS.txt to DNSmmmS.txt
sftp: received 7.10 KB in0.02 seconds
Fetching/mnt/share/./0.jpg to 0.jpg
sftp: received 18.9 KB in0.03 seconds
sftp:/mnt/share> lls –lt
#命令行查看是否下載成功
06/16/2016 05:47¤W <DIR> .
06/16/2016 05:47¤W <DIR> ..
06/16/2016 05:47¤W 19362 0.jpg
06/16/2016 05:47¤W 7277 DNSmmmS.txt
06/16/2016 05:47¤W 86509 pptpd-1.4.0-1.rhel5.x86_64.rpm
實例2、上傳本地文件到遠程服務器
sftp:/mnt/share> lcd d:\Field\SNINF\
#切換本地路徑到d:\Field\SNINF\
Local directory is nowd:\Field\SNINF\
sftp:/mnt/share> lpwd
#打印本地當前路徑
Local directory isd:\Field\SNINF\
sftp:/mnt/share> lls -lt
02/19/2016 07:50¤W <DIR> .
02/19/2016 07:50¤W <DIR> ..
12/11/2015 08:27¤W 16157 Auth Server and SOAP proxy.docx
12/11/2015 08:27¤W 464191 Check Plan--Jacky.docx
12/11/2015 08:27¤W 562801 CIMDB ¡V David.docx
12/11/2015 08:27¤W 12031 Disk Full ¡V For All Systems.docx
12/11/2015 08:27¤W 126440 EMMSC--Fox.docx
12/11/2015 08:27¤W 115928 ENUM ¡VJacky.docx
12/11/2015 08:27¤W 327650 F-Secure.docx
12/11/2015 08:27¤W 107606 GDS--Fox.docx
12/11/2015 08:27¤W 117762 GIMEI¡XFox.docx
12/11/2015 08:27¤W 310862 GUP CGUP ¡ΠRay.docx
12/11/2015 08:27¤W 650939 IP call --Sharon.docx
12/11/2015 08:27¤W 779957 Mex health check--Niker.docx
12/11/2015 08:27¤W 124195 NetScout (DPI)¡XFox.docx
12/11/2015 08:27¤W 198426 POC--Jacky.docx
12/11/2015 08:27¤W 326368 Radius Proxy -Niker.docx
12/11/2015 08:27¤W 190044 SMTP health check--Niker.docx
12/11/2015 08:27¤W 45643 Stretti DFS¡XSharon.docx
12/11/2015 08:27¤W 233654 Stretti DISC ¡VJacky.docx
12/11/2015 08:27¤W 449498 Traffic Router Health Check¡XDavid.docx
12/11/2015 08:27¤W 21789 Traffic Usage System alarm handling -Gateway, RadiusGWProxy, RadiusProxy Server.docx
12/11/2015 08:27¤W 734859 Video Transcoder¡XDavid.docx
12/11/2015 08:27¤W 14815 Virtual Browser.docx
12/11/2015 08:27¤W 22554 ZMMSC.docx
12/11/2015 08:27¤W 219776 ZProxy ¡ΠFox.docx
12/11/2015 08:27¤W 221199 ZWAPGW NZWAPGW ¡ΠFox.docx
sftp:/mnt/share> put
Uploading Traffic UsageSystem alarm handling - Gateway, RadiusGWProxy, RadiusProxy Server.docx toremote:/mnt/share/Traffic Usage System alarm handling - Gateway, RadiusGWProxy,RadiusProxy Server.docx
sftp: sent 21.2 KB in 0.01seconds
#在彈出的Windows框中選擇文件上傳 注意上傳路徑與當前路徑要相同
sftp:/mnt/share> put
Uploading VirtualBrowser.docx to remote:/mnt/share/Virtual Browser.docx
sftp: sent 14.4 KB in 0.02seconds
sftp:/mnt/share> put
Uploading CheckPlan--Jacky.docx to remote:/mnt/share/Check Plan--Jacky.docx
sftp: sent 453 KB in 0.05seconds
sftp:/mnt/share> put
Uploading ZMMSC.docx toremote:/mnt/share/ZMMSC.docx
sftp: sent 22.0 KB in 0.00seconds
sftp:/mnt/share> ls -lt
drwxrwxrwx 1 1000 users 4096 Jun 16 13:54 .
drwxr-xr-x 7 root root 4096 Jun 15 14:06 ..
-rwxrwxrwx 1 1000 users 220151 Jun 15 14:26.goutputstream-ZHJ8IY
-rwxrwxrwx 1 1000 users 19362 Jun 16 12:270.jpg
-rwxrwxrwx 1 1000 users 16157 Jun 16 13:39Auth Server and SOAP proxy.docx
-rwxrwxrwx 1 1000 users 63952 Jun 16 12:29bamquickinstall.pdf
-rwxrwxrwx 1 1000 users 464191 Jun 16 13:53Check Plan--Jacky.docx
-rwxrwxrwx 1 1000 users 7277 Jun 16 13:33DNSmmmS.txt
-rwxrwxrwx 1 1000 users 7277 May 12 10:43DNSS.txt
-rwxrwxrwx 1 1000 users 111395 Jun 15 15:46libpcap-0.9.4-15.el5.x86_64.rpm
-rwxrwxrwx 1 1000 users 363677 Jun 15 14:59ppp-2.4.4-14.1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 48430 Jun 15 14:57 ppp-devel-2.4.4-14.1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 86211 Jun 15 15:38pptpd-1.4.0-1.rhel4.x86_64.rpm
-rwxrwxrwx 1 1000 users 86509 Jun 15 14:46pptpd-1.4.0-1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 220151 Jun 15 13:22Screenshot.png
-rwxrwxrwx 1 1000 users 21789 Jun 16 13:52Traffic Usage System alarm handling - Gateway, RadiusGWProxy, RadiusProxyServer.docx
-rwxrwxrwx 1 1000 users 14815 Jun 16 13:53Virtual Browser.docx
-rwxrwxrwx 11000 users 22554 Jun 16 13:54 ZMMSC.docx
sftp:/mnt/share>
實例3、在遠程服務器建立刪除目錄
sftp:/mnt/share> mkdir /mnt/share/test
#在遠程服務器上建立目錄/mnt/share/test
sftp:/mnt/share> cd /mnt/share/test
sftp:/mnt/share/test> pwd
#查看是否建立成功
Remotedirectory is /mnt/share/test
sftp:/mnt/share/test> cd /mnt/share/
sftp:/mnt/share> rmdir /test
cannotremove /test: no such a directory
sftp:/mnt/share>rmdir /mnt/share/test
#刪除剛建立的目錄/mnt/share/test
sftp:/mnt/share> cd /mnt/share/test
cannotchange to /mnt/share/test: no such a directory
#確認是否刪除成功
實例4、在遠程服務器刪除文件
sftp:/mnt/share> rm ./ZMMSC
#刪除遠程服務器/mnt/share上的文件ZMMSC.docx,./表示當前目錄
cannotdelete /mnt/share/./ZMMSC: no such a file
sftp:/mnt/share> rm ./ZMMSC.docx
deleted/mnt/share/./ZMMSC.docx
sftp:/mnt/share> rm ./Traffic UsageSystem alarm handling - Gateway, RadiusGWProxy, RadiusProxy Server.docx
usage:rm file
sftp:/mnt/share> rm ./DNSS.txt
deleted/mnt/share/./DNSS.txt
sftp:/mnt/share> ls
#查看是否成功刪除
drwxrwxrwx 1 1000 users 4096 Jun 16 14:25 .
drwxr-xr-x 7 root root 4096 Jun 15 14:06 ..
-rwxrwxrwx 1 1000 users 220151 Jun 15 14:26.goutputstream-ZHJ8IY
-rwxrwxrwx 1 1000 users 19362 Jun 16 12:270.jpg
-rwxrwxrwx 1 1000 users 16157 Jun 16 13:39 AuthServer and SOAP proxy.docx
-rwxrwxrwx 1 1000 users 63952 Jun 16 12:29bamquickinstall.pdf
-rwxrwxrwx 1 1000 users 464191 Jun 16 13:53Check Plan--Jacky.docx
-rwxrwxrwx 1 1000 users 7277 Jun 16 13:33DNSmmmS.txt
-rwxrwxrwx 1 1000 users 111395 Jun 15 15:46libpcap-0.9.4-15.el5.x86_64.rpm
-rwxrwxrwx 1 1000 users 363677 Jun 15 14:59ppp-2.4.4-14.1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 48430 Jun 15 14:57ppp-devel-2.4.4-14.1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 86211 Jun 15 15:38pptpd-1.4.0-1.rhel4.x86_64.rpm
-rwxrwxrwx 1 1000 users 86509 Jun 15 14:46pptpd-1.4.0-1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 220151 Jun 15 13:22Screenshot.png
-rwxrwxrwx 1 1000 users 21789 Jun 16 13:52Traffic Usage System alarm handling - Gateway, RadiusGWProxy, RadiusProxyServer.docx
-rwxrwxrwx 1 1000 users 14815 Jun 16 13:53Virtual Browser.docx
sftp:/mnt/share>