Bash and Linux 5 cheatsheet

Bash and Linux 5: Archives and transfer

7 common Bash and Linux 5 tasks.

Create a compressed archive

Pack a folder into a .tar.gz file.

tar -czf archive.tar.gz folder/

Extract an archive

Unpack a .tar.gz file into the current folder.

tar -xzf archive.tar.gz

List an archive's contents

See what is inside without extracting.

tar -tzf archive.tar.gz

Connect to a server

Open a shell on a remote machine.

Create an SSH key

Generate a modern Ed25519 key pair. The public key is the .pub file.

ssh-keygen -t ed25519 -C "[email protected]"

Copy a file to a server

Copy a local file to a remote folder over SSH.

scp file.txt [email protected]:/home/user/

Sync a folder to a server

Copy only what changed, preserving permissions, with progress.

rsync -avz --progress folder/ [email protected]:/srv/folder/

Caution: A trailing slash on the source changes where files land. Add --dry-run to preview.

Was this page helpful?