Creating tar archive: Consider we have multiple files system.log under techplayon directory, we can tar them using following command.Most Command Used tar Commonads with Example file or directory is a space-separated list for extraction or compression.archive-fileis the file name and extension.-r : update or add file or directory in already existed.-j : filter archive tar file using tbzip.-z : zip, tells tar command that creates tar file using gzip.-u : archives and adds to an existing archive file.-t : displays or lists files in archived file.-f : creates archive with given filename.Following it the list of options available with tar command. Options indicates which operation executes on the files (creation, extraction, etc.).It shows the basic syntax, compressing and unpressing with tar and compressing and uncompressing the with the gzip. on linux system tar.gz file can be uncompressed using tar command while on windows machines it can uncompressed using 7-zip, winzip, winrar like toolįollowing figure show the tar command syntax for tar in Linux system.gzip and tar are usually used to create tarballs that are compressed significantly.It is similar to 7-zip, winzip, winrar tools in Windows OS.gzip is a compression tool used to reduce the size of a file.tar means in linux system is tape archive used to to combine multiple files into one. Using tar commands, we can compress the files to a significate amount and transfer to local or remote machine for offline analysis. When we work with telecom system (Base-Stations, Routers, servers), they do dump the logs file in a hug amount – several GBs of data, which is difficult to transfer to another machines for offline debugging. The tar command is to compress files and directories into a highly compress and uncompressed archive file commonly called tarball or tar.gz in Linux. If you find this guide helpful or have more information or additional ideas, you can give me a feedback by posting a comment.In the Linux system, “ tar” stands for tape archive. That is it with extracting tar files to a specific directory and also extracting specific files from a tar file. Img 05: Extract Specific Files From Tar Archive Summary # tar -xvf etc.tar etc/issue etc/nf etc/mysql/ -C /backup/tar_extracts/ In the next example, I will extract specific files out of a tar file to a specific directory as follows: # mkdir /backup/tar_extracts The tar utility also allows you to define the files that you want to only extract from a. Img 04: Extract tar.bz2 Files to Different Directory Example 4: Extract Only Specific or Selected Files from Tar Archive # tar -jvxf documents.tbz2 -C /tmp/tar.bz2/ Now we will be unpacking the documents.tbz2 files to /tmp/tar.bz2/ directory. tbz2 Files to Different DirectoryĪgain repeating that you must create a separate directory before unpacking files: # mkdir -p /tmp/tar.bz2 tgz Files to Different Directory Example 3: Extract tar.bz2. Now we will extract the contents of documents.tgz file to separate /tmp/tgz/ directory. tgz Files to Different Directoryįirst make sure that you create the specific directory that you want to extract into by using: # mkdir -p /tmp/tgz Img 02: Extract Tar Files to Specific Directory Example 2: Extract. # tar -xvf articles.tar -directory /tmp/my_articles/ Let me also use the -directory option instead of -c for the example above. In the above example I used the -v option to monitor the progress of the tar extraction. Img 01: Extract Tar Files to Different Directory To extract the files in articles.tar to /tmp/my_article, I will run the command bellow: # tar -xvf articles.tar -C /tmp/my_article/ You can include the -p option to the above command so that the command does not complain. Let me start by creating the /tmp/my_article directory using the command below: # mkdir /tmp/my_article Always make sure that the directory into which you want to extract tar file exists. In the first example, I will extract the files in articles.tar to a directory /tmp/my_article. Example 1: Extracting tar Files to a Specific Directory
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |