Yet Another Ten One-Liners from CommandLineFu Explained - good coders code, great reuse |
| Yet Another Ten One-Liners from CommandLineFu Explained Posted: 02 Jun 2010 05:35 AM PDT
Here are the first three parts:
31. Quickly access ASCII table.$ man 7 ascii Ever forgot a keycode for some ASCII character or escape code? Look no further, Linux man pages are full of gems like these. One day I actually went through all the man pages to find the most interesting ones. An article about them is upcoming but before I get it published, here are a few interesting ones:
And finally the section 7 man pages that are most packed with wild and cool info,
There are a lot more interesting man pages but these stood out from the rest. 32. Simple timer.$ time read This one-liner can be used a simple timer. For example, if you wish to time something, you can execute it when the event starts and press the return key when the event ends. It will output the time the event took to finish. Here is how this one-liner works. First the If you get annoyed by having to press enter, you can specify that $ time read -N 1 Now you can press any key to stop the timer. If you wish to run a timer for a specific number of seconds, you can add $ time read -t 60 This would stop the timer after 60 seconds. 33. Shutdown a Windows machine.$ net rpc shutdown -I IP_ADDRESS -U username%password Everyone knows the Anyway, the This particular one-liner executes the To reboot a machine use the $ net rpc shutdown -r -I IP_ADDRESS -U username%password If you're on an unsecured network, don't forget about the good old 34. Execute a command independently from the current shell.$ (cd /tmp && ls) This one-liner illustrates subshells. Here the commands Surely, this is only a toy example. If you wanted to know what's in Actually, talking about /long/path/is/long$ pushd . /long/path/is/long$ cd /usr /usr$ popd /long/path/is/long$ Another cool trick is to use /home/pkrumins$ cd /tmp /tmp$ cd - /home/pkrumins$ 35. Tunnel your SSH connection via intermediate host.$ ssh -t reachable_host ssh unreachable_host This one-liner creates an ssh connection to This one-liner can be generalized. You can tunnel through arbitrary number of ssh servers: $ ssh -t host1 ssh -t host2 ssh -t host3 ssh -t host4 ... Now catch me if you can. ;) 36. Clear the terminal screen.$ CTRL+l Pressing CTRL+l (that's small If you wish to clear just some line, you can use argumented version of $ ESC 21 CTRL+l This command outputs a special "clear-screen" sequence to the terminal. The same can be achieved by $ tput clear Another way to clear the terminal (usually when the screen gets garbled) is to use the $ reset 37. Clear the terminal screen.$ ping -a IP Ever had a situation when you need to know when the system comes up after a reboot? Up until now you probably launched 38. List 10 most often used commands.$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head The person who wrote it has the Unix mindset right. He's combining several shell commands to get the result he/she wants. First, If you want to see more than 10 commands (or less), change 39. Check gmail for new mail.$ curl -u you@gmail.com --silent "https://mail.google.com/mail/feed/atom" | perl -ne \ ' print "Subject: $1 " if /<title>(.+?)<\/title>/ && $title++; print "(from $1)\n" if /<email>(.+?)<\/email>/; ' Gmail is cool because they offer an Atom feed for the new mail. This one-liner instructs Here is a the output when I run the command, Subject: i heard you liked windows! (from gates@microsoft.com) Subject: got root? (from bofh@underground.org) 40. Watch Star-Wars via telnet.$ telnet towel.blinkenlights.nl Needs no explaining. Just telnet to the host to watch ASCII Star-Wars. And here is another one, $ telnet towel.blinkenlights.nl 666 Connecting on port 666 will spit out BOFH excuses. That's it for today.I hope you enjoyed the 4th part of the article. Tune in next time for the 5th part. Oh, and I'd love if you followed me on Twitter! |
| You are subscribed to email updates from good coders code, great reuse To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
| Google Inc., 20 West Kinzie, Chicago IL USA 60610 | |
No comments:
Post a Comment
Keep a civil tongue.