Linux下压缩归档简易操作指南(linux归档压缩)
Linux下压缩归档简易操作指南
Linux的目的,一直是提供用户最大灵活性,在压缩归档方面更是如此,MD或PYthon程序员经常使用Linux尤其是熟悉Linux但又不是内核高手的不失为一种不错的选择。
本文定位于介绍Linux下如何进行压缩归档,让用户可以从中找到一些有用的信息,方便实现压缩归档操作,扩展Linux使用范围。
1、用tar命令来压缩:
首先,在实现压缩归档操作之前,使用Linux命令tar将源文件夹中的文件以及文件夹全部归档起来:
假设要压缩的文件夹名为source,压缩的文件为source.tar.gz
tar -czvf source.tar.gz source # 压缩归档
2、用zip命令来压缩
更常用的是使用zip命令来实现压缩操作。其作用类似于上 even if they don’t know everything about the kernel.
This article aims to introduce how to compress and archive in Linux so that users can find some useful information and conveniently achieve the compression and archiving.
1. Compress with tar command
First of all, before implementing the compression and archiving operations, use the Linux command tar to archive all the files and folders in the source folder:
Assuming the name of the folder to be compressed is source, and the compressed file is source.tar.gz
tar -czvf source.tar.gz source # Compress and archive
2. Compress with zip command
More commonly used is the zip command to achieve compression operations. Its function is similar to the tar command, and even supports compressing by password.
Let’s assume that the folder to be compressed is source, and the compressed file is source.zip.
zip -r source.zip source -P “password” # Compress and archive with password
3. Other operations
The Linux system is so powerful that it supports various compression formats, such as zip, tar, gz and so on. Using commands such as gunzip, bunzip2 and 7z can also achieve the purpose of decompression, etc.
In addition, Linux supports releasing files in common compression formats such as tar, zip and gzip. All one has to do is run the following command (here assume the name of the file is source.tar.gz).
tar -zxvf source.tar.gz # Unzip the compressed file
In conclusion, it is not difficult to understand the operations of compression and archiving in Linux. As long as you understand the use of commands such as tar and zip, understand how to use parameters, you can easily complete the corresponding operations.