If we want to extract only a single file from the tar file, we can do so by specifying the name of the file that we want to extract out of the tar file, as follows: $ tar -xvzf test.txt To extract a specific file out of TAR file If we do not provide any path then the tar file is unzipped at the current location. In the above command we have specified the -C argument to give the path of the directory in which we want the tar file to be unzipped. To uncompress tar.gz file into a different directory, use the command below: $ tar xvzf -C /path/to/directory Z: The z option is very important and tells the tar command to uncompress the file (gzip).į: This options tells tar command that you are going to give it a file name to work with. This option will list all of the files one by one in the archive as they are unzipped. ![]() X: This option tells tar to extract the files. ![]() $ tar xvzf įollowing are the options that we have used with the tar command: If your tar file is compressed using a gzip compressor, use this command to uncompress it. On top of archiving a set of files and folders using the tar command, we can also compress them using the gzip command which leads to the creation of the file with extension. In Unix based operating systems, we can use the tar command to zip multiple files, folders etc into a TAR file and for unzipping a TAR file to access its files and folders. Interestingly, TAR stands for tape archiver. Such a zip file can contain multiple files, folders, sub folders all packed in a single file, which is generally created using gzip or bzip2 program on Unix operating systems. The tar program provides the ability to create tar archives. tar.gz file is just a simple archive file that acts as a container for other files. To extract a file in Linux compressed with gunzip, type the following: gunzip filename_tar.To setup any new software or service on your Linux machine, if you are not using any package manager, you will have to download the ZIP or TAR.GZ file for any software, then unzip it and then run any command to start that service.Ī. It also means that you will see any errors in the archive. To extract a file compressed with tar (e.g., filename.tar), type the following command from your SSH prompt: tar xvf filename.tarīasically, this command means that you will see the file “explode”, so don’t worry when you see your screen scrolling wildly. Typing zip or unzip by itself will give you a usage summary, showing nearly all the options available. If you have an archive named myzip.zip and want to get back the files, you would type: unzip myzip.zip gz need to be extracted with the method described in “ gunzip“. For example, if you are trying to unzip a file called file.tar – you would use the method described in “ tar“. Please note that the unzip method you use is defined by the filename you are trying to unzip. This puts the files named file1, file2, and file3 into a new zip archive called myzip.zip. Navigate to the directory where the files are that you want to zip (for instance by typing cd www then cd sounds to move to your /www/sounds directory). To zip files, first have the files uploaded to your server, then log into your account with SSH. This Linux program is compatible with the zip program for Windows and most other operating systems. ![]() You can tell the zip method by the file extension (e.g. The “right” unzip method depends upon the method used to zip the file. (Files zipped in Linux can be extracted using various tools on various platforms including Windows).īelow I have provided various “unzip” methods. ![]() I recommend using the zip function to compress your files for its ease of use and portability. I personally use Ubuntu but you can apply these methods with all the Linux distros. There are several methods of archiving files and retrieving archives in Unix-like systems like Linux.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |