How to compress and extract tar.gz files on Linux
Answered
15
How do I create and extract .tar.gz archives on Linux from the command line?
O
Asked by
omar_linux
Platinum
•
593 rep
1 Answer
23
Create archives
# Create tar.gz archive
tar -czvf archive.tar.gz /path/to/directory
# Create tar.bz2 (better compression)
tar -cjvf archive.tar.bz2 /path/to/directory
# Exclude files
tar -czvf archive.tar.gz --exclude='*.log' /path/to/dir
Extract archives
# Extract tar.gz
tar -xzvf archive.tar.gz
# Extract to specific directory
tar -xzvf archive.tar.gz -C /destination/path
# List contents without extracting
tar -tzvf archive.tar.gz
W
Platinum
•
285 rep
Your Answer
You need to be logged in to answer questions.
Log In to Answer