Using tar to Archive, Extract, Compress, and Uncompress Files
• Xitalogy
The Commands
Introduction
Here I show how to use the Linuxtar command to create uncompressed tarballs (archives) and tarballs compressed with various
compression algorithms of all files and directories in the current working directory. I also show how to simultaneously uncompress (if necessary)
and extract all the files into the current working directory.
Discussion
All the above commands were tested on an Ubuntu 18.04.4 LTS (bionic). For complete details, see the Ubuntu man page for tar.
Here is a breakdown of all the options used above directly from the man page:
-c, –create
create a new archive
-x, –extract, –get
extract files from an archive
-v, –verbose
verbosely list files processed
-z, –gzip
filter the archive through gzip
-j, –bzip2
filter the archive through bzip2
-J, –xz
filter the archive through xz
-f, –file=ARCHIVE
use archive file or device ARCHIVE
You can combine these options together without the need for any dashes as I have done above. There is no need to have an = sign between the f
option and the filename for the archive.