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:
If the 'lm' flag is present, then the CPU is 64-bit.
If no output, then CPU is 32-bit.
Check the status of a 'dd' in progress. useful when creating very large dumps and want to see how far along it is. Sending the kill -USR1 forces dd to dump it's progress to stdout
The value for the sort command's -k argument is the column in the CSV file to sort on. In this example, it sorts on the second column. You must use some form of the sort command in order for uniq to work properly.
This command will log you into somehost via SSH and then go into the background (-f). From there, you can point e.g. firefox at localhost:8000 as a SOCKS proxy. Autossh will use port 20000 and 20001 to send and receive test data on those ports to ensure the SSH tunnel is still running, and will try to re-start the tunnel if it goes down. Make sure you have ssh-agent running, or passwordless ssh keys distributed between the two hosts.
The ip address is of the remote machine running the vncserver. Must log in first to the router then the VNC session. Very nice if you have open-wrt or dd-wrt on your router.
wrapping the snippet in $( )& puts the whole thing in the background so you don't tie up your login session.
I think I could cut down the number of pipes here, any suggestions?
This assumes your mail log is /var/log/mail.log
From 'man netstat'
"netstat -i | -I interface [-abdnt] [-f address_family] [-M core] [-N system]
Show the state of all network interfaces or a single interface
which have been auto-configured (interfaces statically configured
into a system, but not located at boot time are not shown). An
asterisk (``*'') after an interface name indicates that the
interface is ``down''. If -a is also present, multicast
addresses currently in use are shown for each Ethernet interface
and for each IP interface address. Multicast addresses are shown
on separate lines following the interface address with which they
are associated. If -b is also present, show the number of bytes
in and out. If -d is also present, show the number of dropped
packets. If -t is also present, show the contents of watchdog
timers."
The script contains a single command:
cd /a/long/directory/path/i/can/never/remember
This is a nice way to kill processes.. the example here is for firefox!!! substitute firefox for whatever the process name is...
from http://matt.ucc.asn.au/ssh-xfer/
"ssh-xfer is a hackish but handy way of transferring files from remote hosts to your local computer. Firstly, you need to run a slightly modified SSH authentication agent program on your local computer. Patches are available for both OpenSSH and PuTTY, see below. If you haven't used a SSH agent program before, this article seems to be reasonable, or you can look at the OpenSSH/PuTTY docs.
You don't need any modifications to your ssh client or server programs - only the modified SSH authentication agent, and the extra ssh-xfer program."
In the sample output, I pressed ctrl+r and typed the letters las. I can't imagine how much typing this has saved me.
To save the result, redirect the output to another file.
grep -v "^$" file1 > file2
any HTTP requests to the machine on the specified port will be redirected to http://www.whatevs.com... quick, dirty, works fine for sites w/
Turn off almost all of dig's output except for what you'd see in a zone file. This can also be put into ~/.digrc.
This command is somewhat similar to 'nice', but constrains I/O usage rather than CPU usage. In particular, the '-c3' flag tells the OS to only allow the process to do I/O when nothing else is pending. This dramatically increases the responsiveness of the rest of the system if the process is doing heavy I/O.
There's also a '-p' flag, to set the priority of an already-running process.