Okay, so in this video, we are going to see these compression and extraction commands. So let's get started. So I'm going to cover three different ways to compress and extract files in Linux. So there are three different extensions that I'm going to cover that is the tar, then Gz then visit. So first of all, the tar format, so for creating our dot tar compressed file, we can do that using the tar command, then we have to specify CF. That means create the archive file and then we have to specify The name of the data file that we want.
So I'm going to specify abc.dr and space here we have to specify all the files that we want in this compressed file. So I want the demo dot txt file. And the archive is created. So as you can see, ABC dot tar, this file is created and our demo dot txt file is as it is. So if I open this, then as you can see, we have our demo dot txt file. Now, if I want to extract this file, then I just have to change this CF two x F. That means extract the file So enter.
And we already have this so it won't be extracted. So I'll delete this file. And now if we run this again, then as you can see, we have our file extracted. And then another command is df. Now this df command is used to display all the files that we have in this archive. So this is the tar command.
Now we are going to take a look at Jesus and create Jesus archive. So g. Zip is the command that you have to use. And you have to just specify the file name here. So demo dot txt. And that and the archive for demo dot txt is created. Now, if you notice something here, then the main file was deleted and this archive was generated.
So it contains that file, but the main file was deleted automatically while generating this file. So now, to extract our file from this archive, we just have to write the option dash D, that means decompress, so and so. And if you see here, then our file is present here, but the archive that was generated the compressed file that is deleted automatically. So this is the default runs between the GZ and tar. Now, there is another one that is the zip to. So this is similar to Gz.
Here you have to specify dash Zed options option and the file that you want to compress. And same as the GZ. It is going to delete the original file and you're just the zip file will be there. And if you want to extract you have to change the option to D and the name of the compressed file. And as you can see here, the compressed file is deleted and just the extracted file is present here. So it works similar to JSON.
So these were the real of compressing and decompressing files on Linux.