Kiến trúc Von Neumann
Tìm hiểu về FTP :
Giới thiệu
FTP là chữ viết tắt của File Transfer Protocol ‐ Giao thức truyền file. FTP là một giao thức truyền file trên
mạng dựa trên chuẩn TCP nên rất
đáng tin cậy!
Một số lệnh phổ biến của FTP
Sau đây là danh sách một số lệnh thường dùng kèm theo hướng dẫn mà bạn cần biết!
ascii
chuyển sang chế độ truyền
file theo dạng văn bản
Binary
chuyển sang chế độ truyền file theo dạng nhị phân
cd [directory]
chuyển vào thư mục directory
Cdup
chuyển lên thư mục cấp trên một cấp
close
ngắt kết n
ối với máy chủ
del [remote‐file]
xóa 1 file trên máy chủ
dir [remote‐directory|file]
liệt kê nội dung của thư mục hoặc danh sách các file trên máy chủ
help [command]
cho biết hướng dẫn về lệnh
command
lcd [local‐directory]
đặt lại thư mục làm việc trên client là local‐directory
ls [remote‐directory|file] [‐la]
liệt kê nội dung của thư mục hoặc danh sách các file trên máy chủ; tham số ‐la sẽ liệt kê tất cả có kèm
theo mô tả về quyền
mdelete [remote‐files]
xóa nhiều file
trên máy chủ
mget [remote‐files]
download các files trên máy chủ về
mkdir <directory‐name>
tạo thư mục có tên directory‐name
mput [local‐files]
upload các files lên máy chủ
open host [port]
kết nối đến máy chủ FTP có hostname là
host và đang chạy dịch vụ FTP ở cổng port
put <local‐file> [remote‐file]
upload local‐file lên máy chủ với tên mới là remote‐file nếu được
pwd
cho biết thư mục đang làm việc hiện thời
quit
thoát
recv <remote‐file> [local‐file]
nhận remote‐file trên máy chủ và lưu trên máy tính với tên local‐file nếu được
rename [from] [to]
đổi tên file hoặc thư mục from thành to
rmdir directory‐name
xóa thư mục có
tên directory‐name
send local‐file [remote‐file]
gởi local‐file từ máy tính lên máy chủ với tên mới là remote‐file nếu được
status
cho biết trạng thái của phiên làm việc hiện tại
syst
cho biết hệ điều hành của máy chủ
user user‐name [password] [account]
login vào với tên là user‐name, mật khẩu là password, tài khoản là account
?
gọi hướng dẫn
Các ví dụ
Để dễ hi
ểu, các bạn hãy xem các ví dụ sautôi sử dụng các này để upload mấy file lên website đó, không
cần dùng các chương trình FTP mạnh như WS_FTP Pro, FTPNet, CuteFTP, AbsoluteFTP, ...!) Tôi lưu trang
web cần tải lên
server trong c:\website! Bây giờ tôi sẽ tải nó lên!
C:\website>ftp myftpsrv // kết nối đế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ư mụ
c hiện tại đang làm việc!
257 "/home/dt" is current directory.
ftp> status // xem trạng thái hiện tại
Type: ascii; Verbose: On ; Bell: Off ; Prompting: On ; Globbing: On
Debugging: Off ; Hash mark printing: Off . // ascii=1
ftp> cd www
// chuyển vào thư mục 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 // tạo
thư mục /home/dt/www/tools
257 "/home/dt/www/tools" directory created.
ftp> cd tools // chuyển vào thư mục tools
250 Directory changed to /home/dt/www/tools
ftp> lcd c:\website\tools // thay đổi lại local directory = c:\website\tools
Local directory now C:\website\tools.
ftp> bin // chuyển sang chế độ truyền file nh
ị phân
200 Type set to I.
ftp> mput *.* // upload tất 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 // liệt kê nội dung của /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 cần phải xóa nó
250 DELE command successful.
ftp> cd .. // chuyển lên thư mục cấp trên
250 Directory changed to /home/dt/www
ftp> mkdir cgi‐bin2 // tạo thư mục mới
257
"/home/dt/www/cgi‐bin2" directory created.
ftp> rename cgi‐bin2 cgi‐bin // tôi đã nhập vào sai mất rồi, bây giờ phải đổi tên lại thôi!
350 File or directory exists, ready for destination name
250 RNTO command successful.
ftp> cd cgi‐bin // chuyển vào
thư mục cgi‐bin
250 Directory changed to /home/dt/www/cgi‐bin
ftp> lcd c:\website\cgi‐bin // đặt lại local directory!
Local directory now C:\website\cgi‐bin.
ftp> ascii // chuyển sang chế độ truyền file văn bản vì tôi cần upload một 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 nội dung của /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 .
drwxr‐‐r‐‐ 1 dt group 0 Sep 30 14:16 ..
‐rwxr‐‐r‐‐ 1 dt group 222 Sep 30 14:17 test.cgi
226 Transfer complete.
ftp: 182 bytes received in
0.00Seconds 182000.00Kbytes/sec.
ftp> site chmod 755 test.cgi // đặt quyền 755(wrxx‐xr‐x) cho file test.cgi
ftp> ls ‐la // tôi liệt kê lại thư mục cgi một lần nữa
200 PORT Command successful.
150 Opening ASCII mode data connection for /bin/ls.
drwxr‐xr
‐x 1 dt group 0 Sep 30 14:16 .
drwxr‐xr‐x 1 dt group 0 Sep 30 14:16 ..
‐rwxr‐xr‐x 1 dt group 222 Sep 30 14:17 test.cgi
226 Transfer complete.
ftp: 182 bytes received in 0.00Seconds 182000.00Kbytes/sec.
ftp> bye // tất cả đã xong, bây
giờ tôi có thể ngắt kết nối được rồi!
221 Goodbye!
C:\website>
Hi vọng là bạn hiểu được ví dụ trên!
Nói thêm về FTP
Làm thế nào để kết nối với một máy chủ FTP qua một
proxy‐server, chẳng hạn như Wingate? Chỉ cần ftp
đến proxy‐server này và gõ vào như dạng sau, user@host[ort]. Ví dụ máy tôi đang chạy Wingate‐FTP ở
cổng 21 và Serv‐U FTP‐Server v2.5i ở cổng 2121, tôi có thể kết
nối đến Serv‐U FTP‐Server v2.5i qua
Wingate‐FTP như sau:
C:\>ftp localhost
Connected to dt.
220 WinGate Engine FTP Gateway ready
User (dtnone)): dt@localhost:2121
331 User name okay, need password.
Password:
230 User logged in, proceed.
ftp>
Okay, bây giờ tôi upload và download file như bình
thường được rồi!
Hack với FTP