Search code examples
linuxcompressiontar

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


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 *