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!

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

Hide

### Stay in the loop…

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.

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

Hide

Hide

### Credits

Site by David Winterbottom (user root).

# All commands

All commands from sorted by
Terminal - All commands - 10,550 results
rpm -e --allmatches filename.rpm
2009-02-12 23:09:24
Functions: rpm
1

If somehow if you get more than 1 same name rpm package install, then it cannot be removed by using simple rpm -e as it gives you more than one rpm matches error. The --matches will help to remove all the same name rpm packages.

/etc/security/bsmconv
2009-02-12 22:53:02
0

Once Enabled this command enables a trail of all processes on the system. As the name suggested auditing for Solaris machines.

BSM creates a number of files in the /etc/security directory.

tar -zcps <dir> -X <(find <dir> -type f -mtime -<days>) |ssh user@backuphost tar -xzpsC /data/bkup
2009-02-12 22:31:58
Functions: find tar
-3

due to bug can not comment

find /tmp -type f -printf 'rm "%p";\n'
2009-02-12 20:23:24
Functions: find
4

add |sh when you agree the list, I often use that method to prevent typos in dangerous or long operations

find ./backup -type f -print0 | xargs -0 md5sum > /checksums_backup.md5
tail -f /var/log/messages
2009-02-12 19:30:33
Functions: tail
-3

Use this command to see logs update in real time

telnet <ip> <port>
2009-02-12 19:11:03
Functions: telnet
-3

Telnet will make a tcp connection to a remote ip/port to test connectivity. If it times out, it's not reaching the host (maybe the firewall is blocking it). If connection is refused, it's reaching the host, but either the service is not listening on that port, or it's locked.

find * -type d -exec mkdir /where/you/wantem/\{\} \;
2009-02-12 14:42:55
Functions: find mkdir
18
find . -name "*.php" -exec iconv -f ISO-8859-1 -t UTF-8 {} -o ../newdir_utf8/{} \;
2009-02-12 13:07:54
Functions: find iconv
16
lsof -u www-data
2009-02-12 10:17:46
3
2009-02-12 10:08:23
Functions: usermod
4
find <dir> -type f -mtime +<days> -exec scp -r {} user@backuphost:/data/bkup \;
2009-02-12 07:43:29
Functions: find scp
-1

U have to make key exchange in order to avoid continuous password prompt.

ps gv [pid] | head -2
2009-02-12 05:04:55
-1

sh as:

#! /bin/sh

while [ 1 -ne 6 ]; do

pid=ps -ef | grep -v "grep" | grep "trans_gzdy" | cut -c10-17

ps gv $pid | head -2 sleep 1 done check changes of RSS. alias mute="dcop kmix Mixer0 toggleMasterMute ; dcop kmix Mixer0 masterMute | sed -e 's/true/muted/' -e 's/false/unmuted/' " 2009-02-12 04:56:33 Functions: alias 1 arguably better than using the driver interface. lots of potentially cool stuff to be done w/ the dcop client. >realpath ./somefile.c | xclip -selection c 2009-02-11 21:39:22 1 Handy for those times you need to paste a file path in an IDE or some other app. sudo apt-get install xclip Then, for convenience, alias xclip to 'xclip -selection c' so you can just do something like realpath . | xclip if [ ! -z "${DISPLAY}" ]; then someXcmd ; fi
2009-02-11 21:03:56
3

If you want to display a dialog (using xdialog/kdialog/zenity) you

need to make sure that you have a valid X session. Checks for

the existence of the DISPLAY variable.

nmap -sP 192.168.1.100-254
2009-02-11 20:44:43
15

nmap accepts a wide variety of addressing notation, multiple targets/ranges, etc.

\[command]
2009-02-11 19:34:21
66

e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash:

rm [file] # WILL prompt for confirmation per the alias

\rm [file] # will NOT prompt for confirmation per the default behavior of the command

rm -- --myfile
2009-02-11 19:24:22
Functions: rm
7
nmap -sT -p 80 -oG - 192.168.1.* | grep open
2009-02-11 17:47:27
Functions: grep
18

Change the -p argument for the port number. See "man nmap" for different ways to specify address ranges.

cat .ssh/id_rsa.pub | ssh hostname 'cat >> .ssh/authorized_keys'
2009-02-11 17:40:12
Functions: cat hostname ssh
13

This assumes that the server supports publickey authentication. Also, the permissions on your home dir are 755, and the permissions on your .ssh dir are 700 (local and remote).

alias dir="ls -al"
2009-02-11 16:51:01
Functions: alias
0

If you come from a DOS background and accidentally use DOS commands often, this and others like it can be helpful. Add to your .bash_profile, or wherever you keep such things.

svn st | grep /main/java | awk '{print $2}' | xargs echo | xargs svn ci -m "my comment here" 2009-02-11 16:31:05 Functions: awk echo grep xargs -2 alt + . 2009-02-11 15:26:34 7 Insert the last argument to the previous command for ip in$(seq 1 25); do ping -c 1 192.168.0.$ip>/dev/null; [$? -eq 0 ] && echo "192.168.0.\$ip UP" || : ; done
2009-02-11 14:57:34
Functions: echo ping seq
-1

this is very useful when there is a different network host to determine which are turned on or not
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.2584806978702545, "perplexity": 21851.449543559236}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2013-20/segments/1368696383263/warc/CC-MAIN-20130516092623-00061-ip-10-60-113-184.ec2.internal.warc.gz"}