Skip to main content
Maher Sakka
Main navigation
  • Home
  • Contact me
Language switcher
  • English
  • عربي
Breadcrumb
  1. Home
  2. Blog
  3. How To Compress and Extract TAR Files In Linux

How to compress and extract TAR files in Linux

To compress a directory in Linux, you can use the tar command:

tar -zcvf file.tar.gz folder

To exclude a specific folder or files, use the –exclude= option with the folder name:

tar -zcvf file.tar.gz –exclude='temp' –exclude='node_modules' folder

To decompress a file, use the -x option:

tar -xzvf file.tar.gz

To decompress a file to a different directory, add the directory path:

tar -xzvf file.tar.gz /home/debian/destination
Tags
  • Linux
Related posts
  • How to determine which Linux distribution and kernel version you are running
  • How to compress and decompress files in Linux with ZIP
  • How to get the size of directories in Linux
  • How to find files that contain specific text in Linux
Tags
  • Laravel
  • Linux
  • Drupal
  • Database
  • Tips & Tricks
  • Mobile
Recent posts
  • Send an email to multiple recipients at once
  • How to determine which Linux distribution and kernel version you are running
  • How to compress and decompress files in Linux with ZIP
Monthly archive
  • May 2017 (2)
  • August 2018 (1)
  • October 2020 (1)
  • August 2023 (1)
  • July 2024 (2)
  • November 2024 (1)
  • May 2025 (2)
RSS feed

mahersakka.com © 2024