 Hello and welcome. I hope that you're enjoying this series so far on shell commands for your Linux shell and today We're gonna be looking at a program called I notify wait Which allows you to monitor directories and files for modifications and things such as that and just them being accessed So let's go ahead and the command you would have to install so you can pseudo apt install I notify Let's see. I Notify tools on Debbie and base system. I don't know if it might be called something different I already have it installed. So I don't need to do that right now. So I'm gonna say I notify wait and I'm gonna say dash M and I'm gonna look at a directory that does not exist at this moment So I'm gonna hit that it's gonna tell me it doesn't exist. So let's go ahead and and create that real quick So I'm just going to say make dirt So that now exists I can now run this command and it's sitting there and it's watching and it's waiting I'm gonna open up another shell here and I'm going to echo test into a file inside that directory, so I'll say echo test into temp examples My file or move file my file and as you can see up here. It tells you that the in this directory There was a file created. It was my file. It was opened. It was modified and it was written to and closed So that's monitoring a directory for any changes made to it. Let's go ahead. I'm gonna come up here I'm going to kill this command the control C and now I'm going to point it at that file and say my file And there's now it's monitoring that file in particular so I can come back down here and I can run that You know I can keep adding to that or actually I'm adding to it. I'm replacing it each time And let's see. I'm just curious if I do this Yeah, it just it just doesn't say whether it's added to it just tells you that it was open modified written to and closed So but that's just monitoring that one file if I add to a different file You see nothing happens up there because it's only monitoring that one file But if I come back up here and run the original command, which is looking at the directory Now whether I'm adding to file 2 or The first file it will log it up there or not log it, but let you know it will monitor and tell you so let's go ahead and Change that a little bit right here. It's telling you whether it's open closed. So Let's go ahead and monitor this file again. Let's see my file What happens if I go Vim and I say to my file Up there. It tells you, you know what was happened to it and I can say Right file and it tells you know attributes change. So it's telling you a lot of stuff here But let's say we only want to be monitor Notified of the modifications not when it was open not when it was closed Just when it was modified. So let's go ahead and kill this command and We're going to run that same command again But instead of just M We're going to do dash Q and dash E now And then type modified here modify so now You can see it's only telling me when it's been modified. So I saved it there I can write to it this way and it's only telling me when it's been modified Not that it's been open or closed or written to just that it's been modified in some way And there's a lot of options again look through the man pages for more information on that Let's go ahead and send a system message out and there's different ways you can use you send notify I guess there's no not no notify send There's notify dash OSD. I've seen people use to get gooey pop-ups But another command that we can look at is the wall command a wall command I can say wall test and it sends that command to Every shell running it broadcast it says who sent it So if you're on system with multiple people and everyone's using a shell you can run that and it just sends that message Who sent it and when and from where? To the entire system. So that's great. You're working in another shell You may not be looking at this, but you'll get a notification up on the screen when things change So let's go ahead and modify our little command up here so we can incorporate that into it So we're gonna run the same command we ran looking for when it's been modified And this is my first thought when I was testing this out read I'll say line and I'll say do and I'll say wall dollar sign L and Done now if I come down here, and let me open up two shells here Like that so you'll see that it goes to both shells. So I'm gonna modify that file boom So all my shells got a message saying that was modified So that that's awesome. I get that now There are certain times when the if you're modifying the file in a certain way where you're gonna get Multiple outputs. So here I got the one wall command here to it but sometimes there's certain modifications that it seems to modify it twice and You get double messages. I don't necessarily want double messages So especially if you're using one of the GUI applications will get multiple boxes up on the screen So we go ahead and kill this if you look in the man file The man file actually has a slight variation on what I did. So basically it's the same command But what we're gonna do is we're going to be sure to say redirect dev null here Semi colon and we're gonna say Instead of doing while here We're actually going to write it. So we're gonna say while This command is running And we don't need the dash M here according to them. So we're gonna say Q e modify this file dump into while and then we're gonna say wall and We're just gonna say here file modified I'm gonna go ahead and hit enter and In this particular scenario it should work the same way here. It's instead of saying the output from the command It's actually saying our message. So that's a slight variation there and again in the example I'm giving it's not doing two messages, but when I did test it in certain ways you get double messages, especially with the Notify send it was popping up multiple boxes. This variation on the command Works a little bit better So that's again in the man file And there you can you know, if you're concerned, maybe you think you know, there's some reason you want my file that you want No, it's been updated Maybe you're checking a mail file. Although there's better ways to check your mail file using proc mail and stuff But you're waiting for a file to be modified and you want to be notified when it happens You can use the wall command, but I Notify wait and the again the package on at least Debbie and base system is I notify wait dash tools Go ahead install that and now you can Monitor when files and folders are modified and send yourself messages. I mean here. I'm doing a broadcast out everybody using the wall command We again can do gooey where you get the little box with something like notify send But you also have it send you emails or texts from your computer so that you know You're not at your computer. You your phone will get a message Wherever you're at. I do. Thank you for watching Again, this video is part of a series for check out the full playlist As always You can go to my website films by Chris calm. That's Chris the K There's a link in the description there. You can go through all my videos search through them very conveniently You can also support me there in the support section. We got the patreon.com forward slash mil X 1000 Also have paypal link there any support even a dollar a month is much appreciated and Also there you can also look at my script section which we're bringing to my notes and you can search through Right now. I have almost 600 Pastebin notes, but I made a searchable application there so you can search through them all It's not the best written search application because it dumps a lot of data I could have been written much better, but you can search through there and as always I thank you for watching and I hope that you have a great day