9/27/2023 0 Comments Ubuntu tar compress folderIf you don’t use the option -f at all, you will still see an error, a different one this time. Try 'tar -help' or 'tar -usage' for more information. It’s important to provide the filename in the command otherwise you’ll see this error: tar: Cowardly refusing to create an empty archive You should note a couple of things while using the tar command: rw-r-r- 1 abhishek abhishek 9.6K Apr 11 11:41 sample_text_archive Keep in mind while using tar and gzip command Now if I check the size of the compressed folder using ls command, it’s hardly 10 KB. Now if I gzip compress the folder: tar -cvzf sample_text_archive sample_text_files If I use the du command to get the size of the directory, it’s 204 KB. Let’s say I have a bunch of files in a directory. v – verbose mode showing what files are being processedĮxample of using tar and gzip to compress a folder.c – tells tar to create the archive file.z – tells tar that it is dealing with gzip file.Let me explain the options used in the above command to you: The command looks something like this: tar -zcvf output_file_name directory_to_compress The good thing is that you can do both of these steps in one single command by using the z option. If you combine tar with gzip, the tar command will create one single archive file from the folder and then gzip will compress this archive file. The tar command will collate all the files into one archive file. Instead of trying to compress the folder directly, you should use tar on it first. What can you do now? How to gzip compress a file in Linux? Here’s what you can do. Interesting, isn’t it? gzip command cannot compress a directory because essentially, gzip works on individual files, not the entire folder. How do you gzip a directory in Linux? It’s definitely not using the gzip command because if you try to compress a folder using gzip command, you’ll see this error:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |