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.

Universal configuration monitoring and system of record for IT.

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





Maintained by Jon H.

Site originally by David Winterbottom (user root).

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using tar from sorted by
Terminal - Commands using tar - 208 results
tar -cf - folder/ | gpg -c > folder.tpg
2009-05-08 19:20:08
User: copremesis
Functions: gpg tar

gpg's compression is as suitable as gzip's however your backups can now be encrypted.

to extract use:

gpg < folder.tpg | tar -xf -
tar cvzf - data1 data2 | uuencode data.tar.gz | mail -s 'data' you@host.fr
2009-05-01 23:13:08
User: log0
Functions: mail tar uuencode

An easy one but nice to keep in mind.

cd /mnt/old && tar cvf - . | ( cd /mnt/new && tar xvf - )
tar -czvvf backup$(date "+%Y%m%d_%H%M%S").tar.gz /path/to/dir
2009-04-10 21:37:17
Functions: date tar

creates a tar.gz with a name like:


of a given directory.

this file was made 10 April 2009 at 5:30:53pm

see date's man page to customize the timestamp format

tar --exclude='.svn' -c -f /path/to/file.tar /path/to/directory
ssh user@host "(cd /path/to/remote/top/dir ; tar cvf - ./*)" | tar xvf -
2009-03-31 13:08:45
User: dopeman
Functions: ssh tar
Tags: copy files

This command will copy files and directories from a remote machine to the local one.

Ensure you are in the local directory you want to populate with the remote files before running the command.

To copy a directory and it's contents, you could:

ssh user@host "(cd /path/to/a/directory ; tar cvf - ./targetdir)" | tar xvf -

This is especially useful on *nix'es that don't have 'scp' installed by default.

on the listening side: sudo nc -lp 2022 | sudo tar -xvf - and on the sending side: tar -cvzf - ./*| nc -w 3 name_of_listening_host 2022
2009-03-27 09:59:33
User: smcpherson
Functions: sudo tar
Tags: netcat

This is useful for sending data between 2 computers that you have shell access to. Uses tar compression during transfer. Files are compressed & uncompressed automatically. Note the trailing dash on the listening side that makes netcat listen to stdin for data.

on the listening side:

sudo nc -lp 2022 | sudo tar -xvf -

explanation: open netcat to -l listen on -p port 2022, take the data stream and pipe to tar -x extract, -v verbose, -f using file filename - means "stdin"

on the sending side:

tar -cvzf - ./*| nc -w 3 name_of_listening_host 2022

explanation: compress all files in current dir using tar -c create, -v verbose, -f using file, - filename - here means "stdout" because we're tar -c instead of tar -x, -w3 wait 3 seconds on stream termination and then end the connection to the listening host name_of_listening_host, on port 2022

tar -czf - * | ssh example.com "cat > files.tar.gz"
2009-03-24 17:02:02
User: migurski
Functions: ssh tar

I recently found myself with a filesystem I couldn't write to and a bunch of files I had to get the hell out of dodge, preferably not one at a time. This command makes it possible to pack a bunch of files into a single archive and write it to a remote server.

curl http://domain.com/file.tar.gz | tar zx
find -maxdepth 1 -type d -print0 | xargs -0 -I {} tar -cvzf {}.tar.gz {}
2009-03-17 11:12:53
User: piemme
Functions: find tar xargs

Create backup (.tar.gz) for all first-level directory from current dir.

find ~/project -mtime -1 -type f -print | tar jcvf myfiles.tar.bz2 -T -
2009-03-13 13:03:11
User: voyeg3r
Functions: find tar

create tar.bz2 package from files "-type f" modificated today "-mtime -1" in ~/project

tar cf - . | (cd /new/dir; tar xvf -)
2009-03-09 20:30:34
User: jauderho
Functions: cd tar

Add z to the flags to enable compression.

alias wordpress='mkdir wordpress && cd wordpress && wget http://wordpress.org/latest.tar.gz && tar -xvzf latest.tar.gz && mv wordpress/* . && rm -rf latest.tar.gz wordpress && cp wp-config-sample.php wp-config.php'
tar cpfP - $(find <somedir> -type f -name *.png) | ssh user@host | tar xpfP -
2009-02-26 00:01:30
User: raphink
Functions: find ssh tar


* Adjust the find command to your own filters.

* The -P flag forces to keep absolute paths in the tarball, so that you can be sure that the exact same file hierarchy will be created on the second machine.

tar ztf tar-lacking-subdirectory.tar.gz | xargs rm
2009-02-19 00:34:09
User: mulad
Functions: tar xargs

These days, most software distributed in tar files will just contain a directory at the top level, but some tar files don't have this and can leave you with a mess of files in the current folder if you blindly execute

tar zxvf something.tar.gz

This command can help you clean up after such a mistake. However, note that this has the potential to do bad things if someone has been *really* nasty with filenames.

tar -jcvf /folder/file.tar.bz2 --same-owner --same-permissions /folder/
tar zcpf backup.tgz --exclude=/proc --exclude=backup.tgz /
2009-02-18 19:31:27
User: starchox
Functions: tar

You can exclude more system folders or individual files which are not necessary for the backup and can be recreated after the restore procedure, like /lost+found, /mnt, /media, /tmp, /usr ...

Restoring the above backup procedure is as simple as becoming root and typing:

tar zxpf backup.tgz -C /

You can extract any file or directory out of the backup.tgz file for recovery, for instance, if you have a corrupt or mis-configured fstab file, you could simply issue the command:

tar zxpf backup.tgz /ect/fstab -C /

Other options:

v add verbose option to see files processed

A far safer solution is to restore the desired files under a different directory, and then compare, move, or update the files to their original locations afterward.

tar zcf - user | pv /bin/gzip > /tmp/backup.tar.gz
2009-02-18 14:50:45
User: nlinux
Functions: tar

This command tar?s up a directory and sends the output to gzip, showing a rate of 223MB/s.

This may require you installing the pv command.

For debian based users out there:

sudo aptitude install pv
curl http://example.com/foo.tar.gz | tar zxvf -
for i in *.tar.gz *.tgz; do tar -zxvf $i; done
2009-02-18 10:58:12
User: bohemicus
Functions: tar

This is a little bash script that will take all files following the *gz pattern in the directory and apply the tar -zxvf command to them.

tar cvzf - /directory/ | ssh root@host "cat > /dev/nst0"
2009-02-18 07:12:54
User: Tuxmania
Functions: ssh tar

I use this all the time for taking manual backups of stuff i want to keep but not important enough to backup regularly.

find ~/bin/ -name "*sh" -print0 | xargs -0t tar -zcvf foofile.tar.gz
2009-02-17 08:48:34
User: lhb
Functions: find tar xargs

tar options may change ;)

c to compress into a tar file, z for gzip (j for bzip) man tar

-print0 and -0t are usefull for names with spaces, \, etc.

cd /source/directory; tar cf - . | tar xf - -C /destination/directory
(cd /orignl/path tar -cf - . ) | (cd /dst/dir;tar -xvf -)
2009-02-16 09:36:34
Functions: cd tar

uses tar to dump files from /orignl/path to /dst/dir. i find tar's out more readable than cp, and it doesn't mess with modified dates.

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

due to bug can not comment