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 0

  • 1
    lsof | grep -e "[[:digit:]]\+w"
    aysadk · 2020-01-27 23:10:38 4
  • 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 0
  • 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 0

  • 0
    lsof -i -P +c 0 +M | grep -i "$1"
    opexxx · 2013-03-19 10:42:15 0
  • 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 0
  • 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 1
  • 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 0
  • 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 0
  • 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 3

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

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


    -1
    lsof | awk '/*:https?/{print $2}' | sort -u
    sugitaro · 2011-02-04 01:37:17 0
  • 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 0
  • 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 0
  •  < 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

Rename files in batch

Clean way of re-running bash startup scripts.
This replaces the current bash session with a new bash session, run as an interactive non-login shell... useful if you have changed /etc/bash.bashrc, or ~/.bashrc If you have changed a startup script for login shells, use $ exec bash -l Suitable for re-running /etc/profile, ~/.bash_login and ~/.profile. edit: chinmaya points out that $ env - HOME=$HOME TERM=$TERM bash -s "exec bash -l" will clear any shell variables which have been set... since this verges on unwieldy, might want to use $ alias bash_restart='env - HOME=$HOME TERM=$TERM bash -s "exec bash -l"'

find and delete empty directories recursively
this will show the names of the deleted directories, and will delete directories that only no files, only empty directories.

Put a console clock in top right corner
Gives not only date but also some interesting status about the System

Quickly graph a list of numbers
Useful when you've produced a large file of numbers, and want to quickly see the distribution. The value of y halfway along the x axis is the median. Simple! Just create the listOfNumbers.txt file with a number on each line to try it out.

Pull git submodules in parallel using GNU parallel
Make sure to run this command in your git toplevel directory. Modify `-j4` as you like. You can also run any arbitrary command beside `git pull` in parallel on all of your git submodules.

Find the package that installed a command

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

count how many cat processes are running

concatenate avi files
concatenates avi files


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: