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

All commands from sorted by
Terminal - All commands - 11,860 results
grep '^[^#]' squid.conf
2013-02-21 18:51:06
User: Flow
Functions: grep
Tags: regex grep,
-5

grep '^[^#]' sample.conf

\__/ |||| \_________/

| |||| |

| |||| \- Filename

| ||||

| |||\- Only character in group is '#'

| |||

| ||\- Negate character group (will match any cahracter *not* in the

| || group)

| ||

| |\- Start new character group (will match any character in the

| | group)

| |

| \- Match beginning of line

|

\- Run grep

Empty lines will also be not matched, because there has to be at least one non-hash-sign character in the line.

ls -R .
rm ~/.bash_history; ln -s /dev/null ~/.bash_history
2009-10-08 17:40:48
Functions: ln rm
-5

Remove your BASH history and then link it to /dev/null

getenforce
2009-10-08 23:06:00
User: felix001
-5

Shows the status of SElinux.

-- fir3net.com --

sudo update-grub
2014-02-27 19:50:25
User: Anshik
Functions: sudo
-5

sudo gedit /etc/default/grub

This would open the Grub configuration file. In this file we have to edit the line

GRUB_CMDLINE_LINUX=""

to

GRUB_CMDLINE_LINUX="acpi_backlight=vendor"

ga
tail -n +<N> <file> | head -n 1
2011-09-30 08:30:30
User: qweqq
Functions: head tail
-5

Tail is much faster than sed, awk because it doesn't check for regular expressions.

figlet gunslinger_
ps -ef | grep pmon
find . -type d -exec chmod 0755 {} \;
2009-02-18 14:38:22
User: osantana
Functions: chmod find
-5

WARNING! This command may set an invalid permission under your current directory.

This command will set the 0755 permissions to all directories under your current directory. An alternative version of this command is: find ~/.ssh -type d -exec chmod 0700 {} \;

ls -laR > /path/to/filelist
2009-08-12 17:53:40
User: shaiss
Functions: ls
-5

Ever need to output an entire directory and subdirectory contents to a file? This is a simple one liner but it does the trick every time. Omit -la and use only -R for just the names

while (( 1==1 )); do du -c . >> output.log; sleep 2; done; tail -f output.log
2010-07-12 17:23:45
User: aceiro
Functions: du sleep tail
-5

this command shows the space used in postgres directory.

find . | grep ".*\[[Church|CPYAF].*" | while read f; do mv "$f" ../emails;done
. ~/.profile
2009-04-22 16:56:12
User: ruchi
-5

If you edit your .profile you need to refresh it for changes to take place. Simple way to refresh is logout and login. This command is the quickest way to do it.

If you're deleting some variables, they would not get nulled with this command but just removed.

mvn archetype:create -DgroupId=my.work -DartifactId=MyProject
2009-05-20 12:53:23
User: sharfah
Tags: maven
-5

This will create a new directory called MyProject with a pom.xml and the following tree structure:

MyProject

|-->pom.xml

|-->src

| |-->main

| | |-->java

| | | |-->my

| | | | |-->work

| | | | | |-->App.java

| |-->test

| | |-->java

| | | |-->my

| | | | |-->work

| | | | | |-->AppTest.java

perl -pe 's/,/\t/g' < report.csv > report.tsv
function rot13 { if [ -r $1 ]; then cat $1 | tr '[N-ZA-Mn-za-m5-90-4]' '[A-Za-z0-9]'; else echo $* | tr '[N-ZA-Mn-za-m5-90-4]' '[A-Za-z0-9]'; fi }
2011-03-18 09:59:41
User: twjolson
Functions: cat echo tr
Tags: Linux unix tr
-5

Will rot 13 whatever parameter follows 'rot13', whether it is a string or a file. Additionally, it will rot 5 each digit in a number

mkdir replaced;for i in *; do cat "$i"| sed 's/foo/bar/' > "replaced/$i"; done
2011-08-30 08:28:26
User: rubo77
Functions: cat mkdir sed
-5

if you want to replace "foo" with "bar" in all files in a folder, and put the resulting files into a new subfolder

find . -type f | xargs grep -l "string"
2011-08-30 13:22:42
User: Neo23x0
Functions: find grep xargs
-5

Finds a string in files recursively below the current directory on systems without the "egrep" and its "-r" functionality.

cat file.txt | grep -v /$ > newfile.txt
killall conky
wget -qO- whatismyip.org
echo "A great password" | md5sum
2009-04-24 14:32:56
User: ubersoldat
Functions: echo
-5

You can also use sha1sum and variants for longer passwords

''=~('(?{'.('_/@.*@'^'/])@^`').'"'.('"/_/@]/--!.:@</:[@(:/:^'^'[@*]`>@@@@@^`[@_(`@_]_|').',$/})')
taskkill /F /FI "USERNAME eq Cicciopalla"
2012-02-05 12:00:52
User: 0disse0
-5

The taskkill command has the option of the curve, for a complete list just type: taskkill /? As we know, but to give a practical example, suppose you want to act only on the user's processes Cicciopalla use this command