credit goes to icanhaslinux.com http://icanhaslinux.com/2007/09/17/annoy-your-coworkers-linux-style/
You should really use keys. Really. I'm serious. But if you have to add your key, change password etc. for a long list of servers, this might help.
This uses curl to find out the access times of a web service Show Sample Output
compare to alternative : - directly tests the -STOP of the process to continue or stop loop, - background operator should be set (or not) at the call of the function For extension i suggest a slowPID() based on kill like above and a slowCMD based on killall.
Processes biglion quantity of sold ebay coupons/bonus codes, so you can know approximate count of users who buyed the coupons and when sales are come up again. You can change sleep parameter so script will work slowly or faster (default is 5 seconds). Additional requirements: curl Standart tools used: awk, date, cat, grep (bash) Show Sample Output
Check if your HTTP server is vulnerable to a very effective variant of slow HTTP attack called R.U.D.Y (R-U-Dead-Yet?). This command tries to keep many connections to the target web server and hold them open as long as possible. Affected server will exhaust its maximum concurrent connection pool and deny additional connection attempts from legitimate clients. Use it with caution!
Replace 'sleep 10' with the command to wait for Show Sample Output
Needs to be run in a battery sysfs dir, eg. /sys/class/power_supply/BAT0 on my system. Displays the battery's current charge and the rate per-second at which energy is {dis,}charging. All values are displayed as percentages of "full" charge. The first column is the current charge. The second is the rate of change averaged over the entire lifetime of the command (or since the AC cable was {un,}plugged), and the third column is the rate of change averaged over the last minute (controlled by the C=60 variable passed to awk). The sample output captures a scenario where I ran 'yes' in another terminal to max out a CPU. My battery was at 76% charge and you can see the energy drain starts to rise above 0.01% per-second as the cpu starts working and the fan kicks in etc. While idle it was more like 0.005% per-second. I tried to use this to estimate the remaining battery life/time until fully charged, but found it to be pretty useless... As my battery gets more charged it starts to charge slower, which meant the estimate was always wrong. Not sure if that's common for batteries or not. Show Sample Output
Check if SSH tunnel is open and open it, if it isn't.
NB: In this example, 3333 would be your local port, 5432 the remote port (which is, afaik, usually used by PostgreSQL) and of course you should replace REMOTE_HOST with any valid IP or hostname. The example above let's you work on remote PostgreSQL databases from your local shell, like this:
psql -E -h localhost -p 3333
I find the other timers are inaccurate. It takes some microseconds to perform the date function. Therefore, using date/time math to calculate the time for us results in millisecond accuracy. This is tailored to the BusyBox date function. May need to change things around for GNU date function. Show Sample Output
This command produces the output of "du -sk testfile" in every 10 seconds. You can change the command to be whatever you want.
Ummmm.. Saw that gem on some dead-head hippies VW bus at phish this summer.. It's actually one of my favorite ways of using bash, very clean. It shows what you can do with the cool advanced features like job control, redirection, combining commands that don't wait for each other, and the thing I like the most is the use of the ( ) to make this process heirarchy below, which comes in very handy when using fifos for adding optimization to your scripts or commands with similar acrobatics. F UID PID PPID WCHAN RSS PSR CMD 1 gplovr 30667 1 wait 1324 1 -bash 0 gplovr 30672 30667 - 516 3 \_ sleep 3 1 gplovr 30669 1 wait 1324 1 -bash 0 gplovr 30673 30669 - 516 0 \_ sleep 5 1 gplovr 30671 1 wait 1324 1 -bash 0 gplovr 30674 30671 - 516 1 \_ sleep 7 Show Sample Output
Stops when the (last) dd process exits.
The '[r]' is to avoid grep from grepping itself. (interchange 'r' by the appropriate letter)
Here is an example that I use a lot (as root or halt will not work):
while (ps -ef | grep [w]get); do sleep 10; done; sleep 60; halt
I add the 'sleep 60' command just in case something went wrong; so that I have time to cancel.
Very useful if you are going to bed while downloading something and do not want your computer running all night.
You don't want the -ar parameters in this case. The man page for BASH_BUILTINS(1) states: "-a option means to remove or mark all jobs" and "-r option without a jobspec argument restricts operation to running jobs" In this case we are supplying the process id of the job to disown so neither of these should be used.
Instead of having someone else read you the Digg headlines, Have OSX do it. Requires Curl+Sed+Say. This could probably be easily modified to use espeak for Linux.
shell loop to scan netstat output avoiding loolback aliases (local/remote swap for local connections) Show Sample Output
The better alternative to #9756. I don't think I'd ever use the original command, but this one was so bad I had to post this. Sorry. 1. $(ls) is dumb, and will give errors if you have an alias like "ls -Fs" 2. clear is better and more portable than reset state. 3. if you're interested in differences, then use diff, not cat.
Original submitted version would break if any filenames had whitespaces in them. The command is a Bad Idea anyhow, because you will end up `cat`ing a binary or something else specacularly bad.
repeat a command every X seconds , output show the creation of partition image using fsarchiver, each line show the size of the image. Show Sample Output
apt-get install cmatrix cmatrix-xfont wmctrl transset-df
Need to restart computer for mtx font to work
Commands while cmatrix is running:
1 - 9 = Change speed
SHIFT + 1 - 7 = change colors
Q = Quit
Tested in Ubuntu 10.04
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: