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 88

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

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

  • 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 3
  • 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 3
  • 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 3
  •  < 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

Transfer SSH public key to another machine in one step
This command sequence allows simple setup of (gasp!) password-less SSH logins. Be careful, as if you already have an SSH keypair in your ~/.ssh directory on the local machine, there is a possibility ssh-keygen may overwrite them. ssh-copy-id copies the public key to the remote host and appends it to the remote account's ~/.ssh/authorized_keys file. When trying ssh, if you used no passphrase for your key, the remote shell appears soon after invoking ssh user@host.

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

Read aloud a text file in Mac OS X

Count number of files in a directory
Just want to post a Perl alternative. Does not count hidden files ('.' ones).

Download all PDFs from an authenificated website
Replace *** with the appropiate values

Multi-thread any command
For instance: $ find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8 will encode all .wav files into FLAC in parallel. Explanation of xargs flags: -P [max-procs]: Max number of invocations to run at once. Set to 0 to run all at once [potentially dangerous re: excessive RAM usage]. -n [max-args]: Max number of arguments from the list to send to each invocation. -0: Stdin is a null-terminated list. I use xargs to build parallel-processing frameworks into my scripts like the one here: http://pastebin.com/1GvcifYa

disable caps lock
a quick one-line way to disable caps lock while running X.

Get a qrcode for a given string

Setting reserved blocks percentage to 1%
According to tune2fs manual, reserved blocks are designed to keep your system from failing when you run out of space. Its reserves space for privileged processes such as daemons (like syslogd, for ex.) and other root level processes; also the reserved space can prevent the filesystem from fragmenting as it fills up. By default this is 5% regardless of the size of the partition. http://www.ducea.com/2008/03/04/ext3-reserved-blocks-percentage/

Show apps that use internet connection at the moment.
show only the name of the apps that are using internet


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: