how tar a file in linux code example Example 1: how to tar linux tar -zcvf file.tar.gz /path/to/dir/ Example 2: tar.gz terminal tar -xzvf archive.tar.gz