Linux tftp Command
The Linux tftp command is used to transfer files.
TFTP (Trivial File Transfer Protocol) is a simple file transfer protocol, commonly used to transfer small files over a network.
Compared with FTP (File Transfer Protocol), TFTP is more lightweight and relatively simpler in function.
TFTP is typically used in LAN environments, especially for firmware upgrades of network devices and configuration file transfers.
TFTP uses UDP (User Datagram Protocol) as its transport layer protocol, with a default port number of 69. Since UDP is connectionless, TFTP is fast but less reliable, so packet loss may occur during transfer.
Syntax
tftp [选项] [主机名或IP地址]
**Common Options: **
tftpThe command supports several common options; here are some of them and their functions:
-v: Enable verbose mode and display more debugging information.-c: Specify the file to transfer.-l: Specify the local file name.-r: Specify the remote file name.-g: Get a file from the server (equivalent togetcommand).-p: Upload a file to the server (equivalent toputcommand).
Operation instructions:
- connect: Connect to a remote tftp server
- mode: File transfer mode
- put: Upload a file
- get: Download a file
- quit: Exit
- verbose: Display detailed processing information
- trace: Display packet paths
- status: Display current status information
- binary: Binary transfer mode
- ascii: ASCII transfer mode
- rexmt: Set the packet retransmission timeout
- timeout: Set the retransmission timeout
- help: Help information
- ? : Help information
Basic Usage of the TFTP Command
Connect to a TFTP Server
To connect to a TFTP server, you can use the following command:
tftp 192.168.1.1
Where192.168.1.1is the IP address of the TFTP server. After running the command, the system enters TFTP interactive mode and the prompt becomes tftp>.
Download Files
In TFTP interactive mode, you can use get a command to download files from the server. For example, to download a file namedconfig.txt:
tftp> get config.txt
This command willconfig.txtdownload the file from the TFTP server to the current working directory.
Upload files
To upload a file to a TFTP server, you can useputcommand. For example, to upload a file namedbackup.cfg:
tftp> put backup.cfg
This command will backup.cfg to upload the file to the TFTP server.
Exit TFTP interactive mode
To exit TFTP interactive mode, you can usequitorexitCommand:
tftp> quit
Example
To connect to the remote server "218.28.188.288" and then use the put command to download the file "README" from its root directory, use the following command:
tftp 218.28.188.288 #连接远程服务器
After connecting to the server, you can perform the corresponding operations, as follows:
$ tftp 218.28.188.228 #连接远程服务器
tftp> ? #使用?,参考帮助
Commands may be abbreviated. Commands are: #帮助命令列表
connect connect to remote tftp
mode set file transfer mode
put send file
get receive file
quit exit tftp
verbose toggle verbose mode
trace toggle packet tracing
status show current status
binary set mode to octet
ascii set mode to netascii
rexmt set per-packet retransmission timeout
timeout set total retransmission timeout
? print help information
tftp>get README #远程下载README文件
getting from 218.28.188.288 to /home/cmd
Recived 168236 bytes in 1.5 seconds[112157 bit/s]
tftp>quit #离开tftp
Use -v The option enables verbose mode:
tftp -v 192.168.1.1
Download a file and specify a local filename
Suppose you want to download from the TFTP serverconfig.txtfile, and save it aslocal_config.txt, you can use the following command:
tftp 192.168.1.1
tftp> get config.txt local_config.txt
Upload a file and specify a remote filename
Suppose you want to upload a localbackup.cfgfile to the TFTP server and save it asremote_backup.cfg, you can use the following command:
tftp 192.168.1.1
tftp> put backup.cfg remote_backup.cfg
Download files directly using command-line options
If you don't want to enter TFTP interactive mode, you can directly use on the command line -g option to download a file:
tftp -g -r config.txt 192.168.1.1
This command downloads from the192.168.1.1serverconfig.txtfiles.
Limitations of TFTP
Although TFTP is simple and easy to use, it also has some limitations:
- Lower reliability: Since TFTP uses the UDP protocol, packet loss may occur during transmission, especially in unstable network environments.
- : The Date class itself does not contain time zone information; time zone handling requires additional classes.: TFTP does not support advanced features such as directory listing or file deletion, and is only suitable for simple file transfers.
- Lower security: TFTP has no built-in encryption mechanism, so transferred file contents may be eavesdropped on or tampered with.
Linux Command Reference