Linux tar usage introduction
First we need to understand two concepts: packaging and compression. Packaging refers to turning a large number of files or directories into a total file; compression means turning a large file into a small file through some compression algorithms.
Why should we distinguish these two concepts? This is due to the fact that many compression programs in Linux can only compress one file, so when you want to compress a large number of files, you have to first package the large number of files into a package (tar command), and then use Compression program (gzip bzip2 command).
tar (选项) (参数)
Options
-A or --catenate: Add files to existing backup files;
-B: Set block size;
-c or --create: Create a new backup file;
-C : This option is used for decompression. If you want to decompress in a specific directory, you can use this option.
-d: Record file differences;
-x or --extract or --get: Restore files from backup files;
-t or --list: List the contents of the backup file;
-z or --gzip or --ungzip: Process backup files through the gzip command;
-Z or --compress or --uncompress: process backup files through the compress command;
-f or --file=: Specify the backup file;
-v or --verbose: display the instruction execution process;
-r: Add files to already compressed files;
-u: Add changed and existing files to the existing compressed file;
-j: Support bzip2 decompression files;
-v: Display the operation process;
-l: File system boundary setting;
-k: Keep the original files without overwriting;
-m: Keep files from being overwritten;
-w: Confirm the correctness of the compressed file;
-p or --same-permissions: Restore the file with the original file permissions;
-P or --absolute-names: use absolute names for file names and do not remove the "/" sign before the file name;
-N or --newer=: Only save files newer than the specified date to the backup file;
--exclude=: Exclude files that match the template style.
Pack the files into a tar package:
tar -cvf log.tar log2012.log
Only packaging, not compression!
tar -zcvf log.tar.gz log2012.log
After packaging, compress with gzip
tar -jcvf log.tar.bz2 log2012.log
After packaging, compress with bzip2
In the folder, only files newer than a certain date are backed up:
tar -N "2018/3/1" -zcvf log.tar.gz test
If you use tar in the simplest way, you only need to remember the following three methods:
Compression:
tar -jcv -f filename.tar.bz2
The name of the file or directory to be compressed
Inquire:
tar -jtv -f filename.tar.bz2
unzip:
tar -jxv -f filename.tar.bz2 -C
Directory to be decompressed
The above is the detailed content of Linux tar usage introduction. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

There are many ways to customize a development environment, but the global Git configuration file is one that is most likely to be used for custom settings such as usernames, emails, preferred text editors, and remote branches. Here are the key things you need to know about global Git configuration files.
