Tar file open linux

How to tar a file in Linux using command line

How to tar a file in Linux using command line

The procedure is as follows to tar a file in Linux:

  1. Open the terminal app in Linux
  2. Compress an entire directory by running tar -zcvf file.tar.gz /path/to/dir/ command in Linux
  3. Compress a single file by running tar -zcvf file.tar.gz /path/to/filename command in Linux
  4. Compress multiple directories file by running tar -zcvf file.tar.gz dir1 dir2 dir3 command in Linux

How to create tar a file in Linux

Say you want to compress an entire directory named /home/vivek/data/:
$ tar -czvf file.tar.gz /home/vivek/data/
To compress multiple directories and files, execute:
$ tar -czvf file.tar.gz /home/vivek/data/ /home/vivek/pics/ /home/vivek/.accounting.db
One can use bzip2 compression instead of gzip by passing the -j option to the tar command:
$ tar -c j vf file.tar. bz2 /home/vivek/data/
Where,

  • -c : Create a new archive
  • -v : Verbose output
  • -f file.tar.gz : Use archive file
  • -z : Filter the archive through gzip
  • -j : Filter the archive through bzip2

How to exclude directories and files when using tar

You can exclude certain files when creating a tarball. The syntax is:
$ tar -zcvf archive.tar.gz —exclude=’dir1′ —exclude=’regex’ dir1
For example, exclude

/Downloads/ directory:
$ tar -czvf /nfs/backup.tar.gz —exclude=»Downloads» /home/vivek/

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

How do I view files stored in an archive?

Now you have an archive, to list the contents of a tar or tar.gz file using the tar command:
$ tar -ztvf file.tar.gz
$ tar -jtvf file.tar.bz2

How do I extracting an archive?

You can extract an archive or tarball with the tar command. The syntax is:
$ tar -xzvf file.tar.gz
$ tar -xjvf file.tar.bz2
Want to extract the contents of the archive into a specific directory such as /home/vivek/backups/? Try passing the -C DIR option:
$ tar -xzvf my.tar.gz -C /home/vivek/backups/
$ tar -xjvf archive.tar.bz2 -C /tmp/

  • -x : Extract files from an archive
  • -t : List the contents of an archive
  • -v : Verbose output
  • -f file.tar.gz : Use archive file
  • -C DIR : Change to DIR before performing any operations
  • —exclude : Exclude files matching PATTERN/DIR/FILENAME
Читайте также:  Пакет исправлений для windows kb822603

Conclusion

You learned how to tar a file in Linux using tar command. For more info please tar command help page here.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How To Open a Tar.gz File In Linux / Unix

I ‘ve received a file called date.tar.gz. How do I open/extract/unpack a tar.gz file on Linux or Unix like operating systems using shell prompt?

A .tar.gz (also .tgz ) file is nothing but an archive. It is a file that acts as a container for other files. An archive can contain many files, folders, and subfolders, usually in compressed form using gzip or bzip2 program on Unix like operating systems.

Tutorial details
Difficulty level Easy
Root privileges No
Requirements tar
Est. reading time 4 mintues

Say hi to tar command line tool

You need to use the tar command which can create and manipulate archive files in .tar.gz under Unix like operating systems. Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following to open and extract a .tar.gz file:

Where options are as follows:

  • -z : Uncompress the resulting archive with gzip command.
  • -x : Extract to disk from the archive.
  • -v : Produce verbose output i.e. show progress and file names while extracting files.
  • -f data.tar.gz : Read the archive from the specified file called data.tar.gz.

How To Open a Tar.gz File In Linux / Unix System

By defaults files will be extracted into the current directory. To change the directory use -C option. In this example, extract files in /data/projects directory:

To view a detailed table of contents (list all files) for this archive, enter:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

file-roller : GUI tool

GNOME Archive Manager Running on my Ubuntu 20.04 LTS desktop

Fig.01: Gnome Archive Manager

Fig.02: Linux: Open Files With an Archive Manager

Fig.03: Linux GUI Extract Files From an Archive — data.tar.gz

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

can i access n edit the complicated structured tar files

Get the Midnight commander:

sudo apt-get install mc

Ah been meaning to install this for the next time I have the privilage to use an ssh to fix a computer system. Thanks for the reminder.

Thank you very much its super very effective

