Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a .tar.bz2 file Linux

On my Linux machine, I wish to create a .tar.bz2 file of a certain folder. Once I place myself in that folder (in the terminal), what do I type in the terminal command line to place the compressed folder in the home directory of my machine?

Let's say I am in the folder /home/user/folder. In the folder "folder" are several files (txt, .c etc). How do I compress that folder of type .tar.bz2 and place it in my /home directory?

In the /home/user/folder, I've tried sudo tar -cvjSf folder.tar.bz2 but get an error:

tar: Cowardly refusing to create an empty archive

like image 737
Adam Avatar asked Apr 23 '14 14:04

Adam


People also ask

What is a tar bz2 file in Linux?

An archive containing Tar files compressed with Bzip2 is referred to as an bz2 file. The process of extracting tar. If the tar -XF command precedes your archive name, it will work. how do i create a tar file in linux? how do i compress a tar bz2 file in linux? how do i create a tar file? how do i unzar a bz2 file in linux?

How do I create a tar gz file in Linux?

The general form of the command for creating tar.gz files is as follows: tar -czf archive-name.tar.gz file-name... Here’s what the command options mean: -c - instructs tar to create a new archive. -z - sets the compression method to gzip. -f archive-name.tar.gz - specifies the archive name.

How do i compress a tar file using bzip2?

Creating Tar Bz2 Archive Another popular algorithm for compressing tar files is bzip2. When using bzip2, the archive name should end with either tar.bz2 or tbz. To compress the archive with the bzip2 algorithm, invoke tar with the -j option.

How to create a tar archive with gzip?

The archive is piped to gzip, which compress and write the archive to the disk. Create a tar.gz file from all “.jpg” files: The wildcard character ( *) means all files that end with “.jpg” extension. Create a tar.gz file, transfer it over ssh and extract it on the remote machine: tar.gz file is a Tar archive compressed with Gzip.


1 Answers

You are not indicating what to include in the archive.

Go one level outside your folder and try:

sudo tar -cvjSf folder.tar.bz2 folder 

Or from the same folder try

sudo tar -cvjSf folder.tar.bz2 * 

Cheers!

like image 56
pietromenna Avatar answered Sep 25 '22 23:09

pietromenna