Learn how Linux manages open files and explore a number of utilities to watch files as they grow.

" />
x
Loading
 Loading
Hello, Guest | Login | Register

On the T(r)ail of Open Files

Learn how Linux manages open files and explore a number of utilities to watch files as they grow.

If you’re more of a Linux user than a programmer, you may not have given much thought to how the operating system handles files. As a user, you simply give a filename to a program (from the “Open” command on a menu, from the command line, or however) and the file is (hopefully) accessed however it’s supposed to be.

However, programmers who perform low-level access of files– for instance, to seek to a particular point in a file or rewinding the file to its start– have to understand more about Linux file handling. That’s where we’re headed this month: seeing how Linux handles files that have been opened by a program, and learning how you can take advantage of this even if you don’t usually write programs that handle files.

Along the way, we’ll look at tail –f, MultiTail, and less+F. These three programs can show you what’s happening to a file as it grows (as data is added to end of the file). They’re handy for viewing log files and monitoring a long-running process.

Open Files

Let’s start with a quote from the Linux man page for open(), the low-level system call that programmers can use to open a file:

The open() system call is used to convert a pathname into a file descriptor (a small, non-negative integer for use in subsequent I/O as with read, write, etc.). When the call is successful, the file descriptor returned will be the lowest file descriptor not currently open…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. KDE 4.4: Does It Work Yet?
  2. Writing Custom Nagios Plugins with Python
  3. Power Up Linux GUI Apps
  4. Tweeting from the Command Line with Twyt
  5. When Memory Serves You: Using ramfs and tmpfs
Follow Linux Magazine
Rackspace