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.


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.
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

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!
Hide

Top Tags

Hide

Functions

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 - 207 results
tar -cvzf home_backup.tar.gz --exclude={.*,Downloads} /home/<user>
2012-07-24 12:16:33
User: mesuutt
Functions: tar
4

If you want to exclude only one file or directory you should use as --exclude=file_or_directory

tar cvzf - /folder/ | ssh [email protected] "dd of=/dest/folder/file.tar.gz"
2012-07-13 17:54:51
User: kruspemsv
Functions: ssh tar
1

You can ran this also with cat for example:

tar zcvf - /folder/ | ssh [email protected] "cat > /dest/folder/file.tar.gz"

Or even run other command's:

tcpdump | ssh [email protected] "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
0

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 [email protected] "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
1

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
12

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
11

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
19

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
-3

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
0

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
0

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
1

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
1

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 [email protected] 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
0

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
0

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
-1

Simple Compressed Backup of the /etc

Linux compatible