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.

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





Commands using tar from sorted by
Terminal - Commands using tar - 206 results
tar cvzf - /folder/ | ssh root@ "dd of=/dest/folder/file.tar.gz"
2012-07-13 17:54:51
User: kruspemsv
Functions: ssh tar

You can ran this also with cat for example:

tar zcvf - /folder/ | ssh root@ "cat > /dest/folder/file.tar.gz"

Or even run other command's:

tcpdump | ssh root@ "cat > /tmp/tcpdump.log"
tar zcpvf backup.tgz $(find $HOME -maxdepth 1 -name '.*' -and -not -name '.')
2012-05-01 17:48:24
User: DavidAlfonso
Functions: find tar
Tags: backup

This will make a backup of all hidden files and folders in the home folder.

GZIP="--rsyncable" tar -czf something.tgz /something
tar zcvf /path/to/your-`date +%Y-%m-%d`.tar.bz2 ./your/directory --exclude ./you/dont/want/to/include
ssh user@remote "cat /path/to/archive.tgz" | tar zxvf -
find /protocollo/paflow -type f -mtime +5 | xargs tar -cvf /var/dump-protocollo/`date '+%d%m%Y'_archive.tar`
2012-02-03 16:24:08
User: 0disse0
Functions: find tar xargs

Finally, we can make the file "unchangeable"

sudo chattr +i

tmpfs(){ cd /;for i in $@;do tar czvf /tmp/$i $i;mount -t tmpfs tmpfs /$i;tar xvzf /tmp/$i;cd ~ ;}# usage: tmpfs etc var
tar czf git_mods_circa_dec23.tgz --files-from <(git ls-files -m)
tar -xaf archive.tar.gz --strip-components=1
2011-11-29 07:38:19
User: sirex
Functions: tar
Tags: tar strip

If archive has leading directory level same as archive name and you want to strip it, this command is for you.

tar xfz filename.tar.gz -C PathToDirectory
2011-11-17 12:43:56
User: Dhinesh
Functions: tar
Tags: tar.gz

The command extracting the tar contents into particular directory ...

while true; do nc -l 7000 | tar -xvf -; done
2011-10-26 23:43:51
User: anhpht
Functions: tar

At client side:

tar c myfile | nc localhost 7000 ##Send file myfile to server

tar c mydir | nc localhost 7000 ## Send directory mydir to server

tar -cf - /etc | tar -xf - -C </destination/folder>
tar cvf - /src | ( cd /dest ; tar xvf - )
2011-09-22 15:35:24
User: a8ksh4
Functions: cd tar

This is how I've done it in the past

(cd src && tar -cf - .) | (cd dest && tar -xpf -)
2011-09-22 11:30:57
User: Cowboy
Functions: cd tar

Simple tar pipe to be used to copy directories while including hidden files and maintaining file permissions

find ./ -iname "*.dmp" -maxdepth 0 -type f -exec tar czvf {}.tar.gz --remove-files {} \; \;
2011-09-07 08:36:29
User: evilinside
Functions: find tar

This command will :

-Archive all *.dmp files individually (one file per archive) from current directory .

-Delete original file after has been compressed.

svn st -q | cut -c 2- | tr -d ' ' | xargs tar -czvf ../backup.tgz
2011-08-31 10:30:29
User: titus
Functions: cut tar tr xargs

This works more reliable for me ("cut -c 8-" had one more space, so it did not work)

find . -type d|xargs tar rf ~/dirstructure.tar --no-recursion
2011-08-03 16:21:10
User: gdevarajan
Functions: find tar xargs

The original suggestion did not work for me, when operating on folders located on an external mount (ie other than the root device) in Ubuntu. A variation using xargs does the trick.

ssh -C USER@HOST tar -c --exclude /proc --exclude /sys / | tar -x
cd / ; tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev /
2011-07-20 15:44:07
User: strzel_a
Functions: cd tar

Backup your entire system on a tar ball file format.

tar cf - . |(cd /targetdir; tar xvf -)
for i in *.tar.gz; do tar -x -v -z -f $i && rm -v $i; done
for i in "*.txt"; do tar -c -v -z -f $i.tar.gz "$i" && rm -v "$i"; done
tar -caf some_dir.tar.xz some_dir
2011-06-09 19:00:06
Functions: tar

the -a flag causes tar to automatically pick the right compressor to filter the archive through, based on the file extension. e.g.

"tar -xaf archive.tar.xz" is equivalent to "tar -xJf archive.tar.xz"

"tar -xaf archive.tar.gz" is equivalent to "tar -xzf archive.tar.gz"

No need to remember -z is gzip, -j is bzip2, -Z is .Z, -J is xz, and so on :)

tar jcpf /home/[usuario]/etc-$(hostname)-backup-$(date +%Y%m%d-%H%M%S).tar.bz2 /etc
2011-04-29 22:53:11
User: mack
Functions: date tar

Simple Compressed Backup of the /etc

Linux compatible

mkdir copy{1,2}; gzip -dc file.tar.gz | tee >( tar x -C copy1/ ) | tar x -C copy2/
2011-04-14 17:02:05
User: depesz
Functions: gzip mkdir tar tee
Tags: bash tee tar

Sometimes you might need to have two copies of data that is in tar. You might unpack, and then copy, but if IO is slow, you might lower it by automatically writing it twice (or more times)