The commonly used compressed file on Linux is the tar.gz file, which is tgz, and the command corresponding to these files is tar. But there are also some files that we uploaded from the Windows computer, such as zip files, the command corresponding to these files is unzip. A summary is given below.
1 、 tar
tar has the following parameters:
- -c : create parameters for creating compressed archives;
- -x : Parameters for decompressing compressed archives;
- -z : Whether to compress with gzip;
- -v: Display files during compression;
- -f: put the file name at the top, followed by the file name immediately after f, no parameters can be added
For example, package the /home/fengchi863/deeplearning/imageCaptcha/nets folder (only package, not compress):
tar -cvf /home/fengchi863/deeplearning/imageCaptcha/nets.tar /home/fengchi863/deeplearning/imageCaptcha/nets
After packaging, perform gzip compression:
tar -zcvf /home/fengchi863/deeplearning/imageCaptcha/nets.tar.gz /home/fengchi863/deeplearning/imageCaptcha/nets
The compressed file name after the parameter f is taken by yourself. It is customary to use tar to do it. If the z parameter is added, tar.gz or tgz will be used to represent the gzip compressed tar file.
Extract the tgz file to the specified directory
tar zxvf nets.tgz -C 指定目录
For example, unzip the nets.tgz file to the directory under the user name
tar zxvf nets.tgz -C /home/fengchi863
2、unzip
Files transferred to linux via ssh are sometimes zip compressed files on Windwos. Then use zip to unzip it.
unzip 指定文件 -d 目标文件夹
For example, unzip the nets.zip file to the current directory
unzip nets.zip