Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.


Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.
Hide

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:

Hide

News

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Lists all listening ports together with the PID of the associated process

Terminal - Lists all listening ports together with the PID of the associated process
netstat -tlnp
2009-02-15 14:20:25
User: fulat2k
Functions: netstat
179
Lists all listening ports together with the PID of the associated process

The PID will only be printed if you're holding a root equivalent ID.

Alternatives

There are 8 alternatives - vote for the best!

Terminal - Alternatives
lsof -Pan -i tcp -i udp
2010-06-07 15:22:44
User: atoponce
Tags: netstat lsof
26

This command is more portable than it's cousin netstat. It works well on all the BSDs, GNU/Linux, AIX and Mac OS X. You won't find lsof by default on Solaris or HPUX by default, but packages exist around the web for installation, if needed, and the command works as shown. This is the most portable command I can find that lists listening ports and their associated pid.

netstat -plnt
2011-09-30 19:56:32
User: DopeGhoti
Functions: netstat
6

While `lsof` will work, why not use the tool designed explicitly for this job?

(If not run as root, you will only see the names of PID you own)

netstat -nptl
2009-12-11 10:23:43
User: sputnick
Functions: netstat
2

Alternative of OJM snippet :

This one show the IP too, where ports bind. It's very important, because if there's only 127.0.0.1 instead of 0.0.0.0, connections from internet are rejected.

netstat -anpe
2011-12-06 18:27:09
User: anarcat
Functions: netstat
1

Lists all opened sockets (not only listeners), no DNS resolution (so it's fast), the process id and the user holding the socket.

Previous samples were limiting to TCP too, this also lists UDP listeners.

netstat -tunlp
2010-06-07 13:26:05
User: ender_x
Functions: netstat
Tags: netstat
-2

Shows you all listening tcp/udp ports, and what program has them open(depending on rights)

Know a better way?

If you can do better, submit your command here.

What others think

BSD equivalent:

sockstat -l4

(that's a small L)

Comment by lme 408 weeks and 3 days ago

for german users there is a simple way to remember a similar command:

netstat -tulpen

(tulpen = tulips in german)

Comment by Hollow 405 weeks and 6 days ago

I prefer:

netstat -paten

also easy to remember :-) and gives not only listening ports, but also running processes and their owning users

p.s. mnemonic of course is

netstat -patent

but 2nd t is simply redundant

Comment by vleolml 401 weeks ago

Following will also show UDP sockets:

netstat -tulnp
Comment by realist 386 weeks and 5 days ago

lsof -Pan -i tcp -i udp

Comment by solarislackware 371 weeks and 4 days ago

not for OS-X :(

Comment by ab 359 weeks and 6 days ago

In OS-X I am using a little script: http://gist.github.com/330338

Comment by nuxlli 357 weeks and 3 days ago

the switches in this command are gnu-specific. likely, the gnu netstat won't be running on any other operating systems than linux-based ones. a better utility that is more portable is lsof, as @solarislackware pointed out.

Comment by atoponce 345 weeks ago

Best to run:

# netstat -plntu

This way you see UDP conns too.

Comment by kernel01 179 weeks ago

2016-1-26 xiaozhengm

http://www.coachfactory--outletonline.com

http://www.fitflopuk.me.uk

http://www.michaelkorsukbag.co.uk

http://www.get-coachoutletonline.org

http://www.michaelkors-handbag.me.uk

http://www.runningshoes.com.co

http://www.toms-outlet.cc

http://www.ugg-boots-store.com

http://www.louboutinshoes.cc

http://canadagoose.outletmalls.us.com

http://www.nike-blazerlow.fr

http://uggs.uggaustralia.qc.com

http://www.nikestoreuk.me.uk

http://www.true-religionjeans.net.co

http://coach.outletmalls.us.com

http://www.adidasshoes.name

http://michaelkors.adsmall.us.com

http://www.hermesbelt.in.net

http://www.mulberry-bags.org.uk

http://coach.eshopping.us.com

http://louisvuitton.outletmalls.us.com

http://www.hermesuk.org.uk

http://www.katespadeoutletsale.in.net

http://toms.adsmall.us.com

http://www.fitflopssaleclearance.com

http://michaelkors.eshopping.us.com

http://ugg.adsmall.us.com

http://www.louis-vuitton-outlet.us.com

http://www.canadagoosejackets.org.uk

http://ugg.eshopping.us.com

http://www.timberlanduk.me.uk

http://www.jordan13.org

http://christianlouboutin.outletmalls.us.com

http://www.coachoutlet-storeonline.in.net

http://www.instylermax.in.net

http://www.coachfactoryoutletus.in.net

http://www.coachoutlet-storeonline.us.com

http://tiffany.outletmalls.us.com

http://www.louboutin.org.uk

http://www.monclerjacketsoutlet.us.com

http://louboutin.adsmall.us.com

http://www.louisvuitton-borse.it

http://www.mcmhandbags.name

http://www.truereligion-outlet.com

http://www.new-balanceoutlet.us

http://www.louisvuitton-sac-pascher.fr

http://www.outlet-toms.cc

http://canadagoose.shopgioia.com

http://www.coach-factory-outlet-online.us.com

http://www.top-coachoutletstore.org

http://www.edhardy-outlet.name

http://www.jordan6.net

http://www.longchamphandbags.com.co

http://www.chaussurelouboutin-pascher.fr

http://www.ghdstraighteners.me.uk

http://www.nike-tn-pascher.fr

http://www.saclongchamp-solde.fr

http://www.coachcanadaoutlet.ca

http://burberryoutlet.outletmalls.us.com

http://sunglasses.outletmalls.us.com

http://www.michael--korsoutlet.us.com

http://www.nikefreeruns.uk

http://michaelkors.outletmalls.us.com

http://www.mk-michaelkorsoutletonline.com

http://www.cheaplouisvuittonhandbags.org

http://burberry.eshopping.us.com

http://www.michaelkors-outletonlines.in.net

http://www.airjordan-pascher.fr

http://www.ralphlaurenuk.me.uk

http://www.moncler-jackets.org

http://www.adidassuperstar.co.uk

http://abercrombie.shopgioia.com

http://www.authenticlouisvuittonhandbags.net

http://www.airforce1-nike.fr

http://www.coach-factoryoutlet.cc

http://www.coachoutletonlinespick.org

http://www.coachouletbtf.com

http://rayban.eshopping.us.com

http://www.ghdhairstraighteners.com.co

http://www.ralph-lauren-pas-cher.fr

http://ralphlauren.shopgioia.com

http://rayban.adsmall.us.com

http://www.mcmoutlet.us

http://www.louisvuittonuk.me.uk

http://www.jordan-femmepascher.fr

http://www.toms.in.net

http://burberry.outletmalls.us.com

http://www.cheap-uggsonsale.in.net

http://oakley.adsmall.us.com

http://www.basketballshoes.net.co

http://ugg.shopgioia.com

http://www.raybansoutlet.in.net

http://www.mizunorunningshoes.in.net

http://www.pandoracharms.com.co

http://www.truereligion-outlet.in.net

http://www.michaelkorsoutletoff.in.net

http://www.tomswedges.in.net

http://ugg.outletmalls.us.com

http://www.cheapjordansshoes.in.net

http://www.mymichaelkorssoutlets.org

http://www.airjordan-uk.org.uk

http://www.michaelkors-handbags.me.uk

http://www.nikeblazers.me.uk

http://burberry.shopgioia.com

http://timberland.adsmall.us.com

http://coach.adsmall.us.com

http://www.nike-airmax90.me.uk

http://www.nikesb.uk

http://www.nikerosherunwomen.me.uk

http://www.christianlouboutinuk.me.uk

http://www.ugg-boots-australia.com

http://www.adidas-trainers.me.uk

http://www.michaelkors-discount.com

http://www.polooutlet.us.com

http://www.niketrainers.com.co

http://www.airmax95.org.uk

http://www.montblancpens.us.org

http://www.adidasuk.org.uk

http://www.poloralphlauren.net.co

http://www.rolex-replicawatches.com.co

http://www.ralph-lauren.me.uk

http://www.jordan3.net

http://www.cheapwholesaleuggboots.com

http://hollister.shopgioia.com

http://www.michaelkorshandbags.cc

http://www.fitflops.in.net

http://www.snapbacks-wholesale.us

http://www.edhardyukclothing.me.uk

http://www.michaelkors-outlet-handbags.com

http://www.fitflops.us

http://www.raybans.org.uk

http://northface.outletmalls.us.com

http://nike.outletmalls.us.com

http://www.michaelkorsoutletforus.com

http://www.toryburchoutlet-sale.in.net

http://www.juicy-couture.us

http://www.raybansunglassesdeals.com.co

http://www.louis-vuittonhandbags.us

http://www.quality-outlet.com

http://christianlouboutin.eshopping.us.com

http://www.cheap-tomsoutlet.us

http://www.longchampoutlet.net.co

http://www.michaelkors-bags.me.uk

http://www.louisvuittonoutlets.name

http://www.coach-factoryoutlet.eu.com

http://www.tomsshoes.us.com

http://www.canadagooseoutlet.cc

http://canadagoose.adsmall.us.com

http://www.adidasgazelle.me.uk

http://christianlouboutin.shopgioia.com

http://www.kate-spadeoutlet.com.co

http://www.pradaoutlet.name

http://www.guccioutlet.com.so

http://www.jordan4.net

http://canadagoose.eshopping.us.com

http://www.michael-korshandbags.net.co

http://www.soccer-jerseys.us.com

http://www.nikerosheruns.me.uk

http://www.truereligion-outlet.net.co

http://oakley.shopgioia.com

http://www.sunglass-outlet.us

http://www.chiflatiron.in.net

http://www.tomsoutletstore.in.net

http://www.coachoutletstoreonlines.us

http://www.gucci-borse.it

http://www.jordan8.net

http://www.michaelkors-mkoutlet.in.net

http://www.chaussure-louboutin.fr

http://www.michaelkors-outletsale.com

http://www.michael-korsuk.me.uk

http://www.nike-airmax.org.uk

http://burberry.adsmall.us.com

http://www.montblanc-pens.name

http://www.sac-longchamppliage.fr

http://www.saclongchamp--pascher.fr

http://www.michaelkorsoutletvip.in.net

http://www.cheapjordans.com.co

http://www.louisvuitton-outletstores.org

http://www.marc-jacobs.in.net

http://www.pandorajewelryoutlet.name

http://www.christianlouboutinsell.net

http://www.michael-kors-handbags.uk

http://rayban.shopgioia.com

http://www.oakleysunglassesfake.in.net

http://www.kate-spadeoutlet.us

http://www.coach-factoryoutlet.com.co

http://www.gucci-outlet.org

http://www.adidas-shoes.me.uk

http://ralphlauren.eshopping.us.com

http://oakley.eshopping.us.com

http://www.vipmichaelkors-outletonline.com

http://www.canadagooseuk.me.uk

http://www.oakley--sunglasses.us.org

http://www.kate-spadeoutlet.in.net

http://truereligion.adsmall.us.com

http://jordan.outletmalls.us.com

http://www.guccioutlet.net.co

http://www.nikeuk.me.uk

http://www.katespadeuk.me.uk

http://www.christianlouboutinoff.us

http://www.nikecortez.com.co

http://www.nikehuarache.com.co

Comment by xiaozhengm 50 weeks and 6 days ago

Throw away barf bags can be a favorable requirement if you are unwell as well as experience motion illness. Attiring them a dependable means to fix manage their own sickness in the handy way is very important. Premium quality barf bags help out with making certain absolutely no chaos is produced plus the bag could be discretely thrown away.Sickness generally triggers customers to throw up and this can be a sudden and uncontrolled reply through the system, that simply leaves them no time to discover the ideal spot to alleviate themselves. Throwing up is normally together with any bad smell that will contaminate the oxygen and bring about other individuals to help sense nauseous. You will need to make sure that the emesis will be nicely included, won't create a chaos and also dirty the actual environment. Barf bags are a good way to ensure the vomit can be properly covered inside the bag. Many people have problems with motion health problems when you are traveling, which then causes his or her stomachs in order to write and ache, from time to time causing the need to vomit. Be it a motor vehicle, motorboat, coach or maybe airplane barf bags are a great system for you to incorporate puke regardless of whether people most likely are not able to use the actual washroom.Schools, centers in addition to unexpected emergency bedrooms consist of and frequently employ emesis containment bags to help you sick and tired people fight their particular disease in a very set free method. Barf bags are constructed from high-density polyethylene that will means that the items usually do not leak out there as well as develop a wreck in any manner. These kind of barf bags are sufficiently strong to be able to include the emesis with virtually no splilling. Furthermore, these kinds of bags can be throw-away along with easy to allow them to end up being rapidly removed immediately after employ.The underside connected with bags have decided with a trademarked technological innovation which elephant seals these barf bags completely at one end along with assures there isn't any pockets or maybe available areas where emesis could easily get separated. Even though the underside in the bags tend to be sealed, the other end is left open in addition to meant to let website visitors to location their jaws into your bag and vomit.After utilize, http://www.hermesbeltsbirkinkellybag.co.uk/ the actual bag may either become sealed that has a tape or even could be garbled along with bound to include the emesis inside. Both styles associated with bags can be extremely effectively set up to avoid virtually any spillage and permit someone to seal your own emesis up until you discover a waste container and other suited place to discard it. These types of bags are simple to hold too making it user friendly these kind of bags while traveling. These kinds of bags are available in features regarding forty five or perhaps installments of a lot of and may easily be ordered on the internet.Barf Bags are also available along with areas to create the actual individual which is generally found in hospitals along with labradors once the emesis on the client ought to be reviewed. These kinds of bags come in features regarding 50 or perhaps cases of one thousand and will easily be purchased on the net at your convenience.

Comment by stephanieg915 7 hours ago

Are you sick and tired of holding big bags using large band? Want to switch the signal from one thing light-weight and also cost-effective? Declare hello there for the drawstring bookbag bags. Most of these bags tend to be comfortable, cozy and lightweight to be a feather and additional they have straps that are adjustable along with lean. The major advantage of utilizing drawstring bags is that you can retract them like a towel and also store these individuals quickly inside your cubical when not in use. Many are consequently smaller you could easily fit these in your pocketbook! Retail store nearly anything during these bags such as food items stuff, ebooks, pens, water bottles, yet others. You can even choose between various shades available such as dark-colored, green, discolored, blue, brown leafy, and so on.Drawstring http://www.hermesbeltsbirkinkellybag.co.uk/ bags are generally utilized by students because they're stylish, decorative and are available in wonderful models. These days, businesses manufacture used searching bags, gym bags, beach bags, food market bags as well as materials bags with the ease of buyers. These bags are environment friendly and less costly when compared to the approaches created from plastic-type material. Many of the retailers today manufacture purchasing bags along with trademarks to enhance their own organization in addition to entice customers. Even so, this bags are usually gentle, organic are available in several shapes and sizes to fit the needs of clients. The ways to access the main advantage of modifying the item with adornments, flowered images, as well as other eye-catching types. The reason organizations choose these bags is it makes a longer lasting perception on the customers. Simultaneously, the idea bath areas organizations the benefit of affordable ad. Small companies particularly are not able to commit a great deal with marketing their products. Through the help of logo design published bags, they will easily attract buyers without spending a fortune on advertising. Shopping bags are usually cost-effective plus they feature more wallets, facet bags, as well as individual spaces for possessing pencils, mobile phone devices, etc. The foremost good reason that people love such Eco-friendly purchasing bags is they are constructed of organic supplies that don't cause harm to the environment or the person. As an illustration, a number of the materials utilized for bag make have harmful substances which could result in skin color problems including skin rashes, itching, and so forth.With all of these positive aspects and more promo bags while hand out is one best option if you want to draw in many customers. Via using this method, it is possible to market your goods in addition to entice a lot of men and women. The real thing ., as a result of trade show bags below wholesale, you can purchase several bags you desire from very economical prices. Regardless of you want to take, you could depend on these bags as they are very mobile about and trendy to check out!

Comment by stephanieg915 6 hours ago

Your point of view

You must be signed in to comment.