Document directory
- To put it bluntly, check whether the file has been modified.
The MD5 algorithm is often used to verify the integrity of network file transmission and prevent file tampering. The full name of MD5 is the message digest algorithm (Message-Digest algorithm 5). This algorithm computes information of any length by bit, generate a "fingerprint" (or "Message Digest") with a binary length of 128 bits (32 bits in hexadecimal format "), different files may generate the same message digest.
In Linux or UNIX, md5sum is a tool program used to calculate and verify the file message digest. Generally, after Linux is installed, the md5sum tool runs directly on the command line terminal. You can use the following command to obtain the md5sum command to help man md5sum
1. Run the following command to generate a fingerprint (Message Digest) using md5sum File> file. MD5 or md5sum File> file. MD5:
Note:> and> the difference is:> indicates redirecting the abstract generated by the file to the file. MD5, but will overwrite file. the content in MD5, and> adds the output digest to file. after the MD5 file. You can also output the message digest of multiple files to an MD5 file. The wildcard * is used. For example, there are several ISO files in a directory, output the abstract of these ISO files to ISO. in the MD5 file, the command is as follows: md5sum *. ISO> ISO. MD5
2. Use MD5 message digest to verify the file. There are two methods:
1. for example, the downloaded file and the file. the Digest file of the MD5 packet is placed in the same directory, and then verified using the following command: md5sum-C file. then, if the verification is successful, the output is: Correct
2. for example, if you download the file and run the following command: md5sum file, an MD5 message digest is output, and then the digest is directly associated with the file. the content in MD5 is compared. if the content is the same, the verification is correct.
========================================================== ======
Usage of md5sum in Linux
Tips for oracle users
Md5sum is a very powerful command for security implementation. Some configuration files you manage (such as listener. ora, tnsnames. ora, and init. ora) are very important for a successful Oracle infrastructure and any modifications may cause downtime. These are usually part of the change control process. Do not believe that the files mentioned by others have not been changed. use MD5 checksum to run the command. Create a checksum file and recreate it each time the plan is changed. As part of compliance, run 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 checksum for All executable files in $ ORACLE_HOME/bin and compare them continuously to capture unauthorized modifications.
1. Generate the MD5 value of a file
[Oracle @ node1 bin] $ md5sum LSNRCTL
87df51eb21ee0643e47988a0d8136f18 LSNRCTL
2. Check whether the file has changed
[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
======================================
To put it bluntly, the following example shows whether the verification file has been modified:
[root@localhost RESTORED_FILES]# mkdir test[root@localhost RESTORED_FILES]# cd test/[root@localhost test]# touch f1.txt f2.txt[root@localhost test]# lsf1.txt f2.txt[root@localhost test]# md5sum *.txt > md5sumtest.md5[root@localhost test]# cat md5sumtest.md5 d41d8cd98f00b204e9800998ecf8427e f1.txtd41d8cd98f00b204e9800998ecf8427e f2.txt[root@localhost test]# echo "hahaha" > f1.txt [root@localhost test]# md5sum -c md5sumtest.md5 f1.txt: FAILEDf2.txt: OKmd5sum: WARNING: 1 of 2 computed checksums did NOT match[root@localhost test]# echo "hahaha" > f2.txt [root@localhost test]# md5sum -c md5sumtest.md5 f1.txt: FAILEDf2.txt: FAILEDmd5sum: WARNING: 2 of 2 computed checksums did NOT match[root@localhost test]# cat /dev/null > f1.txt[root@localhost test]# md5sum -c md5sumtest.md5 f1.txt: OKf2.txt: FAILEDmd5sum: WARNING: 1 of 2 computed checksums did NOT match[root@localhost test]# cat /dev/null > f2.txt[root@localhost test]# md5sum -c md5sumtest.md5 f1.txt: OKf2.txt: OK[root@localhost test]#