TOC is not supported in this version (ex.Mobile)
Windows and Macs are often compressed with zip, but Linux often downloads files compressed with tar or tar.gz.
By default, package management is possible in apt/yum, etc., but what should I do if I want to compress the files I downloaded myself or the files I have now? The very answer is tar (there are of course gzip and other utilities)
First of all, you should know that tar is a bundle command, not a compression command. Remember that there is a compression option when you tie it, not just by writing a tar.
Compress (Common)
tar -cvf [filename.tar] [foldername]
ex)
$> tar -cvf targetFolder.tar targetFolder
→ compress from targetFolder to targetFolder.tar
Try following me
If you create a target folder temporarily as follows and look it up, you can see that the target folder has been created as follows.
And then,
$> tar -cvf targetFolder.tar targetFolder
when you call this command
The console window calls for compressed targetFolder/ (if there is content inside, the compressed content is listed)
And then,
$ ls -alt
You can see the made a compressed file
Decompress (tar)
tar -xvf [filename.tar]
ex)
$> tar -xvf targetFolder.tar
→ decompress from targetFolder.tar to current folder
Try following me
First, to delete the target folder at the parent folder
$> rm -ivfr targetFolder
And then,
$> ls -alt
If you do, you can see that only targetFolder.tar remains as shown below and the targetFolder has been deleted.
In this state, you can execute below command
$> tar -xvf targetFolder.tar
You can see that the decompressed content (only targetFolder/ because there are no files in the folder at this time) is displayed.
When you executed below command, you can see the decompressed file
$> ls -alt
Compress (gzip)
tar -zcvf [filename.tar.gz] [foldername]
The difference from tar is simple in terms of the difference that you write z in front of the option cvf.
Decompress (gzip)
tar -zxvf [filename.tar.gz]
The difference from tar is simple in terms of the difference that you write z in front of the option cvf.
Manual Page
Details of the options are available on the manual page. (The command is available from the root permission.)
man tar
Among them, the most common ones I just used are compression (zcvf) and decompression (zxvf), and the options are as follows.
z: gzip (ex extension is gz) when you want to compress or decompress a compressed file
c: If you want to compress
x: If you want to decompress
v: Show the contents of the file in the console window when compressing/decompressing (why it is exposed as /targetFolder when executing the top command)
f: Specify a file name
[CentOS] How to use tar
🇰🇷 Korean
'개발 창고 > Server' 카테고리의 다른 글
How to handle high volume traffic (3) | 2024.08.12 |
---|---|
[Ubuntu] 확장자 일괄 처리 (9) | 2023.12.26 |
[AWS] How to build WordPress with LightSail (0) | 2023.12.04 |
[Linux] How to use /etc/fstab file (0) | 2023.11.13 |
[Linux] How to use "smbclient" command (0) | 2023.11.12 |