atool
is designed for this job. A copy of the man page is available here.
To compress files use
apack ARCHIVE FILE
and to decompress them use
aunpack ARCHIVE
(alternatively you can use atool -a
and atool -x
respectively).
It works with pretty much any archive format you can think of including gzip, bzip, lzip, 7z, rar, ar, deb, rpm, jar[1] and most combinations of tar and a compression method.
The advantage of this over 7zip is that 7zip removes executable permissions. So, for example, 7zip makes it much more difficult to install software from archived sources because you need to manually chmod +x
the appropriate files before running any make or any install scripts.
[1] The online man page linked is for an older version that doesn't handle jar files.