linux tar folder and subfolders

Ads
 

linux tar folder and subfolders

Hi,

I am new to Linux operating system. I have a directory which contains many files in several directories and sub-directories. There are many files in each directory and sub-directories. So, I want a simple way to compress these files preserving the directory structure so that when it is extracted I get the same structure.

What are the options for me for zipping it into a file possible Linux tar file. I just searched and found that the tar.gz file is best file format for compressing such directories.

Help me with the command in Linux for archiving folder and subfolders into tar or tar.gz file.

Thanks

View Answers

April 22, 2020 at 3:34 PM

Hi,

The tar utility of Linux is very powerful and you use it for working the with the archive files/directories in Linux.

If you want to tar folder and subfolders in Linux then you can use the following command:

tar cvzf mydata.tar.gz mydata

Above command creates mydata.tar.gz by including all the data inside mydata folder.

Inside mydata folder you can have any number directories/sub-directories and files.

So, above command will help in your case.

Thanks


April 22, 2020 at 3:36 PM

Hi,

Check the following tutorial for more examples:

Thanks

Ads









Related Tutorials/Questions & Answers:
linux tar folder and subfolders
. Help me with the command in Linux for archiving folder and subfolders into tar...linux tar folder and subfolders  Hi, I am new to Linux operating... for me for zipping it into a file possible Linux tar file. I just searched and found
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
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 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
Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )
Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )   I need to create a folder structure... . i need some help in getting folder structure using this java . Folder
tar command
tar command  Hi, What is tar command in Linux and how it is used? 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... tar file in ubuntu? Thanks   Hi, Here is command to create tar file
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... tar file in ubuntu? Thanks   Hi, Here is command to create tar file
tar directory and subdirectories
tar directory and subdirectories  Hi, I am developing program on Linux machine. I have to create the .tar file of a directory and subdirectories... easy in Linux or Unix. You can easily create tar archive of directory
ModuleNotFoundError: No module named 'batch-tar'
ModuleNotFoundError: No module named 'batch-tar'  Hi, My Python... 'batch-tar' How to remove the ModuleNotFoundError: No module named 'batch-tar' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'tar-diff'
ModuleNotFoundError: No module named 'tar-diff'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tar-diff' How to remove the ModuleNotFoundError: No module named 'tar-diff
ModuleNotFoundError: No module named 'tar-diff'
ModuleNotFoundError: No module named 'tar-diff'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tar-diff' How to remove the ModuleNotFoundError: No module named 'tar-diff
ModuleNotFoundError: No module named 'tar-progress'
ModuleNotFoundError: No module named 'tar-progress'  Hi, My Python... 'tar-progress' How to remove the ModuleNotFoundError: No module named 'tar-progress' error? Thanks   Hi, In your python
Folder in Java.
Folder in Java.  I have any problem how to make Folder in java program? Can Anybody help me in this part
Where is my.cnf in linux?
Where is my.cnf in linux?  Hi, Can anyone tell me where is my.cnf in linux? Thanks   Hi, Its is /etc folder. The complete path with file name is /etc/my.cnf. Thanks
create folder
create folder  what code we should write as a web application that it create an empty folder on client's desktop
Sitemap Linux Tutorial
| Site Map | Business Software Services India Linux Tutorial Section What is Linux? | Introducing Linux OS | Beginner Guide to Linux Server | Checking the Fedora Core 4 ISOs On Windows | Utility: tar for archieving files
ModuleNotFoundError: No module named 'devstack-plugin-tar-installer'
ModuleNotFoundError: No module named 'devstack-plugin-tar-installer'  ...: No module named 'devstack-plugin-tar-installer' How to remove the ModuleNotFoundError: No module named 'devstack-plugin-tar-installer' error
Create tar.gz file in Linux command line
directory name or file name for adding into the tar.gz file. Linux tar command... backup. This command is used by the administrator of Linux/Unix system. The tar..., UNIX and Mac operating systems. What is tar utility in Linux/UNIX? Tar
create a folder in jsp page
create a folder in jsp page  i want to create a folder in jsp page And it can be delete aslo
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
Java lock file or folder.
Java lock file or folder.  Is it possible to create a desktop application to lock or encrypt file or folder in windows by using java code?? if possible can provide some reference?? because i can't find it... thanks
Last modified date of a folder
Last modified date of a folder  How to get the last modified date of a folder specified by a link in html
jdbc in linux
jdbc in linux  what will be database url if i'm using mysql database on linux platform ? what will be driver name & class name to be used in "Class.forName()" method ? plz give short source code
Linux Programming
Linux Programming  1.Write a program that reads an integer by the user and displays it in octal (base 8): Enter an integer number between 0 and 32767: 2012 In octal, your number is: 3734 (Use the same input and output format
java program to copy the contents of one folder to another folder
java program to copy the contents of one folder to another folder  java program to copy the contents of one folder to another folder   Have a look at the following link: Java Copy one folder to another
URL folder download to local
URL folder download to local  I have a requirement to download all the folders and files inside from a SVN link to my local directory. Can you help how it could be done
image save to folder in java
image save to folder in java  Hi, I am working with java. In my application i want to give facility to user to add and change image. I use open... folder and that path stored into database, for furhter retrivation. Please guide me
how to search a text in all files in a folder in unix
how to search a text in all files in a folder in unix  Hi, I am... Linux users are performing such task? What is the command that I can run from... a text in all files in a folder in unix? Thanks   Hi, I Ubuntu or any

Ads