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 tagged 7z from sorted by
Terminal - Commands tagged 7z - 6 results
tar -cvf - /path/to/tar/up | xz - > myTarArchive.tar.xz
2014-03-18 19:51:50
User: razerwolf
Functions: tar
1

compress directory archive with xz compression, if tar doesn't have the -J option (OSX tar doesn't have -J)

tar -cJf myarchive.tar.xz /path/to/archive/
2014-03-13 03:34:18
User: Sepero
Functions: tar
1

Compress files or a directory to xz format. XZ has superior and faster compression than bzip2 in most cases. XZ is superior to 7zip format because it can save file permissions and other metadata data.

for ARG in * ; do sudo -u USER 7z x -o"$(echo $ARG|sed 's/\(.*\)\..*/\1/')" "$ARG" ; done
2012-12-31 19:47:24
User: n158
Functions: sudo
0

Magic line will extract almost all possible archives from current folder in its own folders. Don't forget to change USER name in sudo command. sed is used to create names for folders from archive names w/o extension. You can test sed expression, used in this command:

arg='war.lan.net' ; x=$(echo $arg|sed 's/\(.*\)\..*/\1/') ; echo $x

If some archives can't be extracted, install packages:

apt-get install p7zip-full p7zip-rar

Hope this will save a lot of your time. Enjoy.

dd if=<device> | pv | nc <target> <port>
2012-01-27 18:37:36
Functions: dd
Tags: dd nc pv 7z
8

Create an image of "device" and send it to another machine through the network ("target" and "port" sets the ip and port the stream will be sent to), outputting a progress bar

On the machine that will receive, compress and store the file, use:

nc -l -p <port> | 7z a <filename> -si -m0=lzma2 -mx=9 -ms=on

Optionally, add the -v4g switch at the end of the line in order to split the file every 4 gigabytes (or set another size: accepted suffixes are k, m and g).

The file will be compressed using 7z format, lzma2 algorithm, with maximum compression level and solid file activated.

The compression stage will be executed on the machine which will store the image. It was planned this way because the processor on that machine was faster, and being on a gigabit network, transfering the uncompressed image wasn't much of a problem.

7z a -mx=9 -ms=on archive.7z files_for_archiving/
2011-10-22 09:26:42
User: nssy
Tags: 7z 7zip
1

Creates a solid archive with the highest possible compression (Ultra). Advantage of 7z is that it will use all the processor cores to create the archive. (Ok. at least version 9.04 does)

tar cf - /path/to/data | 7z a -si archivename.tar.7z
2009-07-14 14:21:30
User: slashdot
Functions: tar
8

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.