Commands tagged lsof (40)

  • spectrum protect's dsmc command shows file names and total amount of restore. This command shows which files are actually open and their siz in GB and highlights the change to the previous output Show Sample Output


    1
    watch -n60 -d 'lsof -w /filesysname|grep -v NAME|awk '\''{$7=int($7/1073741824) " GB"; print $7, $9}'\'''
    BodoGreif · 2019-09-02 11:49:20 386

  • 1
    lsof | grep -e "[[:digit:]]\+w"
    aysadk · 2020-01-27 23:10:38 352
  • Where COMMAND is the process(es) name. I prefer to get all states but you may add ESTABLISHED in the grep regex. lsof -c apache2 | egrep -o 'TCP.*ESTABLISHED.*$' -nP flags are optional and UDP is irrelevant for established connections Similar but using the process id: lsof -nP -p PID | egrep -o '(TCP|UDP).*$' Show Sample Output


    0
    lsof -nP -c COMMAND | egrep -o '(TCP|UDP).*$' | sort -u
    forcefsck · 2011-01-25 12:04:13 5
  • Shows files and processes of the command php


    0
    watch -d=c -n3 'lsof -itcp -iudp -c php'
    AskApache · 2013-03-14 01:24:50 5

  • 0
    lsof -i -P +c 0 +M | grep -i "$1"
    opexxx · 2013-03-19 10:42:15 5
  • Shows which applications are making connections, and the addresses they're connecting to. Refreshes every 2 seconds (watch's default). Test on OSX, should work anywhere watch and lsof work. Show Sample Output


    0
    watch "lsof -i -P |grep ESTABLISHED |awk '{printf \"%15.15s \\t%s\\n\", \$1, \$9}'"
    skarfacegc · 2013-04-03 02:04:11 6
  • Inner "ps...grep..." command searches for a process matching the specified . "lsof -p lists all file descriptors owned by . Includes open files, sockets, devices, etc... Show Sample Output


    0
    sudo lsof -p `sudo ps aux | grep -i neo4j | grep -v grep | awk '{ print $2 }'`
    andycunn · 2013-06-02 10:15:30 8
  • Show top apps that use internet, sorted by count connections and grouped by TYPE and Protocol Show Sample Output


    0
    sudo lsof -P -i -n | awk '{print $1,$5,$8}' | tail -n +2 | uniq -c | sort -nr
    anton_slim · 2014-12-18 05:22:33 10
  • Show what the process are opening many many file descriptos now, we can analyze this for the reason why server is worked slowly. Show Sample Output


    0
    sudo lsof | awk '{print $1,$2}' | sort | uniq -c | sort -nr
    anton_slim · 2014-12-18 05:42:15 9
  • us lsof, grep for any pid matching a given name such as "node". Show Sample Output


    0
    lsof -i -n -P | grep -e "$(ps aux | grep node | grep -v grep | awk -F' ' '{print $2}' | xargs | awk -F' ' '{str = $1; for(i = 2; i < NF; i++) {str = str "\\|" $i} print str}')"
    hochmeister · 2015-02-14 23:24:00 11

  • 0
    lsof -Pn +D /var/cache/ | awk '{print $1}' | sort | uniq
    olto · 2015-11-12 05:30:44 14

  • -1
    lsof -p <process_id> | wc -l
    virtualshock · 2009-07-20 17:46:54 4
  • % lsof -v lsof version information: revision: 4.78


    -1
    lsof | awk '/*:https?/{print $2}' | sort -u
    sugitaro · 2011-02-04 01:37:17 4
  • This option selects the listing of all Internet and x.25 (HP-UX) network files. Show Sample Output


    -1
    lsof -i
    shsingh · 2011-10-03 02:06:30 4
  • This option is much faster, as it checks only network nodes. Show Sample Output


    -2
    lsof -Pi | grep LISTEN
    5partan · 2011-10-03 12:50:18 4
  •  < 1 2

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Have subversion ignore a file pattern in a directory
If you don't want to commit files to subversion, and don't want those file to show up when doing an "svn stat", this command is what you need

Figure out what shell you're running
short, sweet, and works after sudoing a new shell.

This allows you to find a string on a set of files recursivly
The -r is for recursive, -F for fixed strings, --include='*.txt' identifies you want all txt files to be search any wildcard will apply, then the string you are looking for and the final * to ensure you go through all files and folders within the folder you execute it.

Trick find -exec option to execute alias
An alias cannot be executed as command in a find -exec line. This form will trick the command line and let you do the job.

convert wmv into xvid avi format

Virtual Console lock program
vlock command locks the current console by default. Also you can lock all the consoles on the server by using -a parameter. For details, pl man vlock. ps: Generally speaking , system will not install vlock programme . So you should use ' $ sudo apt-get install vlock ' to install vlock .

Filter the output of a file continously using tail and grep
The OPs solution will work, however on some systems (bsd), grep will not filter the data, unless the --line-buffered option is enabled.

Install pip with Proxy
Installs pip packages defining a proxy

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

check remote port without telnet


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: