Create an archive with command "gzip"

gzip works with files, not directories. Therefore to create an archive of a directory you need to use tar (which will create a single tarball out of multiple files):

tar cvf myetc.tar /etc

or, for a gzipped archive:

tar cvzf myetc.tar.gz /etc

Gzip works only with a single file, or a stream - data piped to gzip. So you first need to generate one file, like with tar, and then you could gzip that. The other option is to gzip all individual files, and then tar that into one file.

Both these solutions are stupid and should not be used. You should use tar with the built in compression option and do it all in one command.

Tags:

Archive

Gzip