Linux File Transfer Commands
Linux File Transfer Commands:
ftp: A traditional file transfer protocol; widely used but has lower security.sftp: Secure Shell-based secure file transfer protocol, providing interactive file management capabilities.tftp: Simple Trivial File Transfer Protocol, primarily used for firmware upgrades of network devices.lftp: Powerful FTP client supporting multiple file transfer protocols and advanced features.ftpwho: View the list of users currently connected to an FTP server.lprm: Remove print jobs from a printer queue.wget: Command-line download tool capable of downloading individual files or entire websites.smbclient: Access Windows shared folders on Linux systems.rsync: Efficient incremental file transfer utility that minimizes network bandwidth usage.scp(Secure Copy): Securely copy files between remote hosts.
Detailed Descriptions
1. ftp (File Transfer Protocol)
Introduction: A traditional file transfer protocol; widely used but has lower security. Supports basic operations such as uploading, downloading, and managing files.
Commands & Options:
ftp remote_host: Connect to a remote FTP server.get filename: Download a file from the remote server.put filename: Upload a file to the remote server.ls/dir: List directories on the remote server.cd directory: Change directory on the remote server.
Examples:
ftp ftp.example.com: Connect to the remote FTP server.get file.zip: Download file.zip from the remote server.put localfile.txt: Upload localfile.txt to the remote server.
2. sftp (Secure File Transfer Protocol)
Introduction: A secure file transfer protocol based on SSH, encrypting the transmission process. Provides interactive browsing and management capabilities for files.
Commands & Options:
sftp user@remote_host: Connect to a remote SFTP server.get filename: Download a file from the remote server.put filename: Upload a file to the remote server.ls/dir: List directories on the remote server.cd directory: Change directory on the remote server.
Examples:
sftp user@example.com: Connect to the remote SFTP server.get file.pdf: Download file.pdf from the remote server.put localfile.txt: Upload localfile.txt to the remote server.
3. tftp (Trivial File Transfer Protocol)
Introduction: A simple file transfer protocol, primarily used for firmware upgrades of network devices. Features are relatively basic and do not support complex file management operations.
Commands & Options:
tftp -i remote_host get filename: Download a file from the remote host.tftp -i remote_host put filename: Upload a file to the remote host.
Examples:
tftp -i 192.168.1.100 get firmware.bin: Download firmware.bin from the remote host at IP address 192.168.1.100.tftp -i 192.168.1.100 put newfw.bin: Upload localfile newfw.bin to the remote host at IP address 192.168.1.100.
4. lftp
Introduction: A powerful FTP client supporting multiple file transfer protocols. Provides more advanced features such as resume downloads and parallel downloading.
Commands & Options:
lftp remote_host: Connect to a remote FTP/SFTP server.get filename: Download a file from the remote server.put filename: Upload a file to the remote server.mirror /remote/dir /local/dir: Recursively download a remote directory.pget -n 4 filename: Download a file using four parallel connections.
Examples:
lftp ftp.example.com: Connect to the remote FTP server.get file.zip: Download file.zip from the remote server.put localfile.txt: Upload localfile.txt to the remote server.mirror /remote/docs /local/backup: Recursively download directory/remote/docsfrom the remote host into/local/backup.pget -n 4 largefile.iso: Download file largefile.iso using four parallel connections.
5. ftpwho
Introduction: Used to view the list of users currently connected to an FTP server. Can display connection status and upload/download statistics for each user.
Commands & Options:
ftpwho: Display the current list of users on the FTP server.
Examples:
ftpwho: View users currently connected to the FTP server.
6. lprm
Introduction: A command used to remove print jobs from a printer queue. Can delete specific print jobs or all print jobs for the current user.
Commands & Options:
lprm -P printer_name job_id: Delete a specified print job.lprm -a: Remove all print jobs belonging to the current user.
Examples:
lprm -P office_printer 123: Delete job ID 123 from printer named "office_printer".lprm -a: Remove all print jobs for the current user.
7. wget
Introduction: A command-line download tool capable of downloading individual files or entire websites. Supports features such as resume downloads and automatic retries.
Commands & Options:
wget url: Download a specified file or website.wget -c url: Resume interrupted download (continue).wget -r url: Recursively download an entire website.
Examples:
wget https://example.com/file.zip: Download file.zip.wget -c https://example.com/largefile.iso: Resume downloading largefile.iso.wget -r https://example.com: Recursively download the example.com website.
8. smbclient
Introduction: Allows access to Windows shared folders on a Linux system. Provides functionality for browsing, uploading, and downloading files.
Commands & Options:
smbclient //remote_host/share -U username: Connect to a remote Windows share.get filename: Download a file from the share.put filename: Upload a file to the share.ls/dir: List directories on the share.cd directory: Change directory within the share.
Examples:
smbclient //192.168.1.100/documents -U john: Connect to remote Windows share "documents".get file.docx: Download file.docx from the share.put localfile.txt: Upload localfile.txt to the share.
9. rsync
Introduction: An efficient incremental file transfer utility that minimizes network bandwidth usage. Supports synchronization between local and remote systems, preserving file attributes and permissions.
Commands & Options:
rsync -avz /source/dir/ /dest/dir/: Synchronize source directory to destination directory.rsync -avz user@remote_host:/remote/dir /local/dir: Sync a directory from the remote host.rsync -avz /local/dir user@remote_host:/remote/dir: Sync a local directory to the remote host.
Examples:
rsync -avz /home/user/documents/ /backup/documents: Synchronize the documents directory in/home/userto the backup directory.rsync -avz user@example.com:/remote/files /local/backup: Sync the/remote/filesdirectory from a remote host into/local/backup.rsync -avz /local/project user@example.com:/remote/project: Synchronize the local project directory to/remote/projecton the remote host.
10. scp (Secure Copy)
Introduction: Securely copy files between remote hosts. Supports uploading and downloading of individual files and directories.
Commands & Options:
scp file user@remote_host:/remote/path: Upload a local file to the remote host.scp user@remote_host:/remote/file /local/path: Download a file from the remote host.scp -r /local/dir user@remote_host:/remote/path: Recursively upload a local directory to the remote host.scp -r user@remote_host:/remote/dir /local/path: Recursively download a directory from the remote host.
Examples:
scp file.zip user@example.com:/remote/downloads: Upload localfile file.zip to/remote/downloadson the remote host.scp user@example.com:/remote/document.pdf /local/documents: Download document.pdf from the remote host into/local/documents.scp -r /home/user/project user@example.com:/remote/projects: Recursively upload the project directory in/home/userto/remote/projectson the remote host.scp -r user@example.com:/remote/backups /local/backup: Recursively download the backups directory from the remote host into/local/backup.