Notifications
Clear all

Linux Commands Cheat Sheet - File Transfer & Management


(@scriptguru)
Byte Beginner
Joined: 9 months ago
Posts: 24
Topic starter  

This sheet is designed to assist you in efficiently managing file transfers within your Linux environment, covering everything from basic copy and move operations to advanced file synchronization and archiving techniques.

Command Description
cp file1 file2 Copy file1 to file2.
cp -r dir1 dir2 Recursively copy dir1 and its contents to dir2. If dir2 doesn't exist, it will be created.
mv file1 file2 Move or rename file1 to file2.
scp file1 user@host:directory Securely copy file1 to a remote host.
scp user@host:file1 file2 Securely copy a file from a remote host to a local destination.
rsync -av source destination Synchronize files/directories between the source and the destination. The -a option preserves permissions, timestamps, etc., and -v provides verbose output.
rsync -avz source user@host:destination Synchronize files/directories to a remote system with compression enabled.
rsync -avz user@host:source destination Synchronize files/directories from a remote system to a local destination with compression.
wget URL Download files from the internet.
curl -O URL Fetch a file from a URL and write it to a local file with the same name.
curl -o localname URL Fetch a file from a URL and save it as localname on the local filesystem.
tar -cvf archive.tar files Create an uncompressed tar archive containing files.
tar -xvf archive.tar Extract the contents of archive.tar.
tar -czvf archive.tar.gz files Create a gzipped tar archive.
tar -xzvf archive.tar.gz Extract a gzipped tar archive.
zip -r archive.zip files Create a ZIP archive containing files.
unzip archive.zip Extract the contents of a ZIP archive.
gzip file Compress file using gzip. The original file is replaced with a compressed version ending in .gz.
gunzip file.gz Decompress file.gz with gzip.
bzip2 file Compress file using bzip2. The original file is replaced with a compressed version ending in .bz2.
bunzip2 file.bz2 Decompress file.bz2 with bzip2.
dd if=/dev/sdx of=/dev/sdy Clone raw data from one drive (sdx) to another (sdy). Useful for creating exact backups.
dd if=/dev/sdx of=/path/to/image.img Create an image file of a drive.
dd if=/path/to/image.img of=/dev/sdx Restore an image file to a drive.
ssh user@host Secure Shell login to host as user, useful for secure file manipulation through commands on the remote host.
nc -l -p port > file (On receiver) Use netcat to listen on a port and write incoming data to file.
nc host port < file (On sender) Use netcat to send file to a host listening on port.

   
Quote
Share: