How do I compress a tar file in Linux

Ads
 

How do I compress a tar file in Linux

Hi,

I want to create the tar.gz file file of a directory in Linux. My directory contains many sub directories and many files are there inside it.

I want to know the tar command for creating tar of directory and all the contents inside it. the created tar file should include all the directories and files inside the main directory.

Tell me the command for this.

Thanks

View Answers

February 10, 2020 at 12:30 AM

Hi,

The tar command was first introduced in the seventh edition of unix v7 in January 1979. Since then it is being used by the Linux and Unix users around the world. This command comes with many features to work with files and directories.

The tar command can be used to work with files and directories, and it can be used to compress and decompress the files and directories with following informations:

  • File names - Inside the tar file names are well preserved.
  • Directory structure - Inside the tar file, Directory structure are well preserved.
  • File permission - Inside the tar file, File permissions are well preserved.
  • SELinux permissions - Inside the tar file, SELinux permissionss are well preserved.
  • Timestamps - It also preserve the timestamps details
  • File ownership - You can also preserve the file ownership
  • File access permissions and more - It also offers to save the file access permissions.

Here is command to create tar file:

tar -czvf myfile.tar.gz mydir

Thanks


April 22, 2020 at 3:37 PM

Hi,

Check the following tutorial for more examples:

Thanks

Ads









Related Tutorials/Questions & Answers:
How do I compress a tar file in Linux
How do I compress a tar file in Linux  Hi, I want to create the tar.gz file file of a directory in Linux. My directory contains many sub directories and many files are there inside it. I want to know the tar command
How do I compress a tar file in Linux
How do I compress a tar file in Linux  Hi, I want to create the tar.gz file file of a directory in Linux. My directory contains many sub directories and many files are there inside it. I want to know the tar command
Advertisements
How do I compress a tar file in Linux
How do I compress a tar file in Linux  Hi, I want to create the tar.gz file file of a directory in Linux. My directory contains many sub directories and many files are there inside it. I want to know the tar command
how to check the size of a tar file in linux
how to check the size of a tar file in linux  Hi, I want to check the size of tar file in Linux. How to check the size of a tar file in linux? What Linux command I should use to check the size of a tar file? Thanks
How do I tar a directory without retaining the directory structure?
How do I tar a directory without retaining the directory structure?  Hi, I want to create tar file without retaining the directory permission. How to do this? Thanks   Use tar czf ~/backup.tgz Thanks
How do I tar a directory without retaining the directory structure?
How do I tar a directory without retaining the directory structure?  Hi, I want to create tar file without retaining the directory permission. How to do this? Thanks   Use tar czf ~/backup.tgz Thanks
how to create tar file in ubuntu
how to create tar file in ubuntu  Hi, I have a directory with many sub directories and files in it. I want to create tar file of the directory so that it can be moved to another computer easily. I am searching for command to do
how to create tar file in ubuntu
how to create tar file in ubuntu  Hi, I have a directory with many sub directories and files in it. I want to create tar file of the directory so that it can be moved to another computer easily. I am searching for command to do
linux tar folder and subfolders
for me for zipping it into a file possible Linux tar file. I just searched and found...linux tar folder and subfolders  Hi, I am new to Linux operating..., I want a simple way to compress these files preserving the directory structure
How to compress a file in Java?
How to compress a file in Java?  How to compress a file in Java through Java code? I want a good example in Java. Thanks   Hi, Check the tutorial Compressing the file into GZIP format. Thanks
How do I import a CSV file in R?
How do I import a CSV file in R?  Hi, I have a CSV file with 900000 records and I want to load it for analytics. How do I import a CSV file in R... file: data = read.csv("data.csv", header = TRUE) Above code loads the data
How do I install a .deb file via the command line?
How do I install a .deb file via the command line?  How do I install a .deb file via the command line?   Hi, You can install it with following command: sudo dpkg -i DEB_PACKAGE Example: sudo dpkg -i packagename.deb
how do i upload a file by using servlet or jsp?
how do i upload a file by using servlet or jsp?  hi plz tell me the write java code
How do I read a large file quickly in Java?
How do I read a large file quickly in Java?  Hi, I my project I have to read vendor feed which comes in text file. Size of the file is usually in 1-2 GB in size. What is the best way to read the file efficiently? How do I read
how do i allow users to download a xls file in html?
how do i allow users to download a xls file in html?  can anyone help me to allow users to download a xls file in html? i tried with href="path...;i tried with href="path/filename.xls click here but it works only in chrome
How do I upgrade mysql?
How do I upgrade mysql?  How do I upgrade mysql
How can I do it? .click();
How can I do it? .click();  I have a very unusual problem. I want...("a"); x.click(); </script> So it's click on an element witch one Id's is "a", but I want that it make mouseup in this element. How can I do it, because if I write
how do i solve this problem?
how do i solve this problem?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
How do I decompile Java class files?
How do I decompile Java class files?  How do I decompile Java class files
How do I initialize a byte array in Java?
How do I initialize a byte array in Java?  How do I initialize a byte array in Java
How do I compare strings in Java?
How do I compare strings in Java?  How do I compare strings in Java
How do i do the coding for 'leaving a comment' in java
How do i do the coding for 'leaving a comment' in java  i am designing a webpage.In my webpage i want to add the option of adding a comment by the readers of the page.how do i do
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I need ANT? If so, please give instructions. I am a student. http
How do I get started with Bootstrap
How do I get started with Bootstrap  Hi, I am new to Bootstrap and want to learn it in. What all things I should know before starting Bootstrap? How do I get started with Bootstrap? Thanks
How do I get started with Bootstrap
How do I get started with Bootstrap  Hi, I am new to Bootstrap and want to learn it in. What all things I should know before starting Bootstrap? How do I get started with Bootstrap? Thanks
How do I learn Spring Framework?
How do I learn Spring Framework?  Hi, I have completed my Engineering in 2017. During my college days I learned Core Java, Advanced Java, JDBC, JSP.... How do I learn Spring Framework? Thanks
How do I learn Spring Framework?
How do I learn Spring Framework?  Hi, I have completed my Engineering in 2017. During my college days I learned Core Java, Advanced Java, JDBC, JSP.... How do I learn Spring Framework? Thanks
How do I learn Spring Framework?
How do I learn Spring Framework?  Hi, I have completed my Engineering in 2017. During my college days I learned Core Java, Advanced Java, JDBC, JSP.... How do I learn Spring Framework? Thanks
How do I learn Spring Framework?
How do I learn Spring Framework?  Hi, I have completed my Engineering in 2017. During my college days I learned Core Java, Advanced Java, JDBC, JSP.... How do I learn Spring Framework? Thanks
How do I learn Spring Framework?
How do I learn Spring Framework?  Hi, I have completed my Engineering in 2017. During my college days I learned Core Java, Advanced Java, JDBC, JSP.... How do I learn Spring Framework? Thanks

Ads