How is the fuser command used in Linux?
The fuser command in Linux is used to display information about processes using a specific file or directory. The basic usage method is as follows:
fuser [options] filename/directory
Common options include:
- -Kill the process that is currently using the specified file or directory.
- -m: Displays information about the mounted file systems.
- -v: Show detailed information.
- – u: display username.
- Interactive mode to confirm killing the process.
To view the process information of the file test.txt that is currently being used, you can use the following command:
fuser test.txt
To kill the process using test.txt, you can use the following command:
fuser -k test.txt