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



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
sudo wget -c "http://nmap.org/dist/nmap-5.00.tar.bz2" && bzip2 -cd nmap-5.00.tar.bz2 | tar xvf - && cd nmap-5.00 && ./configure && make && sudo make install
2009-07-26 11:36:53
User: hemanth
Functions: bzip2 cd make sudo tar wget

Just copy and paste the code in your terminal.

Note : sudo apt-get for debian versions , change as per your requirement .

Source : www.h3manth.com

tar c folder_to_encrypt | openssl enc -aes-256-cbc -e > secret.tar.enc
2009-07-23 06:03:39
User: recursiverse
Functions: c++ tar

command to decrypt:

openssl enc -aes-256-cbc -d < secret.tar.enc | tar x

Of course, don't forget to rm the original files ;) You may also want to look at the openssl docs for more options.

(cd /source/dir ; tar cv .)|(cd /dest/dir ; tar xv)
2009-07-19 10:31:13
User: marssi
Functions: cd tar

the f is for file and - stdout, This way little shorter.

I Like copy-directory function It does the job but looks like SH**, and this doesn't understand folders with whitespaces and can only handle full path, but otherwise fine,

function copy-directory () { ; FrDir="$(echo $1 | sed 's:/: :g' | awk '/ / {print $NF}')" ; SiZe="$(du -sb $1 | awk '{print $1}')" ; (cd $1 ; cd .. ; tar c $FrDir/ )|pv -s $SiZe|(cd $2 ; tar x ) ; }

tar -pczf archive_name.tar.gz /path/to/dir/or/file
2009-07-17 19:53:02
User: ryuslash
Functions: tar
Tags: bash tar gzip

Create a single tar.gz archive

I know it's a very basic one, but it's one I keep forgetting.

7z x -so testfile.tar.7z | tar tvf -
2009-07-15 21:00:58
User: slashdot
Functions: tar

Sometimes it is handy to be able to list contents of a tar file within a compressed archive, such as 7Zip in this instance, without having to extract the archive first. This is especially helpful when dealing with larger sized files.

(cd /source/dir ; tar cvf - .)|(cd /dest/dir ; tar xvpf -)
tar cf - /path/to/data | 7z a -si archivename.tar.7z
2009-07-14 14:21:30
User: slashdot
Functions: tar

Using 7z to create archives is OK, but when you use tar, you preserve all file-specific information such as ownership, perms, etc. If that's important to you, this is a better way to do it.

tar cvfz changes.tar.gz --exclude-vcs `svn diff -rM:N --summarize . | grep . | awk '{print $2}' | grep -E -v '^\.$'`
2009-07-13 19:39:10
User: jaysee
Functions: awk diff grep tar

Handy when you need to create a list of files to be updated when subversion is not available on the remote host. You can take this tar file, and upload and extract it where you need it. Replace M and N with the revisions specific to yours. Make sure you do this from an updated (svn up) working directory.

tar -C <source> -cf - . | tar -C <destination> -xf -
ls *tgz | xargs -n1 tar xzf
tar -C <source_dir> -cf . | tar -C <dest_dir> -xf -
tar -C <source_dir> -cf . | tar -C <dest_dir> -xf
tar -tf <file.tar.gz> | xargs rm -r
for i in $(tar -tf <file.tar.gz>); do rm $i; done;
2009-07-06 19:57:23
User: din7
Functions: rm tar

Remove annoying improperly packaged files that untar into the incorrect directory.

Example, When you untar and it extracts hundreds of files into the current directory.... bleh.

tar -cj /backup | cstream -t 777k | ssh host 'tar -xj -C /backup'
2009-07-02 10:05:53
User: wires
Functions: host ssh tar

this bzips a folder and transfers it over the network to "host" at 777k bit/s.

cstream can do a lot more, have a look http://www.cons.org/cracauer/cstream.html#usage

for example:

echo w00t, i'm 733+ | cstream -b1 -t2

hehe :)

( cd SOURCEDIR && tar cf - . ) | (cd DESTDIR && tar xvpf - )
for i in *.tar.gz; do tar -xzf $i; done
2009-06-13 03:58:48
User: kureikain
Functions: tar
Tags: tarball

You can flexibly change file pattern(*.tar.gz) and uncompress command to other job!

Example, remove all files :

for i in *.tar.gz; do rm $i; done

(Just for example, because if you really want to remove file, simply use wildcard like this rm *.tar.gz)

cd <YOUR_DIRECTORY>; for i in `ls ./`; do tar czvf "$i".tar.gz "$i" ; done
2009-06-11 18:33:27
User: ElAlecs
Functions: cd tar

Very simple and useful, you need to change the word "directory" for your directory

tar czv Pictures | split -d -a 3 -b 16M - pics.tar.gz.
2009-06-09 19:48:01
User: asmoore82
Functions: split tar

Leave it to a proprietary software vendor to turn a cheap and easy parlor trick into a selling point. "Hey guys, why don't we turn our _collection of multiple files_ into a *collection of multiple files*!!" Extract the ^above with this:

cat pics.tar.gz.??? | tar xzv

^extract on any Unix - no need to install junkware!

(If you must make proprietary software, at least make it do something *new*)

if [ -e windows ]; then use 7-Zip

find /var/logs -name * | xargs tar -jcpf logs_`date +%Y-%m-%e`.tar.bz2
tar -zcvpf backup_`date +"%Y%m%d_%H%M%S"`.tar.gz `find <target> -atime +5` 2> /dev/null | xargs rm -fr ;
2009-05-26 17:15:52
User: angleto
Functions: rm tar xargs
Tags: backup

create an archive of files with access time older than 5 days, and remove original files.

tar -tf file.tar | tar -T - -uf file.tar
2009-05-22 00:28:13
Functions: tar

This will update the tarball, adding files that have changed since the last update.

This assumes that the tarball is in the same directory as the files being archived.

N.B. This command can't be used on compressed tarballs.

N.B. This will add the updated files to the tarball, so that the tarball will have two versions of each file. This will make the tarball larger, but doesn't have any other significant effect.

tar cvf - foodir | gzip > foo.tar.gz
2009-05-19 11:33:51
User: sharfah
Functions: gzip tar
Tags: tar gzip

Where foodir is the directory you want to zip up.

gunzip < foo.tar.gz | tar xvf -
ssh -i $PRIVATEKEY $HOST -C 'cd $SOURCE; tar -cz --numeric-owner .' | tee $DESTINATION/backup.tgz | tar -tz
2009-05-18 20:36:45
User: GeckoDH
Functions: ssh tar tee
PRIVATEKEY - Of course the full path to the private key \n HOST - The host where to get the backup \n SOURCE - The directory you wish to backup \n DESTINATION - The destination for the backup on your local machine