[linux] 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

This question is related to linux compression tar

The answer is


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!


Try this from different folder:

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

Examples related to linux

grep's at sign caught as whitespace How to prevent Google Colab from disconnecting? "E: Unable to locate package python-pip" on Ubuntu 18.04 How to upgrade Python version to 3.7? Install Qt on Ubuntu Get first line of a shell command's output Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Run bash command on jenkins pipeline How to uninstall an older PHP version from centOS7 How to update-alternatives to Python 3 without breaking apt?

Examples related to compression

Image steganography that could survive jpeg compression How to enable GZIP compression in IIS 7.5 Create a .tar.bz2 file Linux How are zlib, gzip and zip related? What do they have in common and how are they different? Create a tar.xz in one command Creating a ZIP archive in memory using System.IO.Compression How to compress an image via Javascript in the browser? How to reduce the image size without losing quality in PHP How to send a compressed archive that contains executables so that Google's attachment filter won't reject it How to reduce the image file size using PIL

Examples related to tar

gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now Create a .tar.bz2 file Linux what does -zxvf mean in tar -zxvf <filename>? tar: file changed as we read it Create a tar.xz in one command How to tar certain file types in all subdirectories? Tar a directory, but don't store full absolute paths in the archive How to uncompress a tar.gz in another directory How to extract filename.tar.gz file Utilizing multi core for tar+gzip/bzip compression/decompression