Linux Stall
  • Home
  • Android
  • How to
  • Perl
  • Tips
  • Tutorials
No Result
View All Result
Linux Stall
No Result
View All Result
Home How to

Packing and Unpacking Files In Linux

Chankey Pathak by Chankey Pathak
July 11, 2020
in How to
46 3
0
how to install software in linux from .zip ztar.gz .tar.bz2
16
SHARES
811
VIEWS
Share on FacebookShare on Twitter

In this post I will be showing you how to pack/compress and unpack/decompress files in Linux using a variety of utilities such as the tar command as-well as others.

Packing/Compressing Files

Let’s start by creating a simple .tar file, please keep in mind that this doesn’t really compress your files, rather it puts them all into a package. You can specify files and directories, either will work. To pack all the files in your directory you can use wildcards as-well, here is an example of packing files below.

[email protected]:~/tutorial# tar -cvf files.tar ~/tutorial/file*
tar: Removing leading `/' from member names
/root/tutorial/file1.txt
/root/tutorial/file2.txt

If you want to actually compress your files into a .tar.gz archive, then you can simply add a -z argument to the tar command. Here is an example of compressing files using the tar command.

[email protected]:~/tutorial# tar cvzf files.tar.gz ~/tutorial/file*
tar: Removing leading `/' from member names
/root/tutorial/file1.txt
/root/tutorial/file2.txt

Next let’s create a simple zip file, you can do this by running the following zip command and substituting my information for what you want to zip.

[email protected]:~/tutorial# zip -r files.zip ~/tutorial/file*
  adding: root/tutorial/file1.txt (stored 0%)
  adding: root/tutorial/file2.txt (stored 0%)

Unpacking/Decompressing Files

To extract the files out of a .tar.gz file you can use the tar command and substitute the file name for your desired file name.

[email protected]:~/tutorial# tar xvzf files.tar.gz
root/tutorial/file1.txt
root/tutorial/file2.txt

To extract a simple tar file (not compressed, simply archived), you will also use the tar command except you will drop the z argument.

[email protected]:~/tutorial# tar xvf files.tar
root/tutorial/file1.txt
root/tutorial/file2.txt

For zip files you can simply run the unzip command followed by the archives name, there are more options which can be viewed by running unzip –help.

[email protected]:~/tutorial# unzip files.zip
Archive:  files.zip
 extracting: root/tutorial/file1.txt
 extracting: root/tutorial/file2.txt

I hope this post has helped you learn how to pack and unpack files in Linux, please don’t forget to comment/share. Thanks!

Tags: commandshow totarball
Previous Post

Useful Remote IPMI Commands For Managing Servers

Next Post

How to Install And Setup Rootkit Hunter On Linux Server

Chankey Pathak

Chankey Pathak

Data Scientist at Morgan Stanley. I've been using Linux since past 12 years. I plan to share what I know about Linux in this blog.

Related Posts

The three-dimensional network topology infographics with ip addresses 3d illustration
How to

Identifying and Resolving IP Address Conflicts with Linux

July 23, 2020
procmon
How to

Microsoft releases ProcMon (Process Monitor) utility for Linux

July 21, 2020
searching file
How to

How to find files by size in Linux

July 12, 2020
Blue padlock icon computer security system vector
How to

How To Enable TLS Encryption On Postfix

July 12, 2020
Blue padlock icon computer security system Encryption
How to

Running Commands Automatically Over SSH

July 12, 2020
sar command output
How to

How to Install And Enable SAR (SYSSTAT) On Linux Servers

July 12, 2020
Next Post
rkhunter software setup linux

How to Install And Setup Rootkit Hunter On Linux Server

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Terms and Conditions
  • Contact Us
  • About Us

© 2012 - 2020 Linux Stall - A place for all your Linux needs.

No Result
View All Result
  • Home
  • Android
  • How to
  • Perl
  • Tips
  • Tutorials

© 2012 - 2020 Linux Stall - A place for all your Linux needs.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In