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 by servermanaged from sorted by
Terminal - Commands by servermanaged - 56 results
ps -o comm,%mem,args -u www-data
mkdir dir; cd $_
2010-01-13 11:56:36
Functions: cd mkdir
1
_ expands to the last argument of the last command that was executed
watch vmstat -sSM
2009-12-04 22:35:45
Functions: vmstat watch
4

Monitor with watch command and vmstat, memory usage

ftp>!w
2009-11-26 21:41:28
Functions: ftp
1

By putting ! in front of a command, we are able to run it from an ftp session.

cat > list -
2009-10-29 20:20:11
Functions: cat
3

Quick write some notes to a file with cat. Ctrl+C when you have finish.

nethogs -p eth0
2009-10-24 19:43:31
23

Nethogs is a useful tool for monitor bandwidth consumption by pid. Tested on Debian an CentOs

for i in $(netstat --inet -n|grep ESTA|awk '{print $5}'|cut -d: -f1);do geoiplookup $i;done
2009-10-18 20:41:47
Functions: awk cut grep netstat
3

Sample command to obtain a list of geographic localization for established connections, extracted from netstat. Need geoiplookup command ( part of geoip package under CentOS)

ls -alh #mycomment
2009-10-06 13:55:06
Functions: ls
5

Comments can be used directly on the command line so I can save in the history a brief description of what command does.

awk '{print(substr($0,1,5))}' file
2009-10-05 18:58:49
Functions: awk
-2

Consider this file :

laminate

this

file

with awk

hello to

commandlinefu

I can use awk substring to laminate words :

lamin

this

file

with

hello

comma

Similar to http://www.commandlinefu.com/commands/view/2000/laminate-files-line-by-line

hardinfo -am benchmark.so -f html > report.html
2009-10-05 17:41:25
1

Nicely display in html format a detailed report of the machine, including cpu benchmarks.

egrep 'Failed password for invalid' /var/log/secure | awk '{print $13}' | uniq
2009-10-04 18:08:13
Functions: awk egrep
1

Work for me on CentOS, grep and print ip addresses of ssh bruteforce attempts

ps ax -o "%p %U %u %x %c %n"
2009-07-14 17:21:59
Functions: ps
4

ps command gives the possibility to display information with custom formatting with the -o options followed by the format specifier list.

ruby -e " 3.times { system 'pdflatex mydoc.tex' } "
2009-07-05 09:55:59
0

When I make a latex document, I need to compile three times for generate an updated index of contents. With ruby on command line, I run this operation with a fast one liner.

cat /var/log/auth.log | logtool -o HTML > auth.html
2009-07-03 18:17:22
Functions: cat
3

Logtool is a nice tool that can export log file to various format, but its strength lies in the capacity of colorize logs. This command take a log as input and colorize it, then export it to an html file for a more confortable view. Logtool is part of logtool package.Tested on Debian.

vim -c new myfile
2009-07-03 17:54:43
Functions: vim
1

: new command allow to split a Vim screen in two separate windows. Each window can handle its own buffer.

Passing the -c new options when Vim start cause to split screen automatically.

nload -u m eth0
2009-07-03 17:47:38
6

Nload is part of nload package, tested under Debian. Nload display network bandwidth statistics, -u m options stands for MBit unit measure.

clamscan -ir --bell ~user/
2009-05-21 13:09:31
-2

Scan for viruses, recursively and print only infected files, with bell sound. Clamscan is part of clamav package. Tested on Debian.

notifyme -C `cat /etc/passwd | cut -d: -f1`
2009-05-19 19:17:05
Functions: cut
4

Notifyme is a program that listen in background for users login, and report on login and logout. Users can be specified from a list or in a ~/notify.rc file. -C options force to display messages on the center of the screen.See man notifyme for more details. Part of notifyme package, tested on Debian.

tiger
2009-05-19 19:07:11
-2

From man tiger : Tiger is a package consisting of Bourne Shell scripts, C code and data files which is used for checking for security problems on a UNIX system. It scans system configuration files, file systems, and user configuration files for possible security problems and reports them.

mytop --prompt
2009-05-19 19:04:57
0

mytop is a top like monitor for displaying Mysql server statistic and performance. Part of mytop package ,tested on Debian.

kudzu -p
2009-05-12 10:34:59
Functions: kudzu
-3

Kudzu is available on CentOS, used for configuring and detecting new hardware device installed, is also usefull for device listing.

perl -lane 'print "$F[0]:$F[1]:$F[2]"' myfile
2009-05-09 21:30:55
Functions: perl
0

Consider this line :

random perl language this make possible is

is possible to rearrange words with $F perl variable and word index, starting from 0.

wmwave
2009-05-09 20:33:27
-4

wmwave is part of wmwave package, when launched display a small wireless link monitor on your desktop with noise, level and link power.

setfont cybercafe
2009-05-09 20:08:47
1

setfont load vga console font. The default font directory is usually in /lib/kbd/consolefonts. Setfont is part of kbd package. Tested on CentOS.

ethstatus -i eth0
2009-05-09 19:33:39
6

ethstatus part of ethstatus package, is a consolle based monitor for network interfaces. Nicely display on screen a real time summary about bandwidth, speed and packets.