Pages

Thursday, October 29, 2009

Compression and Decompression in Ubuntu

This is a presentation of tar:
Linux: File Compression and Archiving with gzip, zip, rar, tar, unzip...

Các file lưu trữ (đôi khi gọi là file nén) trên hệ thống UNIX/Linux (thường phần mở rộng là tar.gz hoặc .tgz) có thể được trích xuất (bung nén - extract) bằng một lệnh đơn giản.

Ví dụ: Để bung một file lưu trữ nén tên là target.tar.gz vào thư mục hiện hành, ta dùng lệnh:

gzip -dc target.tar.gz | tar xf -
tar xvzf target.tar.gz

Nếu file được nén với chuẩn bzip2 (i.e., .tar.bz2), chúng ta có thể thay thế gzip bằng lệnh bzip2.

Nếu file nén với lệnh nén của UNIX (phần mở rộng là .z) thì chúng ta dùng lệnh sau:

zcat target.tar.Z | tar xf -

Nếu nén ở dạng *.tar.xz thì:
tar Jxf *.tar.xz hoặc dùng unxz -z: để nén, và -d để giải nén.
Hy vọng với tóm tắt này sẽ là nơi để tham khảo quý báu.

Q. How do I extract tar.gz file under Linux / UNIX like operating systems?

A. tar.gz is nothing but compressed tar archive.
The tar program provides the ability to create tar archives, as well as various other kinds of manipulation. For example, you can use Tar on previously created archives to extract files, to store additional files, or to update or list files which were already stored.
Initially, tar archives were used to store files conveniently on magnetic tape. The name "Tar" comes from this use; it stands for tape archiver. Despite the utility's name, Tar can direct its output to available devices, files, or other programs (using pipes), it can even access remote devices or files (as archives).

Extract tr.gz. file

To extract one or more members from an archive, enter:
tar -zxvf {file.tar.gz}
If your tarball name is backup.tar.gz, enter the following at a shell prompt:
tar -zxvf backup.tar.gz

Extracting an Entire Archive

To extract an entire archive, specify the archive file name only, with no individual file names as arguments.
tar -zxvf backup.tar.gz

tar xjvf cornbread.tar.bz2

Nếu chỉ là .bz2 thôi thì:
bunzip2 spankythefish.bz2

Chuẩn nén 7z
Cài đặt: sudo apt-get install p7zip
Bung nén: p7zip -d filename.7z

Chuẩn nén rar
Dùng rar hoặc unrar

Chuẩn nén zip
zip và unzip

No comments:

Post a Comment