Firefox 16, a treat for developers http://t.co/cnd27CzT
Basic commands, Part I: Compress and decompress files using rar, bzip, tarball(tar) and gunzip
This is a serie of lessons of “Basic Commands “ that focuses on command-line usage, in this serie you will learn the tools and tricks of the command line, which are in many cases faster, more powerfull, and more flexible than GUIprogram.
Today in this part i will show you the main commands to compress/decompress files using rar, bzip, tarball(tar) and gunzip.
Tarball (tar):
GNU tar is an archiver that creates and handles file archives in various formats using the ‘tar’ command ,it was originally used as a backup tool to write data to magnetic tape drives .You can use tar to create file archives, to extract files from previously created archives, store additional files, or update or list files which were already stored.
-Create a uncompressed tarball :
tar -cvf archive.tar file1
-Create an archive containing ‘file1′, ‘file2′ and ‘dir1:
tar -cvf archive.tar file1 file2 dir1
-Show contents of an archive:
tar -tf archive.tar
-Extract a tarball :
tar -xvf archive.tar
-Extract a tarball into / tmp :
tar -xvf archive.tar -C /tmp
-Create a tarball compressed into bzip2
tar -cvfj archive.tar.bz2 dir1
-Decompress a compressed tar archive in bzip2
tar -xvfj archive.tar.bz2
-Decompress a compressed tar archive in gzip
tar -cvfz archive.tar.gz dir1
-Decompress a compressed tar archive in gzip
tar -xvfz archive.tar.gz
Meanning of the c,v,f and z,j options:
-’c’ option tells tar to create an archive,
-’v’ displays the files added to the tarball and
-’f’ specifies the filename. After the filename, all other parameters are the files or directories to add to the archive.
Tarballs are commonly compressed using gzip or bzip2 using the -z or -j command options.
For complete details, see the tar man page
$ man tar
bzip2 :
bzip2 is a freely available, patent free (see below), high-quality data compressor. It typically compresses files to within 10% to 15% of the best available techniques (the PPM family of statistical compressors), whilst being around twice as fast at compression and six times faster at decompression.(Read the documentation of bzip2).
-Compress a file called ‘file1′
bzip2 file1
-Compress a file called ‘file1′
bzip2 file1
-Decompress a file called ‘file1.bz2′
bunzip2 file1.bz2
RAR Archiver :
RAR is a proprietary file format for data compression and archiving, developed by Eugene Roshal.
Under Linux and UNIX, use command called unrar. By default unrar is not being installed on Linux, FreeBSD or UNIX oses. You can install unrar command with the help of apt-get or yum command.See how to install rar on Linux
-Create an archive rar called ‘file1.rar’
rar a file1.rar test_file
-Compress ‘file1′, ‘file2′ and ‘dir1′ simultaneously
rar a file1.rar file1 file2 dir1
-Decompress rar archive
rar x file1.rar
OR
unrar x file1.rar
Gzip :
gzip is a software application used for file compression. gzip is short for GNU zip; the program is a free software replacement for the compress program used in early Unix systems, intended for use by the GNU Project.
gzip was created by Jean-Loup Gailly and Mark Adler. Version 0.1 was first publicly released on October 31, 1992. Version 1.0 followed in February 1993.
Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.There is a good article if you want to learn more a bout gzip, see this link.
-Decompress a file called ‘file1.gz’
gunzip file1.gz
-Compress a file called ‘file1′
gzip file1
-Compress with maximum compression
gzip -9 file1
ZIP Archiver:
zip is a compression and file packaging utility for Unix, VMS, MSDOS, OS/2, Windows NT, Minix, Atari and Macintosh, Amiga and Acorn RISC OS. It is analogous to a combination of the UNIX commands tar and compress.
-Create an archive compressed in zip
zip file1.zip file1
-Compress in zip several files and directories simultaneously
zip -r file1.zip file1 file2 dir1
-Decompress a file called file1
unzip file1
This was all for this part, see you on Part II of Basic commands series.
Links :
- http://directory.fsf.org/project/tar/
- http://www.ubuntuforums.org
- http://www.gnu.org/software/tar/tar.html
- http://www.bzip.org/
- http://www.cyberciti.biz/
- http://www.gzip.org/
- http://linux.about.com/od/commands/l/blcmdl1_gzip.htm
- http://en.wikipedia.org/
![]()
Basic commands,Part I: Compress and decompress files using rar, bzip, tarball(tar) and gunzip by M. Zinoune is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Based on a work at www.unixmen.com.
-
http://voku-online.de
Like us on Facebook
This week Top Posts 
Top Things to do After Installing Ubuntu 13.04 ‘Raring Ringtail’ : Ubuntu 13.04 Raring Ringtail final is almost out. The final release it scheduled for release on Apri...0 comment(s) |
Howto: Upgrade to Ubuntu 13.04 Raring Ringtail from 12.04, 12,10 | Desktop & Server : Updated 05-04-2013: Ubuntu 13.04 Raring Ringtail will be released Soon, If you have ubuntu 12,10, 12...0 comment(s) |
Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comment(s) |
Unix/Linux File Recognition. Did You Know? : Did you know that Unix and Linux has no concept of a file extension? What is a file name extension?
...0 comment(s) |
Configure conky-Lua in Ubuntu (12.10 & 13.04 Raring Ringtail), Fedora, debian and LinuxMint | Howto Conky : Updated 05-04-2013: Conky is a free, light-weight system monitor for X, that displays any informatio...0 comment(s) |
Howto- Resolve nosound problem on Ubuntu 13.04 Raring Ringtail,12.10 and Older : Updated 05/04/2013 : One of the common issues facing Ubuntu users after installing or upgrading Ubun...0 comment(s) |
Recent Posts
- Unix/Linux File Recognition. Did You Know?
- Migrate from MySQL to MariaDB in FreeBSD
- Connect Your Android Galaxy Tablet to Ubuntu via USB
- ElementaryOS Beta 1 and 2 Comparison and Review
- Introduction to the Linux Command Line
- A Secure Password
- Linux Kernel 3.10. It’s BIG!
- Monitoring Users Activity Using psacct or acct Tools in Linux
- Run Your Own Social Network Using elgg on RHEL / CentOS and Scientific Linux
- Getting Debian 7.0 ‘Wheezy’ Up and Running
Recent Comments



















SK
| #
Andrew look into your httpd.conf file at line no 350. There might be a syntax error.
andrew
| #
hello I have this error
[root@cloud html]# /etc/init.d/httpd restart
then this appears
Starting httpd: httpd: Syntax error on line 350 of /etc/httpd/conf/httpd.conf: without matching section.
plz tell how to fix this.
Maximiliano Schultheis
| #
this was amazing, thank you so much! Tip 3 did the trick!
SK
| #
I am working on it. Stay tuned. Thanks for the comment.
adriana rizzati
| #
You are right, I saw them just now and they are awesome!