Adam
Adam

Reputation: 2552

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

Upvotes: 113

Views: 187418

Answers (3)

pietromenna
pietromenna

Reputation: 2276

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 *

Upvotes: 215

MADHUSUDAN RATNALU
MADHUSUDAN RATNALU

Reputation: 23

tar cvzf file.tar.gz *.c OR tar cvzf file.tar.gz *

for more read this article https://www.geeksforgeeks.org/tar-command-linux-examples/

Upvotes: -4

Robert Juhasz
Robert Juhasz

Reputation: 141

Try this from different folder:

sudo tar -cvjSf folder.tar.bz2 folder/*

Upvotes: 14

Related Questions