64

I have a directory that I want to compress to send it by e-mail, I've tried this:

tar -cvf filename.tar.gz directory_to_compress/

But when I try to send it by e-mail, Google says:

filename.tar.gz contains an executable file. For security reasons, Gmail does not allow you to send this type of file.

How to compress a directory into a tar.gz file from command line?

slackmart
  • 4,754
  • 3
  • 25
  • 39

4 Answers4

129
tar -cvzf filename.tar.gz directory_to_compress/

Most tar commands have a z option to create a gziped version.

Though seems to me the question is how to circumvent Google. I'm not sure if renaming your output file would fool Google, but you could try. I.e.,

tar -cvzf filename.bla directory_to_compress/

and then send the filename.bla - contents will would be a zipped tar, so at the other end it could be retrieved as usual.

Levon
  • 138,105
  • 33
  • 200
  • 191
8

To bypass google's check, which is what you really want, simply remove the extensions from the file when you send it, and add them back after you download it. For example:

  • tar czvf file.tar.gz directory
  • mv file.tar.gz filetargz
  • [send filetargz via gmail]
  • [download filetargz]
  • [rename filetargz to file.tar.gz and open]
Adriano Varoli Piazza
  • 7,297
  • 5
  • 39
  • 50
3

Another easy way to circumvent google's check is to use another compression algorithm with tar, like bz2:

tar -cvjf my.tar.bz2 dir/

Note that 'j' (for bz2 compression) is used above instead of 'z' (gzip compression).

kirx
  • 31
  • 1
2

Try this:

tar -czf my.tar.gz dir/

But are you sure you are not compressing some .exe file or something? Maybe the problem is not with te compression, but with the files you are compressing?

divaka
  • 593
  • 7
  • 12