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/
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.
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
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:
This is a useful command to backup an sd card with relative total size for piping to pv with a progressbar
use this command to gzip the file and write to stdout and from the stdout redirect to the another file
The command uses ssh(1) to get to a remote host, uses tar(1) to archive a remote directory, prints the result to STDOUT, which is piped to gzip(1) to compress to a local file. In other words, we are archiving and compressing a remote directory to our local box.
Similar, but uses tarball instead of zip file
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)
This version compresses the data for transport.
Useful when you have multiple files or binary files that you need to transfer to a different host and scp or the like is unavailable.
To unpack on the destination host copy paste output using the opposite order:
openssl enc -d -base64 | gunzip | tar -x
Terminate openssl input using ^d
Note: gzip is outside of tar because using -z in tar produces lots of extra padding.
This is a safest variation for "sitepass function" that includes a SALT over a long loop for sha512sum hash
It is an easy method unzip a file and copy it to remote machine. No unziped file on local hard drive
Opens a snapshot of a live UFS2 filesystem, runs dump to generate a full filesystem backup which is run through gzip. The filesystem must support snapshots and have a .snap directory in the filesystem root.
To restore the backup, one can do
zcat /path/to/adXsYz.dump.gz | restore -rf -
In this example we convert a .tar.bz2 file to a .tar.gz file.
If you don't have Pipe Viewer, you'll have to download it via apt-get install pv, etc.
tar directory and compress it with showing progress and Disk IO limits. Pipe Viewer can be used to view the progress of the task, Besides, he can limit the disk IO, especially useful for running Servers.
Should do exactly the same - compress every file in the current directory. You can even use it recursively:
gzip -r .
Dumps a compressed svn backup to a file, and emails the files along with any messages as the body of the email
It grabs all the database names granted for the $MYSQLUSER and gzip them to a remote host via SSH.
You set the file/dirname transfer variable, in the end point you set the path destination, this command uses pipe view to show progress, compress the file outut and takes account to change the ssh cipher. Support dirnames with spaces.
Merged ideas and comments by http://www.commandlinefu.com/commands/view/4379/copy-working-directory-and-compress-it-on-the-fly-while-showing-progress and http://www.commandlinefu.com/commands/view/3177/move-a-lot-of-files-over-ssh
What happens here is we tell tar to create "-c" an archive of all files in current dir "." (recursively) and output the data to stdout "-f -". Next we specify the size "-s" to pv of all files in current dir. The "du -sb . | awk ?{print $1}?" returns number of bytes in current dir, and it gets fed as "-s" parameter to pv. Next we gzip the whole content and output the result to out.tgz file. This way "pv" knows how much data is still left to be processed and shows us that it will take yet another 4 mins 49 secs to finish.
Credit: Peteris Krumins http://www.catonmat.net/blog/unix-utilities-pipe-viewer/