An archive packs a whole folder into one file: easier to download, to send or to keep as a copy. This page shows tar, which every Linux has, zip for people who use Windows, and how to split a big archive into parts. The commands were tested on Ubuntu 26.04 LTS.


1. tar: the Linux Standard

Pack the folder Photos into photos.tar.gz:

tar -czf photos.tar.gz Photos

c creates, z compresses with gzip, f names the file. Already compressed files such as photos, films or music hardly get smaller; the archive is then mainly one file instead of many. For example, 90 MB of photos give a 90 MB archive.

  • Look inside without unpacking: tar -tzf photos.tar.gz
  • Unpack into a folder: mkdir restore && tar -xzf photos.tar.gz -C restore

The unpacked folder is identical to the original: diff -r finds no difference.

2. zip: for Windows Users

apt install zip
zip -r photos.zip Photos
unzip -l photos.zip

Windows opens .zip files without extra programs. unzip photos.zip unpacks it on Linux.

zip -e -r private.zip Photos asks for a password. This zip password uses an old, weak method: fine against curious eyes, not for secrets. For real encryption, see Automatic Encrypted Backups of Your Server to Another Server With restic or Encrypt a Data Disk on Your Linux Server With LUKS.

3. Split a Big Archive Into Parts

Some services accept only files up to a certain size. Split the archive into parts of, for example, 4 GB:

split -b 4G -d photos.tar.gz photos.tar.gz.part

This writes photos.tar.gz.part00, photos.tar.gz.part01 and so on. To put them back together:

cat photos.tar.gz.part* > photos.tar.gz

The joined file is identical to the original. Compare checksums to be sure after a transfer: sha256sum photos.tar.gz on both sides must give the same value. On Windows, the Command Prompt joins them with copy /b photos.tar.gz.part00 + photos.tar.gz.part01 photos.tar.gz.

Download the archive with an SFTP program such as FileZilla (Download files from server via FTP – FileZilla). To let someone else download it, see Give Someone SFTP Access to One Folder Only.


Related Guides

View all Linux guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)