Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
fuser answers "who is using this?". The most common case is umount: target is busy: fuser -vm /mnt/usb lists the processes with files open on that file system. With -k it sends them a signal. It also works for ports: fuser 80/tcp prints the PID that owns TCP port 80.
The letter after each PID tells how the file is used: c = current folder, e = running program, f = open file, F = open for writing, r = root folder, m = memory-mapped.
Zo schrijf je het
fuser [OPTION]... NAME...
fuser -k [-SIGNAL] [-i] NAME...Opties 17
Meest gebruikt
Options
-n,--namespaceSPACE- Name space:
file,udportcp(fuser -n tcp 80).
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Why does umount say "target is busy"?
fuser -vm /mnt/usb USER PID ACCESS COMMAND /mnt/usb: root kernel mount /mnt/usb student 4321 ..c.. bashThe shell of student is inside the folder (c = current directory).
2Stop the processes, then unmount
fuser -km -TERM /mnt/usb umount /mnt/usb3Ask before every kill
fuser -kim /srv/data4Which process owns a port?
fuser 80/tcp 80/tcp: 1420 fuser -v -n tcp 225Who has a log file open?
fuser -v /var/log/messages6Check in a script if a file is in use
7Only processes that write to a file
fuser -kw -TERM /srv/app/app.db8Find users on an NFS mount before a server reboot
fuser -vmu /mnt/shared9Free a UDP port
fuser -k 5353/udp10Use the device name instead of the folder
fuser -vm /dev/sdb1Same result as with the mount point; useful when you only know the device.
Niets past bij dit filter.
Let op
fuser -kuses SIGKILL by default: no clean-up. Prefer-k -TERMfirst.- On
/or/home,-kmwould kill almost everything. Always use-vfirst to look.
Tips om te onthouden
lsof +f -- /mnt/usbgives similar output with file names.
Exitcodes
0 | At least one process was found (or killed). |
1 | No process uses the name, or an error. |