How To Monitor Changes in Linux Folders with Pynotify

If you're a Linux user, it's likely that you've come across the need to monitor changes in your Ubuntu directories. Luckily, the Pyinotify package is here to help. In fact, since version 2.6.13 of Linux, inotify has been incorporated as a security functionality, allowing system monitoring programs to open a single file descriptor and gain access to events occurring in a directory or file. This means that you can keep centralized control over your directories and files, accessing attributes such as open, create, close, move/rename, delete, change, and more.

What is Pyinotify?

Overall, Pyinotify is a powerful tool that allows for precise monitoring and management of your Ubuntu directories on Linux systems. With its comprehensive features and easy-to-use interface, it's an essential tool for system administrators and home users alike.

Pyinotify takes things one step further by providing tools like variables, signals, and conditions that make directory management even more specific. Variables contain Python objects, signals are lists of handles that are activated when a signal is issued, and conditions are Boolean variables linked to a signal that is emitted when its status changes.

To use Pyinotify on your Ubuntu 22.04 system, you'll need to meet a few requirements. You must have a Linux kernel version of 2.6.13 or higher and Python 2.4 or higher installed.

To know what version we have of each of these requirements we will execute the following commands:

uname -r (Kernel version)
python -V (Python version)

Install Pyinotify on Linux

To install the application we will use pip, and for this, we will execute the following commands depending on the Linux distro used:


sudo yum install python-pip

Debian / Ubuntu

sudo apt install python-pip


sudo dnf install python-pip

Now we execute the following command for the installation of the application:

sudo pip install pyinotify

There we will install the most recent application in the repository. If you wish to have the latest version of Pyinotify, we will execute the following commands in their order:

git clone
cd pyinotify /
python install

How To Use Pyinotify in Ubuntu 22.04

To use pyinotify in the monitoring of a certain directory, we will execute the following command:

python -m pyinotify -v /home/augusto/TheLinuxCode

With this, we will analyze the changes in the /TheLinuxCode directory.

How To Use Pyinotify in Ubuntu 22.04

We have created a new folder in /TheLinuxCode called Test and we can see how in real time pyinotify detects the change and registers it with its respective event:

How To Use Pyinotify in Ubuntu 22.04

The structure of pyinotify is:

  • Date and time of the event.
  • Size of the event
  • Event type.
  • Route where the event occurred.

To exit pyinotify monitoring, we will use the following key combination Ctrl + C. If we do not specify a directory to analyze the tool, use the /tmp directory by default.

Pyinotify is a valuable tool as administrators that will allow us to take a specific control over the events that occurred in real time in a Linux directory and in this way know in detail what type of event happened and take the necessary measures.

It might be interesting

Epic Games has released Unreal Engine 5 and two free projects

As part of today's State of Unreal presentation, Epic Games announced the release of the Unreal Engine 5 along with two free projects.

iPod provides better gaming experience than PSP and Ds, Apple boss says

Apple’s iPhone and iPod Chief Greg Joswiak is confident that gaming devices will be at the centre of his company’s future success. He believes that the iPod serves as the better gaming device than Sony’s PSP and Nintendo’s DS.

Microsoft begins Office 14’s outside testing

On Tuesday, Microsoft announced that it has started outside testing of those server products that will be included in its Office coming version.

Google started production of mid-budget smartphones Pixel 6a

Google has begun mass production of the Pixel 6a in several Asian countries. This once again confirms the fact that its announcement will take place very soon.