How to Use Tar Command in Linux

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

7/15/24, 10:49 AM How to Use Tar Command in Linux [16 Best Uses]

Linuxier  

Home  Linux Fundamentals  How to Use Tar Command in


Linux [16 Best Uses]

How to Use Tar Command in


Linux [16 Best Uses]
Written by Reviewed by Last updated: June 16, 2024
Ojash  Akshat  Expert verified

TL;DR
To effectively use the tar command in Linux, you can
try these methods:

1 Combine multiple files or directories into a


single tar file with tar -cvf
archive.tar /path/to/directory.

2 Retrieve the contents of a tar file using tar


-xvf archive.tar.

3 View the files and directories within a tar


file without extracting them by running tar
-tvf archive.tar.

4 Create compressed archive files using tar


-czvf archive-name.tar.gz
https://linuxier.com/how-to-use-tar-command-in-linux/ 1/37
7/15/24, 10:49 AM How to Use Tar Command in Linux [16 Best Uses]

/path/to/directory for gzip or tar -


cjvf archive-name.tar.bz2
/path/to/directory for bzip2
compression.
5 Extract specific files from an archive with
tar -xzvf archive-name.tar.gz
path/to/specific/file, saving time
and space.
6 Update an existing archive by adding new
files using tar -rvf archive-
name.tar new-file, avoiding the need
to create a new archive.

Read the guide below to learn how to use the Tar


command in Linux and best practices to use the Tar
command.

Managing files on Linux can be a real challenge, especially


with so many files and directories to handle. But don’t worry,
the tar command is here to help. It lets you bundle, compress,
and manage your files easily. In this post, I’ll show you 16
different ways to use the tar command, from basic tasks to
advanced techniques like encryption and automation. By the
end, you’ll have practical skills to make your file management
simpler and more efficient. Let’s make your Linux experience
smoother.

https://linuxier.com/how-to-use-tar-command-in-linux/ 2/37

You might also like