• Ubuntu tar gz unpacking. Creating and unpacking archives in Linux

    And Xen to work with archives requires only the basic components of the system, namely Tar, Gzip And Bzip2, which, when creating a compressed archive, work as a single whole, because an archiver in itself Tar does not provide the possibility of data compression. It is used for this purpose Gzip or Bzip2. Archives created using Gzip, usually have the extension .tar.gz, and when using Bzip2.tar.bz2.

    Creating a tar archive without compression

    To create such an archive, use the command:

    Tar -cf filename.tar file1 file2 fileN

    Parameter - cf responsible for creating the archive filename.tar, which will include specified files. Directories can also be specified instead of files.

    Creating an archive using compression

    Because at least two methods are available for compression, a separate set of parameters is used to use each method.

    Compression example Gzip:

    Tar -cvzf filename.tar.gz dir_name

    IN in this case we tried to pack the folder dir_name to the archive filename.tar.gz. From specified parameters -z indicates the use of a method Gzip, A -v displays the results of the archive creation process, indicating the packed files or folders.

    Compression example Bzip2:

    Tar -cvjf filename.tar.bz2 dir_name

    This command is similar to the previous one and has a difference in the parameter –j, because it is he who is responsible for using the compression method Bzip2.

    Unpacking the archive

    To unpack the archive, use the command:

    Tar -xvf filename.tar.bz2

    In this case, the archive filename.tar.bz2 will be unpacked into the folder you were in when you ran the command. In order to unpack the archive to some other directory, you can use the command:

    Tar -xvf filename.tar.bz2 -C /path/to/folder

    In this case, the archive will be unpacked in the specified directory.

    View archive contents without unpacking

    For these purposes the following command is used:

    Tar -tf filename.tar.gz

    As a result of executing the command, a list of files and folders stored in the archive will be displayed. If you add to the list of parameters -v, you will get an expanded output of information about the contents, indicating the file size, access rights, names of owners and their groups, etc.

    tar you can use the commands:

    Tar --help #call help on commands and parameters man tar #call extended documentation

    Creating and unpacking ZIP archives

    Creating a zip archive is done with the command:

    Zip archive.zip filename

    Instead of archive.zip indicate the name of the archive to be created. Instead of filename specify the name of the file that needs to be archived. To archive an entire folder, you must use the option –r, which initiates recursive archiving. Without this parameter, only the folder without its attachments will be archived. Example command:

    Zip –r archive.zip dirname

    The archive is unpacked using the command unzip:

    Unzip archivename.zip

    If you need to unpack to a specific folder, then use the parameter –d. For example:

    Unzip –d dirname archivename.zip

    Instead of dirname indicates the folder into which you want to extract data from the archive.

    View full list archiver capabilities zip And unzip you can use the commands:

    Zip --help or unzip --help #call help on commands and parameters man zip or man unzip #call extended documentation

    Unpacking RAR archives

    To extract the contents of the archive, use the command unrar:

    Unrar filename.rar

    You can view the list of files in the archive without unpacking it with the command:

    Unrar –t filename.rar

    Note: It is worth noting that Unrar may not be available by default on some Linux distributions. You can install this software using the following commands:

    CentOS/Fedora:

    Yum install unrar

    Debian/Ubuntu:

    Apt-get install unrar-free

    View the full list of archiver features unrar you can use the commands:

    Rar --help #call help on commands and parameters man unrar #call extended documentation

    An example of creating a backup copy of data on a VPS

    Let's say on a VPS you need to make a backup copy of the site files that are located in the directory /var/www/html/mysite. To create a compressed archive of data located in the specified directory, you must run the following command:

    Tar -cvzf mysite.tar.gz /var/www/html/mysite

    As a result, the contents of the directory /var/www/html/mysite will be archived mysite.tar.gz.

    In most cases, the web has certain limitations when it comes to decompressing files. Or maybe you are using a VPS without any panel at all, and unpacking the archive will require you to run ssh commands on an archive of a certain type. The most common types of archives .tar; .tar.gz And .zip, each has its own creation and unpacking command.

    Unpacking archives using SSH commands

    First of all, you will need to go to the directory where your archive is located. For example, if your archive is located in the directory public_html/files, run the command to go there:

    Cd public_html/files

    How to unpack .tar.gz

    The following command will allow you to extract the contents of the .tar.gz archive:

    Tar -zxvf ArchiveName.tar.gz

    A list of files from the archive will be displayed on the screen and upon completion of unpacking you can enter another command, if necessary.

    How to unpack .tar

    An archive file with the same compression type can be unpacked with the following command:

    Tar -xvf ArchiveName.tar

    A list of files in your archive will appear on the screen and once unpacking is complete, the console will be free to enter other commands.

    How to unpack.zip

    This command will extract the .zip:

    Unzip ArchiveName.zip

    As soon as the process is completed, the command line will be free.

    Creation of archives using commands SSH

    Now that we already know how to unpack all these types of archives, let's also consider the reverse process of creating an archive, compressing files into any desired format.

    How to create .tar.gz

    The method shown below will allow you to compress selected files into an archive:

    Tar -zcf NewArchive.tar.gz yourfile1.php yourfile2.php yourfile3.txt

    If you need to compress the contents of a directory, use this command:

    Tar -zcf NewArchive.tar.gz DirectoryName

    Upon completion, as before, the console will be free for further operations.

    How to create a .tar

    The syntax for creating a .tar archive using the ssh command is very simple:

    Tar -zcf archive-name.tar.gz filename1.php filename2.php filename3.php

    If you want to archive a directory, simply specify the directory name in the list of files to archive.

    Tar -zcf archive-name.tar.gz DirectoryName

    As soon as you can run commands again, your archive is ready.

    How to create a .zip

    This type of archive is even easier to create. The syntax looks like this:

    Zip archive-name.zip filename1.php filename2.php filename3.php

    Compressing a directory has the same syntax:

    Zip archive-name DirectoryName

    The screen will show the process of creating the archive and after the creation is completed, the console will again be free for other commands.

    Conclusion

    Congratulations! Following these simple instructions do you know now? how to create and extract .tar.gz, .tar, .zip archives using SSH commands.

    Good afternoon

    First, briefly and to the point - only the basic information that you came for. In the second part of the article I will talk about useful nuances that you can do without.

    How to unpack the tar archive:

    On Windows:

    On Linux/Unix systems:

    1. Using MC (Midnight Commander is a popular file manager for Linux systems, available in any repository) - just go to the tar file as if it were a folder and copy the contents from there.

    2. From the console using the commands:

    tar -xvf archive-file . tar

    tar - xvfarchive-file. tar. gz

    tar -xvf archive-file.tar.bz2

    tar -xvf archive-file . tar -C /folder_for_unpacking

    Decryption: x - key indicating that the archive needs to be unpacked; v - enables visual display of the unpacking process; f - key, after which we indicate the name of the file to unpack; C - you can (but not necessarily) specify the path for unpacking. If the path is not specified, it will be unpacked into the current folder.

    How to create tar:

    On Linux/Unix systems:

    tar -cf files . tar ./folder_with_files - create a simple tar archive without compression

    tar - cvzffiles. tar. gz . /folder_with_files - create a tar archive compressed with gzip

    tar -cvjf files.tar.bz ./folder_with_files - create a tar archive compressed with bzip2

    Keys: c - create archive; f - specify the file name; z - use gzip compression (the most popular); j - use bzip2 compression; v - enables visual display of the unpacking process;

    On Windows:

    1. Right-click on the folder or selected files, select "7-Zip" -> "Add to archive..." from the menu:

    2. Select the archive format - tar, change the archive name and other settings if necessary and click "Ok":

    Useful information about the Tar archiver:

    Tar is the main archiver for Linux and Unix systems. If you are making an archive for such a system, it is better to use tar. Zip, although supported here, is much slower and is not used by many systems.

    If compression tools are used when creating a tar archive, it is customary to include them in the file name. For example: files.tar.gz is a tar archive created using gzip compression, files.tar.bz2 is a tar archive using bzip2 compression.

    If you have any questions or need clarification, please ask a question or leave a comment.

    I'm always happy to help!

    Operating systems: Linux

    Unpack tar.gz V command line Linux:

    tar zxvf file.tar.gz

    - z: gzip archive [ 1 ]

    - x: extract files from archive

    - v: display a list of files being processed while the command is running

    - f: unpack the file whose name is specified after the command and modifiers. That is, the parameter f instructs the following argument to be used as what to work with instead of the system default backup device, such as /dev/rmt0.

    The command extracts the contents of the compressed archive into the current folder.

    Tar creates an archive from one or more files. Then used gzip to compress it. Or both processes are carried out only with the help tar using the appropriate command options. The duality of nature - archived and then compressed - is reflected in the file name extension ("tar.gz") and requires that two procedures be performed during the extraction process: recovery from the compressed state and decompression. From here z(restore) and x(unpack) in the team.

    Aliosque subditos et theme

    Aligns page content to the center in the visible area of ​​the browser window with using CSS. The container in which all the content of the web page will be located is aligned centered - in width and height - [Open example page]. HTML/XHTML. Code: <a href="https://periscopes.ru/en/css-vyravnivanie-elementov-css---vyravnivanie-po-centru.html">CSS alignment</a> in the center: in width and height - 2

    CSS. Code: html (height: 100%; margin: 0px;) body height: 100%; margin: 0px;) .spacer (position: relative; top: 0px; left: 0px; height: 50%; width: 100px; float: left; margin: 0px 0px -250px 0px; background: #999;).wrapper ( position: relative top: 0px; width: 100%; background: #a3ddc4;) .pagecontent (position: relative; top: 0px; left: 0px; height: 500px; width: 800px; margin: 0 auto; background: #ff6f6f;) Container.pagecontent - for all web page content. This container must be explicitly given dimensions in px, em, etc. - not as a percentage. The height and width can be larger than the visible area of ​​the browser window, but in this case we are talking about a more practical case - when the height and width of the container.pagecontent is smaller than the dimensions of the visible area of ​​the browser window. The.pagecontent block is centered/justified in the viewable area of ​​the browser window using "margin: 0 auto". .Wrapper creates a space where .pagecontent is centered/justified. Width.wrapper is equal to 100%, so that the center/width alignment occurs when different sizes visible area of ​​the browser window. The height of the.wrapper must be equal to the height of the container.pagecontent. .Spacer aligns .wrapper with .pagecontent inside centered/height in the viewable area of ​​the browser window. The width.spacer can be any. The height is 50%, this places the top edge of .pagecontent vertically centered in the viewable area of ​​the browser window. Margin-bottom of the block.spacer equal to half the height.pagecontent aligns the container.pagecontent centered/height at any current height of the visible area of ​​the browser window. This method is suitable for all major modern browsers. It also works in older browsers such as Internet Explorer 6 or early versions Maxthon. But the height of the container in which the page content is located must have explicitly specified dimensions, and if they change, the margin-bottom value of the.spacer block must also be changed accordingly. There is another way to horizontally and vertical alignment centered using CSS, with CSS code that is easier to maintain. Although this method does not work in older web browsers: CSS center alignment: width and height - 1. [ 1 ] And also in Netscape 7.2+, Mozilla 1.5+. [ 2 ] And also in Netscape 7.2+, Mozilla 1.5+.

    There is no "float: bottom" property in CSS, but the effect can be achieved in several other ways. Example: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Link 1 Link 2 Link 3 Float bottom HTML / XHTML. Code:

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    Float bottom
    CSS. Code: .box1 (position: relative; top: 0px; left: 0px; float: left; height: auto; width: 100%;) .content1 (position: relative; top: 0px; left: 0px; float: left; height: auto; width: 100%;) .left1 (position: relative; top: 0px; left: 0px; float: left; height: auto; width: 64%;) .menu1 (position: relative; top: 0px; left: 0px; float: left; height: auto; width: 36%;) .bottom1 (position: absolute; bottom: 0px; right: 0px;) /* Additional CSS, just to give the example some appearance */ . box1 (color: #ddd; text-align: center;).content1 (background: #bbb;).left1 (min-height: 100px; padding: 2%; text-align: justify; background: #006; -moz -box-sizing: border-box; -webkit-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box;) .menu1 (padding: 2%; float: right; background: #060; -moz-box-sizing: border-box; -ms-box-sizing: border-box;) menu1 p (position: relative; top: 0px; left: 0px; float: left; height: auto; width: 100%; padding: 0px; margin: 0px;).menu1 a (color: #ddd; text-decoration: none;).menu1 a:hover (text-decoration: underline;).bottom1 (padding: 2%; color: #eee; background: # 600;) All content of the web page is contained in the box1 container. Inside it are two div containers: 1. content1 with the actual content on the left and a menu on the right. 2. bottom1 after content1.

    These days we come across archive files very often and on all platforms: Windows, Mac or Linux. These could be programs backups systems or databases or just an archive of files. We also often have to create our own archives in Linux in order to transfer several files to friends or upload to a file hosting service. Software packages are distributed in the form of archives, source codes, as well as many other files distributed on the Internet. Learning how to archive files in Linux through the terminal is very important; you may need it when you don’t have access to the graphical interface, or it will simply become more pleasant to work in the terminal over time.

    In this manual, I want to take a detailed look at archiving utilities in Linux; we will look at not only the most popular and universal utility- tar, but also other lesser-known and popular compression algorithms.

    It is important to note that archiving in Linux is not the same thing as compressing Linux files. Archiving is the combination of several small files into one for the purpose of more convenient subsequent transfer, storage, encryption or compression. As I already said, archiving is performed by special utilities. We will not touch archiving files in graphical interface, you will figure them out yourself, our topic is the terminal.

    The most popular archiving utility for Linux is tar. It is used almost everywhere, for archiving sources, packaging packages. Other utilities are used for compression, depending on the compression algorithm, for example, zip, bz, xz, lzma, etc. Archiving is performed first, then compression, separate programs. Automatic start Some compression utilities for the newly created archive are supported in tar and other similar programs using special options.

    Also useful opportunity archiving has encryption. But now let's look at what utilities exist that can be used to archive Linux files and how to use them.

    Tar

    Tar is standard utility, with which archiving is performed Linux files. Gradually from small program archiving it has turned into powerful tool, which supports working with many archive options and compression algorithms. The program supports large number parameters. Let's look at its syntax and main parameters:

    $tar options f file_to_write /folder_files_for_archive

    Now let's look at the main options:

    • A- add a file to the archive
    • c- create an archive in Linux
    • d- compare archive files and unpacked files in the file system
    • j- compress the archive using Bzip
    • z- compress the archive using Gzip
    • r- add files to the end of the archive
    • t- show archive contents
    • u- update the archive relative to the file system
    • x- extract files from the archive
    • v- show detailed information about the work process
    • f- file for recording the archive
    • -C- unpack to the specified folder
    • --strip-components- discard n subfolders

    Now let's look at archiving files in Linux. To create an archive use the following command:

    tar -cvf archive.tar.gz /path/to/files

    And to unpack the linux tar archive:

    tar -xvf archive.tar.gz

    It's very easy to remember to use the packaging option c - C reate, and for unpacking - x-e X tract.

    The compressed archive is created in exactly the same way, only with the -z option, this is if gizp encryption was used; if bzip is needed, then the -j option is used:

    tar -zcvf archive.tar.gz /path/to/files

    $ tar -zxvf archive.tar.gz

    For example, let's look at how to archive a folder in Linux:

    tar -zcvf home.tar.gz ~/

    Although we can do it differently, we get the same archive if we first create a regular archive using tar, and then compress it with a compression utility, only here we get more control over the compression process:

    gzip archive.tar

    You can also remove compression:

    gunzip archive.tar.gz

    We will look at compression utilities below.

    To add a file to the archive use:

    tar -rvf archive.tar file.txt

    To extract a single file, the syntax is the same:

    tar -xvf archive.tar file.txt

    You can extract multiple files by matching pattern using the wildcard parameter, for example, extract all php files:

    tar -xvf archive.tar --wildcards "*.php"

    By default, you can unpack a linux tar archive into the current folder with the name of the archive to unpack into the desired folder use the -C switch:

    tar -xvf archive.tar -C /path/to/dir

    We've looked at the standard utility, now let's briefly look at its alternatives. There are not many of them, and most of them are already outdated.

    Shar

    Shar allows you to create self-extracting archives. It is essentially a shell script and requires a Bash or other Bourne Shell compatible shell to unpack. Shar has several advantages, but it is also potentially insecure since the archive is an executable file.

    Shar options:

    • -o- save archive to file instead of standard output
    • -l- limit output file size
    • -L- limit the size of the output file and split it into parts
    • -n- the archive name will not be included in the header
    • -a- allow automatic generation of titles

    Examples of using shar to archive a Linux folder:

    Create a shar archive:

    shar file_name.extension > filename.shar

    Unpack the shar archive:

    Ar

    ar is a utility for creating and managing archives. Mainly used for archiving static libraries, but can be used to create any archives. Previously used quite often but was supplanted by the tar utility. Currently used only for creating and updating static library files.

    • - d- remove modules from the archive
    • -m- moving members in the archive
    • - p- print specific archive members
    • -q- quick addition
    • -r- add a member to the archive
    • -s- create an archive index
    • - a- add new file to an existing archive

    Now let's look at examples of use. Let's create a static library libmath.a from the object files substraction.o and division.o:

    ar cr libmath.a substraction.o division.o

    Now let's extract the files from the archive:

    This way you can unpack any static library.

    Cpio

    cpio - means Copy in and out (copy input and output). This is another standard archiver for Linux. Actively used in the manager Red packages Hat, as well as for creating initramfs. Archiving in Linux for regular files using this program is not applicable.

    Utility options:

    • -a- reset the time it takes to access files after copying them
    • -A- add file
    • -d- create directories if necessary

    Example of use. Create a cpio archive:

    file1.o file2.o file3.o

    ls | cpio -ov > /path/to/output_folder/obj.cpio

    Unpack the archive:

    cpio-idv< /path/to folder/obj.cpio

    Archiving the linux folder is also done automatically.

    Compressing Archives in Linux

    We looked at how to create an archive in Linux. Now let's talk about compression. As I said, they are used for compression special utilities. Let's briefly look at a few of them

    Gzip

    The most commonly used is Gzip. This is a standard compression utility in Unix/Linux. For decompression, use gunzip or gzip -d First, let's look at its syntax:

    $gzip options file

    $ gunzip options file

    Now let's look at the options:

    • -c- output archive to standard output
    • -d- unpack
    • -f- forcefully unpack or compress
    • -l- show information about the archive
    • -r- recursively iterate through directories
    • -0 - minimum compression level
    • -9 - maximum level compression

    You have already seen examples of use in the description of the tar utility. For example, let's compress a file:

    gzip -c file > archive.gz

    Now let's unpack:

    gunzip -c archive.gz

    But to compress a folder in Linux, you will first have to archive it using tar, and only then compress the archive file using gzip.

    Bzip

    bzip2 is another alternative compression utility for Linux. It is more efficient than gzip, but is slower. To unpack, use the bunzip2 utility.

    I will not describe the options of bzip2; they are similar to gzip. To create an archive on Linux use:

    The file file.bz2 will be created in the current directory

    Lzma

    New and highly efficient compression algorithm. The syntax and options are also similar to Gzip. Use unlzma to unpack.

    Xz

    Another highly efficient compression algorithm. Backwards compatible with Lzma. The calling parameters are also similar to Gzip.

    Zip

    Cross-platform utility for creating compressed archives zip format. Windows-compatible implementations of this algorithm. Zip archives are very often used for exchanging files on the Internet. With this utility you can compress both files and compress the linux folder.

    Utility syntax:

    $ zip options files

    $ unzip options archive

    Utility options:

    • -d delete file from archive
    • -r- recursively traverse directories
    • -0 - archive only, no compression
    • -9 - best compression ratio
    • -F- fix zip file
    • -e- encrypt files

    To create a Zip archive in Linux, use.