Creating A tar File in Linux Via Command Line Options

Creating A tar File in Linux Via Command Line Options

To create a tar file in Linux via the command line, you can use the tar command with the following options:

re‮ot ref‬:lautturi.com
tar -cf archive.tar file1 file2 file3

This will create a tar archive called archive.tar containing the files file1, file2, and file3.

If you want to compress the tar archive using gzip, you can use the z option:

tar -czf archive.tar.gz file1 file2 file3

This will create a gzip-compressed tar archive called archive.tar.gz.

If you want to create a tar archive of an entire directory, you can use the -C option to specify the directory and the -r option to append files to the end of the archive:

tar -C /path/to/directory -cf archive.tar .

This will create a tar archive called archive.tar containing all the files and directories in the /path/to/directory directory.

You can also use the -v option to display the names of the files being added to the archive as they are added:

tar -C /path/to/directory -cvf archive.tar .

For more options and usage examples, you can refer to the tar man page by running man tar in the terminal.

Created Time:2017-10-28 14:02:23  Author:lautturi