1 00:00:00,000 --> 00:00:10,320 While working with remote files every now and then, you probably want to check file 2 00:00:10,320 --> 00:00:12,320 integrity. 3 00:00:12,320 --> 00:00:13,320 Checksums are the solution. 4 00:00:13,320 --> 00:00:19,040 A checksum is a number that serves as a sum of correct digits in data, and which can be 5 00:00:19,040 --> 00:00:23,600 used to detect errors that have occurred during file storage or transmission. 6 00:00:23,600 --> 00:00:27,959 The idea is that based on the content of your file, you should always be able to calculate 7 00:00:27,959 --> 00:00:30,200 the exact same checksum. 8 00:00:30,200 --> 00:00:37,160 MD5 sums or SHA sums are commonly used as a checksum on Linux. 9 00:00:37,160 --> 00:00:43,639 Even if MD5 is considered broken, for simply verifying file downloads it can still be used. 10 00:00:43,639 --> 00:00:51,360 And if more security is needed, you use either SHA-256 or SHA-512, where SHA-512 is giving 11 00:00:51,360 --> 00:00:54,000 the better security. 12 00:00:54,000 --> 00:01:01,959 Use the MD5 sum on any file to calculate that file's MD5 checksum, and SHA sum to calculate 13 00:01:01,959 --> 00:01:04,519 the file's SHA checksum. 14 00:01:04,519 --> 00:01:09,519 The tab represents the number that you want to use in the command. 15 00:01:09,519 --> 00:01:14,400 And to use a checksum for verification, store it in a separate file and distribute it with 16 00:01:14,400 --> 00:01:15,400 a file. 17 00:01:15,400 --> 00:01:16,400 Let me show you. 18 00:01:16,400 --> 00:01:18,519 Okay, let me demonstrate. 19 00:01:18,519 --> 00:01:25,440 To start it, I'm using MD5 sum on etcpasswd. 20 00:01:25,440 --> 00:01:27,599 That's showing the checksum. 21 00:01:27,599 --> 00:01:34,760 And I want to write that checksum to passwd.md5. 22 00:01:34,760 --> 00:01:38,320 Then I'm going to use my verification command. 23 00:01:38,320 --> 00:01:43,720 So md5 sum minus cpasswd md5. 24 00:01:43,720 --> 00:01:47,440 And I can see that etcpasswd is okay. 25 00:01:47,440 --> 00:01:51,519 And then I'm using user add lisa. 26 00:01:51,519 --> 00:01:54,000 And I'm running my MD5 sum again. 27 00:01:54,000 --> 00:01:55,440 And oh boy, what do we see? 28 00:01:55,440 --> 00:01:57,559 One computed checksum did not match. 29 00:01:57,559 --> 00:01:58,559 Why is that? 30 00:01:58,559 --> 00:02:00,860 Because the content of the file has changed. 31 00:02:00,860 --> 00:02:03,320 And that's exactly what the checksum is doing. 32 00:02:03,320 --> 00:02:04,959 It's observing changed content.