ask.slashdot.org/article.pl?sid=08/11/05/2027234
Linux So the other day I messaged another admin from the console using the regular old 'write' command (as I've been doing for over 10 years). To my surprise he didn't know how to respond back to me (he had to call me on the phone) and had never even known you could do that. That got me thinking that there's probably lots of things like that, and likely things I've never heard of. What sorts of things do you take for granted as a natural part of Unix that other people are surprised at?
VIM tricks', it would be nice to see one on regular expressions and the programs that use them. What amazingly cool tricks have people discovered with respect to regular expressions in everyday life as a developer or power user?"
Homepage Some more common ones I've thought of: screen - too useful, run apps in a virtual console which you can attach, deattach and share cd pwd -P - Jump into the real directory (from a linked directory). history - use it with grep if you forgot what you did strings - just show the printable strings from a file tail and head - tail -f is a lifesaver sftp - i really shouldn't need to explain this.
Homepage Not quite the same, but in a similar vein, cat /dev/urandom > /dev/dsp Sometimes a quick white-noise machine is relaxing. Heck, I used that command in combination with 'at' to act as a makeshift alarm clock when I was just moving into my first apartment and had forgotten my only other electronic device with an alarm (my cell phone) at the office.
Generally people are surprised by the fact that you could type some strange incantations into a black window like awk grep etc and make the computer do things without touching the mouse.
And once I had this strange feeling that something was wrong with the CD drive of a machine I was working at in the console until I realized I was opening and closing the CD tray on a machine in another room!
net that could process math expressions at runtime using Regex to get tokens from the expression. But after a code review, my pointy-haired manager made me comment each symbol in the regex. Someone needs to modify a file in a way that screams for regex search with replace, but is a nightmare in visual studio or some other windowy editor. So I have them stand behind me while I write an long, arcane-looking regex line in VI. When I press enter, the entire file instantly morphs into exactly what they want. I can think of no better way to justify my exorbitant bill rate.
Homepage You'd be surprised how often I have seen experienced programmers manually type out long commands or directory paths, instead of using tab completion. Sometimes I have to restrain myself from ripping the keyboard from their hands and using tab to enter the path myself in a 10th of the time.
Instead of finishing the word I was typing, it kept on moving the little "insertion line" thing to the right. I already filed a bug report, but do any of you have a quick fix?
Step back for a moment and you'll find that "man pages" and "info" are actually a pretty awful way to distribute documentation. As a supplement they'd be fine, but as the main source of information on how to use many commands...
The original Bell Labs man pages completely described the system from the point of view of an administrator or user. The current blight of wimpy, inaccurate and incomplete man pages seems to originate from the GNU developers who insist on using the terrible "info" crap, writing huge volumes of text with no real content, and the tradition is continued by Linux developers who generally provide little or no man page documentation -- presumably in the hope that users of their software will be tempted to ask questions on various mailing lists where they can be ritually disemboweled for displaying such a lack of understanding and disturbing the peace of the cognoscenti who have much more important things to do than answer questions of mere users of their software.
Homepage I've seen Windows people go slack-jawed in astonishment as I ssh to the other side of the world and run X programs over forwarding. Some refuse to believe it, others shake their heads and walk away.
com, port 456, via the remote host ssh -R lets you go in the opposite direction (tunnel from remote end to local end), but if your application supports SOCKS, it's even easier: ssh user@remotehost -D8080 Creates a secure tunnel supporting the SOCKS protocol.
dd, device duplicator / disk destroyer mount, what I can't have a desktop icon? also managing disk volumes and the old conventions of /opt, /u, /usr, /usr/local This new fangled Linux craze with all of the UI tools is feeding it. Redhat is training admins that are dependent on a given release of their enterprise software (which I am a huge fan of) but not teaching them how it works under the hood. The one ray of hope seems to be a new generation hacking their bsd and linux based (iPhone/Android) phones and having fun in a somewhat embedded (but full blown) *nix environment.
Homepage When I pop up with my laptop to discuss with a colleague, after a while I might do on their computer: xhost +mylaptopname and on my laptop I do: x2x thecomputername:0 -west Then suddenly my mouse can go over the two computers, my keyboard works on both as well, and I can even copy-paste between the two computers.
For example: lsof /mnt/myMount That will list which processes have anything under /mnt/myMount open It's also useful to find who's accessing what device. For example, say you're trying to listen to an mp3 and Amarok bitches about the sound device not being available. In that case, you could do something like this (assuming you're using ALSA): lsof /dev/snd That will list what processes are accessing any of your ALSA sound devices.
It's almost as if someone's first c program somehow got taken up as a part of standard Unix! Maybe in the days before sed and awk and perl it had some function in pipes that I can't grok, but nowadays other than making hints for video game websites I can't imagine what it's for.
You're giving the shell an asterisk, which it dutifully expands. echo (which in this case is a shell builtin, but it doesn't have to be then just echoes them back. It works for anything, even commands that don't normally take files, or even with files that look like switches (conversely, if you want to treat all subsequent arguments as files, not switches, most programs have a '--' switch): $ ls a -l b c $ ls * -rw-r--r-- 1 marcansoft users 0 2008-11-05 21:58 a -rw-r--r-- 1 marcansoft users 0 2008-11-05 21:58 b -rw-r--r-- 1 marcansoft users 0 2008-11-05 21:58 c $ ls -- * a -l b c In the second example, ls sees "ls a -l b c" and takes -l as a switch instead of a filename.
Homepage Optimized version of that: find / | grep -i $SOMETHING Even more optimized: find / -iname $SOMETHING However, most systems support locate/updatedb already, and that's much faster.
For example, this is equivalent to your command above: find . I wanted to change the mime-type of all the xml files in my svn repository from "application/xml" to "text/xml": find . xml -exec sh -c "svn propget svn:mime-type {} | grep -q application/xml" \;
Journal Xargs is much more fun with complex data processing. txt Oh, I almost forgot about one of my favorite tricks. Count the number of items: wc -l (paste the list into the window and then type CTRL-D) It even works when the list of items has oddities. Except that one of the blank lines wouldn't copy, so I actually needed (n+1)/2. echo $(($((wc -l+1))/2)) Want to make sure your sig is under 120 characters? Type "wc -c" in, paste it into your terminal, then press CTRL-D.
|