Yawn. This is why linux after all these years is a waste of space. In 10 years you still haven’t managed to create a double click installer. Common fanboys hit me with your arrogant linux attitude. I don’t want to hear your explanations no one wants tar files no one wants to use a terminal and until you have a double click install with zip, rar and 7z support i will always call linux rubbish. see yah.

You are dumber than Ted Kennedy the night he crashed his car and brutally shred apart and killed his date. Keep voting Democrat.

Actually it is supported and additional archieve formats can be added with ease to the linux system; many users prefer the terminal, why you may ask because it is power which cannot be met by any GUI tool which is the case on almost every operating system. Also download a .deb file and double-click it; seriously I don’t think you’ve ever had the privillage of using a unix system or linux system for that matter.

Get a life or get a job as I see there is absolutely no reason to discourage new users simply because you are ignorant or lack the skills required to have an even primitive knowledge of the same system that runs most of world’s webservers and 99% of the world’s fastest supercomputers.

So we’re all a bunch of fanboys; I personally have a custom kernel and my system runs even cooler under linux than Windows. I’ve logged hundreds of hours in Windows troubleshooting issues ranging from rootkits to the occassional user whom fails to understand that doubleclicking that exe file will start the installer (same thing as double-clicking a .deb file on a debian/debian-based system).

By the time I was 18 I was an IT whom had worked on databases worth millions. If you honestly expect me to believe for even a moment that you have even experience once so ever on these systems then you are dumber than I first thought. I’ve worked alongside software engineers and systems analysts and have served as an advisor for computer systems all of these were Windows.

Also there was a study done which showed that linux (study used Ubuntu) is more user-friendly than Windows. Now if you want to start an debate on macs I’ll have to remind you that macs are unix-based and after it took 6 months for Apple to patch only one security threat when the linux kernel can be patched in hours.

I’m done…I don’t waste my time with trolls…

…I have a database to write

That’s a silly comment.

It’s because of idiots like you with that mindset faded away into obscurity because they refused to learn new and emerging technologies….much like the ex-mainframer’s I used to work with at one of my prior places of employment (Chubb & Son’s, Inc. in New Jersey) who refused to want to learn Unix or any other operating system because they believed nothing could be superior to Big Iron, as mainframes are called…..after the datacenter was outsourced many of them could not find employment because of their outdated 70’s experience and technical skills and had to take jobs at Lowes, Home Depot, WalMart, KMart, and other non-technology companies….WHY. Because they failed to stay current!! You sound just like that group of losers who had nothing to do but bash this system and that system in favor of Big Iron without thinking ahead to where the future may take them…..

Mojang, remove the Steve skin! That is a stupid comment.

As a decade long linux user I have to say…you’re absolutely right. It’s really frustrating after all this time that a double click option isn’t available. Sorry chaps, it’s the truth.

The Rule of Three is in full effect. Example:

This guy’s a douche.

Go spend your dads money on an expensive laptop made of glue, and enjoy double clicking on Facebook at Starbucks, douche.

Oh yeah, by the way… this guy’s a douche.

You are a Clown. You are just lashing out cause you have no clue how to navigate in such a straight forward system.

any chance I could unzip a tar file on an android fone?

install busybox if the tar command isn’t already installed

Super…using TAR is easy and was able to unpack Eclipse compiler into Linux.
Thanks

Источник

How to open a tar file in Unix or Linux

Last updated: October 12, 2007

A lot of the downloadable Linux or Unix files found on the internet are compressed using a tar or tar.gz compression format. So, knowing how to open or untar these compressed files becomes very important. In the following examples, we will explain how to untar both popular formats and how to extract the contents to a different directory.

How to open or Untar a “tar.gz” file in Linux or Unix

  1. Open a terminal window ctrl+alt+t
  2. From the terminal, change directory to where your .tar.gz file is located,
    (replacing file_name .tar.gz with the actual name of your file)

cd /directory_path/ file_name .tar.gz

NOTE: You can specify a different directory to extract to using the -C parameter and path to the directory as follows:

tar -C /myfolder -zxvf file_name .tar.gz

How to open or Untar a “tar” file in Linux or Unix

  1. From the terminal, change to the directory where your .tar file has been downloaded.
  2. To extract or untar the file to the current directory, type the following,
    (Making sure to replace file_name .tar with the actual filename)

Or to extract to another directory, type

tar -C /myfolder -xvf file_name .tar

Источник

Читайте также:  Yandex disk linux autostart
Оцените статью