19

I need to know the extensions of xzf and its usage. Is it necessarily to be used in installing a software?

sudo tar -xzf utorrent-server-3.0-ubuntu-10.10-27079.tar.gz

Why this is used?

0

4 Answers 4

13

tar is basically The GNU version of the tar archiving utility for more information on tar go to the terminal and type man tar.

You will find out what exactly xzf is used for. Basically they flags (options) when you run a tar command.

[-]x --extract --get:
-z --gzip:
-f --file F:

The order of this command does matter though.

Basically your command

sudo tar -xzf utorrent-server-3.0-ubuntu-10.10-27079.tar.gz

will extract the tar.gz archive that you specify as (utorrent-server-3.0-ubuntu-10.10-27079.tar.gz) as root privileges.

1
  • 4
    The order of the flags does matter, in fact - f has to be the last one. If you type, for example, tar -xfz then it will try to look for a file called z. Essentially the f means "The next thing I type will be a filename".
    – Jez W
    Jul 17, 2013 at 15:12
8

tar is the Swiss army knife of extracting archives. It can handle many different archives, such as tar.gz, tar.xz, tar.bz, tar.bz2, tar.lz...

Your command contains the following three options:

  • -x = extract
  • -z = gzipped archive
  • -f = get from a file, not a tape drive

To find more help on tar, enter tar --help or man tar in your terminal.

So your command extracts the archive utorrent-server-3.0-ubuntu-10.10-27079.tar.gz to a directory. It does not install the utorrent server, unlike dpkg -i or sudo apt-get install.

tar archives for programs typically contain Linux binaries, which you can run with './ binary-name'.

1
  • I wouldn't call tar the “Swiss army knife of extracting archives” since it can only deal with one type of archive format: tar – though various variants thereof. The (de-)compression options are certainly nice but don't change anything about the archive format. Other tools like p7zip (and it's front-ends like File-Roller, Ubuntu's default archive manager) support a far wider range of archives though with less options as their respective specialized tool (e. g. tar, zip, rar etc.). Additionally, p7zip is the specialized tool for 7-Zip archives. Jul 10, 2016 at 12:09
1

The other answers provided are quite good, but I would like to give an example and explain more of why it is used for installations.

First of all, like the others have explained. tar -xzf is just a method for extracting. In installation instructions they will usually tell you the options to use since different options will be required for different archive types.

EXAMPLE USAGE-- TAKEN FROM HERE

Extract a gzipped tar archive ( *.tar.gz ) using option xvzf

Use the option z for uncompressing a gzip tar archive.

$ tar xvfz archive_name.tar.gz

Extracting a bzipped tar archive ( *.tar.bz2 ) using option xvjf

Use the option j for uncompressing a bzip2 tar archive.

$ tar xvfj archive_name.tar.bz2

EXAMPLE INSTALLATION - GOOGLE DROPBOX

Now as for why this is used in Ubuntu installations, consider the Google DropBox installation process found here.

It says to install, do the following:

64-bit:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

Next, run the Dropbox daemon from the newly created .dropbox-dist folder.

~/.dropbox-dist/dropboxd

What these instructions are telling you is:

  1. Navigate to user home directory ~

  2. Download the tar file

  3. Unzip it in the home directory. This will create the folder .dropbox-dist because of how the zip was made.

  4. Run the program in the newly unzipped folder.


UBUNTU INSTALLATIONS

See Ubuntu doesn't work like Windows. In Windows you need to run executable installation programs to configure the registry, the directories, file associations, etc. etc. Ubuntu is very component-ized--that is to say that it is exceptionally rare that any system configuration files need to be changed for an application to be installed. For the most part all that needs to happen is that a few files need to be put in special folders like /var/, /usr/share/applications/, /etc/, and /bin/, (possibly others) which can be done by a batch installation file (like the dropboxd file) with adequate (sudo) privileges. Though this is not necessarily the case-- some programs are completely self contained and don't need to have their files put in special directories. As such, upon untarring/unzipping the files, the installation may already be complete.

It's very different than a Windows installation where system tries to manage everything with a registry-- the important thing is that files are present in specific directories and the system will search those directories as it needs them. If it finds them, good they are installed, and if it doesn't, well it's probably not installed and the system will not even notice (this only goes for non-essential system components). This is why, some programs can be installed without running a batch file or anything.

0

-xzf are arguments to the tar command. You can check their meaning in the man pages with:

man tar

The paramaeters you asked for are:

 -x, --extract, --get
       extract files from an archive

 -f, --file ARCHIVE
       use archive file or device ARCHIVE

 -z, --gzip, --gunzip --ungzip

Your file utorrent-server-3.0-ubuntu-10.10-27079.tar.gz is just an archive and that command extracts the content.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .