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.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

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

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged httpd from sorted by
Terminal - Commands tagged httpd - 15 results
watch "netstat -plan | grep -v LISTEN | grep \":80 \" | awk {'print \$5'} | cut -d: -f 1 | uniq -c | sort -nk 1"
2013-09-05 13:50:00
User: simonsimcity
Functions: watch
0

Doesn't list connections to other ports than port 80. Not f.e. 8080 or 8091.

Excludes programs listening for connections, like your favorite webserver.

openssl rsa -in /path/to/originalkeywithpass.key -out /path/to/newkeywithnopass.key
2012-09-16 19:31:38
User: drerik
2

Strip a password from a openssl key to use with apache httpd server

apache2 -l
httpd -M
2012-05-27 12:04:17
User: rockon
1

Easiest way to check which modules are loaded in apache.

while [ 1 ]; do tail /var/log/httpd/error_log; sleep 2; clear; done
awk -F\" '/^DocumentRoot/{print $2}' $(httpd -V | awk -F\" '/\.conf/{print $2}')
httpd -V | grep -i SERVER_CONFIG_FILE | cut -f2 -d'"' | xargs grep -i '^DocumentRoot' | cut -f2 -d'"'
2011-08-13 20:45:05
User: dcpesses
Functions: cut grep
1

Grabs the Apache config file (yielded from httpd) and returns the path specified as DocumentRoot.

pgrep -c 'httpd|apache2'
2011-02-24 18:03:00
Tags: httpd
-1

this version is going to work on redhat/centos/suse AND ubuntu/debian systems

pidof httpd | wc -w
2011-02-24 16:46:46
User: eneko
Functions: pidof wc
Tags: httpd
-1

Returns the number of running httpd processes

awk '$1~/^DocumentRoot/{print $2}' /etc/apache2/sites-available/default
grep -i '^DocumentRoot' /etc/httpd/conf/httpd.conf | cut -f2 -d'"'
watch "netstat -plan|grep :80|awk {'print \$5'} | cut -d: -f 1 | sort | uniq -c | sort -nk 1"
2010-03-15 09:27:43
User: ik_5
Functions: watch
18

It's not my code, but I found it useful to know how many open connections per request I have on a machine to debug connections without opening another http connection for it.

You can also decide to sort things out differently then the way it appears in here.

awk '/q=/{print $11}' /var/log/httpd/access_log.4 | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1
cat /var/log/httpd/access_log | grep q= | awk '{print $11}' | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1 | mail youremail@isp.com -s "[your-site] search strings for `date`"
2009-11-22 03:03:06
User: isma
Functions: awk cat grep sed strings
-2

It's not a big line, and it *may not* work for everybody, I guess it depends on the detail of access_log configuration in your httpd.conf. I use it as a prerotate command for logrotate in httpd section so it executes before access_log rotation, everyday at midnight.

apache2 -t -D DUMP_MODULES
2009-02-16 17:30:20
User: ElAlecs
Tags: apache httpd
5

This let you know which modules has loaded the Apache server, very useful to know if the mod_rewrite is ready to use.