{"id":12705,"date":"2019-03-28T14:03:19","date_gmt":"2019-03-28T14:03:19","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12705"},"modified":"2019-03-28T14:03:19","modified_gmt":"2019-03-28T14:03:19","slug":"learn-how-to-use-fuser-command-with-examples-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/learn-how-to-use-fuser-command-with-examples-in-linux\/","title":{"rendered":"Learn How to Use \u2018fuser\u2019 Command with Examples in Linux"},"content":{"rendered":"<p>One of the most important task in Linux systems administration, is process management. Its involves several operations under monitoring, signaling processes as well as setting processes priorities on the system.<\/p>\n<p>There are numerous Linux tools\/utilities designed for monitoring\/handling processes such as\u00a0<a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">top<\/a>,\u00a0<a href=\"https:\/\/www.tecmint.com\/find-linux-processes-memory-ram-cpu-usage\/\" target=\"_blank\" rel=\"noopener\">ps<\/a>,\u00a0<a href=\"https:\/\/www.tecmint.com\/difference-between-grep-egrep-and-fgrep-in-linux\/\" target=\"_blank\" rel=\"noopener\">pgrep<\/a>,\u00a0<a href=\"https:\/\/www.tecmint.com\/how-to-kill-a-process-in-linux\/\" target=\"_blank\" rel=\"noopener\">kill<\/a>,\u00a0<a href=\"https:\/\/www.tecmint.com\/how-to-kill-a-process-in-linux\/\" target=\"_blank\" rel=\"noopener\">killall<\/a>,\u00a0<strong>nice<\/strong>\u00a0coupled with many others.<\/p>\n<p>In this article, we shall uncover how to find processes using a resourceful Linux utility called\u00a0<strong>fuser<\/strong>.<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/find-linux-processes-memory-ram-cpu-usage\/\" target=\"_blank\" rel=\"noopener\">Find Top Running Processes by Highest Memory and CPU Usage<\/a><\/p>\n<p><strong>fuser<\/strong>\u00a0is a simple yet powerful command line utility intended to locate processes based on the files, directories or socket a particular process is accessing. In short, it helps a system user identify processes using files or sockets.<\/p>\n<h3>How to Use fuser in Linux Systems<\/h3>\n<p>The conventional syntax for using\u00a0<strong>fuser<\/strong>\u00a0is:<\/p>\n<pre># fuser [options] [file|socket]\r\n# fuser [options] -SIGNAL [file|socket]\r\n# fuser -l \r\n<\/pre>\n<p>Below are a few examples of using\u00a0<strong>fuser<\/strong>\u00a0to locate processes on your system.<\/p>\n<h4>Find Which Process Accessing a Directory<\/h4>\n<p>Running\u00a0<strong>fuser<\/strong>\u00a0command without any option will displays the\u00a0<strong>PIDs<\/strong>\u00a0of processes currently accessing your current working directory.<\/p>\n<pre>$ fuser .\r\nOR\r\n$ fuser \/home\/tecmint\r\n<\/pre>\n<div id=\"attachment_22985\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Find-Running-Processes-of-Directory.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22985\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Find-Running-Processes-of-Directory.png\" alt=\"Find Running Processes of Directory\" width=\"713\" height=\"95\" aria-describedby=\"caption-attachment-22985\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22985\" class=\"wp-caption-text\">Find Running Processes of Directory<\/p>\n<\/div>\n<p>For a more detailed and clear output, enable the\u00a0<code>-v<\/code>\u00a0or\u00a0<code>--verbose<\/code>\u00a0as follows. In the output,\u00a0<strong>fuser<\/strong>\u00a0prints out the name of the current directory, then columns of the process owner (<strong>USER<\/strong>), process ID (<strong>PID<\/strong>), the access type (<strong>ACCESS<\/strong>) and command (<strong>COMMAND<\/strong>) as in the image below.<\/p>\n<pre>$ fuser -v\r\n<\/pre>\n<div id=\"attachment_22987\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/List-of-Running-Processes-of-Directory.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22987\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/List-of-Running-Processes-of-Directory.png\" alt=\"List of Running Processes of Directory\" width=\"709\" height=\"495\" aria-describedby=\"caption-attachment-22987\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22987\" class=\"wp-caption-text\">List of Running Processes of Directory<\/p>\n<\/div>\n<p>Under the\u00a0<strong>ACCESS<\/strong>\u00a0column, you will see access types signified by the following letters:<\/p>\n<ol>\n<li><code>c<\/code>\u00a0\u2013 current directory<\/li>\n<li><code>e<\/code>\u00a0\u2013 an executable file being run<\/li>\n<li><code>f<\/code>\u00a0\u2013 open file, however,\u00a0<strong>f<\/strong>\u00a0is left out in the output<\/li>\n<li><code>F<\/code>\u00a0\u2013 open file for writing,\u00a0<strong>F<\/strong>\u00a0is as well excluded from the output<\/li>\n<li><code>r<\/code>\u00a0\u2013 root directory<\/li>\n<li><code>m<\/code>\u00a0\u2013 mmap\u2019ed file or shared library<\/li>\n<\/ol>\n<h4>Find Which Process Accessing A File System<\/h4>\n<p>Next, you can determine which processes are accessing your\u00a0<code>~.bashrc<\/code>\u00a0file like so:<\/p>\n<pre>$ fuser -v -m .bashrc\r\n<\/pre>\n<p>The option,\u00a0<code>-m<\/code>\u00a0NAME or\u00a0<code>--mount<\/code>\u00a0<strong>NAME<\/strong>\u00a0means name all processes accessing the file\u00a0<strong>NAME<\/strong>. In case you a spell out directory as\u00a0<strong>NAME<\/strong>, it is spontaneously changed to\u00a0<code>NAME\/<\/code>, to use any file system that is possibly mounted on that directory.<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/find-processes-by-memory-usage-top-batch-mode\/\" target=\"_blank\" rel=\"noopener\">Find Top 15 Processes by Memory Usage in Linux<\/a><\/p>\n<h4>How to Kill and Signal Processes Using fuser<\/h4>\n<p>In this section we shall work through using\u00a0<strong>fuser<\/strong>\u00a0to\u00a0<a href=\"https:\/\/www.tecmint.com\/find-and-kill-running-processes-pid-in-linux\/\" target=\"_blank\" rel=\"noopener\">kill and send signals to processes<\/a>.<\/p>\n<p>In order to kill a processes accessing a file or socket, employ the\u00a0<code>-k<\/code>\u00a0or\u00a0<code>--kill<\/code>\u00a0option like so:<\/p>\n<pre>$ sudo fuser -k .\r\n<\/pre>\n<p>To interactively kill a process, where you are that asked to confirm your intention to kill the processes accessing a file or socket, make use of\u00a0<code>-i<\/code>\u00a0or\u00a0<code>--interactive<\/code>\u00a0option:<\/p>\n<pre>$ sudo fuser -ki .\r\n<\/pre>\n<div id=\"attachment_22988\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Interactively-Kill-Process-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22988\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/Interactively-Kill-Process-in-Linux.png\" alt=\"Interactively Kill Process in Linux\" width=\"709\" height=\"148\" aria-describedby=\"caption-attachment-22988\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22988\" class=\"wp-caption-text\">Interactively Kill Process in Linux<\/p>\n<\/div>\n<p>The two previous commands will\u00a0<strong>kill<\/strong>\u00a0all processes accessing your current directory, the default signal sent to the processes is\u00a0<strong>SIGKILL<\/strong>, except when\u00a0<strong>-SIGNAL<\/strong>\u00a0is used.<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/how-to-kill-a-process-in-linux\/\" target=\"_blank\" rel=\"noopener\">A Guide to Kill, Pkill and Killall Commands in Linux<\/a><\/p>\n<p>You can list all the signals using the\u00a0<code>-l<\/code>\u00a0or\u00a0<code>--list-signals<\/code>\u00a0options as below:<\/p>\n<pre>$ sudo fuser --list-signals \r\n<\/pre>\n<div id=\"attachment_22989\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/List-All-Kill-Signals.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22989\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/10\/List-All-Kill-Signals.png\" alt=\"List All Kill Process Signals\" width=\"693\" height=\"95\" aria-describedby=\"caption-attachment-22989\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22989\" class=\"wp-caption-text\">List All Kill Process Signals<\/p>\n<\/div>\n<p>Therefore, you can send a signal to processes as in the next command, where\u00a0<strong>SIGNAL<\/strong>\u00a0is any of the signals listed in the output above.<\/p>\n<pre>$ sudo fuser -k -SIGNAL\r\n<\/pre>\n<p>For example, this command below sends the\u00a0<strong>HUP<\/strong>\u00a0signal to all processes that have your\u00a0<code>\/boot<\/code>\u00a0directory open.<\/p>\n<pre>$ sudo fuser -k -HUP \/boot \r\n<\/pre>\n<p>Try to read through the\u00a0<strong>fuser<\/strong>\u00a0man page for advanced usage options, additional and more detailed information.<\/p>\n<p>That is it for now, you can reach us by means of the feedback section below for any assistance that you possibly need or suggestions you wish to make.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/learn-how-to-use-fuser-command-with-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most important task in Linux systems administration, is process management. Its involves several operations under monitoring, signaling processes as well as setting processes priorities on the system. There are numerous Linux tools\/utilities designed for monitoring\/handling processes such as\u00a0top,\u00a0ps,\u00a0pgrep,\u00a0kill,\u00a0killall,\u00a0nice\u00a0coupled with many others. In this article, we shall uncover how to find processes using &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/learn-how-to-use-fuser-command-with-examples-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Learn How to Use \u2018fuser\u2019 Command with Examples in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12705","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12705"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12705\/revisions"}],"predecessor-version":[{"id":12706,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12705\/revisions\/12706"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}