239

I'm trying to compress a directory and ftp it to a windows ftp.

I have tried every tar command I can find to compress a directory. It appears to be ok. Then I transfer it and view it's contents using Winrar. Winrar keeps telling me the file is corrupted. I have viewed other .gz or .bz2 files using winrar but for some odd reason I can't get it to work.

I would prefer just to have it zip the files so they have a .zip extension but even then when i try to browse it's contents both windows and winrar claim it's corrupt.

Does anyone else have a suggestion as to something else to try?

2
  • (1) what exact tar command are you using? (2) can you untar the resulting file?
    – djeikyb
    Feb 21, 2011 at 9:31
  • 1
    Try using 7zip to view the file in Windows.
    – Oxwivi
    Feb 21, 2011 at 11:59

3 Answers 3

383

Well, most probably your files are perfectly fine before FTP transmission.

Unfortunately, probably you are transferring your files using wrong FTP mode.

FTP do have two modes: binary and ASCII. By default most clients use ASCII mode, which breaks your binary files completely. I don't know which FTP client you are using, but for example in ncftp you can use command "binary" to switch to binary mode.

If you want to create ZIP files using Ubuntu (or almost any other Linux), use zip. You can install it to Ubuntu by running

sudo apt-get install zip

Then you can create zip file by running

zip -r compressed_filename.zip foldername

On related note, you should know that FTP is insecure transmission protocol. Consider switching to sftp, for example. There is many free ssh servers for Windows, including minimal OpenSSH port.

2
  • Good point typically i relied on the client/server to automatically detect ascii vs binary mode and haven't had a problem so I never thought of that as a potential problem. I've ran zip before also and everything appeared fine until I tried to view it. Probably due to the binary/ascii thing.
    – dko
    Feb 21, 2011 at 14:14
  • Anyhow wow thank you, I feel like an idiot now that it was that simple. I should have known that. Anyhow thanks for the tip about the ssh for windows, eventually i was going to switch to that but i know ftp for windows throws fewer variables into the testing and developing factor.
    – dko
    Feb 21, 2011 at 14:19
77

Campression can be done using tar, zip, p7 and even rar in ubuntu. You will need to install rar for rar archiving. Simply right clicking gives you the options for compressing with installed archivers. enter image description here

If you want to use "zip" for .zip extentension you can see manual of zip. The commandline for using tar is:

tar cvzf tarball.tar.gz directory/
4
  • 1
    Awesome theme! What's the name of it? Sep 24, 2014 at 10:00
  • is there any "-q" for "quite mode"? Feb 3, 2015 at 14:05
  • 3
    @MatheusJardimB take out the v option tar czf tarball.tar.gz directory/
    – Adam
    May 6, 2015 at 8:15
  • 7
    c means create, z means compress, v is verbose and f is create a new file.
    – The Onin
    Feb 12, 2020 at 16:41
7

Compression of directories, using parallel compression is an efficient way to save time. pbzip2 can help you getting directories compressed.

tar cf <outputfile_name> --use-compress-prog=pbzip2 <directory_name>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .