How To Compress And Extracting Files

To Compress A File Or Directory

Log into your Linux server.

Locate the files or directory that you want to compress

Type the following commands: For compressing a file;

"tar czvf name_of_compressed_file.gz /location_of_the_file_you_are_compressing.

Or if you are compressing a directory

"tar czvf name_of_compressed_file.gz /location_of_the_directory_you_are_compressing.

The attributes are what tell the program how to handle the compress; 

  • -z: Compress archive using the gzip program
  • -c: Create the archive
  • -v: Verbose |  display progress while creating the archive
  • -f: Archive the File or Directory name

 

Extracting A File Or Directory

Type the following command for extracting a file;

"tar czvf name_of_compressed_file.gz /location_of_the_file_you_are_extracting.

Or if you are uncompressing a directory

"tar xzvf name_of_compressed_file.gz /location_of_the_directory_you_are_extracting.

The attributes are what tell the program how to handle the compress; 

  • -z: Compress archive using the gzip program
  • -x: Extract the archive
  • -v: Verbose |  display progress while creating the archive
  • -f: Archive the File or Directory name
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Installing htop

htop is an interactive process viewer for Linux, which is a powerful alternative to the...

Bind Multiple IP Addresses to a Single Network Interface Card (NIC)

This tutorial demonstrates how to bind multiple IP addresses to a single NICI'll be using LAN...

Clear Memory Cache on Linux Server

By default the Linux OS has a very efficient memory management process that should be freeing any...

Set the time on a Linux server

Log into the server via SSHAt the shell prompt run the following command:date MMDDHHmmYYYYFor...

Check your disk usage in Linux

A good way to check your disk usage for folders on your Linux server is via shell.Download...