The error message tells what to do: you probably need to add
-c (for create), e.g.,
tar -jcf user-logs.tar myargs
as well as some arguments myargs (things to put into the
In the second case, the problem is that you do not have
bzip2 installed. The tar program relies upon this external program to do compression.
If you have a tar archive and simply want to compress it, you could do this:
which (if you had
bzip2 installed) would change the file to
user-logs.tar.bz2 (and usually make it much smaller).
bzip2, it depends on the system you are using. For example, with Ubuntu that would be
sudo apt-get install bzip2
while Fedora might be (perhaps
sudo yum install bzip2
tar program does not know how to compress an existing file such as
bzip2 does that). The
tar program can use external compression programs
xz by opening a pipe to those programs, sending a tar archive via the pipe to the compression utility, which compresses the data which it reads from
tar and writes the result to the filename which the
tar program specifies.
tar and compression utility could be the same program. BSD tar does its compression using
libarchive (they're not really distinct except in name).