UNLIMITED

Linux Format

Monitoring cycles in directory trees

We’re going to use Python 3 to write Linux command line utilities that work with files and finds cycles in directory trees. The thinking here is that it’s faster to write in Python 3 than to use C. However, the tutorial presents some directions for developing the same utility in both C and Go. Let’s start by understanding the problem we’re trying to solve.

The idea behind the utility is that with UNIX symbolic links it’s possible to create cycles (aka loops) in filesystems. Put simply, without symbolic links, there would be no cycles problem. This can perplex back-up software such as tar or utilities such as find and it can sometimes have security implications: for example, accessing files outside of the designated directory tree. FScycles.py, the utility we’ll be focusing on in this tutorial, attempts to inform us about such situations.

The screenshot (below) shows a directory tree using the tree utility – it’s the ~/go directory where Go puts external packages. Because this directory doesn’t contain any symbolic links, create some using

Before getting into the meat of the subject let’s understand the various types of files that can be found in Linux. Remember that UNIX treats everything as a file, even hardware

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format3 min read
Ubuntu 24.10
Ubuntu 24.10 is the first interim release since 24.04, and in the past six months, 24.04 has improved from what was initially released. Ubuntu 24.10 offers a newer kernel (6.11.0) and a few refinements such as Gnome 47, Mutter and an improved app sto
Linux Format1 min read
Intel Patch For Outdated Microcode?
Intel engineer Dave Hansen has sparked a “Microcode Revision Discussion” regarding a proposed Linux patch on the kernel mailing list. This new feature would report outdated microcode through the existing sysfs vulnerabilities reporting system. Specif
Linux Format1 min read
Get More Pieces Of Pi
Les Pounder works with groups such as the Raspberry Pi Foundation to help boost people’s maker skills. My desk has seen a plethora of Raspberry Pi products these last two weeks, starting with the new Raspberry Pi-branded microSD cards and a rubber bu

Related Books & Audiobooks