Tìm hiu v FTP :
trang này đã được đọc ln
Gii thiu
FTP là ch viết tt ca File Transfer Protocol - Giao thc
truyn file. FTP là mt giao thc truyn file trên mng da
trên chun TCP nên rt đáng tin cy!
Mt s lnh ph biến ca FTP
Sau đây là danh sách mt s lnh thường dùng kèm theo
hướng dn mà bn cn biết!
ascii chuyn sang chế độ truyn file theo dng văn bn
binary chuyn sang chế độ truyn file theo dng nh phân
cd [directory] chuyn vào thư mc directory
cdup chuyn lên thư mc cp trên mt cp
close ngt kết ni vi máy ch
del [remote-file] xóa 1 file trên máy ch
dir [remote-directory|file] lit kê ni dung ca thư mc hoc
danh sách các file trên máy ch
help [command] cho biết hướng dn v lnh command
lcd [local-directory] đặt li thư mc làm vic trên client là
local-directory
ls [remote-directory|file] [-la] lit kê ni dung ca thư mc
hoc danh sách các file trên máy ch; tham s -la s lit kê
tt c có kèm theo mô t v quyn
mdelete [remote-files] xóa nhiu file trên máy ch
mget [remote-files] download các files trên máy ch v
mkdir <directory-name> to thư mc có tên directory-name
mput [local-files] upload các files lên máy ch
open host [port] kết ni đến máy ch FTP có hostname là
host và đang chy dch v FTP cng port
put <local-file> [remote-file] upload local-file lên máy ch vi
tên mi là remote-file nếu được
pwd cho biết thư mc đang làm vic hin thi
quit thoát
recv <remote-file> [local-file] nhn remote-file trên máy ch
và lưu trên máy tính vi tên local-file nếu được
rename [from] [to] đổi tên file hoc thư mc from thành to
rmdir directory-name xóa thư mc có tên directory-name
send local-file [remote-file] gi local-file t máy tính lên máy
ch vi tên mi là remote-file nếu được
status cho biết trng thái ca phiên làm vic hin ti
syst cho biết h điu hành ca máy ch
user user-name [password] [account] login vào vi tên là
user-name, mt khu là password, tài khon là account
? gi hướng dn
Các ví d
Để d hiu, các bn hãy xem các ví d sau:(tôi s dng các
này để upload my file lên website đó, không cn dùng các
chương trình FTP mnh như WS_FTP Pro, FTPNet,
CuteFTP, AbsoluteFTP, ...!) Tôi lưu trang web cn ti lên
server trong c:\website! Bây gi tôi s ti nó lên!
C:\website>ftp myftpsrv // kết ni đến máy ch myftpsrv
Connected to myftpsrv.
User (ftpsrv:(none)): dt
331 User name okay, need password.
Password:
230 User logged in, proceed.
ftp> pwd // cho biết thư mc hin ti đang làm vic!
257 "/home/dt" is current directory.
ftp> status // xem trng thái hin ti
Type: ascii; Verbose: On ; Bell: Off ; Prompting: On ;
Globbing: On
Debugging: Off ; Hash mark printing: Off . // ascii=1
ftp> cd www // chuyn vào thư mc www
250 Directory changed to /home/dt/www
ftp> put index.html // upload file index.html lên server
200 PORT Command successful.
150 Opening ASCII mode data connection for index.html.
226 Transfer complete.
ftp: 2095 bytes sent in 0.00Seconds 2095000.00Kbytes/sec.
ftp> mkdir tools // to thư mc /home/dt/www/tools
257 "/home/dt/www/tools" directory created.
ftp> cd tools // chuyn vào thư mc tools
250 Directory changed to /home/dt/www/tools
ftp> lcd c:\website\tools // thay đổi li local directory =
c:\website\tools
Local directory now C:\website\tools.
ftp> bin // chuyn sang chế độ truyn file nh phân
200 Type set to I.
ftp> mput *.* // upload tt c các file trong c:\website\tools
lên server, vào /home/www/tools/
mput test.zip? y
200 PORT Command successful.
150 Opening BINARY mode data connection for test.zip.
226 Transfer complete.
ftp: 10168 bytes sent in 0.06Seconds 169.47Kbytes/sec.
mput test.exe? y
200 PORT Command successful.
150 Opening BINARY mode data connection for test.exe.
226 Transfer complete.
ftp: 54625 bytes sent in 0.11Seconds 496.59Kbytes/sec.
ftp> ls -la // lit kê ni dung ca /home/www/tools
200 PORT Command successful.
150 Opening ASCII mode data connection for /bin/ls.
drwxr--r-- 1 dt group 0 Sep 30 14:13 .
drwxr--r-- 1 dt group 0 Sep 30 14:13 ..
-rwxr--r-- 1 dt group 54625 Sep 30 14:14 test.exe
-rwxr--r-- 1 dt group 10168 Sep 30 14:14 test.zip
226 Transfer complete.
ftp: 247 bytes received in 0.00Seconds
247000.00Kbytes/sec.
ftp> del test.exe // tôi l tay upload lên file test.exe, bây gi
tôi cn phi xóa nó
250 DELE command successful.
ftp> cd .. // chuyn lên thư mc cp trên
250 Directory changed to /home/dt/www
ftp> mkdir cgi-bin2 // to thư mc mi
257 "/home/dt/www/cgi-bin2" directory created.
ftp> rename cgi-bin2 cgi-bin // tôi đã nhp vào sai mt ri,
bây gi phi đổi tên li thôi!
350 File or directory exists, ready for destination name
250 RNTO command successful.
ftp> cd cgi-bin // chuyn vào thư mc cgi-bin
250 Directory changed to /home/dt/www/cgi-bin
ftp> lcd c:\website\cgi-bin // đặt li local directory!
Local directory now C:\website\cgi-bin.
ftp> ascii // chuyn sang chế độ truyn file văn bn vì tôi cn
upload mt s file .cgi + .pl
200 Type set to A.
ftp> put test.cgi // upload file test.cgi
200 PORT Command successful.
150 Opening ASCII mode data connection for test.cgi.
226 Transfer complete.
ftp: 222 bytes sent in 0.00Seconds 222000.00Kbytes/sec.
ftp> ls -la // xem ni dung ca /home/www/cgi-bin
200 PORT Command successful.
150 Opening ASCII mode data connection for /bin/ls.
drwxr--r-- 1 dt group 0 Sep 30 14:16 .