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:
Kills all the threads from the user provided in the WHERE request.
Can be refined through the SQL request, of course, see http://dev.mysql.com/doc/refman/5.1/en/processlist-table.html for the available columns.
Count the number of active connections to a MySQL database.
The MySQL command "show processlist" gives a list of all the active clients.
However, by using the processlist table, in the information_schema database, we can sort and count the results within MySQL.
This command will help you to find how many number of connection are made to given mysql and what are the different hosts connected to it with number of connection they are making.
Listens on local port 5500 and connects to remotehost with username user to tunnel the given socket file. Will work with anything, but can be useful if there's a need for a local application to connect with a remote server which was started without networking.
Create a secure tunnelled connection for access to a remote MySQL database.
For example, connect with MySQL Workbench to root@127.0.0.1:13306.
Finds all tables that need optimising and loops through them, running optimise against them. This works server-wide, on all databases and tables.
mtop allows you to monitor the operation of a MySQL application in real time. See, among the high, the number of queries performed per second, slower queries, the number of active processes.
To install on Ubuntu
sudo apt-get-y install mtop
This should probably only be used for testing in a dev environment as it's not terribly efficient, but if you're doing something that might trash a DB and you still want the old data available, this works like a charm.
-H suppress Headers
-I Inserts instead of csv
-R to give ; as the row delimeter.
Probably you can concatenate each line with a ; while importing to the db.
This will show the locations, in order of preference, that MySQL will look for a configuration file
This version compresses the data for transport.
In the example above 3 tables are copied. You can change the number of tables. You should be able to come up with variants of the command by modifying the mysqldump part easily, to copy some part of remote mysql DB.
`tar xfzO` extracts to STDOUT which got redirected directly to mysql. Really helpful, when your hard drive can't fit two copies of non-compressed database :)
-o : optimize
-p : asks for password
-u : user to use for authentication