Browse Docs

Files

In this section

  • ๐Ÿ—œ Compression

    Zip / Unzip

    1zip <archive.zip> <file1> <file2>     # compress files.
    2zip -r <archive.zip> <directory>      # compress a directory.
    3unzip archive_name.zip [-d directory] # decompress an archive.
    

    Gzip / Gunzip

    gzip is based on the Deflate algorithm (a combination of the LZ77 and Huffman algorithms).

    1gzip -l                                          # show the size of the uncompressed file.
    2gzip <file>                                      # compress.
    3gunzip <file.gz> | gzip -d <file.gz>             # decompress.
    4gzip -9 <my_file>                                # compress a file optimally.
    5gzip -c <file1> <file2> > compressed_file.gz     # compress several files into a single one.
    

    Bzip2 / Bunzip2

    bzip2 is an alternative to gzip, more efficient but slower.

  • ๐Ÿ“ฆ Archive

    Tar - “tape archiver”

    • Preserve files permissions and ownership.

    • The Basics

     1# Archive
     2tar cvf my_archive.tar <file1> <file2> </dir/folder/>
     3
     4## Archive and compress with zstd everything in the current dir and push to /target/dir
     5tar -I zstd -vcf archive.tar.zstd -C /target/dir . 
     6
     7# Extract
     8tar xvf my_archive.tar
     9
    10# Extract and push to target dir 
    11tar -zxvf new.tar.gz -C /target/dir 
    
    • Other useful options โ€ข t : list archive’s content. โ€ข T : archive list given by a file. โ€ข P : preserve absolute path (useful for backing up /etc). โ€ข X : exclude. โ€ข z : gunzip compression. โ€ข j : bzip2 compression. โ€ข J : lzma compression.

  • ๐Ÿ’พ Backup & Sync

    Rsync

    The classic formula

    1rsync -arv --info=progress2 photo backup_photo
    
    • a = archive โ€” preserves permissions (owner, group), times, symbolic links and devices.
    • r = recursive โ€” copies directories and sub-directories.
    • v = verbose โ€” prints what is being copied.

    Examples

    1rsync -apvz --stats --update --exclude gsast/olap_cubes --exclude gsast/param   user@server-src:/export/ user@server-dest:/home/
    2rsync -av -e ssh root@192.168.1.10:/backup/DUMP/* .
    3rsync -azp --stats root@oracle-src:/ec/sw/oracle/client/product/12.2.0.1/network/mesg/ ~/mesg/
    4rsync -azp /home/user/mesg/ root@oracle-dest.example.com:/ec/sw/oracle/client/product/12.2.0.1/network/mesg/
    5
    6ssh root@oracle-dest.example.com "ls -lrt /ec/sw/oracle/client/product/12.2.0.1/network/mesg/"
    7ssh root@oracle-dest.example.com "chown oracle:dc_dba /ec/sw/oracle/client/product/12.2.0.1/network/mesg/*"
    8
    9rsync -aS --delete --rsh /export/home backup-host:/export/save
    

    Propagate deletions to the backup

    If you delete files in the source directory, rsync does not propagate the deletion to the backup directory unless you add the --delete option.

Sunday, October 4, 2026 Monday, January 1, 1