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:
The command tasksel allows the choice of packages from the command line to get predefined configurations for specific services (usually this option is offered during installation).
It remove the square bracket and convert UNIX time to human readable time for all line of a stream (or file).
Use it with cat and '|' for know what is used in a conf file.
For example cat /etc/squid/squid.conf | sed -re '/^#/d ; s/#.*$// ; /^\s$/d' :
Show you what you use in your file conf.
It removes all comments and empty lines.
Empty lines are lines with nothing, a tab, or a space.
How to extract data from one table:
mysqldump --opt --where="true LIMIT 5000" dbinproduzione tabella > miodbditest_tabella.sql
Delete all comments (#) on text :
It deletes the entire comment line and remove comments form end of others.
exec -a $NAME $COMMAND $ARGS
`your_cmd -erase_all_files` is the real process, but harmless-looking getty appears in the process table.
Never actually had a need to do this, but interesting nonetheless... Tested in bash, dash.
-a $NAME
"pass NAME as the zeroth argument to COMMAND", i.e. customise the name of the process (as commonly seen with `ps`)
You can compare directories on two different remote hosts as well:
diff -y <(ssh user1@host1 find /boot|sort) <(ssh user2@host2 find /boot|sort)
To avoid password-prompt on remote host just generate the rsa key locally and copy it to remote host:
ssh-keygen -t rsa
then
ssh you@server1 "mkdir .ssh"
then
scp .ssh/id_rsa.pub you@server1:; .ssh/authorized_keys2
was inspired by http://www.commandlinefu.com/commands/view/8936/boot-from-a-block-device-without-giving-root-privilege-to-virtual-box
volpedimongibello= virtual machine name
fighetto= controller name
tutto.iso= DVD iso image
How to remove the DVD:
VBoxManage storageattach "volpedimongibello" --storagectl "fighetto" --port 1 --device 0 --type dvddrive --medium none
I've been looking for this for a long time. Does anybody know how to do this in dash (POSIX shell)?
An alternative version might be:
exiftool img_1.jpg | diff - <(exiftool img_2.jpg)
If you have ever edited a locally checked out version of a file to tweak it for testing purposes, and came back to it over a weekend, you might have forgotten what you exactly changed. This command helps you see the differences between the the checked in SVN version, and the one you tweaked.
Show running time. eta, progressbar
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.
Deletes lines to of a file. You must put the end line first in the range for the curly brace expansion, otherwise it will not work properly.
For example, to remove line 5 from foo, type: vi +5d +wq foo
Use sed to remove comments from a file.
In this example the comments begin with #.
The command '/^#/d' remove line starting with #.
The command 's/#.*$//' remove comments at end of lines.