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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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:



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!

Top Tags



Commands by knoppix5 from sorted by
Terminal - Commands by knoppix5 - 43 results
tree -ifs --noreport .|sort -n -k2
2012-05-04 09:18:39
User: knoppix5
Functions: sort


tree -ifsF --noreport .|sort -n -k2|grep -v '/$'

(rows presenting directory names become hidden)

for a in $(find . -xdev -type f -printf '%i\n'|sort|uniq -d);do find . -xdev -inum $a -printf '%s %i %m %n %U %G %AD %Ar %p\n';done|sort -n|awk '{if(x!=$2){print "---"};x=$2;print $0}'
2012-04-09 12:52:07
User: knoppix5
Functions: awk find sort uniq

The listing will be nice separated with dashes in chunks of identical files.

Output format:

Size Inode Mode Count_of_identical_files UID GID Date Time Path/Filename

hardlink -vpot .
2012-04-09 12:40:38
User: knoppix5

Meaning of switches (see man page too):

v verbose

p ignore mode (permissions)

o ignore owner, group

t ignore time of modification

Disadvantage: If you modify any linked file, this will propagate to all other files which occupy the same space.

for a in $(cat sample.txt); do echo "$(wc -m<<<$a) $a";done|sort -n
2012-03-15 08:51:42
User: knoppix5
Functions: cat echo sort

optionally you can add

|cut -d' ' -f2|uniq

to the end of the command line.

strings -f sample.txt
while read l; do echo -e "$l"; done <1.txt >2.txt
2012-03-13 14:27:49
User: knoppix5
Functions: echo read
Tags: bash read

Bash only, no sed, no awk. Multiple spaces/tabs if exists INSIDE the line will be preserved. Empty lines stay intact, except they will be cleaned from spaces and tabs if any available.

GET www.example.com
GET checkip.dyndns.org
2012-03-07 07:55:42
User: knoppix5

Clean output, if used in scripts:

GET checkip.dyndns.org|grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'


GET icanhazip.com
fuser -km /media/sdb1
2012-02-27 13:41:05
User: knoppix5
Functions: fuser
Tags: kill umount

Alternative if "Lazy unmount" (umount -l) doesn't obey.

Alternative for NFS:

umount -f /media/sdb1

Use with caution: forcing to unmount a busy partition can cause data loss!

grep $'\t' sample.txt
diff --suppress-common-lines -y <(cd path_to_dir1; find .|sort) <(cd path_to_dir2; find .|sort)
2012-02-13 12:49:33
User: knoppix5
Functions: cd diff find

Output of this command is the difference of recursive file lists in two directories (very quick!).

To view differences in content of files too, use the command submitted by mariusbutuc (very slow!):

diff -rq path_to_dir1 path_to_dir2
10,30,50 * * * * ping -q -c1 -w3 | grep '1 received' - || mail -ne -s'Host not reachable' [email protected]
2012-02-06 10:42:46
User: knoppix5
Functions: grep mail ping

Every 20 minutes test if host with IP is 'dead' or not reachable.

The line should be put in your crontab file.

10,30,50 * * * * ping -q -c1 -w3 | grep '1 received' - || env DISPLAY=:0 xeyes
2012-02-06 09:40:11
User: knoppix5
Functions: env grep ping
Tags: ping host crontab

Every 20 minutes ping host with IP address If it's not 'alive' or not reachable, then display something eye-catching (here xeyes) on the desktop.

Hint for newbies: edit crontab with

crontab -e
diff -y <(ssh [email protected] find /boot|sort) <(find /boot|sort)
2012-01-31 15:04:30
User: knoppix5
Functions: diff find ssh

You can compare directories on two different remote hosts as well:

diff -y <(ssh [email protected] find /boot|sort) <(ssh [email protected] find /boot|sort)

To avoid password-prompt on remote host just generate the rsa key locally and copy it to remote host:

ssh-keygen -t rsa


ssh [email protected] "mkdir .ssh"


scp .ssh/id_rsa.pub [email protected]:; .ssh/authorized_keys2
dpkg-repack firefox
2012-01-13 11:47:40
User: knoppix5

If any changes have been made to the package while it was unpacked (ie, conffiles files in /etc modi‐fied), the new package will inherit the changes.

This way you can make it easy to copy packages from one computer to another, or to recreate packages that are installed on your system, but no longer available elsewhere.

Note: dpkg-repack will place the created package in the current directory.

sed -i "s/\(\x09\{1,\}\)\|\( \{1,\}\)/ /g;s/\(\x09\{1,\}$\)\|\( \{1,\}$\)//g" brisati.txt
2011-12-12 10:24:03
User: knoppix5
Functions: sed

This command does the following:

- converts any sequence of multiple spaces/tabs to one space only

- completely removes any space(s)/tab(s) at the end of each line

(If spaces and tabs are mixed in a sequence i.e. [tab][tab][space][tab], you have to execute this command twice!)

c="cp -a";e="~";echo -e "\npaste\n";i=0;k="1"; while [[ "$k" != "" ]]; do read -a k;r[i]=$k;((i++));done;i=0;while :;do t=${r[i]};[ "$t" == "" ] && break; g=$(echo $c ${r[i]} $e);echo -e $g "\ny/n?";read y;[ "$y" != "n" ] && eval $g;((i++));done
2011-12-04 12:45:44
User: knoppix5
Functions: echo eval read


command [options] [paste your variable here] parameter

command [options] [paste entire column of variables here] parameter


(hard-code command "c" and parameter "e" according to your wishes: in example shown command = "cp -a" and parameter = "~")


- Quick exchange only variable part of a long command line

- Make variable part to be an entire column of data (i.e. file list)

- Full control while processing every single item


Paste column of data from anywhere. I.e. utilize the Block Select Mode to drag, select and copy columns (In KDE Konsole with Ctrl+Alt pressed, or only Ctrl pressed in GNOME Terminal respectively).


You can paste only one single variable in a row. If there are more space separated variables in a row only first one will be processed, but you can arrange your variables in a column instead. To transpose rows to columns or vice versa look at Linux manual pages for 'cut' and 'paste'.


- add edit mode to vary command "c" and parameter "e" on the fly

- add one edit mode more to handle every list item different

- add y/n/a (=All) instead of only y(=default)/n to allowed answers


The code is not optimized, only the basic idea is presented here. It's up to you to shorten code or extend the functionality.

alias cdd="history -a && grep '^ *[0-9]* *cd ' ~/.bash_history| tail -10 >>~/.bash_history && history -r ~/.bash_history"
2011-07-13 09:44:16
User: knoppix5
Functions: alias

This alias is meant to append n (here is n=10) most recently used cd commands to the bottom of history file. This way you can easily change to one of previous visited directories simply by hitting 1-10 times arrow up key.

Hint: You can make more aliases implying the same rule for any set of frequently used long and complex commands like: mkisof, rdesktop, gpg...