Servers fuser, files, and processes

fuser, files, and processes

Juliet Kemp

Sometimes you may want to know which process is accessing a particular file
or filesystem — for example, if you get a “device is busy” error message.
fuser will provide this information.

Tip of the Trade: Because sometimes you need to know which process is accessing a particular file or filesystem.

Basic usage is: fuser filename.txt, which will give you this

/home/juliet/filename.txt: 13644

That number is the ID of the process that’s accessing the file. Use fuser -u filename.txt to see which user owns the process:

/home/juliet/filename.txt: 13644(juliet)

For more information, use fuser -v filename.txt:

                     USER        PID ACCESS COMMAND
                     juliet    13644 f.... more

This shows the user and PID, as well as information about how
the file is being accessed (here, f, indicating an open file), and the command being used
to access it (here, more).

The -m switch shows all process accessing the filesystem, which the
file is on; or you can simply specify a filesystem rather than a file. So
fuser -m /dev/sdb1 output looks like:

/dev/sdb1: 18647c 16875m  7122c 19579m  1606c  7258c  5760c 13644c

Most of these processes are accessing the current
directory (c), with a couple using shared libraries (m). Use the -v switch, to get more information.

To kill all processes accessing a particular file, use fuser -k
(add -i for a confirmation message before each
kill). You can also use fuser on network ports: fuser -n tcp 21. This will show which process is using port 21 (useful if you get
a ‘port busy’ message).

Latest Posts

Installing and Activating Hyper-V Linux Integration Services

Editor's Note: Updated to reflect changes with the Hyper-V Linux Integration Services 4.3 release. Microsoft developers have designed components that help in improving the performance of...

What is a Hypervisor Server?

At its most basic, a hypervisor is the “manager” of a software-hardware stack. The term “hypervisor” derives from the word “supervisor.” What is a Hypervisor? When...

HPE SimpliVity 380 Server Review

The HPE SimpliVity 380 Server was designed to deliver the high performance required by enterprise data centers in a simplified package. One of the...

What is Server Virtualization?

Server virtualization is essential for the efficient operation of any datacenter. But what exactly is server virtualization and is it right for your business?...

Using Netsh Commands for Wi-Fi Management in Windows 10

In this Server Tutorial, we’ll show you how to use Netsh Commands for Wi-FI management in Windows 10. Some basic networking settings and functionality...

Related Stories