Common CentOS commands
Because the learning needs will often be used and forgotten, we hereby back up:
1. About compression and decompression:
At the end of lifecycle. After the tar package is generated, you can use other programs
Line compression, so first let's talk about the basic usage of the tar command:
There are many options for the tar command (which can be viewed using man tar), but there are several commonly used options. below
For example:
# Tar-cf all.tar *. jpg
This command is to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.
,-F specifies the package file name.
# Tar-rf all.tar *. gif
This command adds all .gif files to the package of all.tar. -R indicates adding files.
Meaning.
# Tar-uf all.tar logo.gif
This command is used to update the logo.gif file in tarbao all.tar.-u indicates that the file is updated.
# Tar-tf all.tar
This command is used to list all files in the all.tar package.-t is used to list objects.
# Tar-xf all.tar
This command is used to extract all files in the all.tar package.-x is used to unlock the file.
The above is the most basic usage of tar. To help you compress or decompress the package
File, tar provides a special feature. This means that tar can call other pressures while packaging or unpacking.
Program shrinking, such as calling gzip and bzip2.
1) tar calls gzip
Gzipis a program developed by gnuorganization. The file ending with .gz is the result of gzip compression. And gzip
The relative decompression program is gunzip. Use the-z parameter in tar to call gzip. The following is an example.
:
# Tar-czf all.tar.gz *. jpg
This command is to compress all .jpg files into a tar package and use gzip to generate
The package name is all.tar.gz.
# Tar-xzf all.tar.gz
This command unlocks the generated package.
2) tar call bzip2
Bzip2is a more powerful compression program. The file ending with .bz2 is the result of bzip2 compression.
The decompress program relative to bzip2 is bunzip2. Use the-j parameter in tar to call gzip. The following is an example.
Note:
# Tar-cjf all.tar.bz2 *. jpg
This command is to compress all .jpg files into a tar package and use bzip2 to generate
Bzip2compressed package named all.tar.bz2
# Tar-xjf all.tar.bz2
This command unlocks the generated package.
3) tar call compress
Compress is also a compression program, but it seems that people who use compress are not as good as those who use gzip and bzip2.
More .. The file ending with Z is the result of bzip2 compression. The decompress program relative to compress is uncompress.
. Use the-Z parameter in tar to call compress. The following is an example:
# Tar-cZf all.tar. Z *. jpg
This command is to compress all .jpg files into a tar package and generate
An uncompress compressed package named all.tar. Z
# Tar-xZf all.tar. Z
This command is used to unbind the generated package.
With the above knowledge, you should be able to uncompress a variety of files, the following for the tar series of compressed files
As a summary:
1st pair of files ending with .tar
Tar-xf all.tar
2XX for the file ending with .gz
Gzip-d all.gz
Gunzip all.gz
32.16.tgzor .tar.gz
Tar-xzf all.tar.gz
Tar-xzf all. tgz
4)for the file ending with .bz2
Bzip2-d all.bz2
Bunzip2 all.bz2
5 bytes for the file ending with tar.bz2
Tar-xjf all.tar.bz2
6) for files ending with. Z
Uncompress all. Z
72.16.tar. Z
Tar-xZf all.tar. z
In addition, Linux also has corresponding methods to decompress the compressed file .zipand .rar under windows.
Guys:
1)for. Zip
Linux provides zip and unzip programs, zip is a compression program, and unzip is a decompression program. Their Parameters
There are many options. Here we will only give a brief introduction. We will still give an example to illustrate its usage:
# Zip all.zip *. jpg
This command compresses all .jpg files into a zip package.
# Unzip all.zip
This command decompress all files in all.zip.
2XX vs. .rar
To process the. RAR file in linux, you must install RAR for Linux. You can download the file from the Internet, but remember that RAR for Linux is not free. You can download rarfor Linux 3.2 from http://www.rarsoft.com/download.htm.
0, and then install:
# Tar-xzpvf rarlinux-3.2.0.tar.gz
# Cd rar
# Make
After installation, there will be two programs, rar and unrar. rar is a compression program, and unrar is a decompression program. They have many Parameter options. Here we will only give a brief introduction and give examples to illustrate their usage:
# Rar a all *. jpg
This command is to compress all. jpg files into a rarpackage named all.rar. this program will
The extension name is automatically appended to the package name.
# Unrar e all.rar
This command is to extract all files from all.rar.
By now, we have introduced 10 types of compressed files, tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, Zookeeper,. zw..tar.zw..zipw..rar, in linux.
In the future, you do not need to worry about downloading a software without knowing how to solve it in Linux. In addition, the above method is basically effective for Unix.
This article introduces the compressed files tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, Zookeeper,. Z,. tar.zw..zipw.rar in linux.
Operation.
Supplement
Tar
-C: Create a compressed file
-X: Extract
-T: View content
-R: append an object to the end of the compressed archive object
-U: update files in the original compressed package
These five are independent commands, one of which must be used for compression and decompression. They can be used with other commands, but only one of them can be used. The following parameters are optional when files are compressed or decompressed as needed.
-Z: With the gzip attribute
-J: With the bz2 attribute
-Z: With the compress attribute
-V: displays all processes.
-O: unbind the file to the standard output
The following parameter-f is required
-F: use the file name. Remember, this parameter is the last parameter and can only be followed by the file name.
# Tar-cf all.tar * .jpgthis command is to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.-f specifies the package file name.
# Tar-rf all.tar *. gif
This command adds all .gif files to the package of all.tar. -R indicates adding files.
# Tar-uf all.tar logo.gif
This command is used to update the logo.gif file in tarbao all.tar.-u indicates that the file is updated.
# Tar-tf all.tar
This command is used to list all files in the all.tar package.-t is used to list objects.
# Tar-xf all.tar
This command is used to extract all files in the all.tar package.-x is used to unlock the file.
Compression
Tar-cvf jpg.tar *. jpg // pack all jpg files in the Directory into tar.jpg
Tar-czf jpg.tar.gz *. jpg // jpg
Tar-cjf jpg.tar.bz2 *. jpg // jpg
Tar-cZf jpg.tar. Z *. jpg // jpg. Z
Rar a jpg.rar *. jpg // rar format compression, You need to download rar for linux
Zip jpg.zip *. jpg // zip format compression, You need to download zip for linux first
Extract
Tar-xvf file.tar // decompress the tar package
Tar-xzvf file.tar.gz // decompress tar.gz
Tar-xjvf file.tar.bz2 // unzip tar.bz2
Tar-xZvf file.tar. Z // extract tar. Z
Unrar e file.rar // extract rar
Unzip file.zip // decompress the zip file
Summary
*. Use tar-xvf to decompress the package.
* Use gzip-d or gunzip to decompress. gz.
* .Tar.gz and *. tgz are decompressed with tar-xzf.
*. Use bzip2-d For bz2 or bunzip2 for decompression.
* .Tar.bz2 unzip the package with tar-xjf
*. Z decompress the package with uncompress
*. Tar. Z decompress the package with tar-xZf
* Unrar e extraction for rar
* Unzip for. zip
Ii. VIM usage
1. Quit (I didn't know before, it took a lot of time)
Enter "colon", that is, ":" (double quotation marks are not required). A colon will appear below, waiting for the command to be entered. What I entered is WQ. Functions.
W: write, write
Q: quit, quit
Press enter to save and exit.
In fact, there are two ways to save and exit:
A: Enter "x" directly when entering the command, that is, X = WQ.
B: The quickest way: after pressing ESC, press shift + zz directly, or switch to the upper-case mode and press ZZ to save and exit. That is, press Z under 2 in upper-case.
2. Edit:
I: insert. Basically, this is enough.
3. Modify the boot option:
Use vim to edit the/etc/inittab file to modify the boot options
# Default runlevel. The runlevels used by RHS are:
#0-halt (Do NOT set initdefault to this)
#1-Single user mode
# 2-Multiuser, without NFS (The same as 3, if you do not have networking)
#3-Full multiuser mode
#4-unused
#5-X11
# 6-reboot (Do NOT set initdefault to this)
Id: 3: initdefault:
This information indicates that the Linux operating system has six different runlevels, and the system has different States under different runlevels. These six levels are:
#0: Stop (remember not to set initdefault to 0, because it will make Linux unable to start)
#1: single-user mode, just like the security mode in Win9X.
#2: multiple users, but not NFS.
#3: full multi-user mode, standard operation level.
#4: Generally, it is not used. In some special cases, you can use it to do something.
#5: X11, that is, entering the X-Window system.
#6: restart (remember not to set initdefault to 6; otherwise, Linux will be restarted continuously ).