Question

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

Was it helpful?

Solution

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 *

OTHER TIPS

Try this from different folder:

sudo tar -cvjSf folder.tar.bz2 folder/*
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/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top