This article mainly introduces the use of MD5SUM commands in the Linux system, which is used to deal with the related operation of MD5 verification, and the friends who need it can refer to the following
MD5 algorithm is often used to verify the integrity of network file transmission, to prevent files from being tampered with. MD5 full name is the digest to the algorithm (Message-digest algorithm 5), this algorithm for arbitrary length of information on a bitwise basis, resulting in a binary length of 128 digits (hexadecimal length is 32 bits) of the "fingerprint" (or "Digest to"), different file generation phase The possibility of the same newspaper digest is very, very small.
On Linux or UNIX, md5sum is the tool that is used to compute and validate the document digest. In general, the installation of Linux, there will be md5sum this tool, directly in the command line terminal to run directly. You can use the following command to get the md5sum command help man md5sum
1. Use md5sum to produce fingerprint (message digest) commands as follows: Md5sum file > File.md5 or md5sum file >>file.md5
Note: The difference between > and >> is that > indicates that the summary generated by the file is redirected to the file file.md5, but overwrites the contents of the FILE.MD5, while >> appends the summary of the output to the File.md5 file. can also be a number of documents to output the digest to a MD5 file, this to use the wildcard *, such as a directory with several ISO files, to the several ISO file summary output to the Iso.md5 file, the order is as follows: Md5sum *.iso > Iso.md5
2, the use of MD5 newspaper digest to verify the file, there are two methods:
1. For example, the downloaded file files and the File.md5 Report Digest to the file in the same directory, and then use the following command to verify: Md5sum-c file.md5 Then if the validation succeeds, it will output: correct
2. For example, download files file, and then run the following command: Md5sum file command will output a MD5 message digest, and then the report digest to directly and FILE.MD5 content comparison, if the same, the verification is correct.
Usage of Linux md5sum
Tips for Oracle users
Md5sum is a very powerful command for security enforcement. Some of the configuration files that you manage (such as Listener.ora, Tnsnames.ora, and Init.ora) are important for a successful Oracle infrastructure, and any modifications can lead to downtime. These are usually part of the change control process. Don't trust what people say. These files are not changed, and the command is executed using the MD5 checksum. Create a checksum file and recreate the file each time the scheduled changes are executed. As part of compliance, use the md5sum command to check the file. If someone accidentally updates one of these important files, you will immediately capture the changes.
Similarly, you can create MD5 checksums for all executables in the $ORACLE _home/bin and continually compare them to capture unauthorized modifications.
The MD5 value of a file in a lifetime
Copy Code
The code is as follows:
[Oracle@node1 bin]$ md5sum Lsnrctl
87df51eb21ee0643e47988a0d8136f18 Lsnrctl
Second check whether the file changes
The code is as follows:
[Oracle@node1 ~]$ Touch file1 file2
[Oracle@node1 ~]$ ls
File1 file2 Patch.log
[Oracle@node1 ~]$
[Oracle@node1 ~]$ md5sum file1 file2>f1f2
[Oracle@node1 ~]$ md5sum--check f1f2
File1:ok
File2:ok
[Oracle@node1 ~]$ echo "Change" >>file1
[Oracle@node1 ~]$ md5sum--check f1f2
File1:failed
File2:ok
Md5sum:warning:1 of 2 computed checksums did not match
Examples are as follows:
Shell
The code is as follows:
# Touch F1.txt F2.txt
# ls
F1.txt F2.txt
# md5sum *.txt > Md5sumtest.md5
# Cat Md5sumtest.md5
d41d8cd98f00b204e9800998ecf8427e F1.txt
d41d8cd98f00b204e9800998ecf8427e F2.txt
# echo "hahaha" > F1.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:FAILED
F2.txt:OK
Md5sum:warning:1 of 2 computed checksums did not match
# echo "hahaha" > F2.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:FAILED
F2.txt:FAILED
Md5sum:warning:2 of 2 computed checksums did not match
# Cat/dev/null > F1.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:OK
F2.txt:FAILED
Md5sum:warning:1 of 2 computed checksums did not match
# Cat/dev/null > F2.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:OK
F2.txt:OK
The code is as follows:
# Touch F1.txt F2.txt
# ls
F1.txt F2.txt
# md5sum *.txt > Md5sumtest.md5
# Cat Md5sumtest.md5
d41d8cd98f00b204e9800998ecf8427e F1.txt
d41d8cd98f00b204e9800998ecf8427e F2.txt
# echo "hahaha" > F1.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:FAILED
F2.txt:OK
Md5sum:warning:1 of 2 computed checksums did not match
# echo "hahaha" > F2.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:FAILED
F2.txt:FAILED
Md5sum:warning:2 of 2 computed checksums did not match
# Cat/dev/null > F1.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:OK
F2.txt:FAILED
Md5sum:warning:1 of 2 computed checksums did not match
# Cat/dev/null > F2.txt
# md5sum-c MD5SUMTEST.MD5
F1.txt:OK
F2.txt:OK