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 using tar from sorted by
Terminal - Commands using tar - 196 results
cat file.gz.cpt *[a-z] | ccdecrypt -k yoursecretpassword | tar -xzf -
tar czf - /directory/to/tar | ccrypt -k yourpassword | split -b50m - /final/encrypted.cpt
tar cfp - file-to-be-archived | gzip > archive.tar.gz
XZ_OPT=-9 tar cJf tarfile.tar.xz directory
2013-03-30 06:00:39
Functions: tar
0

is preserving creation time, modification time, permission, the directory structure, etc.

tar zcf - foo | gpg -c --cipher-algo aes256 -o foo.tgz.gpg
2013-03-13 09:44:39
User: skkzsh
Functions: gpg tar
0

Decrypt with:

gpg -o- foo.tgz.gpg | tar zxvf -
wget -O- http://example.com/mytarball.tgz | tee mytarball.tgz | tar xzv
2013-03-06 11:11:28
Functions: tar tee wget
0

Very similar as doing "wget http://example.com/mytarball|tar xzv", this one involves the "tee" command between both, which will simultaneously write the tarball and copy it to stdout. So this command will locally save the tarball and extract it - both at the same time while it downloads.

tar -zcvf <archive<.tar.gz --exclude /home/szimbaro/tmp /home/szimbaro
tar --create --file - --posix --gzip -- <dir> | openssl enc -e -aes256 -out <file>
2012-11-27 15:33:45
User: seb1245
Functions: tar
19

Create an AES256 encrypted and compressed tar archive.

User is prompted to enter the password.

Decrypt with:

openssl enc -d -aes256 -in <file> | tar --extract --file - --gzip
tar -cjf - $DIR | nc $HOST $PORT
2012-11-13 16:44:26
Functions: tar
Tags: netcat tar
0

Tar's up $DIR locally (w/bzip2) and sends remotely to $HOST:$PORT where netcat listens (using openbsd netcat). Start up receiving side command first, then execute this.

tar --lzma -xvf /path/to/archive
tar -zcvf file.tgz ./
find ./ -type f -name "*.txt" -exec tar uvf myarchives.tar {} +
2012-07-29 00:35:58
User: bugmenot
Functions: find tar
4

Note: the tar archive must not exist in order to create it. If exists it will only be updated and no already existent files in present search will still remain in the tar archive. The update option has to be used instead of create because the command tar may be executed more than once depending on the number of arguments that find throws. You can see maximum number of arguments with 'getconf ARG_MAX'

ssh -l username server.tdl "tar -czf - /home/username/public_html" | tar -xzf -
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 root@192.168.0.1 "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 root@192.168.0.1 "cat > /dest/folder/file.tar.gz"

Or even run other command's:

tcpdump | ssh root@10.0.0.1 "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 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
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
18

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