Slashdot Mirror


(Useful) Stupid Unix Tricks?

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?

1,775 of 2,362 comments (clear)

  1. rm -rf / by Anonymous Coward · · Score: 5, Funny

    rm -rf /

    1. Re:rm -rf / by soybean · · Score: 1

      great minds think alike

    2. Re:rm -rf / by Anonymous Coward · · Score: 2, Informative

      more like
      sudo rm -rf /

    3. Re:rm -rf / by Frymaster · · Score: 4, Funny

      or the "unix koan" grep "" /dev/null

    4. Re:rm -rf / by acidreverb · · Score: 5, Insightful

      Mediocre minds think alike. Great minds are unique.

    5. Re:rm -rf / by orclevegam · · Score: 5, Funny

      rm -rf /

      wtf??? (do not try this at home)

      Really? What does it do? Think I'll try it and s
      CARRIER LOST

      --
      Curiosity was framed, Ignorance killed the cat.
    6. Re:rm -rf / by macshome · · Score: 4, Funny

      Pshaw! All 1337 sysadmins just live as root!

    7. Re:rm -rf / by Anonymous Coward · · Score: 5, Funny

      OMG OMG What did I do. What did I do. I am so fired. I am so EFFIN fired.

    8. Re:rm -rf / by butalearner · · Score: 5, Funny

      I got something similar to these from some website that I have long forgotten: alias AvadaKedavra kill -9 alias Obliviate rm -rf alias Alohomora chmod -Rf ug+w alias Accio grep -Ir \!:1

    9. Re:rm -rf / by butalearner · · Score: 1

      Damn. If someone could let me know why Slashdot would let me use neither quotation marks nor paragraph tags on the above post, I'd appreciate it. Couldn't get the preview to come up.

    10. Re:rm -rf / by mr_mischief · · Score: 5, Funny

      cat /dev/urandom > /dev/dsp

    11. Re:rm -rf / by Anonymous Coward · · Score: 5, Funny

      sleep 8h; cat /dev/urandom > /dev/dsp

      That's my alarm clock.

    12. Re:rm -rf / by KiviPall · · Score: 3, Funny

      rm -rf /*

      it stands for: Read Mail Really Fast
      You can read mail faster, if you are root

    13. Re:rm -rf / by ProzacPatient · · Score: 1

      rm -rf /

      Unix has security, remember?
      Try "sudo rm -rf /" instead.

    14. Re:rm -rf / by Anonymous Coward · · Score: 5, Funny

      OMG OMG What did I do. What did I do. I am so fired. I am so EFFIN fired.

      Ha, I didn't get fired when I did it. It was about ten years ago now, I had a linux dualboot setup on a test PC and didn't need the linux install any more.

      I thought, "I've always wanted to try rm -r /" so I did. About four seconds later it dawned, with an "oh shit" that I still had the dos/windows 3.11 partition still mounted read write.

      Fortunately, I didn't permanently lose anything between good backups and Norton Disk Doctor.

    15. Re:rm -rf / by uberjack · · Score: 1

      Hmm, Mozart's Fifth Symphony...

    16. Re:rm -rf / by Anonymous Coward · · Score: 1, Interesting

      I personally enjoy doing this:

      touch -- -rf

      This creates a file called -rf that is a bit tricky for the uninitiated to delete. Using rm with tab completion will not help and using quotes will not help. Furthermore, using a wildcard (like *) will not help. The "-rf" is interpretted as command line option to rm. The solution is predictable if you knew how it was created:

      rm -- -rf

    17. Re:rm -rf / by tunapez · · Score: 1

      Do not try this at home(or at /), kids.

      In that vein, is there a way to scrub grub from the MBR via the cli?

      --
      Imagination drew in bold strokes, instantly serving hopes and fears, while knowledge advanced by slow increments...
    18. Re:rm -rf / by aliquis · · Score: 1

      Once upon a time I had a keyboard whose shift keys didn't work longer. It also happened that I ran whatever Linux dist and had a dir filled of files I wanted to remove.

      Solution? User numeric keypad to type a * (which requires shift on the other part of the keyboard at least with a swedish keymap.)

      Except I hit the wrong key so my * become a / instead. Not good.

      Also when trying to install Solaris 8 on my Sun Ultra 30 it never worked to partition the harddrive or something like that, but dd if=/dev/zero of=diskname solved that one .. (don't remember if I used bs=1 or 512 and count=somehugenumber or not.)

    19. Re:rm -rf / by yukk · · Score: 1

      I got something similar to these from some website that I have long forgotten: alias AvadaKedavra kill -9 etc ...

      Yeah, That's a pretty old website right there that uses Harry Potter spells. Also with kill, you're better off knowing what the signals do than making a silly alias, for example kill -HUP will tell a lot of daemons to re-read their config files and sending QUIT or STOP or CONT are all useful at times.

      --
      The trouble with the rat race is that even if you win, you're still a rat." Lily Tomlin
    20. Re:rm -rf / by EthanV2 · · Score: 2, Informative

      I believe you mean NO CARRIER

    21. Re:rm -rf / by thatskinnyguy · · Score: 2, Funny

      Along the same lines, set the root of everyone's home directory to /dev/null. I hear you get excellent results when using this method to reduce space on the file server.

      --
      The game.
    22. Re:rm -rf / by ArhcAngel · · Score: 5, Funny

      I keep getting Windows cannot find 'rm' when I type that in. Am I doing it wrong?

      what the hell. I had karma to burn.

      --
      "A person is smart. People are dumb, panicky dangerous animals and you know it." - K
    23. Re:rm -rf / by davester666 · · Score: 1

      for some unix's, you need to do this instead:

      sudo rm -rf /

      Very useful. Clears away the dead files on your drive to make room for more porn!

      --
      Sleep your way to a whiter smile...date a dentist!
    24. Re:rm -rf / by fahrbot-bot · · Score: 1

      % rm * .o
      .o: No such file or directory

      --
      It must have been something you assimilated. . . .
    25. Re:rm -rf / by fr4nk · · Score: 2, Informative

      dd if=/dev/zero of=/dev/sdx bs=512 count=1

      should clear out the MBR.

    26. Re:rm -rf / by againjj · · Score: 1
      I tried it:

      $ grep "" /dev/null
      $ echo $?
      1
      $

      I am not sure if that is the right answer or not.

    27. Re:rm -rf / by Bemopolis · · Score: 1

      I've heard that somewhere before....

      --
      "I guess the moral of the story is, don't paint your airship with rocket fuel." -- Addison Bain
    28. Re:rm -rf / by sydneyfong · · Score: 1

      You mean "do not try this at /home". :)

      Depending on your filesystem layout, rm -rf / could be having its first run on /usr, which might actually save you, since it will take some time and depending on what you're doing, trash your system to the point that you'll reboot before it gets to /home.

      --
      Don't quote me on this.
    29. Re:rm -rf / by geekoid · · Score: 1

      Unless he changed it.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    30. Re:rm -rf / by alta · · Score: 1

      I remember my first linux box... About 30 slackware floppies downloaded @ 33.6. I finally got it all running on a 486 (each time I found an image was bad I had to re-download). My first command after login? help And help, it was not. After a while of screwing around with it, I decided I needed to delete a particular directory... rm -rf /etc /something/somewhere/stupid notice the space... accident... Anyway, I should have learned not to f my rm -rf... But actually, I just learned to check my paths better when deleting. Oh well.

      --
      Do not meddle in the affairs of sysadmins, for they are subtle, and quick to anger.
    31. Re:rm -rf / by Tetsujin · · Score: 1

      rm -rf /

      wtf??? (do not try this at home)

      Really? What does it do? Think I'll try it and s

      CARRIER LOST

      Now that doesn't make any sense!

      I mean, assuming you had a web browser or something open entering this message - and you removed all the files on your hard drive - the web browser wouldn't immediately crash, 'cause any open files would continue to exist until the last open file handle was closed...

      --
      Bow-ties are cool.
    32. Re:rm -rf / by harry666t · · Score: 1

      I've been piping various stuff into /dev/dsp - the linux kernel image sounds pretty interesting (literally). Also, there is often significant difference between data of the same type - /bin/tar sounds much different from /bin/grep! :)

    33. Re:rm -rf / by aliquis · · Score: 1

      I know the other child thought it was nasty but I used to do it to see if the sound worked or not. So I find it useful.

    34. Re:rm -rf / by ristonj · · Score: 1

      Hey, I'll have to try th

    35. Re:rm -rf / by Omega996 · · Score: 5, Insightful

      sudo is for ubuntu wannabes - real UNIX admins don't sudo - they su - .

    36. Re:rm -rf / by marcus · · Score: 1

      Ouch!

      Here I am cleaning up a build tree and Makefiles for release right now and I have to admit that in the hundreds of times I have done this, I have not made that keystroke error.

      Of course there's always CVS...

      --
      Good judgement comes from experience, and experience comes from bad judgement.
      - W. Wriston, former Citibank CEO
    37. Re:rm -rf / by carrier+lost · · Score: 4, Funny
      CARRIER LOST

      Hello?

    38. Re:rm -rf / by wtfispcloadletter · · Score: 1

      Why not? Just like Windows, Linux needs cleaned out every now and then. Right?

    39. Re:rm -rf / by j79zlr · · Score: 4, Insightful

      Fortunately, I didn't permanently lose anything between good backups and Norton Disk Doctor.

      Yes, you do need good backups whenever you are running Norton products. Good idea.

      --
      I'm not not licking toads.
    40. Re:rm -rf / by myz24 · · Score: 1

      THANK YOU

    41. Re:rm -rf / by Teilo · · Score: 4, Insightful

      No. People who run as root all the time are either n00bs or morons.

      N00bs if they have never spoken the words, "Oh sh*t!" after running a command;

      Morons if they have.

      --
      Mir tut es leid, Menschen daß Einfältigfehlersuchenbaumfolgendenaffen sind.
    42. Re:rm -rf / by orclevegam · · Score: 1, Informative

      LOL, that's awesome.

      --
      Curiosity was framed, Ignorance killed the cat.
    43. Re:rm -rf / by Omega996 · · Score: 5, Insightful

      if you haven't said "oh shit" while doing something as root, you haven't done UNIX administration in a busy production environment.

    44. Re:rm -rf / by zeus_rlz · · Score: 1

      find /home -user `id | sed 's/^uid=\([0-9]*\).*/\1/g'` | xargs ls -d {}

    45. Re:rm -rf / by FCD1 · · Score: 1

      If you like background noise, give boodler a try. It's written in Python and rather old, but still runs on modern systems (I tried it on Debian Lenny and Etch).

    46. Re:rm -rf / by Dtyst · · Score: 5, Funny
      I prefer the Russian roulette version:

      [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live"

    47. Re:rm -rf / by buchner.johannes · · Score: 2, Informative

      I do the same, luckily a lot of music players support something like
      # audacious --play
      # rhythmbox-client --play
      for controlling the running app from the shell. The second actually goes over DBUS.
      more often I use the opposite, --pause, or
      # sleep 15m && sudo poweroff
      for listening to some music in bed before falling asleep.

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    48. Re:rm -rf / by Anonymous Coward · · Score: 1, Funny

      cat /dev/zero > xxx & rm -f xxx

    49. Re:rm -rf / by Shark · · Score: 1

      You can most certainly go "Oh sh*t!" after typing:

      sudo cat /dev/urandom > /dev/sda

      Sudo doesn't prevent you from being clueless. It just gives you a moment to think before you type in your password.

      --
      Mind the frickin' laser...
    50. Re:rm -rf / by geminidomino · · Score: 5, Funny

      Thank you.

      There's two kinds of real UNIX Admins.

      1. Those who have yelled "Oh Shit!"
      2. Those who will.

    51. Re:rm -rf / by rastakid · · Score: 1

      while [ true ]
      do
            sl > /dev/pts/3
      done

      Yes, I mean sl and not ls. Oh, and make sure you direct it to the correct terminal (pts3 in this case). The target will be forced to logout, or log you out... *evil grin*

    52. Re:rm -rf / by garaged · · Score: 1

      I've used sudo way before ubuntu was born, I discovered it's beauty on gentoo.

      --
      I'm positive, don't belive me look at my karma
    53. Re:rm -rf / by PuercoPop · · Score: 3, Funny

      my unix koan is:

      puercopop@localhost ~ $ which which
      which: no which in (/usr/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2:/usr/qt/3/bin:/usr/games/bin)

    54. Re:rm -rf / by Shark · · Score: 2, Funny

      Quick, somebody write a patch to gcc so you can 'hear' the name of each function call!

      --
      Mind the frickin' laser...
    55. Re:rm -rf / by mikael · · Score: 1

      That is definitely worth downloading - I always thought these fancy high-end gaming rigs had something missing when they didn't have that beebily-boobily noise that all computers had in 1980's movies in computers.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    56. Re:rm -rf / by anonymous_wombat · · Score: 1

      I once worked at a company where a developer was giving a non-technical person directions over the phone, and told her to type: rm -rf * as root. He neglected to have her check what directory she was in first. Apparently, she was in the root directory, and didn't realize anything was wrong until the delete failed (when /bin/rm got deleted).

    57. Re:rm -rf / by kriebz · · Score: 1

      Not exactly the same, but I once named a file the backspace character. This was under IRIX, fwiw. How do I delete that? I really can't remember how I created it.

    58. Re:rm -rf / by dgatwood · · Score: 1

      It just gives you a moment to think before you type in your password.

      ...and only if you have it set to always prompt for a password and/or you just walked up to your desk after a nice long lunch.

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    59. Re:rm -rf / by Pig+Hogger · · Score: 1

      sudo is for ubuntu wannabes - real UNIX admins don't sudo - they su - .

      Better yet, just do " sudo su - ".

    60. Re:rm -rf / by Trailer+Trash · · Score: 1

      Really? What does it do? Think I'll try it and s CARRIER LOST

      I know that's not real. A real carrier lost has a bunch of punctuation characters first, almost as if someone is holding down shift while hitting the number keys...

    61. Re:rm -rf / by martinw89 · · Score: 1

      Not very innovative on my part after you've already mentioned urandom, but you can also "listen" to your hard drive:
      cat /dev/sda > /dev/dsp
      Replace sda with your hard drive, of course. It's a very trippy experience, when it reaches uncompressed sound files they will be outputted correctly.

    62. Re:rm -rf / by curecollector · · Score: 1

      Read Mail Real Fast!

    63. Re:rm -rf / by Scherpbier · · Score: 1

      touch /-i

      Doesn't prevent "rm -rf /", but does cause "cd /;rm -rf *" to prompt for confirmation.

      This only works if there are no other files that are sorted before the '-i' file, naturally!

    64. Re:rm -rf / by Scherpbier · · Score: 1

      That's why you need to create a file called '-i' in every directory you don't want this to happen to!

    65. Re:rm -rf / by ehintz · · Score: 1

      I did better... My boss (IT Director) was having some sort of trouble with something like apache config. So I sent 'im a mail and said "This'll fix all your problems!". He blindly copy/pasted it, hit return, then realized what he'd done and control-c'd.

      Fortunately he's a good guy, and was amused at it all, so we just had a good laugh, restored /var from backups, and got on with life...

      --
      ehintz
    66. Re:rm -rf / by phagstrom · · Score: 1

      PSDoom - very old school console edition.

    67. Re:rm -rf / by TrixX · · Score: 1

      I have actually used sleep 8h; while true; do echo -e '\a'; sleep 0.5; done

    68. Re:rm -rf / by gnud · · Score: 1

      What you get for running as root =)

    69. Re:rm -rf / by Teilo · · Score: 2, Insightful

      It does two things:

      1) It gives you a moment to think.
      2) It forces you to distinguish between commands that can frack your whole system, and commands that will likely only frack a part of it.

      You guys act as if using sudo is an Ubuntu thing. For frack's sake, it predates Linux.

      Since when did living in root ever become a "good thing"? I've been administering Linux systems for 10 years. I was drilled into me then to work as a user, use sudo when necessary, and leave root for those cases where sudo is impractical (in other words - when you have lots of stuff to do as root).

      Unless this is a hubris competition - in which case I'll just say, "Get off my lawn, you damn kids!"

      --
      Mir tut es leid, Menschen daß Einfältigfehlersuchenbaumfolgendenaffen sind.
    70. Re:rm -rf / by Teilo · · Score: 2, Informative

      For recent versions:

      sudo -i

      shorter

      --
      Mir tut es leid, Menschen daß Einfältigfehlersuchenbaumfolgendenaffen sind.
    71. Re:rm -rf / by Anonymous Coward · · Score: 1, Funny

      I keep getting "rm: not found" when I type it in.

      Strangely, the first time I tried it, it just sat there for ages, and then displayed a "#" prompt.

    72. Re:rm -rf / by jubalj · · Score: 1

      CARRIER LOST?

      bull.. i tried it and nothing happened.. just this incessant blinking of my harddisk.. oh well..

    73. Re:rm -rf / by leamanc · · Score: 1

      Yes, please adjust your command as rm -rf ~/ Not quite as damaging, but potentially just as irritating.

      --
      :q!
    74. Re:rm -rf / by Annymouse+Cowherd · · Score: 1

      su -c :P

    75. Re:rm -rf / by g0dsp33d · · Score: 3, Funny
      I love asking my boss any of the following questions regarding a Unix system:
      • What is the undelete command
      • What is the undo command
      • What is the Unix equivalent of CTRL+Z
      --
      lol: You see no door there!
    76. Re:rm -rf / by Omega996 · · Score: 1

      yeah, it does, but time was, it was universally considered a security risk on Open Systems (you know, what old-timers like me call UNIX systems). Just like allowing root login on anything except the console, using sudo was generally considered a bad idea.

      and i'm not disagreeing with you that living as root is generally a horrible idea - i agree with that. but with a locked-down system and a lot of work to do, it's a lot faster to start a shell as root than continually execute 'sudo', especially if you have to type the friggen password every time, as i see you've mentioned.

    77. Re:rm -rf / by LinusMartensson · · Score: 3, Insightful

      This reminds me of when I used DROP on the wrong server and database in MySQL. I love my backups and learned my lessons. Do not work on two things at once unless you are female.

    78. Re:rm -rf / by gmac63 · · Score: 1

      In my fifteen years as a *NIX admin, I have only had three really "OH SHIT!" moments:

      1) when I told a guy over the phone to 'rm -rf /bin' but unknowingly he was at "/". Oooops.

      2) ssh'd into one box, then ssh'd back to the box I was on and ran 'shutdown -h now'. not-so-oooops.

      3) took out a server while in some directory buried in /usr/ and did the same 'rm -rf /bin' thinking I was removing bin/. Doh!!!

      I always run as root. Baaaaaad admin. Bad admin. Sorry guys. It makes one REALLY careful tho.

      --

      INSERT INTO comment VALUE('Doh!') WHERE user='you';
    79. Re:rm -rf / by BrokenHalo · · Score: 1

      real UNIX admins don't sudo - they su - .

      On some systems, it's useful to sudo su.

    80. Re:rm -rf / by andrikos · · Score: 3, Funny
      Does having written rm -r . /var as root in the department mail server counts for the first case?

      A damn space more! Fortunately I realized that it was taking too much time to be the local var so I stopped before going into /var/mail.

    81. Re:rm -rf / by jcuervo · · Score: 1

      You can most certainly go "Oh sh*t!" after typing: sudo cat /dev/urandom > /dev/sda

      Actually, no, you can't. Unless you're already root.

      --
      Assume I was drunk when I posted this.
    82. Re:rm -rf / by BrokenHalo · · Score: 1

      chmod -Rf ug+w

      I've been using Unix for decades, and I never did get to like those verbose switches for chmod. It's so much quicker to use the numeric ones, e.g. 755 vs. +rwxr-xr-x.

      Easy to remember how they work when you consider that 4=read, 2=write and 1=execute and you just add them up as required.

    83. Re:rm -rf / by tzot · · Score: 1

      This is too obvious. You better go to someone who has the habit of running as root all the time, and tell them something along the lines:

      "I'll show you a nice trick. Do the following:

      mkdir -p a/b/c
      cd a
      touch a1 .a0 .a9 b/b1 c/c1

      Now, there are both hidden and non-hidden files in 'a'. You know that if you do a 'rm -rf *', it won't delete the dot-prefixed ones, don't you? The trick is to do a 'rm -rf .*'. Try it."

      Instant success.

      --
      I speak England very best
    84. Re:rm -rf / by g0dsp33d · · Score: 1

      Reminds me of the delightfully morbid glee I got out of running deltree c:/win. Who says you couldn't do anything useful in DOS?

      --
      lol: You see no door there!
    85. Re:rm -rf / by Logic+and+Reason · · Score: 1

      That's why you always type "rm dirname" first, then double-check the dirname, then add the "-rf". Doesn't work on BSDs and Mac OS X (and maybe others), because you have to put rm's switches before the filename(s).

    86. Re:rm -rf / by Annymouse+Cowherd · · Score: 1

      I think your sentence needs cleaned up.

    87. Re:rm -rf / by isilrion · · Score: 1

      Wow. "sleep 8h"? My alarm clock used to be "sleep $((8*60*60))". Thanks, man!

    88. Re:rm -rf / by fishnuts · · Score: 1

      If you're using any modern shell, hit ctrl-v before hitting the backspace key, if you want to pass the backspace character to the command, rather than have it handled by the shell.

      mkdir
      ls -ld ?
      rmdir

    89. Re:rm -rf / by duckInferno · · Score: 1

      I was modifying an old script that somebody had written a long time ago. Part of it finds files in one directory and moves them to another. I eagerly started the test and jumped in to view the log. It was full of mv errors of non-existent files. To my horror the log just kept filling up and up... I tried to kill the script but it wouldn't have it.

      I jumped over to paw through the code and noticed my error: $DATA_DIR wasn't defined.

      find $DATA_DIR/ -name "*" -exec mv -f '{}' $BACKUP_DIR (paraphrased)

      When the script finished half an hour later, almost every single file on the system resided in $BACKUP_DIR. It was restored from backup but we lost pretty much a day's work. Ironically I didn't lose a thing as I still had my script open in memory :)

      --
      Fool me once, shame on you. Fool me twice, watch it -- I'm huge!
    90. Re:rm -rf / by tdknox · · Score: 2, Informative

      Well, unless you're already root, your command will fail with a permission denied error since the > redirect will run with your user permissions, not with sudo permissions.

      So, in that case yes, sudo will prevent an "Oh sh*t!" moment.

      --
      Did you know that gullible is not in the dictionary?
    91. Re:rm -rf / by fishnuts · · Score: 1

      This may also clear out your partition table. I forget where the partition data starts in the MBR, but it's definitely in there somewhere, and generally isn't backed up.

    92. Re:rm -rf / by Chris+Daniel · · Score: 1

      which is a shell builtin, so no, it has no corresponding binary.

      --
      Don't blame me -- I voted for Roslin.
    93. Re:rm -rf / by shonnon · · Score: 1

      Back in my days as a sysmom (a.k.a system admin), I used to joke that "time rm -rf /" was a good disk performance benchmark. One day one of my coworkers had a machine he needed to reinstall, so he brought me back the numbers. :-)

      This was also from the days when there was no rmdir(2) system call - instead rm ran /bin/rmdir whenever it needed to remove a directory (rmdir was setuid root so it could unlink the directory). So after it had cleared out /bin, rm was unable to remove any more directories. He ended up with a skeleton of the root filesystem, with most of the directories but none of the files.

    94. Re:rm -rf / by Curtman · · Score: 4, Informative

      when I told a guy over the phone to 'rm -rf /bin' but unknowingly he was at "/". Oooops

      I don't get it. You told him to give rm an absolute path, it doesn't matter where he was.

    95. Re:rm -rf / by lluBdeR · · Score: 1

      deltree /y c:\windows
      I hate pushing keys

    96. Re:rm -rf / by PuercoPop · · Score: 2, Informative

      Shell built-in? news to me as I have it instaled on /usr/bin/

      My post obviously isn't an actual output but my attempt at a koan. As koan's are supposed to disruput your cognitive process so one can percieve reality as such. Of course you may think it is a sucky koan, but an attemp at least it is.

      You can Mod if Funny now :'(

    97. Re:rm -rf / by g0dsp33d · · Score: 1

      Also:
      pkillall init
      kill -9 -1
      Any thoughts on a recursive kill -HUP? My goal is to find one.

      Disclaimer: don't use *nix commands you found online unless you know what they do.

      --
      lol: You see no door there!
    98. Re:rm -rf / by keeboo · · Score: 1

      That's interesting, but of no real use.

      If you want to make a full HD backup in cheap analog audio media (such as casettes) try this:

      cat /dev/sda > /dev/dsp

    99. Re:rm -rf / by subStance · · Score: 5, Funny

      /dev/random to the dsp device ? I prefer to the midi device, then it sounds like someone throwing a drumkit and grand piano down the stairs at the same time.

      --
      Servlet v2.4 container in a single 161KB jar file ? Try Winstone
    100. Re:rm -rf / by DeathCarrot · · Score: 1

      Haha, reminds me of a gem I wrote a few years back at uni when /dev/pts/* devices were still writeable by anyone.
      for ((i=0;1;i%=4,i++)) do echo -en "\E[3${i};1m"; sleep 0.01; done
      This basically echoes one of four "change colour" commands every 10ms which you can redirect to a /dev/pts to confuse some poor sod. =) Just make sure the person has a sense of humour.
      Use with the yes command for disco-tastic results.

    101. Re:rm -rf / by PinkPanther · · Score: 3, Funny
      What, you enter more than one command in the morning?

      You have a definition for a "short lunch"?

      What the hell kind of sysadmin ARE you?? You certainly don't wear the same brand of suspenders us REAL techies do.

      --
      It's a simple matter of complex programming.
    102. Re:rm -rf / by Maexxus · · Score: 1

      Or alternatively you could use Ctrl+l to clear the terminal, which is rather useful even if you don't have anything to hide.

    103. Re:rm -rf / by Anonymous Coward · · Score: 1, Informative

      That's what sudo -i is for.

    104. Re:rm -rf / by Lillesvin · · Score: 1

      [...] and leave root for those cases where sudo is impractical (in other words - when you have lots of stuff to do as root).

      Or use sudo -s -H, which is great when there's no password set for root (eg. a default Ubuntu install).

      --
      "Live free or don't."
    105. Re:rm -rf / by TheLink · · Score: 5, Funny

      I wonder if anyone has had problems with guiding people to uninstallin stuff like Asterisk over the phone ;).

      e.g.
      A: "Type rm -rf /etc/asterisk
      B: "OK"
      A: "Next..."
      B: "Wait it's not done yet"
      A: "?"
      A: "!"

      Seems like people should be more careful about product directory names ;).

      Don't call your directories stuff like "star" or "slashdot" if you ever might need to get people to remove them over the phone.

      --
    106. Re:rm -rf / by TheLink · · Score: 1

      It depends.

      If the machine is your personal desktop machine, ~/ could be more damaging since that's the unique data is. The rest of the directories can be replaced by a reinstall. If you did / on your personal desktop you'd probably notice before it got to your ~/ ;).

      If the machine is a shared machine or server, then yes / is more damaging.

      BTW we've had silly people who think that the use of ! is a good idea, and they used it production servers, and one day stuff happened ;).

      --
    107. Re:rm -rf / by ndrw · · Score: 2, Insightful

      Clearly, the which which can be which'd is not the true which.

    108. Re:rm -rf / by dysonapr · · Score: 1

      Only sissies sudo...

    109. Re:rm -rf / by simpsop · · Score: 1

      And then there are those of us who.. Oh SHIT! frecover -vxf /dev/rmt/1m -i /stand/system/vmunix

      --
      Application has reported a 'Not My Fault' in module KRNL.EXE in line 0200:103F
    110. Re:rm -rf / by cynicsreport · · Score: 1

      No. People who run as root all the time are either n00bs or morons.

      Good point... Better make that:
      sudo rm -rf /

      --
      - Demosthenes
      cynicsreport.com
    111. Re:rm -rf / by Wilden2003 · · Score: 1

      My best... DELETE FROM table WHERE id = 20 AND 21; Live customer production server. Only a few hundred thousand records tracking several hundred million dollars in transactions. Not a big deal at all. And a horrible call to make... "So was yesterday's backup tape good? How many checks have you cut today?" Fun.

    112. Re:rm -rf / by bm_luethke · · Score: 2, Interesting

      I wrote cluster administration software that scaled roughly into the 5000 node size per cluster (or homogeneous set of nodes - didn't really have to be a cluster).

      Of course, any cluster administration software has a "parallel shell" (even back when I wrote such a thing).

      When I gave tutorials I always used some form of "with great power comes great responsibility" (and that exact quote after the first Spiderman movie) slide and spent a few minutes talking about it. The very next slide simply said "cexec --all rm -rf . /" (--all ran on *all nodes* and *all clusters* in your configuration file - and keep in mind this was a DoE/DoD project so there literally were people with that many nodes).

      You could always tell who the "real" sysadmins were - instant response and no need to talk much about the slide :)

      If you ever want to try out some really big "oh shit" moments work in scalable cluster software administration - not only do you ruin one machine but now you do so with thousands and with efficient start up and execution times you can do so at roughly .00001 extra seconds per node! By the time you realize "oh shit" the command is run and you are dead in the water - yea!!! (rm was one that I pulled out for it's own functionality simply because of that - some people thought that silly until they accidentally did the above).

      --
      ------- Sorry about the spelling, I suffer from two problems. Dyslexia makes it difficult to spell well, lazy makes it
    113. Re:rm -rf / by chthonicdaemon · · Score: 1

      find /home -user `id -u`

      Find prints by default and uname -u does what the sed does. I can't figure out what the {} is supposed to do in the above.

      --
      Languages aren't inherently fast -- implementations are efficient
    114. Re:rm -rf / by hoytak · · Score: 1

      Better is: cat /bin/bash > /dev/dsp

      --
      Does having a witty signature really indicate normality?
    115. Re:rm -rf / by pyropunk51 · · Score: 1

      here is another silly way to kill a machine

      chown -R guest:guest /
      init 6

      --
      double penetration; //ouch
    116. Re:rm -rf / by Pig+Hogger · · Score: 1

      Interesting. Thanks.

    117. Re:rm -rf / by Antique+Geekmeister · · Score: 2, Informative

      Not by me! Sharing root passwords was _nasty_, and sudo provided much better logging of who was going in as root and forcing them to use their own passwords, not a root password.

    118. Re:rm -rf / by dltaylor · · Score: 1

      Very long ago, on a 3B clone running System V:

      Cleaning out the junk .* files in /tmp with rm -rf .* followed very quickly, but too late (obviously), by a ^C.

      If you don't get it, .* includes .. and .. precedes all .[0-9A-Za-z] files.

      Only once and, yes, I had backups (monthly, weekly, and daily, with copies off-site of the weekly), plus it was early in the work day.

    119. Re:rm -rf / by DaleCooper82 · · Score: 1

      Don't panic, just install GNU Utils, put it on your $PATH and try again.

      HTH, D

      --
      :: There is no light at the end of a tunnel. There is a tunnel after a tunnel : Thom Y. ::
    120. Re:rm -rf / by Count+Fenring · · Score: 2, Funny

      Wow. I had never even thought of that.

      Man.... I do sometimes question some decisions made with unix directory operations. Like some of the legal characters in directorynames, for instance. I mean, escaping spaces is all fine and dandy, but what about "/usr/bin/?*&!" Perfectly legal unix filename, but an unholy bitch to deal with. Not that anyone would ever do that with non-malicious motives, but still...

    121. Re:rm -rf / by jroysdon · · Score: 1

      cat /dev/urandom > /dev/dsp

      That's a riot. I ssh'd into my Wife's laptop and had some phone with her. She promptly hit the mute "idiot key" at the top of her keyboard and looked at me and said, "Take that!" I jumped into alsamixer and turned it off and hit the command again. *evil grin*

    122. Re:rm -rf / by jroysdon · · Score: 1

      s/phone/fun

      That was an odd typo, eh?

    123. Re:rm -rf / by beuges · · Score: 1

      Someone did something similar on a production database for the largest cellular provider in South Africa once: UPDATE table SET x = y; (no WHERE clause).

      Now, procedure requires that any queries to the db that modify data are between BEGIN TRANSACTION and COMMIT statements. It's a habit I'm trying to get myself into whenever I query any db.

    124. Re:rm -rf / by Anonymous Coward · · Score: 1, Interesting

      Thinking about it: you're searching for nothing, from nothing. What do you think you're going to find?

    125. Re:rm -rf / by Lavene · · Score: 1

      rm -rf /

      I tried it but sadly my computer seemed to crash before I could get the result. Guess I need to reinstall before I can try it again...

    126. Re:rm -rf / by polymerousgeek · · Score: 1

      I recall doing work on a system once, a server with CA-related stuff primarily on it. I had just generated some new certs, and was going to fix the permissions on them.
      chmod -R go-rwx .

      Except I _slightly_ missed the ".". Oh well, I didn't really need to use that server for next few days or so...

      --
      53 49 47 53 20 53 55 43 4B
    127. Re:rm -rf / by dna_(c)(tm)(r) · · Score: 4, Funny

      42 ?

    128. Re:rm -rf / by JohnVanVliet · · Score: 1

      saying "OH-SHIT after they used the -y in yum to remove something , like part of X11 .

      --
      "I don't pitch OpenSUSE Linux to my friends, i let Microsoft do it for me
    129. Re:rm -rf / by ReedYoung · · Score: 1

      mean, escaping spaces is all fine and dandy, but what about "/usr/bin/?*&!" Perfectly legal unix filename, but an unholy bitch to deal with. Not that anyone would ever do that with non-malicious motives, but still...

      Self-defense is non-malicious, even if it pisses off attackers.
      :p

      --
      "I can't imagine how things could get any worse!" (some guy) "That could just be failure of imaginatioÂn on your p
    130. Re:rm -rf / by polymerousgeek · · Score: 1

      CTRL+D?

      --
      53 49 47 53 20 53 55 43 4B
    131. Re:rm -rf / by Count+Fenring · · Score: 1

      Point, I suppose. s/malicious/perverse/;

    132. Re:rm -rf / by aliquis · · Score: 1

      Or use a filesystem with slow removal of files and directories so you can cancel it ;D

    133. Re:rm -rf / by redhog · · Score: 1

      This is why I nowdays allways write

      rm /foo/bar -rf

      not

      rm -rf /foo/bar

      I once accidentally wrote

      rm -rf / foo/bar

      and then, equally accidentally, slipped and pressed enter before I could fix the problem (I even saw it!).

      With the latter spelling, you have an extra chance to review your command before you tell the system to go berzerk on your root dir.

      --
      --The knowledge that you are an idiot, is what distinguishes you from one.
    134. Re:rm -rf / by mollymoo · · Score: 1

      Tab filename completion is more than just a convenience, it's also a very useful sanity check.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    135. Re:rm -rf / by pato101 · · Score: 2, Informative

      Well, perhaps it depends on your distro. Some shells could have it built-in.

    136. Re:rm -rf / by pato101 · · Score: 1

      real UNIX admins don't sudo

      Specially Spanish real UNIX admins, since sudo means "I sweat", and real UNIX admins do not sweat just as Chuck Norris doesn't.

    137. Re:rm -rf / by jankkhvej · · Score: 1

      DELETE FROM table WHERE id = 20 OR 21; You need an OR clause for fun.

    138. Re:rm -rf / by vrt3 · · Score: 1

      That's why I put the -rf always at the end of the line instead of the beginning. If I accidentally press return before I'm finished (the return and backspace keys far too close to each other, I think), at least the operation isn't recursive.

      --
      This sig under construction. Please check back later.
    139. Re:rm -rf / by sharperguy · · Score: 1

      One day I forgot my password, and the screen was locked.

      However I was still logged in on the vTTY so I ctrl-alt+f1's into it and ran "killall gnome-screensaver" which got me in perfectly.

      --
      "sudo rm -rf your-face"
    140. Re:rm -rf / by Pvt_Ryan · · Score: 1

      I hope he slaps you very hard each time :)

    141. Re:rm -rf / by Malaak · · Score: 1

      cat /dev/zero > /dev/null

    142. Re:rm -rf / by VShael · · Score: 4, Informative

      Pshaw! All 1337 sysadmins just live as root!

      Yes, but all the really stupid ones do as well.

    143. Re:rm -rf / by fzimper · · Score: 1

      a real Ubuntu admin uses sudo bash

    144. Re:rm -rf / by SuurMyy · · Score: 1

      How about mv /etc/asterisk /etc/asterisk.old ? Also, I often mv things to /tmp instead of rm them.

      --
      The lyf so short, the craft so long to lerne
    145. Re:rm -rf / by MikeDirnt69 · · Score: 2, Funny

      No, that is the answer for the opposite!

      --
      Am I eval()? - http://www.monst3r.com.br
    146. Re:rm -rf / by MikeDirnt69 · · Score: 5, Funny
      I prefer this one:

      $ touch woman

      But I always get this back:

      $ touch: woman: Permission denied

      :(

      --
      Am I eval()? - http://www.monst3r.com.br
    147. Re:rm -rf / by danieltdp · · Score: 1

      alias nowhere="find /" && alias nothing="rm -rf && for file in `nowhere`; do nothing; done

      --
      -- dnl
    148. Re:rm -rf / by dyingtolive · · Score: 1

      Really? On RHEL 5 it actually works: [brad@icarus ~]$ which which alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' /usr/bin/which

      --
      Support the EFF and Creative Commons. The war is coming, and they're supporting you...
    149. Re:rm -rf / by that+this+is+not+und · · Score: 1

      don't be redundant.

    150. Re:rm -rf / by jsolan · · Score: 5, Funny

      puercopop@localhost ~ $ which which
      which: no which in (/usr/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2:/usr/qt/3/bin:/usr/games/bin)

      Burn her anyway!

    151. Re:rm -rf / by eta526 · · Score: 1
      r..... m..... -r....... f..... /

      Read Mail -Really Fast /

    152. Re:rm -rf / by RichiH · · Score: 1

      Define 'all the time'. From the context of what you replied to, I suspect you mean 'all the time while doing system maintenance work' and not 'all the time while browsing /.'.

      If you mean to imply that everyone who uses

          su -

      and stays there as long as he needs to do stuff then you misunderstand what sudo was meant to do. *Ubuntu might have made the 'sudo for everything' approach common, but that does not mean it makes any sense. It means you have a single password for your account and for sudo which usually looks like

      cooluser ALL=(ALL) ALL

      which helps against the occasional typo which would destroy your system, but opens up a whole new can of worms and trains the user in wrong behavior. On my systems, you get a bright red prompt while your UID is 0 and on remote hosts the $PS1's color is inverted for making you _really_ aware of where you are.

      And even if you restrict sudo to 'most' programs, those programs will usually be able to write to the filesystem and/or spawn a shell.

    153. Re:rm -rf / by SCHecklerX · · Score: 2, Funny

      Recently a co-worker did the oh shit thing. What is the normal unix flag for increasing verbosity of feedback from a command? Now go man pkill and use your imagination on what happened. :-)

    154. Re:rm -rf / by sidnelson13 · · Score: 1

      you first need to "sudo chmod -R 777 /"

    155. Re:rm -rf / by quarterbuck · · Score: 1

      This was way back when we were in college and we got our logins to our first Unix account.
      Some idiot decided to email a file called "*" to everyone.

      --
      http://slashdot.org/submission/1062723/Cheap-mobile-data-plan?art_pos=2
    156. Re:rm -rf / by famebait · · Score: 1

      Here's a classic blunder I've both done and seen others who really should know better do:

      "OK, let's just clear this whole dir tree so we know
      what we're testing.
      "

      # rm -rf *

      "Damn, all those pesky dot-files and -dirs are still there."

      # rm -rf .*

      --
      sudo ergo sum
    157. Re:rm -rf / by Fumus · · Score: 1

      And aren't those the target audience for this trick?

    158. Re:rm -rf / by famebait · · Score: 1

      All 1337 sysadmins

      Does not compute. People who write "1337" are at best "n00b"s in the world of sysadmins.

      --
      sudo ergo sum
    159. Re:rm -rf / by juanfe · · Score: 1

      Since when did living in root ever become a "good thing"?

      At around the same time that sarcasm detection became a necessary skill for a good sysadmin.

      --
      ***Foucault is watching you..***
    160. Re:rm -rf / by tritonman · · Score: 1

      I've said Oh Shit many times, but usually because I have 3 or 4 unix consoles open to different servers and I end up killing processes on one production server when I meant to do it on a different server.

    161. Re:rm -rf / by famebait · · Score: 1

      Do nothing really fast:

      cat /dev/urandom > /dev/null

      --
      sudo ergo sum
    162. Re:rm -rf / by eugene+ts+wong · · Score: 1

      Hmm, that's a very good suggestion. Thank you for explaining the advantage. I didn't quite understand at first. It's very clever, actually.

    163. Re:rm -rf / by drakaan · · Score: 1

      That's a bit of wisdom I'll remember. I'm more of a grep/awk/kill kinda guy, but an option like that for any *nix command is not one to overlook. In fact, it seems almost like a joke. -n is for newest (and could be -r for "recent"), which is the only reason -v is used there? I sense a super-BOFH in action...now you're going to make me grep all man pages for "-v", aren't you?

      --
      "Murphy was an optimist" - O'Toole's commentary on Murphy's Law
    164. Re:rm -rf / by MoogMan · · Score: 1

      In all seriousness, rm these days won't let you do that.

      If you *really* wanted to do that, you will have to also specify --no-preserve-root

    165. Re:rm -rf / by beerbear · · Score: 1

      Totally OT: your sig is pretty close to German, but not quite there yet. Mensch has an 's' in it. the order of 'Menschen' and 'das' is wrong, and 'das' should be written as 'dass'. And don't get me started on 'einfältigfehlersuchenbaumfolgendenaffen'. :-)
      Iss zere ä speciäl pläize rezerwett in hell vor Germann grammarr Nazis? :)

      --
      Hold my beer and watch this!
    166. Re:rm -rf / by Yetihehe · · Score: 1

      Yeah? Try removing ncurses.. You can't even compile it anymore...

      --
      Extreme Programming - Redundant Array of Inexpensive Developers
    167. Re:rm -rf / by MoogMan · · Score: 1

      echo "Wake up you lazy $£"$^" | festival --tts

    168. Re:rm -rf / by Skrynkelberg · · Score: 2, Insightful

      I laughed.

    169. Re:rm -rf / by jsight · · Score: 1

      I don't think I get what you are saying. On Linux that will clear all the pesky dot-files and -dirs (not including ..) just as you would want. On what OSes does this kill you, and in what way?

    170. Re:rm -rf / by MikeBabcock · · Score: 1

      rm -rf .. is entertaining too.

      --
      - Michael T. Babcock (Yes, I blog)
    171. Re:rm -rf / by MikeBabcock · · Score: 1

      Feel free to dd if=/dev/zero over its blocks.

      Of course, you'd probably want something else there instead.

      --
      - Michael T. Babcock (Yes, I blog)
    172. Re:rm -rf / by pedestrian+crossing · · Score: 1

      chmod -Rf ug+w

      I've been using Unix for decades, and I never did get to like those verbose switches for chmod. It's so much quicker to use the numeric ones, e.g. 755 vs. +rwxr-xr-x. Easy to remember how they work when you consider that 4=read, 2=write and 1=execute and you just add them up as required.

      The "verbose" switches are good if, say, you have varying user permissions on the files which you want to keep intact, but you want to change all of the group permissions to be the same. Using the numbers would wipe out the varying user permissions. Using the g switch would leave the user permissions alone while setting all of the group permissions...

      --
      A house divided against itself cannot stand.
    173. Re:rm -rf / by TheGreatOrangePeel · · Score: 1

      ...speaking of /var/mail reminds me of a bash script I wrote that did a `cat "$fname" | mail -s "Alert!" user@myWorkEmail.com`. Yea. That was in an infinite loop and while I had port 22 (SSH) forwarded to the machine in question, the network at work had all communication to the outside world on that port blocked and I had gotten a lift from a co-worker that morning. Needless to say, I didn't get much email-ing done that day.

    174. Re:rm -rf / by rew · · Score: 1

      Client of mine says he's putting data on an external drive, but then the drive shows up empty on the other computer.

      Turns out he was formatting and writing to sdb1 instead of sdc1. One of the internal drive's partitions. Ooops!

      After figuring that one out I get to clean up the mess. sdb1 is supposed to be a swap partition. mkswap /dev/sdb2 .... Ooops typo! that was supposed to be sdb1! sdb2 is their active data partition.... He'd been formatting their (never used: someone had made a typo) swap partition. I had overwritten (part of) their data partition....

      Oh shit!

    175. Re:rm -rf / by Short+Circuit · · Score: 1

      sudo is for ubuntu wannabes - real UNIX admins don't sudo - they su - .

      "sudo su" ?

    176. Re:rm -rf / by CrazedSanity · · Score: 1

      Priceless. I actually made an audible giggle to that one... that's geek humor if I ever heard it.

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    177. Re:rm -rf / by CrazedSanity · · Score: 1

      Yeah, because logging in as root is much more secure than sudo. I bet you were one of those that said using regular keys was much more efficient than RFID FOB/tags, right? (I mean, why reissue one key/FOB when you could just rekey all the doors and reissue all new keys?)

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    178. Re:rm -rf / by CrazedSanity · · Score: 1

      AMEN!

      Wait, you forgot one other possible sentiment: "Wow, this sure is taking a long time..."

      (and THAT is why directories, especially off the root or "/" partition, should NEVER have a capitol letter or spaces.... ["rm -rf / S tupid"])

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    179. Re:rm -rf / by X0563511 · · Score: 2, Funny

      1/42?

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    180. Re:rm -rf / by Short+Circuit · · Score: 1

      Mine was similar in my first few months of coding. Code-assembled SQL query "DELETE FROM table" + "WHERE id = x", except there was a fringe race condition where the "WHERE id = x" append could be skipped. Customer called and said the program had locked up for several minutes. Learned several lessons from that one....

    181. Re:rm -rf / by VShael · · Score: 2, Insightful

      And aren't those the target audience for this trick?

      Maybe. But as Wil Wheaton says "Don't be a dick."

      This is the Useful/Stupid Unix Tricks thread. Not the Malicious Unix tricks thread.

    182. Re:rm -rf / by CrazedSanity · · Score: 1

      root@linux:/# rm -rf / stupid\ directory\ from\ windows\ user
      rm: cannot find libc.so.6

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    183. Re:rm -rf / by BrokenHalo · · Score: 1

      Using the g switch would leave the user permissions alone while setting all of the group permissions...

      Yes, I know. And I realise my post was a (perhaps over-)simplification, given that the permissions thing can be quite fine-grained.

      But the numbers don't "wipe out" anything. Ignoring suid bits, the owner (the first digit of the triplet) of the file is the owner, which doesn't change. The group = the second digit, and everybody else the third. I don't see how one is more secure than the other.

    184. Re:rm -rf / by CrazedSanity · · Score: 2, Funny

      root@linux:/# cd lib
      root@linux:/lib# ls lib
      [...hacker-injected garbage...]
      root@linux:/lib# rm -rf . /lib

      BOSS: "Boy, this sure is taking a long time."

      root@linux:/lib# ERROR: rm: cannot load libc.so.6

      SYSAD: "But I told you to rename slash-lib-slash-lib to slash-lib-slash-garbage, just in case. Did you..."

      sysadmin@linux:# ls /lib
      ls: cannot load libc.so.6

      SYSAD: [silence, waiting for BOSS to understand what he did, and why he shouldn't have root]

      BOSS: "Yeah, I got this error about 'libc.so.6'"

      SYSAD: "I know. You deleted slash-lib, because you didn't do the rename like I told you to."

      BOSS: "Oh... damn..." (frantic clicking ensues, trying to cancel job)

      SYSAD: "I'll meet you at the office. Bring beer: it's going to be a long night."

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    185. Re:rm -rf / by houghi · · Score: 1

      chmod 666 / -R

      --
      Don't fight for your country, if your country does not fight for you.
    186. Re:rm -rf / by CrazedSanity · · Score: 1

      SYSAD: "I think I need to see the boss before you do."

      SALES: "Why?"

      SYSAD: (wipes brow, feels face turning red) "Its important."

      SALES: (laughs) "Pfft. What did you do? Delete the webserver?"

      SYSAD: (opens mouth, sweats more)

      SALES: (covers mouth to muffle louder laughing) "Holy crap... do you want me to be here to witness your death?"

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    187. Re:rm -rf / by houghi · · Score: 1

      For that reason I have trained myself to type `rm /bin -rf` so the -rf at the end. Especially useful when using [tab] to finish directory names. It gives you the half a second to register that you did not type the right directory `rm /bin -rf` instead of `rm bin -rf`

      --
      Don't fight for your country, if your country does not fight for you.
    188. Re:rm -rf / by 4D6963 · · Score: 5, Funny

      Mediocre minds think alike. Great minds are unique.

      My thoughts exactly.

      --
      You just got troll'd!
    189. Re:rm -rf / by ncc74656 · · Score: 1

      Clearly, the which which can be which'd is not the true which.

      She turned me into a newt!

      --
      20 January 2017: the End of an Error.
    190. Re:rm -rf / by LucidBeast · · Score: 1

      I think you have pointed out what is problem is.

    191. Re:rm -rf / by FooAtWFU · · Score: 1

      The UNIX equivalent of Ctrl+Z? I believe that would be Control-D. I actually prefer the MS-DOS version because 'Z' is the 26th letter and EOF is ASCII character number 26, so it makes sense, but I can deal with it one way or another. ;)

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
    192. Re:rm -rf / by Blackknight · · Score: 1

      A lot of my boxes have a /trash file system, after I'm absolutely sure I no longer need the files I rm them.

    193. Re:rm -rf / by Sancho · · Score: 1

      That's not actually portable. Most non-Linux Unixes require the options to be first. But you can

      rm /foo/bar and then ctrl-b back to the place where you need to type "-rf" and insert it there.

    194. Re:rm -rf / by Omega996 · · Score: 1

      sharing root passwords? how many people would you give root access, besides the admin and his/her backup?

    195. Re:rm -rf / by Omega996 · · Score: 1

      no, the point i was trying to make is that 'real' admins don't have sudo installed on their servers, but seeing as how most UNIX admins nowadays are actually Linux hobbyists, it fell flat. Kind of like saying that you learned to use grep and awk, because your server doesn't have a licensed C compiler, no perl, and company policy doesn't allow you to install software that does not pertain directly to a server's particular role. the response isn't "Man, i remember that crap, or I understand", it's "d00de, ur OS doesn't come with a free-as-in-beer compiler? that's so '80s! why don't you just download the gcc compiler and free your box from the chains of its corporate oppressors, man!"

      aaaah, fuck it. why bother...

    196. Re:rm -rf / by ctnp · · Score: 1

      cmr:/home/cmr/sandbox/freroot/lib/fre> echo $SHELL /bin/tcsh
      cmr:/home/cmr/sandbox/freroot/lib/fre> which which
      which: shell built-in command.

    197. Re:rm -rf / by OutOnARock · · Score: 1


      Do not work on two things at once unless they are both female.

      There...fixed that for ya!

    198. Re:rm -rf / by Omega996 · · Score: 1

      from a software standpoint, when sudo vulnerabilities were quite common, yes it was a lot more secure.

      from a permission restriction standpoint, it's about a wash, provided you're using a 'wheel'-type group for either su or sudo. having a user be able to 'sudo' using his/her own password is significantly less secure, i think anyone can agree.

      I've only worked with AIX, HP-UX, and really old versions of Solaris, but I don't recall sudo being part of any of those operating systems.

    199. Re:rm -rf / by Omega996 · · Score: 1

      oh, and by the way, it's somewhat more difficult to have a key duplicated that says 'do not duplicate' than it is to pull data from an RFID device.

      provided, of course, you're not a locksmith or have access to key blanks.

    200. Re:rm -rf / by DansnBear · · Score: 1

      A fake letter from your fake boss on some fake letterhead giving you permission to copy the keys is all that's needed.

      --

      -= Who are The Headlocks? =-
    201. Re:rm -rf / by habig · · Score: 1

      I once moved /var/mail to /tmp on a Solaris machine, while trying to re-arrange partitions for some more room. Then rebooted.

      The machine comes back up, and I learned that /tmp on Solaris was set to be a ramdisk by default.

      Oops. My boss back then (more than a decade ago) still reminds me about losing years of his mail. (don't remember why we didn't have that backed up, Yet Another Lesson).

    202. Re:rm -rf / by jam244 · · Score: 1

      Here I am thinking for 2 minutes what the hell you actually did with the phone.

    203. Re:rm -rf / by portscan · · Score: 1

      sudo -s works
      (brings up a shell)

    204. Re:rm -rf / by Omega996 · · Score: 1

      hmmm, have you tried that? i couldn't get duplicates made of keys with the 'do not duplicate' made, even with a phone call from the company.

    205. Re:rm -rf / by gowen · · Score: 1

      What is the Unix equivalent of CTRL+Z

      That one's easy : kill -STOP <PID>

      --
      Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
    206. Re:rm -rf / by CrazedSanity · · Score: 1

      I think requiring the user to know the target accounts password--i.e. root--is more problematic. Sure, doing it that way means they have to know enough to be able to do it (the password)... but what happens when there's 20 people that need to do administrative actions? If the root password gets compromised, or one of them is a contractor, that password has to be changed for security reasons whenever somebody leaves: this creates the need to re-distribute the new password. And knowing the root password opens the possibility for them to bypass sudo and go directly for root.

      On the other hand, as long as a password is *required*, if some user in the "wheel" group leaves, they can be removed from the group and their account disabled. The root password should be something that is very complex and stored in a secure place, for the sole purpose of needing to login to the physical machine as root.

      Here's my preferred methodology:
        1.) SSH Access
                  1.1.) users MUST use key-based authentication to login (passwords are insecure and can be retrieved through local key-loggers)
                  1.2.) access explicitly granted to users via the sshd_config file
                  1.3.) root access (via ssh) is explicitly DENIED.
        2.) sudo access
                  2.1.) for users with godly power, add them to the wheel group for unlimited access (this is allowed for a very small group of people, usually one or two)
                  2.2.) users with specific needs get those via groups and group aliases in the sudoers file with access to a very explicit set of commands
                  2.3.) require user's password (avoids giving out root access; users many times will just bypass sudo and go straight to root)
        3.) removing users
                  3.1.) removing key from "~/.ssh/authorized_keys"
                  3.2.) remove user from sshd_config file as an authorized user
                  3.3.) remove user from group

      With #3, there's always the simplest option of just deleting their account (after backup), though the sshd_config should also be updated for cleanliness.

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    207. Re:rm -rf / by dfn_deux · · Score: 1

      I've never seen a [ $[ ] ] construct before, what shell is that used in?

      --
      -*The above statement is printed entirely on recycled electrons*-
    208. Re:rm -rf / by Delkster · · Score: 1

      Seems to work on bash, and checkbashisms doesn't complain about that either (it complains about $RANDOM, though).

      No, I didn't try it with the "rm -rf /" part.

    209. Re:rm -rf / by FictionPimp · · Score: 1

      here was my recent o'shit moment.

      at midnight `shutdown -r now`

      That was bad LOL.

    210. Re:rm -rf / by Omega996 · · Score: 1

      you make some good points, particularly WRT key-based auth and the ease of getting rid of users with access to elevated functions (short of the people who know root's pw, or have access to it).
      well done - you've made a believer out of me.

    211. Re:rm -rf / by FictionPimp · · Score: 2, Informative

      Here we have 5 people with root access on our web server. Who do you blame if root deletes /var/www?

      With sudo I know exactly who to blame.

    212. Re:rm -rf / by FictionPimp · · Score: 1

      I've done it twice at a walmart without anyone even questioning me.

    213. Re:rm -rf / by McNally · · Score: 3, Funny

      I prefer this one:

      $ touch woman

      But I always get this back:

      $ touch: woman: Permission denied

      Try doing it in your own home for better results..

    214. Re:rm -rf / by idontgno · · Score: 1

      That's been one of my longstanding sysadmin mottos: "If you haven't had to reload a production system from release media, you aren't trying hard enough."

      My own "Oh shit" moment was with this command (as, of course, root, and at the system root):

      rm -rf /Rubbish"

      Why is that bad? Well... on QWERTY keyboards, the right SHIFT key is disconcertingly close to the ENTER key... so shift-R turned into "<ENTER>r", which turned into deleting most of /bin in the 10 or so seconds that I was frozen in blind panic.

      Yeah, not really catastrophic; "rm" responded to ^C quickly enough, but it still had that potential.

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    215. Re:rm -rf / by chkn0 · · Score: 1

      ROLLBACK;

    216. Re:rm -rf / by Kiaser+Zohsay · · Score: 1

      Clearly, the which which can be which'd is not the true which.

      She turned me into a newt!

      I got better ...

      --
      I am not your blowing wind, I am the lightning.
    217. Re:rm -rf / by josecanuc · · Score: 1

      Have you tried taping over the "DO NOT DUPLICATE" stamp with a piece of masking tape? Just write something like "Bldg 5" or some other label on it.

      I doubt most duplicators of keys would peel off the tape.

    218. Re:rm -rf / by camperdave · · Score: 1

      If the emtpy set is contained in the empty set, is the empty set really empty?

      --
      When our name is on the back of your car, we're behind you all the way!
    219. Re:rm -rf / by jrockway · · Score: 1

      Please allow me to introduce you to the words "BEGIN TRANSACTION".

      --
      My other car is first.
    220. Re:rm -rf / by rugatero · · Score: 2, Funny

      I prefer this one:

      $ touch woman

      But I always get this back:

      $ touch: woman: Permission denied

      Try doing it in your own home for better results..

      Depends. He might still live with his mother.

      --
      This comment is for entertainment purposes only. Any similarity to real insight or information is purely coincidental.
    221. Re:rm -rf / by rugatero · · Score: 1

      Do not work on two things at once unless you are female.

      Do not work on two things at once unless they are female.

      There, fixed that for you.

      --
      This comment is for entertainment purposes only. Any similarity to real insight or information is purely coincidental.
    222. Re:rm -rf / by famebait · · Score: 1

      On real unix it does (or at least used to) match '..'
      And when the recursive flag is on...

      --
      sudo ergo sum
    223. Re:rm -rf / by jamespharaoh · · Score: 1

      • What is the Unix equivalent of CTRL+Z

      Actually, ctrl+_ works in places like bash and readline programs...

    224. Re:rm -rf / by ComaVN · · Score: 1

      It's not contained in the empty set, it is a subset of the empty set (though obviously not a proper subset)

      --
      Be wary of any facts that confirm your opinion.
    225. Re:rm -rf / by JAZ · · Score: 1

      'man test' for more info.

      --


      "Karma can only be portioned out by the cosmos." -- Homer Simpson
    226. Re:rm -rf / by The+MAZZTer · · Score: 1

      Install cygwin and try again.

    227. Re:rm -rf / by Anonymous Coward · · Score: 1, Funny

      @ your sig -

      Sniff a republican, smell an oppressor

    228. Re:rm -rf / by chrome · · Score: 1

      I've got a system for that; the naming convention for servers should include a character that designates whether it is production, staging, test or development. The PS1 environment variable has the hostname in the prompt a different colour for each environment. Red for prod, yellow for staging, blue for test, green for development. Or something like that. One place I am at aliases rm to rm -i. I think thats a bit paranoid, but might be worthwhile on critical servers where the requirement to actually remove files in a manual way is pretty rare.

    229. Re:rm -rf / by Antique+Geekmeister · · Score: 1

      Depends on the server. For a hosted server, the client and the local admin need access. For a development server, the developers and the admin need access. For a personal box on the network, owned by someone comfortable with their own amdinistration, I still want root access as the admin so I can do critical updates when they're not available or arrange changes in backups at need. In a large deployed environment, there may be half a dozen admins with different shifts and days on call that need access.

      Even your 'admin and their ackup' are two people.

    230. Re:rm -rf / by Lord+Kestrel · · Score: 1

      That's why I've taken to using --version. Most tools these days handle the long-options, and those that don't generally freak out at the double dash.

    231. Re:rm -rf / by zooblethorpe · · Score: 1

      Gah!

      --
      "What in the name of Fats Waller is that?"
      "A four-foot prune."
    232. Re:rm -rf / by makomk · · Score: 1

      Errm... you do realise that -v does exactly the same thing for grep as it does for pkill, right? In fact, I'm guessing this is where it comes from. (Also, it looks like there are some good possible reasons for using the -v argument to pkill; for example, "pkill -v -u root" should kill all processes not belonging to root.)

    233. Re:rm -rf / by Kymermosst · · Score: 2, Informative

      The reason pkill uses -v to negate the match is because it is a variation on the pgrep command, which is used to grep for processes. So, its options are much more like grep.

      So, what option does grep use to negate the match?

      --
      "Alcohol, Tobacco, Firearms, and Explosives" should be a convenience store, not a government agency.
    234. Re:rm -rf / by Kymermosst · · Score: 1

      Yeah, well, real admins learned to type on their own and never use the right-shift key.

      --
      "Alcohol, Tobacco, Firearms, and Explosives" should be a convenience store, not a government agency.
    235. Re:rm -rf / by JCholewa · · Score: 2, Funny

      Unless he meant that there are only about thirteen hundred of them out there. It sure would explain why people ask me to fix their computers so darn often.

    236. Re:rm -rf / by JCholewa · · Score: 2, Informative

      I'm guessing IHBT, but here's an explanation for those who don't quite get it:

      He typed: at midnight `shutdown -r now`
      He meant to type: at midnight "shutdown -r now"
      The "at" command schedules the command in quotes to run at midnight. Putting backquotes around the command, as he actually typed, causes the command to be run immediately.

    237. Re:rm -rf / by ldbapp · · Score: 1

      Ich bin es leid, Menschen daÃY einfÃltigfehlersuchenbaumfolgendenaffen sind.

      Should be "Mir tut es leid, daÃY Menschen ...", but the rest is right on the money.

    238. Re:rm -rf / by zaxus · · Score: 1

      The flagon with the dragon has the brew that is true!

      --
      /. zen: Imagine a Beowulf cluster of Beowulf clusters...
    239. Re:rm -rf / by Short+Circuit · · Score: 1

      You never dialed into a BBS with a modem that used error correction?

    240. Re:rm -rf / by Breakfast+Pants · · Score: 1

      It should have been $(( $RANDOM % 6)), not $[...] which isn't legal bash.

      --

      --

      WHO ATE MY BREAKFAST PANTS?
    241. Re:rm -rf / by n9hmg · · Score: 1

      Lame, some poor bastard might actually do that. They'd have to add sudo of course but still

      Actually, if it were "some poor bastard", he wouldn't need to add sudo, because he'd already be doing everything as root.

    242. Re:rm -rf / by Short+Circuit · · Score: 1

      Mine was more straightforward and nasty. He started it...

      harass.sh:
      dd if=/dev/urandom bs=1K count=1|write $1

      crontab -e:
      */2 * * * * /users/students/me/bin/harass.sh them

    243. Re:rm -rf / by Short+Circuit · · Score: 1

      It's a very trippy experience, when it reaches uncompressed sound files they will be outputted correctly.

      Assuming they're raw PCM with the correct number of channels and with the right byte order.

    244. Re:rm -rf / by Short+Circuit · · Score: 1

      In ancient days of DOS, nc was a godsend and ndd a miracle cure. It wasn't until the dark days whence Symantec began uttering Windows utilities unto the world that the Norton brand became a curse to be feared rather than a blessing to be enjoyed.

    245. Re:rm -rf / by deniable · · Score: 1

      Yup, I did that one with crontab -r (for read) I've never made that mistake again.

    246. Re:rm -rf / by zeugma-amp · · Score: 1

      That's been one of my longstanding sysadmin mottos: "If you haven't had to reload a production system from release media, you aren't trying hard enough."

      Yup. That's why one of my standard interview questions, is "Please desctibe for me the most spectacular manner in which you've taken out a production box".

      I consider it a great 'character' question, as Ireally don't trust people who say they've never done it.

      --
      This is an ex-parrot!
    247. Re:rm -rf / by Bruce+Losis · · Score: 1

      or `grep -v "" /dev/null'

      --
      Don't believe the nonsense, unless you hear it from me directly.
    248. Re:rm -rf / by Hitechwizard · · Score: 2, Funny

      kill woman

      -bash: kill: woman: arguments must be process or job IDs

      Even in Linux you can't bash or kill woman - it requires an argument and I'm sure the job ID is really a reference to your paycheck.

    249. Re:rm -rf / by j79zlr · · Score: 1

      I know, I was joking, mod gods be damned.

      --
      I'm not not licking toads.
    250. Re:rm -rf / by Veni+Vidi+Dormi · · Score: 1

      works for bash 3.2
      for the chickens:
      [ $[ $RANDOM % 6 ] == 0 ] && echo "hit" || echo "miss"

    251. Re:rm -rf / by krenshala · · Score: 1

      or sudo bash

      --

      krenshala

    252. Re:rm -rf / by krenshala · · Score: 1

      Ja

      --

      krenshala

    253. Re:rm -rf / by redhog · · Score: 1

      It has nothing to do w Linux. It's a GNUism. And the first thing I do when trapped in a damn Solaris box (or other junk like that) is to install GNU.

      --
      --The knowledge that you are an idiot, is what distinguishes you from one.
    254. Re:rm -rf / by SharpFang · · Score: 1

      So many replies and I still don't see the No. People who run as root all the time are either n00bs or morons. contradicted.

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    255. Re:rm -rf / by SharpFang · · Score: 2, Funny

      Blah.

      $cd somefolder
      only junk
      $rm -Rf *
      somejunkfile: permission denied.
      $su -
      Password:
      #rm -Rf *

      It was Solaris, ~root was /

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    256. Re:rm -rf / by FictionPimp · · Score: 1

      Thanks, I figured if I explained why it wouldn't be as funny to those who know why.

    257. Re:rm -rf / by CheShACat · · Score: 1

      ... how about "sudo -s"?

    258. Re:rm -rf / by mattcasters · · Score: 1

      Yes, finally some common sense! Now that I haven't been a professional sysadmin for more than a decade, I tend to be even more careful. I'm not really that up-to-date on the latest skillz but I still remember the dangers and the blunders I made in the past.

      Over time you learn to copy/move stuff in stead of simply removing it.

      From the comments I guess there are a lot of wannabe sysadmins on Slashdot with trigger happy "rm -rf" fingers. Learning how to use an Ubuntu installer doesn't really qualify you I guess :-)

      --
      News about the Kettle Open Source project: on my blog
    259. Re:rm -rf / by CheShACat · · Score: 1

      No one wants to feed the troll...

    260. Re:rm -rf / by CheShACat · · Score: 1

      PROTIP: shopt -s dotglob

    261. Re:rm -rf / by SuurMyy · · Score: 1

      I prefer /tmp, when I need only temporary storage, or a temporary backup in case something goes wrong w/what I'm doing at a given moment.

      I also backup all relevant dirs like home-dirs and the like, but have an exception to the rule, $HOME/nobackup. I often put tarballs and stuff like that there that I don't want to look for again.

      --
      The lyf so short, the craft so long to lerne
    262. Re:rm -rf / by CheShACat · · Score: 1

      Similarly, if one of those 5 accounts is compromised, you can see that someone is trying to brute force the root password before it is broken.

      If you cant trust someone with root privileges not to rm -rf /var/www then why the hell give them root in the first place?

    263. Re:rm -rf / by idontgno · · Score: 1
      Complex admins were taught to type at age 7...on a mechanical typewriter...because their teachers wisely saw that their handwriting would never be legible.

      Oh, well, at least the keyboarding style I learned on that ancient Olympic served me well at my first programming terminals.

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    264. Re:rm -rf / by StewBaby2005 · · Score: 1

      I haven't tried this on all Unix or Linux variants, but I believe this will not work, unless you want to press 'Y' 100k times. The correct method is echo 'Y' | rm -r /* The Unix tip I use most is 'xp' in vi to flip the last two characters

    265. Re:rm -rf / by arth1 · · Score: 1

      Indeed.
      People who swear by sudo instead of "su -" think that those who do "su -" stays in the environment after using it. Not so, once you're done, you CTRL-D back to the normal user again.

      And the reason for wanting to use "su -" instead of "sudo" is that "su -" will load root's environment, avoiding the possibility of environment variables set up before calling sudo affecting the command. Like $PATH for the user including, say, /usr/local/bin or even ~/bin before the system paths, and the script you sudo then calls other binaries than the system ones. As root. Similar for other environment variables. This is a major security problem with sudo.
      Especially bad are the systems (mostly Ubuntu-based) that allows wildcards for sudo execution, and even sets env_editor by default, allowing the users to run their own favourite editor AS ROOT. I shouldn't even have to say why this is a bad idea.

      If you really have to use sudo on a system where security of the least importance, at least make sure that every command listed in sudoers is wrapped in a script (or binary) that strips all environment information.

      Better yet, just use "su -". Preferably followed by "chmod go-x /usr/bin/sudo".

    266. Re:rm -rf / by jcuervo · · Score: 1

      I prefer (Ctrl-O gets you back. ;-))

      --
      Assume I was drunk when I posted this.
    267. Re:rm -rf / by myz24 · · Score: 1

      not to mention, su - username -c command

    268. Re:rm -rf / by bluelip · · Score: 1

      Don't know how the parent is funny, but....

      `fortune -o` is most of the time.

      Make sure to add the '-o'

      --

      Yep, I never spell check.
      More incorrect spellings can be found he
    269. Re:rm -rf / by dfn_deux · · Score: 1

      That is what I thought. Any reference for the claim that it isn't "legal" in bash? I've never seen it used before, but I want to know where I can expect this to work.

      --
      -*The above statement is printed entirely on recycled electrons*-
    270. Re:rm -rf / by LinusMartensson · · Score: 1

      The question is, should I vote this funny or insightful?

    271. Re:rm -rf / by poopdeville · · Score: 1

      I've done that once or twice myself. But then I wrote an xmonad 'plugin' to color code my xterms by server.

      --
      After all, I am strangely colored.
    272. Re:rm -rf / by Brad+Eleven · · Score: 1

      It's one of the builtins that also has an analogous script/executable in /usr/bin, for when you're running /bin/sh or somesuch as root.

      ObTrivia: Until a few years ago, Sun was still shipping basename(1) as a one-liner using expr(1). Then someone found a way to break it.

      --
      "Press to test."
      (click)
      "Release to detonate."
    273. Re:rm -rf / by FictionPimp · · Score: 1

      Sometimes you don't have a choice.

      I had to give root access to someone the other day who I know for a fact WILL fuck up the machine he is using. The guy has no unix training at all and even asked me where the desktop was.

      But I am not the boss, however I can prove it was not my fault when he tries (oh and he will) to blame me for his fuckups.

    274. Re:rm -rf / by ModernGeek · · Score: 1

      You were using DOS and Windows 3.1 in 1998?

      --
      Sig: I stole this sig.
    275. Re:rm -rf / by jon3k · · Score: 1

      interesting, what does that do exactly? ctrl+o didn't fix it by the way, but a $reset did.

    276. Re:rm -rf / by jon3k · · Score: 1

      what you described is why I have a specially crafted shell script called "s" that handles that setup for me.

      $s yum update

      is actually much more convenient than using su - and then having to drop back out (and let's admit the truth - forgetting to drop back out sometimes)

    277. Re:rm -rf / by jon3k · · Score: 1

      One little thing I use quite a bit is:

      $pgrep [process] | xargs kill

    278. Re:rm -rf / by jcuervo · · Score: 1

      Apparently, 0x0e and 0x0f are ASCII SI ("shift-in") and SO ("shift-out"). I guess the idea was to switch the terminal to and from an alternate character set or something? I dunno.

      (I meant Ctrl-O in the same context -- e.g., <Ctrl-V><Ctrl-O><Enter>. The magic happens when bash echoes it to the terminal in a "command not found" message. A /usr/bin/reset will fix it, too.)

      --
      Assume I was drunk when I posted this.
    279. Re:rm -rf / by Oryn · · Score: 1

      puercopop@localhost ~ $ which which

      which: no which in (/usr/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2:/usr/qt/3/bin:/usr/games/bin)

      Burn her anyway!

      tv@Anubis:~$ which which
      /usr/bin/which

      did I miss something?
      Its an actual command on my system

    280. Re:rm -rf / by doshell · · Score: 1

      I understand the philosophical side of the question, but mathematically speaking it's simply a matter of definition.

      You say "set A is contained in set B" if, for every element x of A, x also belongs to B. Applying this to your statement, both A and B are the empty set. Since A has no elements, then surely every element it contains has whatever property you can conceive (in particular, every element belongs to B), therefore the empty set is contained in the empty set. Mathematicians call this a vacuous truth because the statement is true by actually not applying to any elements of the set (since there aren't any).

      If this doesn't make sense to you, consider that the negation of the proposition is "there is at least one x in A such that x doesn't belong to B". Since A has no elements this proposition is obviously false --- therefore the first one must be true.

      Some people have trouble with this statement because they confuse the "is contained in" relation with the "belongs to" relation. While it is true that the empty set is contained in the empty set, it is not true that the empty set belongs to the empty set (otherwise it would not be empty). This is the difference between placing an empty bag inside another (previously empty) bag, and checking whether the contents of an empty bag are also inside another empty bag.

      --
      Score: i, Imaginary
    281. Re:rm -rf / by doshell · · Score: 1

      Technically, "A contains B" means the same as "B is a subset of A". The parent may have been confusing containment with membership, which I tried to clear up in my reply.

      --
      Score: i, Imaginary
    282. Re:rm -rf / by Wanon · · Score: 1

      If which wasn't on your PATH, then you wouldn't be able to execute which without an absolute path. Meaning your shell would return command not found, not the output of which.

    283. Re:rm -rf / by Allnighterking · · Score: 1

      1.restore
      2. :u
      3. ctrl + z

      --

      I'm sorry, I'm to tired to be witty at the moment so this message will have to do.

    284. Re:rm -rf / by camperdave · · Score: 1

      It was mostly my set theory knowledge taking a holiday that day. I was thinking that for a set to be a subset of another that the set needed to be an element of the other, instead of the subset being a set of elements from the other

      --
      When our name is on the back of your car, we're behind you all the way!
    285. Re:rm -rf / by Fizzl · · Score: 1

      let's clean etc.
      cd /etc
      rm * ~

      (notice ^space)

    286. Re:rm -rf / by Breakfast+Pants · · Score: 1

      Opps, I was wrong. Strange that I don't see it in the bash manual ( http://www.gnu.org/software/bash/manual/bashref.html ).

      --

      --

      WHO ATE MY BREAKFAST PANTS?
    287. Re:rm -rf / by T-Ranger · · Score: 1

      who are you calling a dollar dollar carrot?

    288. Re:rm -rf / by LihTox · · Score: 1

      $[ ] does (integer) math in bash. So "echo $[4+1]" returns 5.
      The outer [] in bash is the same as the "test" command (see "help test" for details).

    289. Re:rm -rf / by CYREX2K · · Score: 1

      haahhahahha

    290. Re:rm -rf / by dfn_deux · · Score: 1

      I always used $(( arg op arg )) to do int. math in bash. Is there any difference in the two methods?

      --
      -*The above statement is printed entirely on recycled electrons*-
    291. Re:rm -rf / by LihTox · · Score: 1

      I don't know; they seem to be equivalent. My bash man page only lists $((...)) for arithmetical expansion, so maybe $[...] is the legacy version?

    292. Re:rm -rf / by WgT2 · · Score: 1

      Math is the foundation of computer science.

      That is: you are correct.

      (Which would also explain the requisite study of boolean logic for Computer Science Engineering classes.)

    293. Re:rm -rf / by Trailer+Trash · · Score: 1

      Search for "carrier lost" here on /. and you'll know what I mean.

      And, yes, I dialed into plenty of bbs's with and without error correction.

    294. Re:rm -rf / by Sobrique · · Score: 1

      Check your alias for 'rm'. You will _probably_ find it's aliased as rm -i. Thus rm -f will override that, meaning you _don't_ have to press 'y' for everything.

    295. Re:rm -rf / by mr_mischief · · Score: 1

      It might be /dev/audio or something else again on your system. It might be busy playing audio for some other process, for that matter.

    296. Re:rm -rf / by Bigbutt · · Score: 1

      Mojo Nixon. Elvis is everywhere!

      [John]

      --
      Shit better not happen!
    297. Re:rm -rf / by RichiH · · Score: 1

      Unlikely, imo. He would still execute the command and then execute whatever the program returns. At which point the machine has been shutdown cleanly, already.

    298. Re:rm -rf / by RichiH · · Score: 1

      sudo vim :!bash
      rm -rf /var/www

    299. Re:rm -rf / by Ofloo · · Score: 1

      it depends, if you're continuously doing root tasks such as configuring daemons and so forth.. then there is no point not going root ..

  2. Well by Anonymous Coward · · Score: 5, Funny

    Well.

    dd if=/dev/zero of=/dev/sda1

    1. Re:Well by FooAtWFU · · Score: 5, Interesting
      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.

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
    2. Re:Well by debatem1 · · Score: 1

      I was just about to say, I use this as an alarm clock

    3. Re:Well by evanbd · · Score: 2

      You know, cp works just as well, and the syntax is simpler. dd is great, but you might as well use cp in many cases.

      cp /dev/zero /dev/sda1

    4. Re:Well by dougmc · · Score: 1

      Dunno about relaxing, but I always just used `ls -lRa /usr > /dev/dsp' (or /dev/audio) when I needed to make some noise to test my speaker setup ...

    5. Re:Well by twowoot4u · · Score: 1

      `dd if=/dev/zero of=/dev/sda` is way more fun because it can overwrite important partition-records :-D

    6. Re:Well by Vireo · · Score: 1

      Maybe I'm wrong here but I was under the impression that reading /dev/urandom produces pseudorandom bytes but only up to exhaustion of the entropy pool. A machine which sits there doing nothing during the night may have a low entropy pool, and thus may not be the most reliable alarm clock. Maybe you should read /dev/random instead...

    7. Re:Well by simcop2387 · · Score: 1

      and for a system using alsa, without oss emulation ls -lRa /usr | aplay

    8. Re:Well by Hatta · · Score: 4, Informative

      You only need a tiny bit of entropy to seed the pseudorandom number generator in /dev/urandom. Once it's seeded you get all the pseudorandom numbers you want. /dev/random gives you truly random numbers, and is highly dependent on the amount of entropy the system has. It will block if you run out of entropy, urandom will not.

      --
      Give me Classic Slashdot or give me death!
    9. Re:Well by PitaBred · · Score: 1

      Make sure you use bs=1M or something larger (maybe 16m?), otherwise you might have the chance to actually shut it off and recover files. dd is slow as hell if you do a drive transaction for every single bit ;)

    10. Re:Well by Technonotice_Dom · · Score: 5, Interesting

      Heck, I used that command in combination with 'at' to act as a makeshift alarm clock[..]

      You mentioned it only in passing, so I thought I'd draw a little more attention to it. The 'at' command is a really handy way to automate one-off tasks that many people seem to miss. The interface is neat too, understanding plain English time specifications.

      I've often seen people add a one-off task to a crontab, then try and forget to remove the entry once it's run!

    11. Re:Well by SigmaTao · · Score: 1

      Why not put both together... dd if=/dev/urandom of=/dev/sda1 :-)

    12. Re:Well by theguywhosaid · · Score: 1

      Back to write, me and a buddy made a hobby out of write-ing mp3s to each others consoles mid-vi session until we noticed another user named 'leet', who was never continuously logged in for more than a few minutes without getting mp3'ed and screwing his console.

    13. Re:Well by KmArT · · Score: 1

      Reminds me of the days on IRC when newbies looking for warez were given the hot ftp site of 127.0.0.1.. For some reason, they could never login, but many were so grateful that folks would be so charitable to give out a site..

    14. Re:Well by Larryish · · Score: 1

      Oh God, I hate that.

      Running out of entropy, that is.

    15. Re:Well by H3g3m0n · · Score: 1

      I used the following to warn me when my system crashed.

      #!/bin/sh
      while true; do
      ssh -o ServerAliveInterval=2 -o ConnectTimeout=5 ender echo OK: \`date\` || mpg123 /home/hegemon/bin/Go\ Go\'s-\ HEY\ MICKEY\!\ \(1\).mp3
      sleep 1
      done

      Need to setup ssh keys for pass wordless login though.

      --
      cat /dev/urandom > .sig
    16. Re:Well by flirek · · Score: 1

      dd if=/dev/zero of=/dev/sda bs=512 count=1 faster, not real damage, much to learn during recover :)

    17. Re:Well by DaVince21 · · Score: 1

      How do you use it if /dev/dsp doesn't exist? I don't have it with my integrated Intel sound chip for some reason.

      --
      I am not devoid of humor.
    18. Re:Well by eta526 · · Score: 1

      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.

      Now if only I could do that to a few servers in the data center downstairs. Imagine: Amidst all the fan noise, you're walking down the aisle and you hear... static. How do you troubleshoot THAT?!

    19. Re:Well by Neeth · · Score: 1

      127.0.0.1 had good stuff, though. Mostly pr0n.

      --
      Yes, I am the one with the legendary sig.
    20. Re:Well by Poltras · · Score: 1

      If you want to do it fast, dd will always be more performant. Depends on the size of sda1 :P

    21. Re:Well by evanbd · · Score: 1

      If you want to do it fast, dd will always be more performant. Depends on the size of sda1 :P

      Are you sure about that?

      evand@Desktop:/data$ dd if=/dev/zero of=tmp0 bs=1M count=128
      128+0 records in
      128+0 records out
      134217728 bytes (134 MB) copied, 0.875425 seconds, 153 MB/s

      evand@Desktop:/data$ dd if=tmp0 of=tmp1 bs=1M count=128
      128+0 records in
      128+0 records out
      134217728 bytes (134 MB) copied, 1.80238 seconds, 74.5 MB/s

      evand@Desktop:/data$ time cp tmp0 tmp1
      real 0m0.838s
      user 0m0.004s
      sys 0m0.644s

      evand@Desktop:/data$ dd if=tmp0 of=tmp1
      262144+0 records in
      262144+0 records out
      134217728 bytes (134 MB) copied, 2.16979 seconds, 61.9 MB/s

    22. Re:Well by Androclese · · Score: 1

      Along the cp lines...

      # cp -rp * /some/directory/

      For when you want to copy the content of a file(s) to another place, as root, and keep the original permissions, ownership, and timestamps in-tact.

    23. Re:Well by kaosfury · · Score: 1

      Actually, I use that quite a lot from a liveCD distro. Great way to securely wipe a disk. dd if=/dev/urandom of/dev/sda1 is better though.

      --
      "Trust that little voice in your head that says 'Wouldn't it be interesting if...' and then do it." - Duane Michals
    24. Re:Well by SMOKEING · · Score: 1

      cat /boot/vmlinuz >/dev/dsp

      and hear the subliminal message in it.

    25. Re:Well by aug24 · · Score: 1

      That alarm clock is the neatest *nix hack I have heard yet. Nice one.

      Justin.

      --
      You're only jealous cos the little penguins are talking to me.
    26. Re:Well by joeljkp · · Score: 1

      Here's a good one:

      cat /dev/input/mice > /dev/sda1

      --
      WeRelate.org - wiki-based genealogy
    27. Re:Well by nozzo · · Score: 1

      oops. me and my curious nature... now where did I put that ubuntu cd! :-(

    28. Re:Well by lekikui · · Score: 1

      You may have ALSA instead. Try

      aplay < /dev/urandom

      For example

      --
      "Lisp ... made me aware that software could be close to executable mathematics." - L. Peter Deutsch
    29. Re:Well by DaVince21 · · Score: 1

      Thanks, that works!

      --
      I am not devoid of humor.
  3. session-sharing with screen -x by FooAtWFU · · Score: 5, Insightful
    (used in my company for doing the agile/extreme "pair programming" think with a remote devloper, among other things).

    screen is awesome.

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
    1. Re:session-sharing with screen -x by CppDeveloper · · Score: 2, Funny

      When I worked in a government building not too far outside of DC several of us used to enjoy telneting into our co-workers Sparc's and running X programs. My favorite was the one that made the screen look like it was melting. Also popular would be the one that caused random letters in a document to drop down a line.

    2. Re:session-sharing with screen -x by phayes · · Score: 1

      Ahhhh, the joys of xbounce & xroach...

      --
      Democracy is a sheep and two wolves deciding what to have for lunch. Freedom is a well armed sheep contesting the issue
    3. Re:session-sharing with screen -x by jbeaupre · · Score: 1

      I used it more to scatter the programs I needed to work with all over campus. My workstation was crap. So ANSYS over here, Pro-E over there, IRC local, etc. I haven't found a decent equivalent for Windows.

      --
      The world is made by those who show up for the job.
    4. Re:session-sharing with screen -x by Nutria · · Score: 1

      Need to leave a simulation running for a week or two? Screen is there. Trying to do something slightly complicated/non-interuptable on a flaky connection? Run screen and you won't lose a thing when your connection drops. Need to start a dozen things in a hurry before wasting the remainder of the day in silly meetings?

      Sane operating systems have "batch queues" that you submit shell scripts to, and which captures all text output to a log file.

      --
      "I don't know, therefore Aliens" Wafflebox1
    5. Re:session-sharing with screen -x by Shinobi · · Score: 1

      Oh, the good old days of our 3D animation classes, rsh'ing into the other SGI's in the classroom, trying to find the ones not already taken for renderjobs... :p

    6. Re:session-sharing with screen -x by DirkNiblick · · Score: 1

      How does one of the users exit that screen without destroying the whole session? (Too lazy to Google. (That's pretty lazy.))

    7. Re:session-sharing with screen -x by hrimhari · · Score: 2

      Ah, but screen lets you reattach to what you left running and isn't limited to batch scripts.

      For instance, I once had to run a modified "finch" to act as a gateway between a demo and an IM network and I found it very useful to not be obliged to keep a terminal window opened AND be able to check it from anywhere, anytime, through an SSH connection.

      --
      http://dilbert.com/2010-12-13
    8. Re:session-sharing with screen -x by skis · · Score: 1

      'Ctrl+a' then 'd' for "detach"

    9. Re:session-sharing with screen -x by bluefoxlucid · · Score: 1

      I used to use that to pop penisland up on my teacher's projected screen during class.

    10. Re:session-sharing with screen -x by bluefoxlucid · · Score: 1

      nohup if it can run in the background.

    11. Re:session-sharing with screen -x by AshtangiMan · · Score: 1

      Ha. Reminds me of a similar time in a similar building. We had SGIs and a cute gal from my company started working in the same agency I was. I sent a lot of xeyes to get laughs.

    12. Re:session-sharing with screen -x by mollymoo · · Score: 5, Funny

      In a similar vein, back in the days of floppies you could have endless fun ejecting other people's disks from Sun workstations. They put it in, you eject it. They put it in, you eject it. Repeat till you get bored or it looks like they're about to do a 'who'.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    13. Re:session-sharing with screen -x by xmas2003 · · Score: 1

      xroach was a classic - great fun!

      --
      Hulk SMASH Celiac Disease
    14. Re:session-sharing with screen -x by Macka · · Score: 1

      Don't forget xrotmap ... psychedelic man ;-)

    15. Re:session-sharing with screen -x by Idbar · · Score: 1

      Well, if was fun to ssh into coworkers SGI's (indy's for example) and play out loud any of the lovely sounds included in the system, like the cannon or the lion roaring, and see people jumping from their chairs.

    16. Re:session-sharing with screen -x by spazdor · · Score: 1

      Pair programming likes to have sex with other programming methods of the same gender?

      --
      DRM: Terminator crops for your mind!
    17. Re:session-sharing with screen -x by Flimzy · · Score: 1

      I started using ytalk (a talk client with some extra features) since about 1998 to do similar things.

    18. Re:session-sharing with screen -x by sjames · · Score: 1

      I used to torture a coworker w/ xsnow.

    19. Re:session-sharing with screen -x by sjames · · Score: 2, Interesting

      Log in to the Sparc next to an unsuspecting suit and do "cat bark.au >/dev/dsp"

    20. Re:session-sharing with screen -x by Just+Brew+It! · · Score: 1

      Ahh, the old 680x0 based Sun workstations... fun times. I remember back in the late '80s when I figured out how to get direct access to the frame buffer via remote (rsh) shell session. Had a blast flipping the screen image on co-workers' workstations upside-down (one guy actually started whacking the monitor to try and get it to flip back), making the screens snow for the holidays, etc... :D

    21. Re:session-sharing with screen -x by Anonymous Coward · · Score: 1, Funny

      xroach. I set it on a colleague's login whom I'd warned not to use 'xhost +', and instead to use 'ssh -X' for getting X sessions to work correctly when logged in elsewhere. The shriek when she came back from lunch and thought there were real roaches on the screen was pretty prize, even though my boss yelled at me about it.

      Fortunately, everyone laughed when I showed them how to smash the roaches, and they tended to play it when bored. That helped ease my reprimand quite a lot when the woman who screamed got really into it.

    22. Re:session-sharing with screen -x by root-a-begger · · Score: 1

      I agree. screen session sharing is great. This is a plug but highly on topic, http://shellshadow.com/ is collaborative PuTTY. I think you'll find it works great for cases where shared screen is less safe or accessible for the enjoined user.

    23. Re:session-sharing with screen -x by richlv · · Score: 1

      how does this work with different screen/terminal sizes ? attaching to a session that was previously run on different terminal size shows garbage & requires repainting/resizing it.
      yeah, i'm too lazy to try this myself ;)

      --
      Rich
    24. Re:session-sharing with screen -x by yahyamf · · Score: 2, Interesting

      do ssh sunworkstation eject instead. You won't show up in `who`

    25. Re:session-sharing with screen -x by quarterbuck · · Score: 5, Informative

      eject is a useful tool, If you have a rack of servers all alike and you need to identify one of them . Some servers have blinking lights etc. but mine had no audio nor lights. But it had a CD tray.
      I simply put eject and "eject -t" in a loop and go look in the server room -- the hyperactive server is the one I was looking for.

      --
      http://slashdot.org/submission/1062723/Cheap-mobile-data-plan?art_pos=2
    26. Re:session-sharing with screen -x by famebait · · Score: 1

      Trying to do dissertation work in the graphics lab at my uni, all the slackers playing doom on the SGIs with the sound on was really, really annoying.

      But I had rsh access to all of them. Killing the game would have aroused suspicion. But noone figured out that the sound disapperaing all the time was anything but a bug.

      --
      sudo ergo sum
    27. Re:session-sharing with screen -x by cinderblock · · Score: 1

      Use eject -T to open AND close the tray.

    28. Re:session-sharing with screen -x by kgbspy · · Score: 1

      What do you mean you're not constantly running in 80x24...? Aah the good old days of using screen on an IBM 3151...

      --
      ~
      ~
      ~
      -- INSERT --
  4. There is this part ... by 140Mandak262Jamuna · · Score: 5, Funny

    ... 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. Yeah, some are surprised by that thing.

    --
    sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
    1. Re:There is this part ... by Forty+Two+Tenfold · · Score: 5, Funny

      I once made my friends' jaws hit the floor when I burned a cd for them - from console.

      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!

      --
      Upward mobility is a slippery slope - the higher you climb the more you show your ass.
    2. Re:There is this part ... by infinite9 · · Score: 4, Interesting

      I do both microsoft and unix development. This has led to some interesting situations. I wrote a mathematical parser in c#/.net that could process math expressions at runtime using Regex to get tokens from the expression. The regex wasn't too bad. But after a code review, my pointy-haired manager made me comment each symbol in the regex. 40 lines of comments to describe 1 line of code.

      As a consultant, VI is my absolute favorite tool. Not on unix projects, on microsoft projects. It always happens eventually. 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. lol

      --
      Disconnect your television. Do your own research. Draw your own conclusions. They're probably lying. Don't be a sheep.
    3. Re:There is this part ... by Eil · · Score: 1

      I was halfway across the country on business and needed a file on my workstation at home. We have DSL, so I was able to call up my wife and have her press the power button on my workstation to turn it on. It was one of those big full tower cases with a zillion fans so you KNEW when that thing was on.

      After a couple minutes, I was able to log in and retrieve the file. Once I got the info I needed, I told the wife I was all done. She asked what she needed to do to shut it off. I said, "Don't worry, it's already taken care of." I had already typed 'shutdown -h now' a few moments before so the timing was perfect: Just as I finished the statement, the machine shut off, the hard drives parked with an audible clank, and the fans spun down.

      She was floored.

    4. Re:There is this part ... by sydneyfong · · Score: 5, Funny

      True story.

      A friend and I help admin the computers in my (former) high school. Due to security the doors were locked during off hours, and I'm not a frequent helper so I don't have the keys, but my friend did.

      There was once when I was basically stranded in the computer lab, and my friend was in the server room (where the cell phone signals didn't reach). I don't know what he was doing at that time, but "walls" (on the linux machines) and "net sends" (to the Windows servers) didn't seem to work, so I ran a script to open and close the CD tray hoping to catch his attention.

      I got a message asking "wtf are you doing?" a few minutes later :)

      --
      Don't quote me on this.
    5. Re:There is this part ... by iamapizza · · Score: 1

      I was going to say vi too... it does surprise some people. "Unix has text editors? I thought it's just a command prompt OS...?!?"

      Anyways, time for me to ZZ this post.

      --
      Always proofread carefully to see if you any words out.
    6. Re:There is this part ... by mario_grgic · · Score: 1

      Yeah. And on Mac OS X you can drive GUI without ever touching the mouse or trackpad. Expose for switching between windows (including multiple app windows) and spotlight for launching apps or finding and opening your documents.

      It really is kind of like working in the terminal (of course there is no piping of commands), but it beats clicking everywhere in Windows.

      --
      As the island of our knowledge grows, so does the shore of our ignorance.
    7. Re:There is this part ... by Anonymous Coward · · Score: 3, Interesting

      eject cdrom is great for locating poorly labeled machines too!

    8. Re:There is this part ... by Trailer+Trash · · Score: 4, Funny

      Years ago in college we had a few Sun 3 workstations, and all of us CS types had logins on them of course. I also worked for the university computing department as did one of my fellow CS students. Often I'd be working on the Sun 3 when he'd log in and run his "xeyes from hell script", which would essentially open a bunch of xeyes with random geometries.

      Usually, when he was doing this he was sitting in another office working on a DOS machine running NCSA Telnet, which had the awesome feature that it would run an FTP server when you were using telnet.

      So, I would go to another machine, figure out his IP address using "w", and ftp to his desktop. Then I'd type the killer: "cd a:".

      With that, it would use the old BIOS call, which in the absence of a floppy would literally lock up the machine and prompt you to stick a disk in.

      It gets better (or, worse if you're Colin). After he'd scrape up a floppy and stick it in, I would get the prompt back letting me know he'd found one. No problem: "cd b:".

      There was no second floppy on that particular machine, so the BIOS would emulate two floppies and keep track of which was which. So he had to run and grab another to make the machine usable again. At that point, I could lock the machine up at will simply by cd'ing to the other floppy. And he would find me, and use "write" to ask for a truce.

      Funny thing is, it was really easy to turn off the ftp server. I guess I can let that cat out of the bag now.

    9. Re:There is this part ... by tnk1 · · Score: 1

      You clearly fail to understand the power of Emacs.

      Sorry... I had to.

    10. Re:There is this part ... by shaitand · · Score: 2, Funny

      This reminds me of the games I used to play with the wife. She is a windows gamer and always in the computer room. So I ssh'd into my *nix system and first ejected and retracted the cdrom a few times. Then I printed a page that said something to the effect of me being the ghost of someone who had died in the apartment and that I needed to communicate with the living.

      Had a nice effect, I had a big monster laser printer and there is no way you could fail to hear it warm up. Freaked her out good and proper.

    11. Re:There is this part ... by shaitand · · Score: 1

      My last significant mac experience was OS 9 but at least back then you could much more easily drive MS Winblows with the keyboard than MacOS. As far as the OS goes you can still control everything on windows with the keyboard. Individual apps may not play along though.

    12. Re:There is this part ... by tsalmark · · Score: 1

      Worked for a guy that decked his house out with x10 gear. one night some friends were over, we logged into the control computer and started flipping switches. took him almost an hour to figure it out and phone me.

    13. Re:There is this part ... by snuf23 · · Score: 1

      Windows has keyboards shortcuts for GUI operations. Aside from individual key shortcuts, you can use tab to cycle through screen widgets, alt-tab to switch windows, alt to select the current window's menu, cursor keys to navigate the menu bar and start menu etc.

      --
      Sometimes my arms bend back.
    14. Re:There is this part ... by mario_grgic · · Score: 1

      Yeah, but there is no comparison. I want to open the document in c:/Documents and Settings/user name/Reference/CS/C++/ANSI/C++ Programming.pdf in Windows I would have to press Win key to get to start menu, then a sequence of arrow keys or to get to my docs, then navigate that etc to get to the document.

      In OS X, I would do cmd+space to bring spotlight and then just type C++ prog and I would have my document as top hit. If I wanted to be more precise I could type kind:pdf C++ prog. Often times less typing (most of the time 3 letters) is enough.

      And of course there are more complex searches like find me all images I ever took at aperture f1.4 and where I used flash. And one can save these searches as dynamic folders that update as you add more files that match the criteria. Once you get used to that kind of power using Windows becomes a major pain in the ass.

      --
      As the island of our knowledge grows, so does the shore of our ignorance.
    15. Re:There is this part ... by Lodewijk · · Score: 2, Interesting

      I love doing:

      wget -qO- http://cdimage.debian.org/debian-cd/4.0_r5/i386/iso-cd/debian-40r5-i386-netinst.iso | cdrecord

      Straight from the net to my cd-burner. Try to do that with Windows...

    16. Re:There is this part ... by nocomment · · Score: 2, Funny

      meh, good OS but lacks a decent editor.

      --
      /* oops I accidentally made a comment, sorry */
      /* http://allyourbasearebelongto.us */
    17. Re:There is this part ... by mallumax · · Score: 1

      FTP to desktop ? Which FTP client allows you to type commands like "cd a:" ?

    18. Re:There is this part ... by YourExperiment · · Score: 1

      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.

      Notepad++ does regular expression search and replace pretty nicely, and while that's not quite as useful as having the facility in Visual Studio would be, it's still more accessible (to most users) than vi.

      I can think of no better way to justify my exorbitant bill rate.

      You're a consultant, you don't need to justify anything.

    19. Re:There is this part ... by Timex · · Score: 4, Funny

      True story:

      I was in a class learning how to install and run a network management program (this was mid-1990s), and the class had a set of IRIX systems to work from. There were six systems to work on, so some of the students had to pair-up.

      The class was pretty-much done, and we were waiting to be dismissed.

      Suddenly, I get a message on the console of my system stating that the system would reboot in five minutes. (This was the system default.) I went in, found and killed the shutdown process, then checked the logs to see who kicked it off. It was the two clowns in front of me. I went into their system (there was no real security here, if you haven't figured that out. The systems weren't on the Internet, so it wasn't a big deal) and set the system to init state 0 (this reboots the system immediately, for you guys that are oblivious to init states).

      They looked at each other, they looked at me (I was just sitting there, looking at their reaction), and they looked at each other again. One said, "See? I TOLD you we shouldn't have f*d with him!"

      Heh. :)

      --
      When politicians are involved, everyone loses.
    20. Re:There is this part ... by beaviz · · Score: 1

      Freaked her out good and proper.

      Ohh. You we're the slashdot user that was married ... once.

    21. Re:There is this part ... by asliarun · · Score: 1

      As a consultant, VI is my absolute favorite tool. Not on unix projects, on microsoft projects. It always happens eventually. 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 don't want to sound pedantic, but Visual Studio (.NET) has always supported regular expressions in its search and replace function (you need to specify that you want to use Regular Expressions in the options section of the Find and Replace window). It is not as macho as using VI admittedly, but it gets the job done, and there is full feature support for regex syntax. Regex is pretty cool though, and usually dazzles microsoft programmers as they've probably never used it.

    22. Re:There is this part ... by jonadab · · Score: 1

      You want to look like you *really* know computers, to someone who *really* doesn't? On a Windows system, open up a command prompt, and do this:
      cd \
      dir /s

      Honest to goodness, they invariably assume you're doing something really clever.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    23. Re:There is this part ... by Pentagram · · Score: 1

      On a similar note, I was talking to my girlfriend (who was at home) on IM and she hadn't responded for a while, so I ssh'd to my box and executed "beep; beep; beep" a few times. Scared her a lot, but it almost backfired: she nearly pulled the plug out of the machine, thinking it was about to explode. Luckily she decided to call me instead :)

      "beep" by the way is a very handy app, and my contribution to this discussion. I know there are a few ways to activate the speaker, but it's handy to just have a command for it.

      E.g.: $ ./script-that-will-take-a-long-time-to-finish; beep
      => will beep when the script completes.

    24. Re:There is this part ... by Lord+Kestrel · · Score: 1

      C:\> wget http://example.com/blah.iso
      C:\> dvdburn blah.iso
      C:\>

      (Look at the Windows Resource Kit sometime)

    25. Re:There is this part ... by Hal_Porter · · Score: 1

      echo "You have SINNED!" | smbclient -M victimpc -U God

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    26. Re:There is this part ... by kgbspy · · Score: 1

      Or Ctrl-A _ if you're using screen and would prefer a visual notification of the lack of activity in that particular window.

      --
      ~
      ~
      ~
      -- INSERT --
    27. Re:There is this part ... by fgouget · · Score: 1

      I ran a script to open and close the CD tray hoping to catch his attention.

      For extra credit, time the open /close orders to send your message in Morse code.

  5. Uhhmmm... by Crazy+Brian · · Score: 2, Funny

    It doesn't crash?

    --
    "Do what you can, with what you have, where you are."
    1. Re:Uhhmmm... by Isaac1357 · · Score: 2

      To be fair, X crashing is not the same as the OS itself crashing.

    2. Re:Uhhmmm... by Vagnaard · · Score: 1, Funny
      Last time X crashed, it took all my firefox bookmarks with it.

      They were only bystanders... they had nothing to do with it... That's so cruel. Oh the humanity!

      --
      He had a baseball bat, and I was tied to a chair. Pissing him off was the smart thing to do. - Max Payne
    3. Re:Uhhmmm... by Randle_Revar · · Score: 1

      Over here on Debian Unstable, I have lately been having lots of X freezes that sometimes freeze the whole machine. No ssh, no ping response.

    4. Re:Uhhmmm... by sloanster · · Score: 1

      > Could have fooled me, I minimized a screen in firefox which for some reason resulted in x crashing and at least nicely closing all the apps I had open. Doesn't crash my ass.

      Not saying it couldn't have happened under some hypothetical situation, but in 15 years of linux use I've never seen that happen. Chances are, something else was going on there.

    5. Re:Uhhmmm... by nizo · · Score: 1

      I had a similiar probablem that turned out to be bad memory (everything was fine until the machine crashed and burned upon hitting the bad spot, usually right as I loaded some gigantic flash from somewhere). Probably worth checking if you haven't already anyway :-)

    6. Re:Uhhmmm... by Vancorps · · Score: 1

      Of course it has a root cause but the bottom line is that it does crash and even crashes hard sometimes requiring me to press and hold the power key to shut the thing off. Then I turn it back on and away I go.

      My point towards the OP was that it does crash on occasion and that is simply true. RAM can go bad, video drivers can and often do suck, hard drives sometimes don't go bad enough to trigger SMART events, sometimes it's just plain thermal overload. The bottom line is that the apps do crash and don't always crash gracefully when probably management of the hardware would allow it to display a proper error message stating thermal overload or bad ram instead of dumping memory.

    7. Re:Uhhmmm... by Vancorps · · Score: 1

      Depends on how it's crashed. In the scenario I described you would be correct as it did recover and I was able to go back to work.

      In another instance on the same machine X will freeze up completely rendering the whole machine unusable, it won't even respond to ping. It looks like another poster has a similar issue. Of course I'm using Ubuntu so mileage of course varies.

    8. Re:Uhhmmm... by Randle_Revar · · Score: 1

      Yeah, I tried a new kernel, Ubuntu's X, and a different video card, and RAM is next on the list.

    9. Re:Uhhmmm... by nizo · · Score: 1

      When I ran memtest from the grub menu (it gets installed with ubuntu) it puked on my second of three simms, which makes sense (machine would run fine, and then just hard lock when it hit the bad simm). Good luck diagnosing the problem.

    10. Re:Uhhmmm... by harry666t · · Score: 1

      Aside from not having to wait for fsck to complete, what exactly do I gain? I lose all unsaved work anyway.

    11. Re:Uhhmmm... by setagllib · · Score: 1

      Firefox bookmarks are backed up automatically, so at least you didn't lose anything.

      By the way, run a stable distro with open source drivers. I can't remember the last time anything crashed, let alone something critical like X.Org.

      --
      Sam ty sig.
    12. Re:Uhhmmm... by TheLink · · Score: 1

      If it's Desktop Linux for Aunt May, it's the same thing.

      Same if you have unsaved work in your GUI apps. If you know a way around that problem, I'd be very interested.

      --
    13. Re:Uhhmmm... by harrkev · · Score: 1

      If you have an Ubuntu CD lying around, you do know that Memtest is on the CD, right?

      --
      "-1 Troll" is the apparently the same as "-1 I disagree with you."
    14. Re:Uhhmmm... by Randle_Revar · · Score: 1

      Oh, I have a copy of memtest. And I do know that Ubuntu has it on the cd.

  6. Stupid Tricks by Anonymous Coward · · Score: 2, Interesting

    One command I really like is,

    "du -s * | sort -n"

    This lists the size and name of every file or folder in a directory and orders them from smallest to largest.

    1. Re:Stupid Tricks by mihalis · · Score: 1

      10 biggest files or subdirs in current working dir:

      $ du -sk * | sort -nr | head -10

    2. Re:Stupid Tricks by Remloc · · Score: 1

      alias adu='du -k|grep "^[1-9][0-9]* \./[^/]*$"|sort -n'

      Restricts to 1st level directories.

    3. Re:Stupid Tricks by HuckleCom · · Score: 1

      also du -hs

    4. Re:Stupid Tricks by GXTi · · Score: 1
      If you just have a list of files (not directories you want to count the contents of as well):

      ls -lS

      Naturally, normal ls arguments work here.

    5. Re:Stupid Tricks by sofar · · Score: 1

      ls -sSrh

      much more readable and faster

    6. Re:Stupid Tricks by g0rAngA · · Score: 1

      I've always wanted to know how to sort them if you use the -h switch ("du -hs"). The -h appends 'K', 'M', or 'G' to the size, making it buttload easier to read. You get 80G instead of 82871652.

      But it does break the ability to sort.

    7. Re:Stupid Tricks by kriebz · · Score: 1

      du -s * | sort -n | awk -F "\t" '{print "\"" $2 "\"" }' | xargs du -sh

      only tested in GNU/Linux. awk should proabably be gawk. Prints human readable sizes in size order.

    8. Re:Stupid Tricks by kriebz · · Score: 1

      it's a little slow, but I wrote a one-liner to do this. It's posted above, but I'll post it again here:
      du -s * | sort -n | awk -F "\t" '{print "\"" $2 "\"" }' | xargs du -sh

    9. Re:Stupid Tricks by portscan · · Score: 1

      actually, i was going to say:

      du -a --max-depth=1 | sort -n

      does the same thing, but more explicitly. then if you want everything:

      du -a | sort -n

      or just things on your current filesystem:

      du -ax | sort -n

      for straight summaries, du -cks is crap. instead use:

      du -sh

    10. Re:Stupid Tricks by xenocyst · · Score: 1

      command below is similar except:
      1. rather than descending into directories, just give their size
      2. human readable sizes while preserving correct sort by size

      du -s ./* | sort -n | cut -f 2 | xargs du -hs

      --
      And, no, I should not have used the goddamn Preview mode first.
    11. Re:Stupid Tricks by voxner · · Score: 1

      du -sh * | sort -n
      This makes more sense I guess.

    12. Re:Stupid Tricks by portscan · · Score: 1

      try

      du --max-depth=1

    13. Re:Stupid Tricks by kgbspy · · Score: 1

      for straight summaries, du -cks is crap. instead use:

      du -sh

      On the topic of humourous command flags, one of my favourites is a directory listing, reverse sorted by creation time:

      $ ls -Fart

      --
      ~
      ~
      ~
      -- INSERT --
  7. grep and awk by yakmans_dad · · Score: 4, Insightful

    So much easier for me to use than perl. I presume the modern unix user prefers perl.

    1. Re:grep and awk by colmore · · Score: 1

      I've switched to Ruby for scripting.

      I *can* write organized maintainable Perl scripts.

      I *do* write organized and maintainable Ruby scripts.

      Haven't tried it for any of that webapp stuff yet though.

      --
      In Capitalist America, bank robs you!
    2. Re:grep and awk by orclevegam · · Score: 1

      So much easier for me to use than perl. I presume the modern unix user prefers perl.

      Depends. I use grep for simple command line based output searching, E.G. "locate foo.o | grep lib/bar". For scripting, or more complex logic I use perl.

      --
      Curiosity was framed, Ignorance killed the cat.
    3. Re:grep and awk by Tetsujin · · Score: 1

      So much easier for me to use than perl. I presume the modern unix user prefers perl.

      The lack of any coherent datatypes is one of the weaknesses of the Unix shell. Even if shells offer arrays, for instance, programs running in the shell can't interact with them directly. Having access to useful data structures is IMO one reason why people are moving away from the shell and toward scripting languages.

      --
      Bow-ties are cool.
    4. Re:grep and awk by jlarocco · · Score: 1

      I think you missed the OP's point.

      In the shell, a lot of people (myself included) use "perl -e 'script...'" instead of awk, grep, sed, and the rest once the processing gets complicated enough. Maintainability is irrelevant because the script is specifically meant to be run one time to get the particular results you need.

      In other words, instead of:

      ps ... | grep ... | awk ... | sed ... | xargs ... | ...

      Just:

      ps ... | perl -e '...'

      If Ruby has something similar to the Perl's '-e' command line option it would probably work just as well.

    5. Re:grep and awk by dmsuperman · · Score: 1

      Not at all. I'm a modern user (in fact, I haven't even touched a shell before May this year) and I much prefer grep and awk and all the other command line goodies that GNU presents to me.

      --
      :(){ :|:& };: Go!
    6. Re:grep and awk by klui · · Score: 1

      I also prefer grep, cut, sed, and awk over Perl. But if I need something a little more powerful, I prefer Python. Mainly because you can create and run your scripts interactively. But the indentation is a little bit of a pain if you want to copy your interactive script to an editor.

    7. Re:grep and awk by Omega996 · · Score: 1

      i dunno - i don't think of perl as the same sort of tool as i do grep, awk, or sed. besides, what if your version of UNIX doesn't have a perl interpreter installed, and your company didn't pay for the c compiler licenses for your OS?

      grep and awk for the win.

    8. Re:grep and awk by xouumalperxe · · Score: 1

      I actually got into shell scripting in a very piecemeal fashion, so ended up learning bits and pieces of grep, awk, sed, while looking at/for specific examples of things I needed. In the end, I found myself capable of putting together scripts with those tools, whereas I still can't program perl if my life depended on it.

    9. Re:grep and awk by thogard · · Score: 1

      You may find perl is much faster than awk, sed and grep especially when combined.

    10. Re:grep and awk by shaitand · · Score: 1

      I prefer to use all of the above ;)

    11. Re:grep and awk by Omega996 · · Score: 1

      really? odd, i remember working on commercial UNIX systems within the past 5 years that did not have C compilers installed by default, that did not include a perl interpreter, and where we were generally forbidden to install software on the server that did not directly pertain to its mission.
      Some healthcare companies are really paranoid about the software that gets installed on their machines, right down to monthly reviews of smitty output (on AIX) to make sure that nothing had been added to the system.
      it's not so unusual in a locked-down environment, though i agree it's not always so cool to deal with.

    12. Re:grep and awk by TheLink · · Score: 1

      You might find perl's -n switch useful as well.

        -n assume 'while (<>) { ... }' loop around program

      --
    13. Re:grep and awk by marcosdumay · · Score: 1

      "I presume the modern unix user prefers perl."

      Ok, that is funny. No, newbies seem to prefer python for some reason that I can not understand. But if modern you are talking about people of my age (meet linux by 97), so I like grep quite well, but prefer sed to awk.

    14. Re:grep and awk by Timex · · Score: 1

      If Ruby has something similar to the Perl's '-e' command line option it would probably work just as well.

      I believe 'irb' would fit the bill...

      --
      When politicians are involved, everyone loses.
    15. Re:grep and awk by nevermore94 · · Score: 1

      Exactly. I started out my first programming job writing cross compatible utility shell scripts that had to work on AIX, DEC, and SCO UNIXes as well as Linux across 500 or so servers that didn't have consistent PERL installs, if it was there at all. So, I got very good at writing complex and very portable scripts using only sh with the standard complement of grep, sed, & awk. awk became truly indispensable as it was the only higher level scripting tool that I had available to me that was was pretty much the same on all IXes.

      --
      Nevermore.
    16. Re:grep and awk by jonadab · · Score: 1

      > I presume the modern unix user prefers perl.

      Absolutely. Perl not only obsoletes sed and awk, but also sh and a number of other things, and you don't have to keep track of separate syntax (including command-line syntax) for each of them. One tool does everything.

      Well, two tools: perl and a good text editor. Who needs anything else?

      Of course, for one-liners you can just run your perl script directly from the shell prompt without bothering to put it in a file. Then again, if you're a serious Emacs user, the shell prompt is almost certainly running in your text editor in the first place. (Yeah, eshell rocks. Who needs bash?)

      --
      Cut that out, or I will ship you to Norilsk in a box.
  8. Find / Grep by BigJClark · · Score: 2, Informative


    I find a combination of find/grep to be pretty useful. Not sure about how unknown it is, but I do know that several UI-based linux admins around our office don't know about "stacking" commands. (I know, I know, one would think they would be mutually-exclusive ;) )

    find . | grep [string]

    --

    Hi, I Boris. Hear fix bear, yes?
    1. Re:Find / Grep by Anonymous Coward · · Score: 1, Informative

      find . -exec grep -l {} \;

    2. Re:Find / Grep by cavtroop · · Score: 1

      and they call themselves 'linux admins'?

      Geez, low barrier to entry you have over there... :)

    3. Re:Find / Grep by NevarMore · · Score: 1

      locate [string]

    4. Re:Find / Grep by Aphoxema · · Score: 1

      I have to do that all the time in Ubuntu because Nautilus has a terrible search function and I'm too lazy to use anything else. WHY SHOULD I NEED ANYTHING BESIDES TEXT?!

      --
      "Most people, I think, don't even know what a rootkit is, so why should they care about it?"
    5. Re:Find / Grep by Anonymous Coward · · Score: 5, Funny

      I have a theory that find + xargs + grep is Turing-complete. Can't prove it, but it feels right.

    6. Re:Find / Grep by imp7 · · Score: 2, Informative

      How about the using find for what it is...

      find . -name [String]

      You have a bit more control when you are looking for a file and you are not grep'ing through more thee just file names. Plus you need to remember to put in any wildcards if you don't know the whole file name.

    7. Re:Find / Grep by Yuan-Lung · · Score: 1

      find . | grep [string]

      Nah, that's just the same as a find . -name "*[string]*"... You want something crazier...
      try this:
      find . | xargs grep [string]

    8. Re:Find / Grep by BigJClark · · Score: 1


      ahhh you are right... surprising, use a command for years, and not even know the full extent of what its capable of.

      --

      Hi, I Boris. Hear fix bear, yes?
    9. Re:Find / Grep by mi · · Score: 1

      and they call themselves 'linux admins'?

      Linux is not Unix.

      --
      In Soviet Washington the swamp drains you.
    10. Re:Find / Grep by Bandman · · Score: 1

      The manpage for 'find' is amazing. I also love the manpage for 'bash'.

      And whoever decided to extend 'date' into the miracle that is GNU date deserves a medal.

    11. Re:Find / Grep by jweller · · Score: 2

      If you can't stack commands, you wouldn't be given the root password on any of my machines, much less be made an admin.

    12. Re:Find / Grep by jaxtherat · · Score: 1

      I'm sorry, UI-based linux admins? Surely you mean 'users' rather than 'admins'

      --
      http://www.zombieapocalypse.tv/
    13. Re:Find / Grep by Richard+Steiner · · Score: 1

      ...other things I've heard people say:

      AIX is not UNIX.
      BSD is not UNIX.
      Solaris is not UNIX.

      What's left? Coherent? z/OS? :-) :-)

      --
      Mainframe/UNIX Bit Twiddler and long time Windows/Linux Hobbyist.
      The Theorem Theorem: If If, Then Then.
    14. Re:Find / Grep by BigJClark · · Score: 1


      Indeed not. A full collection of the little gnome bastards. Quick with a mouse, slow with a keyboard ;)

      --

      Hi, I Boris. Hear fix bear, yes?
    15. Re:Find / Grep by mdf356 · · Score: 1

      This won't show you the file names that matched.

      find . -exec grep $1 {} /dev/null \;

      or limit it to C source files:

      find . -name "*.[ch]" -exec grep $1 {} /dev/null \;

      or limit it to plain files:

      find . -type f -exec grep $1 {} /dev/null \;

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    16. Re:Find / Grep by mi · · Score: 1

      What I meant, actually, was that Linux is easy enough for the "dummies" to be able to act as admins... It is no bad thing — it just explains, why some of these people are not of the caliber of some Unix-admins. Not that I have not met my share of dumb-asses among those too, but a typical Unix-admin to a Linux one is like a bison next to a cow.

      --
      In Soviet Washington the swamp drains you.
    17. Re:Find / Grep by hazem · · Score: 1

      Why should I need anything besides text?!

      The porn isn't as good?

    18. Re:Find / Grep by nabsltd · · Score: 1

      find . | grep [string]

      I take it this is for a system with a non-GNU grep (stock Solaris, maybe?).

      grep -Rs "string" *

    19. Re:Find / Grep by stjobe · · Score: 1

      "Read man bash like you read the bible. No, scratch that, man bash IS the bible"
        - unknown

      --
      "Total destruction the only solution" - Bob Marley
    20. Re:Find / Grep by msuarezalvarez · · Score: 1

      Read on the -exec thingie in find. Your construction will hit command line length limits in many patforms easily.

    21. Re:Find / Grep by chainLynx · · Score: 1

      All of this is cool, I suppose, but there is a tool that I use now called ack that has taken care of most of my find / grep / xargs/ exec / whatever needs: http://petdance.com/ack/

    22. Re:Find / Grep by jefu · · Score: 1

      I thought about this once and managed to figure out the basic idea for building a simple turing machine with find, grep, touch and rm (I think) - these build the actions and the whole thing would have been run with a "while" loop in the shell. I'd have to work it out again, but I seem to remember keeping the tape in subdirectories, the machine in a file (that was grepped) and the current cell was just a file name. But I never actually programmed it, so I could have it all wrong.

    23. Re:Find / Grep by wanderingknight · · Score: 1

      locate is a wonderful tool. Learn it, use it, love it.

    24. Re:Find / Grep by AJWM · · Score: 1

      Yep, if you can't manage the machine in runlevel 3, you can't manage the machine.

      Heck, most of the time I'm adminning multiple servers, something like "for s in `cat hosts`; do ssh -q $s your commands here ; done" is your friend.

      --
      -- Alastair
    25. Re:Find / Grep by Pvt_Ryan · · Score: 1

      apparently you left out

      windows is not unix.. :P

    26. Re:Find / Grep by Pvt_Ryan · · Score: 1

      pft with commands like touch, finger, grep yea it is. :)

    27. Re:Find / Grep by kitgerrits · · Score: 1

      You'll love this one:
      find . |grep -e foo -e bar
      It will return the combined results of foo and bar!

      (I wish I knew about this when I was young, took a lot of joining and sorting earlier)

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    28. Re:Find / Grep by kitgerrits · · Score: 1

      After discarding HP/UX, all I can think os if Tru64 and SCO.
      I haven't seen either of them being used in years, though...

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    29. Re:Find / Grep by Logic+and+Reason · · Score: 1

      grep -r

    30. Re:Find / Grep by kelnos · · Score: 1

      Please, I've admined AIX and Solaris boxes in the past. They're not that bad. Most of the "difficulty" is just that they have different conventions on many things than Linux does.

      Having said that, I *do* prefer Linux machines... probably just out of familiarity.

      --
      Xfce: Lighter than some, heavier than others. Just right.
    31. Re:Find / Grep by Omega996 · · Score: 1

      odd, apparently X/Open doesn't agree with your statements re: AIX - It's been UNIX 98 branded since 2001 (AIX 5 on POWER architecture).

    32. Re:Find / Grep by Yuan-Lung · · Score: 1

      Read on the -exec thingie in find. Your construction will hit command line length limits in many patforms easily.

      That's what the xargs is for. The data is passed via stdin instead of command line.

    33. Re:Find / Grep by setagllib · · Score: 1

      Actually -Cx gives you context. -C1 gives you one line above and below the matching line, -C2 gives two, etc. -H only gives you the filename.

      --
      Sam ty sig.
    34. Re:Find / Grep by gnud · · Score: 1

      You might need to add dc. But then I think you're set =)

    35. Re:Find / Grep by MrCreosote · · Score: 1

      find . -name "shell pattern"

      --
      MrCreosote Meow!Thump!Meow!Thump!Meow!Thump! "You're right! There isn't enough room to swing a cat in here!"
    36. Re:Find / Grep by vericgar · · Score: 1

      And for those pesky files with spaces in the name that your wife likes to create:

      find . -print0 | xargs -0 grep [string]

    37. Re:Find / Grep by Aphoxema · · Score: 1

      Not to mention the awesome ASCII porn.

      --
      "Most people, I think, don't even know what a rootkit is, so why should they care about it?"
    38. Re:Find / Grep by iggya · · Score: 1

      Here's a locate, backticks, and bangbang trick. Suppose you have a file somewhere that you know the name of, but not the location of. You can use locate to find it: locate filename. But then suppose you want to look at the file. Here's an example:

      locate myspecialfile.txt
      /home/iggy/some/dir/myspecialfile.txt

      #then, in the next command:
      less `!!`
      # use backtick bangbang backtick, which expands to less `locate myspecialfile.txt`,
      # which expands to less /home/iggy/some/dir/myspecialfile.txt

    39. Re:Find / Grep by eta526 · · Score: 1
      Speaking of stacking commands, you can stack greps to find, for example: "type file | grep foo | grep bar" in order to find both foo and bar on the same line in any order. Is there a way to find foo OR bar on any line (besides running two separate grep commands and merging the results, which loses the order)

      Another handy feature: "type file | grep foo -A10 | grep bar" will find any line with bar in it which within 10 lines after an instance of foo. -A and -B (after and before) have wonderful utility for searching for events occurring shortly before or after other events in logs.

    40. Re:Find / Grep by dfiguero · · Score: 1

      For systems without grep -R:

      find . -exec grep -i somestring {} \; -print

      --
      My penguin ate my sig
    41. Re:Find / Grep by RobBebop · · Score: 1

      There's a Solaris machine at my job that doesn't let me specify the normal parameters in grep to drill down into the directory tree to find the declaration/usage of functions and variables in my program, so I've taken to the following as a helper:

      grep SearchString `find . -name "*.c"`

      --
      Support the 30 Hour Work Week!!!
    42. Re:Find / Grep by databoi · · Score: 1

      locate [string]

      Without a locate db, this doesn't work!

    43. Re:Find / Grep by Richard+Steiner · · Score: 1

      Pedant. I was listing things I've heard people say, not commenting on their accuracy. :-)

      --
      Mainframe/UNIX Bit Twiddler and long time Windows/Linux Hobbyist.
      The Theorem Theorem: If If, Then Then.
  9. grep -R by cain · · Score: 1

    To find a string in a file I used to do "find . | xargs grep foo". A cow orker saw me doing that and told me about grep -R, recursive grep. So the same statement would be "grep -R foo ."

    1. Re:grep -R by e9th · · Score: 1

      That just means you're getting old. The -R option is a newcomer. Certainly SVR4 grep didn't have it.

    2. Re:grep -R by multipartmixed · · Score: 4, Interesting

      Hell, I think it's probably a GNU extension, because it's still not in Solaris.

      I think rgrep appeared around BSD 4.4, though.

      Oh well. I still surprise people with backticks. *sigh*

      --

      Do daemons dream of electric sleep()?
    3. Re:grep -R by amorsen · · Score: 2, Informative

      To find a string in a file I used to do "find . | xargs grep foo"

      It's generally wise to use -print0 and -0...

      --
      Finally! A year of moderation! Ready for 2019?
    4. Re:grep -R by digitalhermit · · Score: 2, Informative

      Instead of using find and xargs it's sometimes easier to use the -exec parameter to find:

            find . -type f -exec ls -l {} \;

      xargs is very useful in other circumstances. One thing that I get asked about a lot is how to pass variables. Main thing to remember is to call the shell via xargs to process variables and other parameters.

      BTW: How does one ork a cow?

    5. Re:grep -R by cain · · Score: 4, Funny

      BTW: How does one ork a cow?

      Very, VERY, carefully.

    6. Re:grep -R by Bandman · · Score: 1

      I do all kinds of stuff like that, but I got in the habit a long time ago of doing it the "hard" way...

      Example: creating tarballs of datestamp'd directories:

      for FILE in 200808* ; do tar zcvf $FILE.tar.gz $FILE && rm -rf $FILE ; done

    7. Re:grep -R by Bandman · · Score: 2, Insightful

      GNU spoils us Linux folks. The 'date' command on any non-GNU system is like GNU date's retarded little brother

    8. Re:grep -R by vagabond_gr · · Score: 1

      find -type f -ls .

      does the same easier and faster. Not sure if it's POSIX though.

    9. Re:grep -R by Neon+Spiral+Injector · · Score: 1

      Backticks don't nest, so I've moved to the newer $(...) construct.

    10. Re:grep -R by Just+Some+Guy · · Score: 1

      Hell, I think it's probably a GNU extension, because it's still not in Solaris.

      Yeah, because Solaris is often regarded for its pleasant and user-friendly shell environment, so if Solaris doesn't support a convenient option, it must be a weird GNU thing. Either that or it was invented after 1987 and Sun is still evaluating it for inclusion.

      --
      Dewey, what part of this looks like authorities should be involved?
    11. Re:grep -R by mario_grgic · · Score: 1

      Yes, on Mac OS X, you often times have to since on Mac esp. spaces in file/directory names are so common.

      --
      As the island of our knowledge grows, so does the shore of our ignorance.
    12. Re:grep -R by Omega996 · · Score: 1

      hahahaha, i know what you mean - $(...) doesn't look right to me, and without thinking my hands will automatically drop in the backticks.

    13. Re:grep -R by kitgerrits · · Score: 1

      Uhm, with GNU find, you can use:
      find . -type f -ls

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    14. Re:grep -R by 1110110001 · · Score: 1

      With the gnu tools installed use ggrep - also works with other commands, i.e. find becomes gfind, ..

    15. Re:grep -R by tzot · · Score: 1

      You need to explain the "newer" in "the newer $(...) construct". This is the computer age, and this construct existed in ksh at least for 15 years, so I hardly can call "new" something that old. It and the backticks are both old now, and what you say is old news. Like, "I got bored of diapers so I learned to pee in the toilet".

      --
      I speak England very best
    16. Re:grep -R by mollymoo · · Score: 1

      "Newer" is a relative term, its use does not imply either of its operands are new in absolute terms.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    17. Re:grep -R by Bill+Evans · · Score: 1

      BTW: How does one ork a cow?

      You're kidding, right?

      --
      Oh, this Beta, it is not so good.
    18. Re:grep -R by famebait · · Score: 1

      BTW: How does one ork a cow?

      Threel-egged spool and a tail

      --
      sudo ergo sum
    19. Re:grep -R by MikeBabcock · · Score: 1

      Backticks are a lot of fun. Explaining how they work in the context of double-quotes is more fun. I often do simple things like:

      something interesting | tee "/var/log/interesting_`date +%s`_$$.log"

      --
      - Michael T. Babcock (Yes, I blog)
    20. Re:grep -R by jonadab · · Score: 1

      > if Solaris doesn't support a convenient option, it must be a weird GNU thing. Either
      > that or it was invented after 1987 and Sun is still evaluating it for inclusion.

      If you use BSD for six months, you'll discover that a lot of those convenient command-line tool options really *are* Gnu extensions, and just because every Linux distribution since SLS has supported them all doesn't mean the rest of the world has ever heard of them. Also, as a general rule, the idea of useful things being installed by default seems to be pretty much lost on the non-Linux world.

      I don't happen to know about grep -R, though.

      Disclaimer: it's been over a year since I quit using FreeBSD, so my info may be out of date. Slightly.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    21. Re:grep -R by n9hmg · · Score: 1

      You know what? On large heirarchies, fscking around with xargs is MUCH faster. forking and execing a grep for every object has a lot of overhead, while letting grep (or whatever) iterate through a list can really speed things up, by comparison. The OE where that's most evident (among those I've got for comparison) is windows. It doesn't spawn new processes well, no matter what the cygwin guys do.

  10. On to the pranks! by Anonymous Coward · · Score: 4, Funny

    I once worked with an admin that wrote a program that wrote directly to a users terminal and prompted in the same way "write" did. One notable exception is that he let you put whatever username@hostname you wanted.

    I got quite a few requests from "yourmom@pronindustry.com" to chat...

    1. Re:On to the pranks! by crono_deus · · Score: 1
      Heh. Speaking of pranks...

      A TA of mine once wanted to baggy-pants someone in a truly memorable way. He called me over to his computer and entered simply:

      cat gcc | write [dude's username]

      HIlarity, of course, ensued.

      --
      Ne Cede Malis.
    2. Re:On to the pranks! by Pvt_Ryan · · Score: 1

      kill -9 `pidof xxx`

      I remember when i was at uni we wrote/modified a script that was a mix of bash and expect that ssh'd around the computer lab opening and closing the cd-rom drives while playing an amusing tune on the internal speakers.

      Was quite amusing to ssh in and do that from the next room while there was a class in session.

    3. Re:On to the pranks! by pak9rabid · · Score: 1

      I once worked with an admin that wrote a 'compiler' that would remove a random line of text from source code before compiling....if you replace 'worked' with 'read about', and 'admin' with 'BOFH'.

  11. Tab by computersnstuff · · Score: 5, Informative

    I'm sure everyone at some point is surprised of tabbed completion.

    1. Re:Tab by Anonymous Coward · · Score: 5, Funny

      I'm sure everyone at some point is surprised of tabbed completion.

      Woah! Got any more?



      (yes, I'm being sarcastic)

    2. Re:Tab by jd · · Score: 1

      I think more are surprised that the tab completion enhancements package for BASH haven't been updated in years.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    3. Re:Tab by Craig+Davison · · Score: 5, Informative

      With bash, you can even get tab completion for hostnames. Try this:

      ssh user@l[tab]

      Everything after the @ is filled in from /etc/hosts.

    4. Re:Tab by RabidMonkey · · Score: 1

      I was very suprised the other day ... I was using a system I don't get onto very much, to scp some files around. out of habit, I was trying to get a file, doing

      scp user@remotesystem:/home/user/big-file-name-with-lots-of-stupid-things

      and out of habit I hit tab .. and it completed the filename for me.

      The box has ssh keys shared, so I assume that was the channel for this, but was amazed at how it completed a filename on another system.

      nifty.

      --
      We emerge from our mother's womb an unformatted diskette; our culture formats us. - Douglas Coupland
    5. Re:Tab by gEvil+(beta) · · Score: 5, Funny

      I just tried using this in Word. 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?

      --
      This guy's the limit!
    6. Re:Tab by jcam2 · · Score: 4, Insightful

      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.

    7. Re:Tab by Craig+Davison · · Score: 1

      I don't think bash makes ssh connections. Are you sure it didn't just fill that in because /home/user/big-file-name-with-lots-of-stupid-things exists on the local system too?

    8. Re:Tab by fimbulvetr · · Score: 1

      It does make ssh connections, at least on the newest ubuntus with pub keys set up.

    9. Re:Tab by skiingyac · · Score: 1

      CTRL-r for reverse command history search, many people don't know that one.

    10. Re:Tab by ustolemyname · · Score: 1

      It's true. I just found out about this last week. Makes using the terminal on my neo freerunner... tolerable.

    11. Re:Tab by 19thNervousBreakdown · · Score: 1

      Also from ~/.ssh/known_hosts.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    12. Re:Tab by 19thNervousBreakdown · · Score: 1

      I'm sure it is why it did that, I ran into it once myself and was amazed and excited for about three seconds.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    13. Re:Tab by Chris+Pimlott · · Score: 1

      Also from ~/.ssh/known_hosts.

      Nowadays it's standard to hash entries in the known_hosts file, to avoid giving an intruder a list of interesting hosts.

    14. Re:Tab by sorak · · Score: 2, Insightful

      How about this?

    15. Re:Tab by mr_mischief · · Score: 1

      There's a feature of bash that auto-completes more than filenames. You may not have it installed or enabled. It's often a separate package in package-managed distros.

      For example, bash on Mandriva 2008.0 is bash-3.2-5mdv2008.0 but the bash completion RPM is bash-completion-20060301-18mdv2008.0 to get the extra features. Those versions may or may not have been updated since release, and I didn't check.

      The bookmarks for ncftp and knowns hosts for ssh are but two examples of things it will autocomplete. Samba, quota, minicom, several different browsers, the OpenOffice applications, and more are configured with autocompletion rules under bash on my system.

    16. Re:Tab by 19thNervousBreakdown · · Score: 1

      Rainbow tables.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    17. Re:Tab by terkozer · · Score: 1

      I'm pretty sure it doesn't use /etc/hosts. It uses hosts that you've previously ssh'd to, which are stored in ~/.ssh/known_hosts.

    18. Re:Tab by jez9999 · · Score: 4, Funny

      Apparently in Unix you can connect to another computer - get this - *without having to be at the screen* to see it! I think the software was developer by a company called Shell or something. You use 'shhhh' to use it, which I think tells the computer to basically quieten down its TCP communications so it can get ready for the connection to the other machine. I'm probably not doing it justice but you have to see for yourself.

      It's not as good as Windows though because you still have to use typing to do things, and then it's only very boring things like deleting files. :-( I haven't found Solitare or Pinball yet. Hopefully Shell will invent a remote desktop program soon though so we can replace Remote Desktop!

    19. Re:Tab by Bandman · · Score: 5, Funny

      Seriously, I was giving a presentation at a LUG meeting a few years ago, and during a break, some guys came up to me and said "We know you can't type that fast. How do you do that?"

    20. Re:Tab by rubberglove · · Score: 1

      and ~/.ssh/config

    21. Re:Tab by Bandman · · Score: 3, Informative

      funny! I just chanced on this blog entry about ZSH. It sounds really intriguing and apparently has great tab completion.

    22. Re:Tab by __aawkdb2598 · · Score: 1

      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.

      I've given up on restraining myself... I think of it as an act of friendship :D

      After a couple minutes, so do they ;)

    23. Re:Tab by rubberglove · · Score: 1

      that one is great, but I didn't appreciate it until I realized that you have to keep hitting CTRL-r to go cycle further back through your history.

      What's nice is that it also works in the psql and mysql command-line clients --- which is great, since I always forget the exact grant statement and ip addresses I need to use when setting up new mysql databases.

    24. Re:Tab by MiniMike · · Score: 1

      There is a work-around. Try inserting the letters 'a' thru 'z', and then 'A' thru 'Z' at the 'insertion line' thing until you find the one that works. Repeat for the next letter. You will have to do this until the bug is fixed.

    25. Re:Tab by prockcore · · Score: 1

      Actually, here's something I found out a couple of months ago that really did surprise the hell out of me.

      If you use passwordless keys in ssh, scp can do tab completion of the *remote* filesystem.

    26. Re:Tab by prockcore · · Score: 1

      http://ozlabs.org/~jk/docs/bash_completion/

      Bash's programmable completion. Can tab complete remote server files, Make targets, parameters to git/subversion etc.

    27. Re:Tab by Bandman · · Score: 1

      I knew the /etc/hosts, but I had no idea about known_hosts. That's excellent!

    28. Re:Tab by Tsunam · · Score: 1

      The other spot it fills in from is your .ssh/config file as well if you have Host entries in there. Quite handy actually to have every server you log into at work in there and just writing scripts around that list or being able to do.. ssh app1 instead of ssh linuxapp1.host.domain.internal or such.

    29. Re:Tab by JambisJubilee · · Score: 1

      If you don't have root access to modify /etc/hosts, you can always add a ip address/hostname pair to your ~/.bash_hostfile. The tab completion works as expected.

    30. Re:Tab by Chris+Pimlott · · Score: 1

      Rainbow tables.

      Given how on-the-ball the openssh folks are, I'd be willing to bet they use a salt.

    31. Re:Tab by geekoid · · Score: 1

      It doesn't work, and I can prove it.

      Type:
      It was a dark and stormy [TAB]

      Sure as hell, it doesn't finish my book for me.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    32. Re:Tab by goodwid · · Score: 3, Informative

      One of my favorites (in tcsh, at least) is to use ^[p which completes into the history..

      Also, !$ for the previous command's parameter, or !! for the previous command, or !3 for re-doing the third entry in history. Fun stuff.

      --

      The net interprets censorship as damage and routes around it. -- John Gilmore
    33. Re:Tab by billius · · Score: 1

      I'm sure everyone at some point is surprised of tabbed completion.

      Don't forget ctl+a to get to the beginning of a line, too. Why I wasn't taught both of those things on the first day of my first UNIX class I will never understand.

    34. Re:Tab by khellendros1984 · · Score: 1

      In my work environment, I occasionally have to jump onto machines running older Unixes, and they're often missing BASH, or even a sanely-configured SH. Anyhow, my point is that if I hit tab on those machines, it puts a tab into the output. In fact, on some of those machines, backspace produces something like ctrl-c, killing whatever line I was typing in.

      --
      It is pitch black. You are likely to be eaten by a grue.
    35. Re:Tab by 0100010001010011 · · Score: 1

      Tab completion kicks ass in Debian (the only distro I've really delved into).

      I spent a few hours trying to figure out why a new apt module wasn't installed in apache. Came across the a2enmod feature. Tab completion enabled, lists all the Apache Modules.

      apt-get is tab completion enabled, dpkg, just all these random utilities that I hit tab and it'll give me valid input options.

    36. Re:Tab by kramulous · · Score: 1

      Yeah, I had this bug a couple of years ago.

      Drop down to the command line (Run->cmd[enter])
      and type
      format c:[enter]

      It asks a few of the usual annoying questions, just accept or yes.

      Then, there is this marvelous little program called Ubuntu when installed is the final fix.

      --
      .
    37. Re:Tab by LarsG · · Score: 1

      These days I am more surprised/annoyed when I come across a system that doesn't do tab completion.

      As for useful tools.

      screen has been mentioned already, I really wish there was a proper equivalent for X programs.

      cut

      tail -f and -F

      ssh -X user@machine programname

      apropos

      locate

      the -h option to df and du

      --
      If J.K.R wrote Windows: Puteulanus fenestra mortalis!
    38. Re:Tab by wanderingknight · · Score: 1

      Tell me about it. I routinely have to dive into an old AIX server that only has ksh, not bash, and man does it drive me insane. Not only it doesn't support tab completion, it doesn't even support standard history recall! Pressing up just moves the cursor up and sends the escape character to the console, resulting in a garbage command.

    39. Re:Tab by kindbud · · Score: 1

      That's not a feature of bash, per se, it's a feature of the bash profile shell script, which calls /etc/bash_completion to source functions for each command that will have completion support. For ssh, it looks in known_hosts for completion, not /etc/hosts.

      --
      Edith Keeler Must Die
    40. Re:Tab by Pinky · · Score: 1

      In bash you can choose what program to use to do tab completion for a particular command.

      for example:

      complete -C "resolveBookmark" jump

      tells bash to use my resolveBookmark command to do tab completion for my jump command.

      If I type "jump wo", bash executes "resolveBookmark jump wo". resolveBookmark returns a list of completion suggestions for "wo".

      Both jump and resolveBookmark are python scripts.

      enjoy..

    41. Re:Tab by Anonymous Coward · · Score: 1, Funny

      Autocompletion reads your mind! In fact this message was typed entirely by pressing repeatedly.

    42. Re:Tab by ArTourter · · Score: 2, Informative

      Actually, it is filed in from the known_hosts files, both global and user specific. you also don't need to specify the user:

      ssh [tab][tab]

      will list all the hosts and IPs you have used in the past.

      I wish it would complete the -o flag, but it doesn't on my system.

    43. Re:Tab by Pvt_Ryan · · Score: 1

      Thanks for the link, tried zsh a while back and wasn't impressed but then the author seems to have had the same issue as me. I'll give it another go..

      Mods: Mod him up

    44. Re:Tab by TheRaven64 · · Score: 1

      Zsh has been able to make background ssh connections and tab-complete remote files for ages. Apparently this was added with bash 3, but isn't enabled by default.

      --
      I am TheRaven on Soylent News
    45. Re:Tab by Pvt_Ryan · · Score: 1

      I actually laughed at that, though whether that says more about me than the joke i don't know.

    46. Re:Tab by Anonymous Coward · · Score: 1, Informative

      My ZSH is configured to use ~/.ssh/known_hosts for this too. And usernames get completed for things like su or chown... and arguments...

    47. Re:Tab by customizedmischief · · Score: 1

      Does anyone else find themselves trying to use this in the password field? For me, there is brief annoyance that it doesn't work, followed closely by a feeling of silliness mixed with relief.

      --
      Oops.
    48. Re:Tab by kohaku · · Score: 1

      Heh, I did almost the exact same thing; I had a work placement at ARM back when I was in high school, and my boss was showing me something in the console. I said how impressed I was with his typing speed... I never forgot about tab completion after that :D

    49. Re:Tab by setagllib · · Score: 1

      A lot of the functionality was merged in anyway.

      --
      Sam ty sig.
    50. Re:Tab by colin_s_guthrie · · Score: 1

      Certainly on my system it doesn't use /etc/hosts (it may use it as a fall back I guess, not looked). In my env it completes from ~/.ssh/known_hosts and ~/.ssh/config. Altogether more sensible IMO.

      Also make sure you get the programmable scripts http://www.caliban.org/bash/#completion_download to pimp your completion. Can't live without it.

    51. Re:Tab by bodan · · Score: 1

      On Ubuntu it certainly does. Search for 'scp' in /etc/bash_completion for how it does. (It actually runs 'ls' over ssh to find completion strings.)

      --
      "I think I am a fallen star. I should wish on myself."
    52. Re:Tab by xaxa · · Score: 1

      You joke, but OpenOffice writer has a form of completion.

      If you've typed a long word before, type it again and it will suggest the comp|letion

    53. Re:Tab by 19thNervousBreakdown · · Score: 1

      It appears I've salted my joke...

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    54. Re:Tab by shish · · Score: 1

      rainbow tables require you to pre-know (or at least calculate) all possible values; thus it works ok for dictionary words (easy to know) and short alphanumeric strings (easy to generate), but generating a set of tables which contain every possible domain name would take an un-usefully long time.

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
    55. Re:Tab by lahvak · · Score: 1

      I don't know about bash, but zsh does make ssh connections. It also looks at a contents of a tar ball when you type something like tar xjf tarball.tar.bz2 blah

      --
      AccountKiller
    56. Re:Tab by WeirdJohn · · Score: 1

      I remember my amazement that UNIX didn't have completion for many years, as I'd grown addicted to ESC-completion in TOPS20 back in 1980. I was so relieved when I first met bash in 1994.

    57. Re:Tab by Kvan · · Score: 1

      Or for those on the righteous path, "set -o emacs" lets you use your favorite keys (^p, ^n, ^b, ^f, ^a, ^e etc.), and also Esc Esc for completion.

      --

      "A *person* is smart. People are dumb, panicky, dangerous animals and you know it."
      - 'K' in Men in Black.

    58. Re:Tab by jozmala · · Score: 1

      shhhhh -xxx

      Should give ya the effect u want. U can use image viewer and firefox with that also.

      --
      ©God :Copyright is exclusive right for creator to determine the use of his creation.
    59. Re:Tab by MadMidnightBomber · · Score: 1

      I've seen someone at a LUG meeting reboot their computer after changing their IP address. I wish I was joking.

      --
      "It doesn't cost enough, and it makes too much sense."
    60. Re:Tab by richie2000 · · Score: 1

      Stop using Word.

      --
      Money for nothing, pix for free
    61. Re:Tab by foobat · · Score: 2, Funny

      or how often your the sysadmin for a bunch of scientists who ask you a question.

      "so i go into this directory"

      cd /into/a/really/long/directory/without/using/tab/completion

      "and run this command" /why/don't/you/just/add/this/to/your/path/command

      and they type REALLY slowly, sometimes i'm sitting there for a good ten minutes before i just get angry

    62. Re:Tab by eta526 · · Score: 1

      This is correct. For example: bash supports it, sh does not.

    63. Re:Tab by RichiH · · Score: 3, Informative

      Long story short, I know no single person who really used zsh for more than a week and went back to their old shells. By "really" I mean "steal a zshrc from somewhere" or "read the docs". The feature list is too long to even begin, but suffice it to say that once you are used to zsh, you can not imagine why you ever used anything else. Yes, it's that amazing.

      Get "From Bash to Z Shell" if you like dead trees. Subscribe to the mailing list & join the IRC channel if not.

      Find me under my username on freenode or send a PM via /. if you want a quite extensive zshrc which does loads of neat stuff.

    64. Re:Tab by denmarkw00t · · Score: 1

      For sure! My "operating systems" professor was a n00b to the *NIX and wouldn't ever tab completion. Unfortunately, this was even worse because it meant that no one in the class - and most of them were pretty new to things other than Windows - would learn this helpful trick either. He also didn't do code indentation very well - using notepad.exe just makes it worse

    65. Re:Tab by Bandman · · Score: 1

      I think the problem with moving from bash to zsh for me would be the lack of universal application.

      I used to use dvorak, until it drove me insane that no one else anywhere used it. I just accepted the fact that I work in a world that isn't dvorak friendly and now I type qwerty. I'm certain the same thing would happen if I switched to zsh.

      Hell, I get pissy because MacOS doesn't have gnu date on it

    66. Re:Tab by RobBebop · · Score: 1

      I think the software was developer by a company called Shell

      The oil company? No wonder they are so rich!

      --
      Support the 30 Hour Work Week!!!
    67. Re:Tab by RichiH · · Score: 1

      OS X comes with zsh installed, by default (albeit in a weird place, iirc).

      I have root on the machines I use on a regular basis or I can request software to be installed. If that were not the case, I would throw one or two compiled binaries into my svn which I use for RC files and use those on systems where ZSH is not installed.

    68. Re:Tab by Yetihehe · · Score: 1

      Try to do cvs com[tab] or in other places, it's like magic!

      --
      Extreme Programming - Redundant Array of Inexpensive Developers
    69. Re:Tab by Spug · · Score: 1

      Try ^N and ^P

    70. Re:Tab by jonadab · · Score: 1

      > I'm sure everyone at some point is surprised of tabbed completion.

      Apparently most of the kids these days haven't figured it out yet, because they're falling all over themselves to use graphical file managers, which take about eight times as long to do anything as a plain old shell with reasonably good tab completion. Most of the Linux distributions not only *install* Nautilus by default these days, but put it in your session by default too. I still haven't found a use for it.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    71. Re:Tab by jonadab · · Score: 1

      I like the tab completion in eshell. It takes the context of what you've already typed (e.g., the name of the command) into consideration when choosing the best completions.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    72. Re:Tab by badkarmadayaccount · · Score: 1

      del C:>WINDOWS

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    73. Re:Tab by boss_hog · · Score: 1

      If you're in a large-scale (1000's of machines) nfs/automount environment, sometimes typing it out can be as fast or faster than waiting for the shell to read the dir and figure it out.

      just saying... I wish it weren't true, but I've seen it happen.

    74. Re:Tab by RichiH · · Score: 1

      PS: This is not 'moving from Bash to Z Shell'. It's 'all shells from Bash to Z Shell'. It covers csh, ksh etc, as well.

    75. Re:Tab by jberryman · · Score: 1

      Not sure when this functionality was added in Debian, but all of a sudden after typing 'man [tab]' i would get options from man pages (instead of the commands in my path) and after typing 'sudo [tab]' I get options for commands requiring root which don't show up when not prefaced with sudo.

    76. Re:Tab by Sobrique · · Score: 1
      I always ran into it on CSH. Backspace mapping to ^? and a 'break'. VERY annoying. Fix is by using 'stty erase':

      % stty erase "^?"
      % stty intr "^C"
      % stty kill "^X"

    77. Re:Tab by Sobrique · · Score: 1
      I had something similar, when installing VMWare ESX for some Windows-centric colleagues. And even more confusing was the fact that this was in Germany, so I was toggling to 'UK' keyboard, and just touch typing, because that was far faster.

      Ah yes, my Das Keyboard shows some value to my geek-fu.

      Sadly no more, as I had repeated problems with passwords (workplace that mandates 30d password changes, and wierd combos lead to a few too many 'shift' errors)

  12. I never knew that command by PingXao · · Score: 5, Insightful

    And I've been administering Linux systems for awhile now. 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... not so much.

    1. Re:I never knew that command by systemeng · · Score: 2, Insightful

      Compared to Javadocs, I'd say man pages are a gift from the dieties.

    2. Re:I never knew that command by Directrix1 · · Score: 1

      You ever heard of the 'apropos' command?

      --
      Occam's razor is the blind faith in the natural selection of least resistance and in universal oversimplification. -- EF
    3. Re:I never knew that command by PhilipPeake · · Score: 5, Insightful

      This is only true because people write such terrible and incomplete manual pages.

      The original Bell Labs man pages completely described the system from the point of view of an administrator or user. The only better documentation was the source.

      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.

    4. Re:I never knew that command by jd · · Score: 1

      One of the best computer-based documentation systems I ever saw on a computer was Norton Guides. Context-sensitive, pop-up as needed, easily-browsed, navigation was far saner than info. It was little-known when it was around, and died from attention starvation. I've seen nothing comparable for Unix - or, indeed, for any other OS.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    5. Re:I never knew that command by multipartmixed · · Score: 1

      Why?

      nroff an macros might not be all that readable, but you can still grep 'em. That's how _I_ found stuff when I didn't know the magic incantation, back in the dark days before google. (Although, altavista used to wildcard searches, THAT was handy!)

      I don't know anything about info, that doesn't come with UNIX. But I'll bet info pages are pretty greppable too.

      --

      Do daemons dream of electric sleep()?
    6. Re:I never knew that command by Perl-Pusher · · Score: 1

      Yes, I much prefer having my documentation in pdf on a separate dvd, or better yet a paper clip

      Sarcasm aside, I'll take a man page over the documentation most software comes with.

    7. Re:I never knew that command by prgrmr · · Score: 1

      Linux man pages tend to suck sewage water. Real Unix man pages (AIX, HP-UX, DG-UX, DEC) are awesome, and nearly all of them in 1 and 1M contain examples of use.

    8. Re:I never knew that command by greed · · Score: 1

      "man pages" are a decent enough way to distribute command and subroutine documentation.

      What they do NOT provide is an overview; like things you might need to know to perform certain tasks. Once you know about "cp" for copying files, the "cp" man page is useful. And a good "SEE ALSO" section is essential.

      Overall systems documentation for UNIX was traditionally not provided on-line; IBM actually had some pretty good task-oriented docs on-line in 1993, when I first ran into AIX. The big problem with that, though, was this hideous thing called InfoExplorer you had to use... and they didn't have proper man pages once you knew the basics of the task.

      Today, the equivalent for Red Hat Enterprise Linux, for example, is a separate CD. It's not part of manpages or info.

      "man -k keyword" or "whatis keyword" is the way we used to find stuff because the actual doco was somewhere else.

      To the best of my knowledge, man pages originally were a supplement to the paper books. But they were much easier to update, so you'd never really want to read the paper reference manuals. (Guides and user manuals, yes.)

      As for the info stuff... get over it, GNU, and give us complete nroff source. IBM tried a better-than-man documentation system, and it just doesn't work. Do UNIX the UNIX way; if we wanted something else, we'd buy something else.

    9. Re:I never knew that command by Mr.+Slippery · · Score: 1

      who insist on using the terrible "info" crap

      info was doing hypertext back when the WWW was nothing by a gleam in Tim Berners-Lee's eye. Show some respect.

      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    10. Re:I never knew that command by pbhj · · Score: 4, Funny

      [...] a gift from the dieties.

      Are they the ultra-slim super humans I keep hearing about? Or am I confusing them with deadly cocktails??

    11. Re:I never knew that command by SatanicPuppy · · Score: 1

      I agree with you in the sense of "If you need to do something but you don't know the name of the command, man pages suck." Threads like this are always valuable because even experts don't know every command.

      On the other hand, man pages are a nice handy reference for each command, they often come with a "related commands" section which is handy, and I've worked with a lot of operating systems and never seen anything better.

      --
      ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
    12. Re:I never knew that command by CBravo · · Score: 1

      Well, they lost the battle so please convert to the next standard (and I like emacs).

      Respect is earned, not enforced.

      --
      nosig today
    13. Re:I never knew that command by Emperor+Zombie · · Score: 1

      Compared to Javadocs, I'd say man pages are a gift from the dieties.

      What's a diety? A god that's trying to lose weight?

      --
      I'm so excited I just made water in my pantaloons!
    14. Re:I never knew that command by j35ter · · Score: 1

      Yeah, but the hyperlink stuff is what brought us this whole GUI mess in the first place.
      Real men use bash and man!

      --
      Delta-Mike November Bravo Tango
    15. Re:I never knew that command by Lorkki · · Score: 1

      It also means that they've had more time to improve on both usability and their writing conventions. Not exactly something to be proud of in light of the respective results.

    16. Re:I never knew that command by Bromskloss · · Score: 2, Insightful

      The original Bell Labs man pages completely described the system from the point of view of an administrator or user. The only better documentation was the source.

      Would you produce an example of such a man page, so that we may admire it?

      --
      Swedish plasma phys. PhD student; MSc EE; knows maths, programming, electronics; finance interest; seeks opportunities
    17. Re:I never knew that command by ZeroPly · · Score: 1

      When I took OS design way back in my undergrad days, we were expected to learn the nuts and bolts on our own and be able to use csh proficiently. Our professor told us the only thing we needed was the "man" command and to just use that instead of asking him stupid questions.

      So someone innocently asked him how the man command worked and he said to use "man man".

      We thought he was joking, it took about a minute for it to sink in that he was serious and you could actually do this in Unix.

      --
      Support microSD: in a post 9/11 world, it is unwise to carry your data on media that you cannot comfortably swallow.
    18. Re:I never knew that command by Eil · · Score: 1

      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.

      But hey, at least you're not bitter about it.

    19. Re:I never knew that command by whatteaux · · Score: 1

      [...] a gift from the dieties.

      Are they the ultra-slim super humans I keep hearing about? Or am I confusing them with deadly cocktails??

      I thought they were Japanese politicians.

    20. Re:I never knew that command by Creepy+Crawler · · Score: 1

      So Richard Simmons, Weight Watchers, and Jenny Craig made the man pages?

      egads.

      --
    21. Re:I never knew that command by Undead+NDR · · Score: 2, Insightful

      Info sucks, both as a program and as a concept. I want to read my man pages in my $PAGER, not in a dumbed-down Emacs mockup where the info I need is typically buried away in some untold subnode.

      If a piece of software doesn't come with its good old man page, it simply doesn't deserve to be used.

    22. Re:I never knew that command by sydneyfong · · Score: 1

      I've been messing with Linux for about 7 years, admined some small servers (as a volunteer for some small non-commercial entities) and have been using Linux as my main desktop since around 2002. I've never understood how to use "info" (probably due to the fact that I never "got" emacs, being a VI person), but man pages (at least on Debian) are pretty nice to use.

      They aren't the thing you look for when you are completely new to the command, or perhaps the toolset in general, but typically it's the best thing you have other than the source.

      For the basic command line scripting stuff man pages are usually quite complete as a reference. If you don't know which command to use, chances are that you should read a book on the subject, or at least read some intro on the web.

      --
      Don't quote me on this.
    23. Re:I never knew that command by LarsG · · Score: 1

      'apropos' is kinda like google. It is very useful, provided you know what to search for.

      --
      If J.K.R wrote Windows: Puteulanus fenestra mortalis!
    24. Re:I never knew that command by the_brobdingnagian · · Score: 1

      I even had an argument with one of my friends. I kept answering his questions with: "bash(1)" or "ssh(1)" or whatever he needed documentation about. He kept telling me how useless and confusing manpages where, but I couldn't understand why and kept referring him to manpages. After a while he even started to get annoyed with me and I decided to investigate why. It turned out he was using Linux and I was using OpenBSD. The manpages I was refering him to really did suck on Linux. It took a while before I convinced him a well writen manpage can actuaally be usefull.

    25. Re:I never knew that command by mollymoo · · Score: 1

      I've been messing with Linux for about 7 years, admined some small servers (as a volunteer for some small non-commercial entities) and have been using Linux as my main desktop since around 2002. I've never understood how to use "info" (probably due to the fact that I never "got" emacs, being a VI person), but man pages (at least on Debian) are pretty nice to use.

      I never quite "got" info either, it feels like using a sledgehammer to crack a nut and takes longer than just searching a long man page. But Debian's man pages are often horrible because they are so strict in implementing the DFSG that they can't use the original documentation, so the man page is often a brief, inaccurate summary nobody has touched in ten years.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    26. Re:I never knew that command by Mister+Liberty · · Score: 1

      Real men use bash and man!

      Real real men use

      $> strings -n 40 `which <your_binary_here>` | less

    27. Re:I never knew that command by AJWM · · Score: 1

      Context sensitive help doesn't help when you're trying to find a way to do Y and have no idea what context you need to be in to do that.

      The man page may not be immediately obvious either if you don't know the command name, that's when "apropos" helps.

      --
      -- Alastair
    28. Re:I never knew that command by Anonymous Coward · · Score: 1, Informative

      And the VMS HELP pages were (and probably still are) inestimably better than Unix style man pages. Even 20 years later I still miss them.

    29. Re:I never knew that command by dwye · · Score: 1

      What they do NOT provide is an overview; like things you might need to know to perform certain tasks

      SunOS had an Intro page for each man section that also listed the whatis lines for each entry in that section. That seems to have been dropped, anymore.

      To the best of my knowledge, man pages originally were a supplement to the paper books.

      To the best of my knowledge, they were the source of the paper books. They certainly were, back in Version 6.

      But they were much easier to update, so you'd never really want to read the paper reference manuals. (Guides and user manuals, yes.)

      I guess that you are one of those poor souls that never read a set of encyclopedias from cover to cover, then :-)

      They were easier, because it was hard to get a good archive binder or ten; the secretary that I had buy ours had never heard of them, so I had to bring mine from home to show her.

      As for the info stuff... get over it, GNU, and give us complete nroff source.

      That would be admitting that RMS made an error, and that info was not perfect. Never happen.

    30. Re:I never knew that command by Anonymous Coward · · Score: 1, Insightful

      Info's great if you're already a fan of emacs maybe but I'm not and it's kludgy and difficult to navigate. If it must all be hypertext, why not HTML which I can browse with whatever browser I want? I can hit it up from the desktop with Firefox or links from the CLI, search it with whatever indexing I like best and all without having to learn a really uncomfortable control scheme I'll only use for info.

    31. Re:I never knew that command by kitgerrits · · Score: 1

      From that I have seen, Linux man pages were mostly a reference guide.
      If you actually wanted to learn something, you'd go looking for a HOWTO.
      Unfortunately, I haven't heard from TLDP in years...

      Hint: take a look in /usr/share/doc

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    32. Re:I never knew that command by mandolin · · Score: 1

      the tradition is continued by Linux developers who generally provide little or no man page documentation

      Debian, at least, requires all packages to provide manpages for every "program, utility, and function". To not do so is a bug (policy manual 12.1)

      So at least on that distribution, I find the manpage selection to be very broad. I have also not generally had a problem with manpage quality. But YMMV.

    33. Re:I never knew that command by Alioth · · Score: 1

      That's just the authors though. The man pages on OpenBSD are superb. OpenBSD is one OS that I've used where you don't have to search the web for a HOWTO document on doing something complex, like configuring 'pf' or what a device driver supports - the man pages are clear, concise and complete.

    34. Re:I never knew that command by theendlessnow · · Score: 1

      Yes... man pages and info are a pain. I've started writing a talking paper clip application to address the issue (thinking about a dog app to replace find).

    35. Re:I never knew that command by Niten · · Score: 4, Funny

      Pretty much anything in here: http://www.openbsd.org/cgi-bin/man.cgi

    36. Re:I never knew that command by Mr.+Slippery · · Score: 1

      Well, they lost the battle so please convert to the next standard (and I like emacs).

      Texi2HTML will happily output "the next standard" in hypertext, HTML, from a texinfo document.

      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    37. Re:I never knew that command by BrokenHalo · · Score: 1

      You ever heard of the 'apropos' command?

      You beat me to it. apropos would probably have to be the newbie's best friend.

      Also whatis, which also appears on some systems as wtf.

    38. Re:I never knew that command by BrokenHalo · · Score: 1

      Also useful here is man filename | col -b | grep whatever if you have a huge manpage (gcc, for instance) and you're looking for something specific.

    39. Re:I never knew that command by Mr.+Slippery · · Score: 1

      I want to read my man pages in my $PAGER, not in a dumbed-down Emacs mockup where the info I need is typically buried away in some untold subnode.

      Info isn't for man pages. Info is for larger documents.

      You don't want to read the complete elisp manual (about 340,000 words, according to cat /usr/share/info/elisp* | gunzip | wc) in $PAGER.

      These days, you might distribute that sort of documentation as a tarball of HTML files. And indeed, you can get HTML out of texinfo files - as well as PDFs for printing, or on-line viewing if your tastes run that way.

      If you don't like the default reader, there are others.

      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    40. Re:I never knew that command by TheLink · · Score: 1

      I use man -k.

      But that's not the point.

      The point is "man" is like a dictionary. Not a "Cool Unix Tricks for Dummies" guide.

      Hardly anyone reads through all the manpages and then ponders on them to find cool combinations to use it.

      That's why this topic was promising. Unfortunately so far I'm halfway down and it's been somewhat disappointing.

      --
    41. Re:I never knew that command by SpaghettiPattern · · Score: 1

      There was a time when man pages were almost everything you got. To precious save disk space man pages were made available as dead trees.
      Ideally in UNIX every command or configuration file should actually be documented in man-pages. Same holds for (procedural) APIs. Having done Java programming I must admit that Javadoc isn't bad at all.
      But not everyone does this and even the most savvy people in an organization will compromise in that dept. In the early 90ies I worked for a well known corporation developing C on UNIX for OS9. Large project with about 20 people actually coding. Although c2man was very suited and available, nobody seem to care. Instead they preferred to read the code or hop by to the person writing the code to get info. I did care but as a contractor you don't have much of a saying in these costing matters.

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    42. Re:I never knew that command by dkf · · Score: 1

      You don't want to read the complete elisp manual (about 340,000 words, according to cat /usr/share/info/elisp* | gunzip | wc) in $PAGER.

      Hang on there a moment, I most certainly would like to do that. Especially as it would allow me to quickly find anything that I might be interested in, and not just the individual words that the authors thought were worthy of indexing. OK, when I'm online I can just google, but when I'm working on the train I want everything where I can get at it. (The route the train takes has terrible network connectivity due to physical constraints like tunnels and deep cuttings. But at least it makes people yakking on their mobiles shut up...)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    43. Re:I never knew that command by dkf · · Score: 1

      Debian, at least, requires all packages to provide manpages for every "program, utility, and function". To not do so is a bug (policy manual 12.1)

      So at least on that distribution, I find the manpage selection to be very broad. I have also not generally had a problem with manpage quality. But YMMV.

      In my experience, they've got some way to do to get the quality up to where it should be. OTOH, it's a lot of work and massive kudos to them for taking it on. (Key problems tend to be things like failing to explain assumptions on which the software is based, resulting in something that can be used by experts or utter novices, but which isn't helpful to people who are generally good but not experienced with that particular tool.)

      Documentation is important. Unsexy, but important. It's also something that people can help a lot with while learning a tool.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    44. Re:I never knew that command by Bill+Evans · · Score: 1

      You ever heard of the 'apropos' command?

      Exactly. Try this:

      man apropos

      (Sorry, couldn't help myself.)

      --
      Oh, this Beta, it is not so good.
    45. Re:I never knew that command by RichiH · · Score: 2, Insightful

      Agreed. Any man page which does not list examples & common use cases at the end sucks.

    46. Re:I never knew that command by Mr.+Slippery · · Score: 1

      Hang on there a moment, I most certainly would like to do that. Especially as it would allow me to quickly find anything that I might be interested in, and not just the individual words that the authors thought were worthy of indexing.

      You do know that the standard info reader has full search capabilities, right? This is one advantage of info versus the "tarball of HTML files" approach.

      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    47. Re:I never knew that command by famebait · · Score: 1

      Bollocks. The people contributing the commands shouldn't be allowed to without writing proper man pages to go with them.

      --
      sudo ergo sum
    48. Re:I never knew that command by Zuulie · · Score: 1

      I couldn't have said it better myself. As many other people pointed out, most other Un*ces still have excellent man-pages, especially OpenBSD. As for replacing man pages with web based versions... don't even get me started on that one.

    49. Re:I never knew that command by berbo · · Score: 1

      dietIE is Microsoft's new "bloatless browser"

    50. Re:I never knew that command by pimpimpim · · Score: 1

      My first days of linux consisted of Suse, because it came in a nice box with all CDs and a hefty manual (practical when you have no DSL). After Suse, I had openbsd installed for a few years in my early linux days, and its man documentation is really as good as its reputation. I needed it a lot, because Suse used many non-standard file locations :(

      --
      molmod.com - computing tips from a molecular modeling
    51. Re:I never knew that command by Lord+Kestrel · · Score: 1

      Why not just "man foo", and then hit / to search?

    52. Re:I never knew that command by BrokenHalo · · Score: 1

      Cool, thanks, I didn't know that. I learned something new - w00t! :-)

      Except...

      $ man foo
      No manual entry for foo
      $

    53. Re:I never knew that command by laddiebuck · · Score: 1

      Fair do, but today's systems are a thousand times more complex. /usr/share/doc on a Debian system is pretty good.

    54. Re:I never knew that command by An+ominous+Cow+art · · Score: 1

      And you also had the the Orange Wall. I still have a couple of boxes of VMS manuals I can't bring myself to get rid of.

    55. Re:I never knew that command by Dolda2000 · · Score: 1

      This is only true because people write such terrible and incomplete manual pages.

      The original Bell Labs man pages completely described the system from the point of view of an administrator or user. The only better documentation was the source.

      I agree completely, but I'd like to add here that some Linux distros are better than others. I've found that Debian is one of the better -- especially since Debian packagers tend to write manpages for programs that lack them while packaging.

      Of course, the BSDs (probably because of them being real Unix) beats every Linux distro by far. That was one of the things that hit me the hardest when I started using FreeBSD. "Wow, the manpages are usable!"

      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

      I agree with you to some part here, but not completely. I certainly agree that the info system should not be a replacement for manpages, but it has a very definite function in that in can describe larger systems of programs (and larger programs, like Emacs) more completely than can manpages.

      Indeed, there are many info manuals that are extremely useful, such as the one for glibc and the GNU autotools. I use them very often. The one for emacs is also actually very good, but I don't find myself using it very often at all, since emacs is so good at documenting itself anyway. There are some that aren't all that good, too, though. The one for gcc comes to mind.

    56. Re:I never knew that command by badkarmadayaccount · · Score: 1

      May I suggest some of our other FOSS brethren- Solaris, *BSD?

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    57. Re:I never knew that command by danpritts · · Score: 1

      Better yet, if you don't know how to use "info", try reading the man page to figure it out. Just try.

    58. Re:I never knew that command by jon3k · · Score: 1

      I disagree. Too many people skip down and just hack something together from an example without actually learning the command. It makes for dangerous admins with only a fractional understanding of the tools who will eventually fuck something up.

    59. Re:I never knew that command by RichiH · · Score: 1

      Unix and its siblings never struck me as a system with much handholding when you fuck up. Why should manpages be any different? Not that I think that half-knowledge from good examples is better than half-knowledge from random guessing, mind.

      Also, design for your target audience, not for a potential situation which most good admins/users will surpass quickly.

    60. Re:I never knew that command by empaler · · Score: 1

      Ahah! I thought I was the only one who had this extreme dislike, as the web is littered with phrases like "X is a cool command. To learn about it, just 'man X'".

      man is awful!

    61. Re:I never knew that command by ralph.corderoy · · Score: 1

      Couldn't agree more. And it is GNU's fault with its insistence on info that's led to the demise in decent man pages. It was *normal* to learn Unix from the man pages alone back when I learnt it; there was little else. Even later, some good man pages kept up the tradition, e.g. I learnt Perl from the single perl(1) back before it split.

  13. rev by LeninZhiv · · Score: 1

    The rev command has got to be one of the most useless Unix commands I've ever come across. 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.

    1. Re:rev by genner · · Score: 4, Funny

      The rev command has got to be one of the most useless Unix commands I've ever come across. 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.

      Unhackable encryption of course.

    2. Re:rev by Chris+Pimlott · · Score: 4, Interesting

      I sometimes use rev to sort text by the end of the line, not the first. This is often useful when comparing two similar file structures.

      For example:

      $ wc -l foo/* bar/*
            6 foo/dead.letter
          86 foo/xorg.conf
            6 bar/dead.letter
          54 bar/xorg.conf

      $ wc -l foo/* bar/* | rev | sort | rev
          86 foo/xorg.conf
          54 bar/xorg.conf
        152 total
            6 foo/dead.letter
            6 bar/dead.letter

      (Yes, I'm aware you can use sort -k to specify the sort key, but this is quicker and easier)

    3. Re:rev by duguk · · Score: 1

      I don't know about rev, but I've used tac (reverse of cat) a few times for messing about with scripts many many years ago.

    4. Re:rev by Forty+Two+Tenfold · · Score: 1

      USELESS!? Try it in conjunction with a killap like cowsay and fortunes!

      $ fortune | rev | cowsay -d

      --
      Upward mobility is a slippery slope - the higher you climb the more you show your ass.
    5. Re:rev by mr_mischief · · Score: 1

      Damnit, as if I didn't waste enough time on the fortune files already.

    6. Re:rev by evilviper · · Score: 1

      The rev command has got to be one of the most useless Unix commands I've ever come across.

      It's actually VERY useful.

      Many programs output data that has a variable length, or variable number of fields/separators. In such cases it is often much easier to select the correct data as either a number of bytes, white-space or other separator, from the end-of-line, rather than the start.

      Such things can be done with, eg. awk, but with much more complexity, and multiple-steps.

      --
      Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
    7. Re:rev by linuxpyro · · Score: 1

      The rev command has got to be one of the most useless Unix commands I've ever come across. 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.

      I feel the same way about the yes command.

      --
      Saying "I'll probably get modded down for this" in a post is the best way to get it modded up.
    8. Re:rev by Undead+NDR · · Score: 1

      Unhackable encryption of course.

      Especially when coupled with 'tac'.

    9. Re:rev by kitgerrits · · Score: 1

      At least it's shorter than:
      wc -l foo/* bar/* |awk '{print $2,$1}' |sort |awk '{print $2,$1}'
      Although this can be useful for processing things like Postfix logs.

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    10. Re:rev by kitgerrits · · Score: 1

      Oh, and two more tricks for awk:
      $NF (number of fields), points to last variable in line
      $NR (number of rows, gives current line #)

      Try looking up BEGIN and END for more fun stuff with AWK!

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    11. Re:rev by smellotron · · Score: 1

      tac

      You just made my day! I've looked for that commmand for years! All this time, I've been using

      awk '{ printf "%10d %s\n", NR, $0 }' | sort -rn | awk '{ print substr($0,12) }'

    12. Re:rev by v1456vqe · · Score: 1

      As long as rev reverses what's it given, its useful. That is the unix philosophy, do one thing that you promise to do well and let the user decide how to use. These days there are use cases every where, with programmers, managers predicting what the user wants to do and deciding how he should do it. And declare a tool to be useless if it doesn't fit into the 'how to do it'

    13. Re:rev by Anonymous Coward · · Score: 1, Informative

      This might be horrendously ugly, but I use it all the time, normally in pairs. One example is to grab file extensions in a bourne-shell (not bash) compatible way

      as in:

      EXT=`echo $FILE | rev | cut -f 1 -d '.' | rev`

      I know I know there are shell builtins for stuff like this for all recent shells. But why would you want to fuss with those.

    14. Re:rev by x78 · · Score: 1

      Oh no! yes is a far more interesting command!
      What yes is used for I really have no clue

      --
      Don't panic
    15. Re:rev by Bill+Evans · · Score: 1

      Two words: rhyming dictionary.

      rev | sort | rev

      --
      Oh, this Beta, it is not so good.
    16. Re:rev by dyingtolive · · Score: 1

      Uh, I'm grasping at straws here, but how about alias ls='ls | rev | tac' for the win?

      --
      Support the EFF and Creative Commons. The war is coming, and they're supporting you...
    17. Re:rev by remmelt · · Score: 1

      yes | mysqladmin drop database

    18. Re:rev by remmelt · · Score: 1

      ....

      mysqladmin -f drop database

      Thanks!

    19. Re:rev by MikeBabcock · · Score: 1

      Also, "sort -g" sorts numerically.

      For example, I sometimes do:

      rpm -qa --queryformat "%{size} %{name}\n" | sort -g | less

      --
      - Michael T. Babcock (Yes, I blog)
    20. Re:rev by Anonymous Coward · · Score: 1, Informative

      The rev command has got to be one of the most useless Unix commands I've ever come across.

      That's crazy talk. I use rev all the time in shell scripts. Especially if I need the last bit of information in a line of unpredictable length. I''m so grateful for the core-utils.

    21. Re:rev by rkww · · Score: 1

      The rev command has got to be one of the most useless Unix commands I've ever come across. I can't imagine what it's for.

      An iscsi qualified name contain a reversed domain name:

      iqn.yyyy-mm.{reversed domain name}

      So foo.bar.bar -> bar.baz.foo:

      REV=`hostname | tr "." "\n" | rev | tr "\n" "." | rev`

    22. Re:rev by genner · · Score: 1

      tail -1 filename

      does the same thing and is much simpler.

    23. Re:rev by Adam+Hazzlebank · · Score: 1

      I've used it as a quick and dirty hack to create the reverse strand of a DNA sequence before. You replace A with T and G with C (with whatever) and then run the resulting sequence through rev. Reverse stand!

  14. Listing directory contents without the ls command by thepacketmaster · · Score: 4, Informative
    echo *

    I discovered if you give the echo shell command an asterisk as a parameter, it dumps out the file names of the current directory. (The sad thing is I had a practical use for this when a less-than-clueful-collegue deleted the /bin directory, leaving the system without an ls program).

    --

    --

    Luck is just skill you didn't know you had.

  15. A simple search by AKAImBatman · · Score: 2, Informative

    find . -exec grep -l keyword {} \;

    Works like a charm for finding a file containing a keyword. Another one I often use is:

    Human readable disk space:

    df -h

    Track down where your space is going:

    du -h

    1. Re:A simple search by UnderScan · · Score: 2, Informative
      Your

      find . -exec grep -l keyword {} \;

      is fine for non-GNU UNIX grep.

      If you have GNU grep, then

      grep -lR keyword .

    2. Re:A simple search by corsec67 · · Score: 1

      find . -exec grep -l keyword {} \;

      grep -l keyword -r .

      --
      If I have nothing to hide, don't search me
    3. Re:A simple search by cain · · Score: 1

      find . -exec grep -l keyword {} \;

      In fewer keystrokes:

      grep -R keyword .

    4. Re:A simple search by SuiteSisterMary · · Score: 1

      du -h --max-depth=1

      Also good,

      du -b * | sort -nr

      --
      Vintage computer games and RPG books available. Email me if you're interested.
    5. Re:A simple search by Foldarn · · Score: 1

      use this instead: find . | xargs grep -l keyword much faster.

    6. Re:A simple search by xaositects · · Score: 1

      find the top 20 space wasting files in a dir:

      du -cks | sort -rn | head 21

      du with sizes in human readable format:

      du -cksh

    7. Re:A simple search by element-o.p. · · Score: 1

      I add -x to the du command so that it won't cross to other mounted file systems, since I'm usually trying to find out what is using up all the space on a particular partition.

      --
      MCSE? No, sir...I don't do Windows. Yes, I am an idealist. What's your point?
    8. Re:A simple search by AKAImBatman · · Score: 1

      I spend most of my time on Solaris, so I try to forget about GNU extensions. Though untarring without "-z" or "-j" is a real pain in the neck.

    9. Re:A simple search by Waffle+Iron · · Score: 1

      Human readable disk space:

      df -h

      Same thing, but without having to do annoying KiB to MiB to GiB conversions in your head:

      df --si
      du --si

    10. Re:A simple search by morgan_greywolf · · Score: 1

      The k is redundant with the h in there. On that last command. Just 'du -csh' is all you need. Note: -h only works with GNU grep.

    11. Re:A simple search by AKAImBatman · · Score: 4, Informative

      Xargs is much more fun with complex data processing. e.g.

      Convert all PSDs to PNGs:

      ls *.psd | cut -d . -f 1 | xargs -L1 -i convert {}.psd {}.png

      Parse out and sort column 2 from a semicolon delimited file:

      cat myfile.txt | cut -d \; -f 2 | sort > output.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. e.g. I had a list where every other line was blank. So I needed to count n/2 the value. 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. Instant character count.

      Ah, all the fun stuff you can do with Unix tools.

    12. Re:A simple search by skiingyac · · Score: 1

      search and replace multiple files: perl -p -i -e 's/foo/bar/g' file1 file2 file3

    13. Re:A simple search by AKAImBatman · · Score: 1

      Err... the whole point of the "-h" is to output the result in "human readable form". Using "-h" gives you GB, MB, or KB depending on how large the byte count is.

      e.g.:

      bash-2.05$ df -h
      Filesystem size used avail capacity Mounted on
      /dev/dsk/c0t0d0s0 7.3G 94M 7.1G 1% /
      /dev/dsk/c0t0d0s1 185G 10.5G 174G 6% /usr

    14. Re:A simple search by Forty+Two+Tenfold · · Score: 1

      boss: Joyce, could you copy the April charts for our partners, they'll come in a few... ...
      assistant: Hi, you want those charts for April, yes?
      partners: Yes, if you'd be so kind, we've got a blank disk here.
      assistant: But of course!
      Puts the floppy into the drive and:
      # mkfs -t vfat -c /dev/fd0h1440
      # mount -t vfat -o iocharset=iso8859-2,codepage=852 /dev/fd0 /mnt/floppy
      # find / -noleaf -type f -name charts_April.[a-zA-Z] -exec cp '{ }' /mnt/floppy \;
      # ls -la /mnt/floppy/Wyniki_KwiecieÅ.[a-z][A-Z] && sync && sleep 3
      Removes the floppy and passes it to the partners.
      partners: Holy fuck!
      assistant: Oh, dear, I forgot to unmount again.

      --
      Upward mobility is a slippery slope - the higher you climb the more you show your ass.
    15. Re:A simple search by Forty+Two+Tenfold · · Score: 1

      Of course, I blew it at the translation, never mind :P

      --
      Upward mobility is a slippery slope - the higher you climb the more you show your ass.
    16. Re:A simple search by JohnnyBGod · · Score: 1

      Erm... what was wrong with 'grep -nri keyword *'?

    17. Re:A simple search by MrMunkey · · Score: 1

      du -h

      I prefer

      du --max-depth=1 -h

      That way I can see the size of just the current directories rather than all the sub-directories as well.

    18. Re:A simple search by nocomment · · Score: 1

      I use the 'douche' command for that. It's also more compatible with other oses: du -sh

      --
      /* oops I accidentally made a comment, sorry */
      /* http://allyourbasearebelongto.us */
    19. Re:A simple search by miLosh_pleXus · · Score: 1

      well, at least on solaris systems this find command does not *work like a charm* when searching approx. more than 2000 files (or however many filenames fit on your shell stack). and it greps directories too, thus the correct and always *working like a charm* cmd to grep in several files is:

      find . -type f |xargs grep keyword

    20. Re:A simple search by Amazing+Quantum+Man · · Score: 1

      To avoid excessive forks, try:

      find . -type f -print0 | xargs -0 grep -l keyword

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    21. Re:A simple search by Chris+Pimlott · · Score: 3, Informative

      Your

      find . -exec grep -l keyword {} \;

      is fine for non-GNU UNIX grep.

      If you have GNU grep, then

      grep -lR keyword .

      Most systems will GNU grep will also have an rgrep command which is the same as 'grep -r'.

      But the find approach allows much more sophisticated searches. Such as:

      find . -name \*.xml -not -user root -exec grep -l keyword {} \;

      (search all .xml files that aren't owned by root)

    22. Re:A simple search by phlurg · · Score: 1
      You can also trick grep into displaying the filenames by adding /dev/null, e.g.,

      find . -exec grep -l keyword {} /dev/null \;

    23. Re:A simple search by phlurg · · Score: 1

      You can also trick grep into displaying the filenames by adding /dev/null, e.g.,

      find . -exec grep -l keyword {} /dev/null \;

      Er, I meant without the '-l', so you get the filename and the matched line...

    24. Re:A simple search by mr_mischief · · Score: 2, Interesting

      I often prefer

      du -sh *

      It gives me the human-readable total for several subdirectories of the current total, summed up as total recursive usage for each. Then I can look deeper at the subdirectories that are actually causing the problem, perhaps without the -s.

    25. Re:A simple search by jonaskoelker · · Score: 1

      Human readable disk space

      How about human viewable disk space? "Baobab", the gnome disk usage analyzer, or konqueror's file size view or RadialMap view? I find that a lot easier to work with: looking at relative sizes works a lot faster than comparing numbers.

      (Okay, they're not command line tools and as such a bit OT, but they're awesome tools)

    26. Re:A simple search by Waffle+Iron · · Score: 1

      No, it gives you binary derived GiB, MiB and KiB. These are a royal PITA to deal with when the output contains any mixture of the three.

      The '--si' option gives you honest-to-goodness decimal GB MB and KB numbers, which is the way God intended humans to see them.

    27. Re:A simple search by BuildMonkey · · Score: 1

      Much faster:
      grep -r keyword .

      If you want to skip binary files when searching (usually I do):
      grep -Ir keyword .

      Of course, this only works with GNU grep. The find version you show works on systems without GNU grep, like the Solaris system I'm working on this week. (Client's server, cannot add it.)

    28. Re:A simple search by AKAImBatman · · Score: 1

      The '--si' option gives you honest-to-goodness decimal GB MB and KB numbers, which is the way God intended humans to see them.

      If God intended us to use SI units, he wouldn't have made binary base-2. :-P

    29. Re:A simple search by vagabond_gr · · Score: 1

      grep -rl keyword .

      Much faster. You run only grep and only once, not once per file.

      grep --exclude-dir=.svn

      This is also life saving when greping in svn working copies.

    30. Re:A simple search by xeoron · · Score: 1
      For watching network sockets, I find this one most useful on Linux systems:

      sudo watch -n1 "netstat -nape --inet && echo "-- lsof --" && lsof -iTCP"

    31. Re:A simple search by AKAImBatman · · Score: 1

      If you're going to go for a graphical tool, then go from easy to awesome. As long as you have a JVM, just click on the Webstart link and go! :-)

    32. Re:A simple search by The+Cisco+Kid · · Score: 1

      'locate' is a much faster way to find files, unless they've only been recently created, and as long as the machine is on 24/7.

      (man locate, man updatedb for more info)

    33. Re:A simple search by bigtangringo · · Score: 1

      Same as your first command:

      grep -ri keyword /path/to/whatever/

      --
      Yes, I am a smart ass; it's better than the alternative.
    34. Re:A simple search by AKAImBatman · · Score: 1

      The locate command is useless. Worse than useless, in fact. Most systems I've used don't have a proper locate database configured. Even when they do, half the time we're talking about combing through log files. (i.e. recent data) Which makes locate even more useless than useless. (If that's possible! :-P)

    35. Re:A simple search by Eil · · Score: 1

      find . -exec grep -l keyword {} \;

      This might be easier, unless there's some advantage to using find that I'm unaware of:

      grep -rl keyboard .

    36. Re:A simple search by Bandman · · Score: 1

      Doesn't unix tar have -y for .Z ?

    37. Re:A simple search by Bandman · · Score: 1

      If you don't want directories,

      ls -alSr | tail -n 10

    38. Re:A simple search by Bandman · · Score: 1

      Unless you've forgotten to mount the remote shares, and you're wondering why / is completely full...

      Never had that happen...nope, not me...

    39. Re:A simple search by AKAImBatman · · Score: 1

      unless there's some advantage to using find that I'm unaware of

      You mean, like the half-dozen posts above yours that point out that '-r' doesn't work on actual Unix systems? ;-)

      To reiterate, I mostly use Solaris. In result, '-r' and 'rgrep' don't work unless explicitly installed. I don't usually install them for three reasons:

      1. I'm often using employer systems which I do not administrate

      2. Updating dozens of systems is a PITA and a waste of time

      3. It's just easier to depend on what you know will be there. ;-)

    40. Re:A simple search by Bandman · · Score: 1

      du -hs

    41. Re:A simple search by AKAImBatman · · Score: 1

      Nope. That's a GNU feature. And in any case, who uses .Z files anymore? I'm more concerned about .gz and .bz2 files. :-)

    42. Re:A simple search by tom17 · · Score: 1

      Oh really?

      bash-3.00$ uname -sr
      SunOS 5.10
      bash-3.00$ grep -r foo .
      grep: illegal option -- r
      Usage: grep -hblcnsviw pattern file . . .

      Don't assume that everyone has the same grep you have on your Linux. Especially in a Unix tricks thread :)

      Tom...

    43. Re:A simple search by Hatta · · Score: 1

      Is piping it through gzip or bzip really all that bad? It's still just one line.

      --
      Give me Classic Slashdot or give me death!
    44. Re:A simple search by Hatta · · Score: 1

      No, locate is great. It's set up correctly by default on any distribution I've used. If you're looking for log files the content changes often, but the file name is pretty much always the same, which is all locate is good for anyway.

      I find I don't nearly create as many new files as I do view and edit old files. And when I do, they're fresh in my memory anyway, so I don't need to use locate for those. So whenever I need to update my CV, it's 'locate CV'. Forgot where I put my nes roms? Do 'locate -i excitebike'. Need the sequence to some primers I designed last year? Try 'locate -i ras | grep primers'

      Of course this all depends on you using meaningful file and directory names, but you were doing that anyway, right?

      --
      Give me Classic Slashdot or give me death!
    45. Re:A simple search by anom · · Score: 1

      Grep has this built in grep -r [-i] "keyword" *

    46. Re:A simple search by EvanED · · Score: 1

      'locate' is a much faster way to find files, unless they've only been recently created, and as long as the machine is on 24/7.

      And as long as your home directory is mounted when updatedb is run, and indexes it, etc.

      For instance, locate is useless on my school/work computer because my home directory is on a network FS that doesn't get indexed. It's very frustrating because I basically have to use find for anything I want to see.

    47. Re:A simple search by shewfig · · Score: 1

      Xargs is much more fun with complex data processing[...]

      It's especially fun when 'find' finds nothing, and returns that to xargs, which happily applies the given command to the nothing it was given... I lost /var that way once.

      But it doesn't REALLY get fun until you write shell scripts that are supposed to work on both Linux and Solaris... because one has a 'find' which smart-splits the list like 'xargs', and the other has a 'xargs' that won't do something to nothing... 2 complete, yet completely incompatible, solutions.

    48. Re:A simple search by AKAImBatman · · Score: 1

      You do realize that your command does diddly squat, right? The task was to CONVERT photoshop images into PNG images, not rename them.

    49. Re:A simple search by thogard · · Score: 1

      gzip called zcat will decompress both .Z and .z files. Handy for zcat foo.tar.gz | tar -xvf -;cd *;./configure && make && su root -c make install ... if your brave

    50. Re:A simple search by fuckface · · Score: 1

      Um, yeah, until grep comes across a named pipe (or some other irregular file) and comes to a screeching halt. You come back 3 hours later and still have no prompt. I wish there was an option for "only recurse over REGULAR files."

    51. Re:A simple search by TREE · · Score: 1

      Yet Another Reason To Use Debian. :)

    52. Re:A simple search by Bombcar · · Score: 1

      I've discovered that at least on modern Ubuntu, tar figures out compression itself: tar xvf file.tgz works without the z.

    53. Re:A simple search by Bandman · · Score: 1

      Nice. I'm not sure I'd trust it in production, but cool nonetheless

    54. Re:A simple search by hackstraw · · Score: 1

      Track down where your space is going:

      du -h

      Its better to do:

      du | sort -n

      The big directories are at the bottom, and that is where you should start cleaning up first.

    55. Re:A simple search by Lally+Singh · · Score: 1

      I was a TA for the unix course here, and the final exam was a shell script that validated XML files using only your basic tools: shell scripts, pipes, sed, awk, and grep.

      Piping through ( subshells ) at times, as a giant pipeline. Well, that was my solution to it.

      --
      Care about electronic freedom? Consider donating to the EFF!
    56. Re:A simple search by TheLink · · Score: 1

      I prefer just doing it in one go:

      du -k | sort -nr | more

      --
    57. Re:A simple search by AnteTempore · · Score: 1

      Xargs is much more fun with complex data processing. e.g.

      Convert all PSDs to PNGs:

      ls *.psd | cut -d . -f 1 | xargs -L1 -i convert {}.psd {}.png

      Ahh, but you will get bitten by all the files with single quotes (like: Mum's birthday.psd)

      Parallel to the rescue (then you can also make sure you use all your cpu cores):

      ls *.psd | cut -d . -f 1 | parallel -j+0 convert {}.psd {}.png

    58. Re:A simple search by MikeBabcock · · Score: 1

      du -ms * | sort -g is even better.

      --
      - Michael T. Babcock (Yes, I blog)
    59. Re:A simple search by corbettw · · Score: 1

      Parse out and sort column 2 from a semicolon delimited file:

      cat myfile.txt | cut -d \; -f 2 | sort > output.txt

      Um, why wouldn't you just:

      awk -F; '{print $2}' myfile.txt | sort > output.txt

      Seems easier to me.

      --
      God invented whiskey so the Irish would not rule the world.
    60. Re:A simple search by jon3k · · Score: 1

      Locate is great for quickly finding a file by name. I'd much rather:

      $locate [random-file]

      than

      $find / -name [random-file] -print

      It's all about the right tool for the right job.

  16. Screen by hardburn · · Score: 4, Funny

    A sys admin was recently surprised that I didn't use screen. My explaination was that all that C-x stuff reminded me too much of using Emacs.

    Moderators are free to mod this Flamebait or Insightful, depending on personal bias.

    --
    Not a typewriter
    1. Re:Screen by Randle_Revar · · Score: 2, Informative

      you don't have to use Ctrl-a. You can bind screen's escape to any key.

    2. Re:Screen by dirtyhippie · · Score: 1

      haha, i have the same problem :-)

    3. Re:Screen by geekoid · · Score: 1

      +1 insightbait

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    4. Re:Screen by Just+Some+Guy · · Score: 1

      Moderators are free to mod this Flamebait or Insightful, depending on personal bias.

      Too bad there's not "-1: Tarded". Seriously, you deliberately avoid one of the most useful tools known to Unix admins just because of a (very) superficial similarity to another tool?

      Use case: start a giant build on your home server inside a screen session. Get to work. Wonder if it's still going, SSH in, and run screen -x to check on it.

      --
      Dewey, what part of this looks like authorities should be involved?
    5. Re:Screen by VoidCrow · · Score: 1

      I know what you mean, but screen is usable.

    6. Re:Screen by Hatta · · Score: 1

      Once you start using Screen, you start needing it a lot more often. For instance, how do you keep your same instance of irssi logged in when you're moving from terminal to terminal? What do you do when you're running a long ass video compression in one terminal window, and then you want to update your video driver? Hope you started screen first.

      --
      Give me Classic Slashdot or give me death!
    7. Re:Screen by PitaBred · · Score: 1

      It may remind you of using emacs, but I'm not aware of any other ways to keep an interactive session running in the background other than screen. I like being able to run any console program (hello rtorrent!) from a re-connectable interface that is resistant to connection hiccups.

    8. Re:Screen by TheRaven64 · · Score: 1

      Yes, there are much better reasons for hating screen, like the fact it randomly mangles terminal control sequences and breaks the back buffer, replacing it with its own, more limited, version.

      --
      I am TheRaven on Soylent News
    9. Re:Screen by dysprosia · · Score: 1

      So use dtach.

    10. Re:Screen by dbrower · · Score: 1
      I stopped using screen when I turned in my vt220 for something that had multiple windows and the ability to start more than one xterm.

      Why would anyone want to use screen?

      puzzled,

      -dB

      --
      "It if was easy to do, we'd find someone cheaper than you to do it."
    11. Re:Screen by word_virus · · Score: 1

      I've had good luck with the following couple of lines in my .screenrc: defscrollback 2000 termcapinfo xterm ti@:te@

    12. Re:Screen by mollymoo · · Score: 1

      Why would anyone want to use screen?

      For remote sessions from a machine you sleep or reboot a lot.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    13. Re:Screen by Anonymous Coward · · Score: 1, Informative

      in ~/.screenrc you can remap pretty much all the keys, including the control key. I've set mine to '`', and it works like a charm.

    14. Re:Screen by RichiH · · Score: 1

      I like the CTRL-A syntax as that keeps the ESC key free for the truly important editors :)

    15. Re:Screen by Khopesh · · Score: 1

      That's not what screen is for. I use BOTH screen and mrxvt (although anybody not attached to mrxvt but liking the idea of tabs might want to try xfce4-terminal or gnome-terminal or konsole, all of which have tabs plus freaking UTF-8 support).

      Screen really shines across SSH. You only need one ssh connection if it results in a screen session. I've got screen -r >/dev/null 2>&1 in my startup scripts (~/.bashrc or ~/.zshrc) on all the servers I use. If it doesn't put me in a screen session, I try to figure out if the server has rebooted (in which case I start a new screen session) or if I'm already connected elsewhere (in which case I manually run screen -x ).

      --
      Use my userscript to add story images to Slashdot. There's no going back.
    16. Re:Screen by rasputin465 · · Score: 1

      A sys admin was recently surprised that I didn't use screen. My explaination was that all that C-x stuff reminded me too much of using Emacs.

      I've always used emacs whenever I need a quick terminal-based text editor (yeah I know, "real users use vi"; whatever). But one server I used to work on had a problem where for whatever reason emacs wasn't working, and so I would use pico instead. And the problem with pico on this machine was that C-x C-s (which was ingrained in muscle-memory for me, reflex-like) would freeze the whole terminal. The only recourse would be to login separately, find the PID of the pico process and kill -9 (and only -9), whereby none of the changes had been saved. My co-workers sharing my office were both annoyed and amused because they'd be quietly working and at least a few times a day, out of nowhere I would just immediately shout, "FUCK!!".

    17. Re:Screen by BrunoUsesBBEdit · · Score: 1

      We tagged this post as "Funny" because "Sad" wasn't an option. There are plenty of good reasons not to use screen, but Ctrl key bindings is not one of them. Those good reasons include:
      1. I spend all my time in the GUI anyway.
      2. I can't get anything done over SSH, I use VNC.
      3. What's screen? I use DOSKey isn't that the same?

    18. Re:Screen by jon3k · · Score: 1

      Because a lot of us having a running process we'd like to reattach to remotely.

      I have a server that's always running 3 screen session: one for irssi, one for rtorrent and one for ventrilo. I can, at any time, from anywhere, ssh in and reattach to those running sessions. I still have scroll back buffers in irssi so I can catch up on the conversation, I can add more torrents to rtorrent or administer my ventrilo server.

    19. Re:Screen by dbrower · · Score: 1
      I usually just setup a persistant vnc server on the host in question, and attach to it. I suppose it depends on the capacity of the target system, and the available bandwidth to it. Neither of these is usually an issue for me. I can imagine those with embedded targets and slow modems being concerned, but I still remain amazed that anyone uses this feature of the knife very often. Next thing I'll hear about is someone using "cu" or "tip".

      -dB

      --
      "It if was easy to do, we'd find someone cheaper than you to do it."
  17. X-forwarding by mikeb · · Score: 5, Informative

    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.

    1. Re:X-forwarding by BigJClark · · Score: 5, Insightful


      ... or even funnier, is how long (as in decades) we've been able to do that.

      --

      Hi, I Boris. Hear fix bear, yes?
    2. Re:X-forwarding by Anonymous Coward · · Score: 2, Funny

      other side of the world and run X programs over forwarding.

      The real amazing thing is that they stayed their waiting so long!

    3. Re:X-forwarding by kwabbles · · Score: 1

      Whatever. We all know that x forwarding was an idea stolen from Microsoft's Terminal Server technology.

      --
      Just disrupt the deflector shield with a tachyon burst.
    4. Re:X-forwarding by blair1q · · Score: 1

      not quite, but rdesktop was

    5. Re:X-forwarding by Anonymous Coward · · Score: 1, Interesting

      For those of us that are new(ish) to the Linux world, would you be willing to describe the commands/process?

    6. Re:X-forwarding by Shikaku · · Score: 3, Informative

      http://www.math.umn.edu/systems_guide/putty_xwin32.html

      First result of X-Forwarding on Google.

    7. Re:X-forwarding by Chris+Pimlott · · Score: 5, Informative

      You could easily have an entire Ask Slashdot just on ssh, perhaps the greatest unix command ever invented.

      One of it's many great uses is creating secure tunnels:

      ssh user@remotehost -L123:example.com:456

      Open a tunnel on your local machine, port 123, to example.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.

    8. Re:X-forwarding by Toreo+asesino · · Score: 1

      That wouldn't essentially be remote desktop would it?

      (Just curious)

      --
      throw new NoSignatureException();
    9. Re:X-forwarding by miffo.swe · · Score: 1

      X-forwarding was how i finally won my collegue over from the dark side. He was hammering on windows in putty to the linux servers but when i showed him how he could use whatever GUI stuff he could need over SSH from a linux box he was home. Lately my fellow and former gates-kisser has started lamenting all the linux-stuff he misses when he works on Windows-boxes.

      --
      HTTP/1.1 400
    10. Re:X-forwarding by GenP · · Score: 1

      Without the detach option. Kill the connection and the app dies on the remote end.

    11. Re:X-forwarding by kwabbles · · Score: 1

      Whatyoutalkinbout? Everyone knows that every idea is stolen from Microsoft.

      --
      Just disrupt the deflector shield with a tachyon burst.
    12. Re:X-forwarding by doti · · Score: 1

      Sorry, but X forwarding predates Microsoft's existence.

      --
      factor 966971: 966971
    13. Re:X-forwarding by jtev · · Score: 1

      No, with X you can display applications from multiple hosts on the same destop space. So you can run an app on your local machine, your machine at home, and the server you're admining all at the same time, displaying all three on your desktop, in a transparent manner. That means that hypothetically I could be looking at porn via my home computer, monitoring gtop on the server I admin, and pretending to be doing work all at the same time. Though, since X is a bitmaped protocol, it would make my porn viewing experiance suboptimal, and I never know if work is monitoring my screen, so I save the porn or home. Just saying I could.

      --
      That which is done from love exists beyond good and evil
    14. Re:X-forwarding by vagabond_gr · · Score: 1

      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.

      The astonishment is only about how *paifully slow* it is. Seriously, to run GUIs nothing in the unix world can beat terminal services. VNC can come close, but not quite.

      Still, most of the time you *don't want* to run GUIs, and then the efficiency and ease of use of ssh has no match.

    15. Re:X-forwarding by j35ter · · Score: 1

      Whatever. We all know that x forwarding was an idea stolen from Microsoft's Terminal Server technology.

      Man, you've got to have balls this big *puts two fists together* in order to post something like this on /.
      Either that or you're just another troll...

      --
      Delta-Mike November Bravo Tango
    16. Re:X-forwarding by et764 · · Score: 1

      In college I was working on a collaborative programming project in one of my classes. It was one that didn't really lend itself well to decomposing into things we could work on independently. We were using Emacs as our editor, which has this cool feature where you can open new frames on completely different displays. Thus, the guy I was working with and I each had our own Emacs window on our own computer and were editing the same file at the same time. I was impressed.

    17. Re:X-forwarding by Dr.+Evil · · Score: 1

      He should install Cygwin/X and use PuTTY for the forwarding. The shell is nowhere near as slick as the Linux shell, but the functionality is there, particularly the X forwarding. He could use OpenSSH on Cygwin if he's not big on PuTTY, but the GUI integration and screen logging is better in PuTTY.

    18. Re:X-forwarding by Toreo+asesino · · Score: 1

      Not unless you logoff, the session is closed by an admin, or it time-outs it won't. This X stuff sounds very similar so far

      --
      throw new NoSignatureException();
    19. Re:X-forwarding by Toreo+asesino · · Score: 1

      You know a technology is good when it's demonstrated in terms of porn load-balancing.

      Excellent explanation, thanks!

      --
      throw new NoSignatureException();
    20. Re:X-forwarding by RollingThunder · · Score: 1

      No kidding.

      I once installed Oracle via the GUI when I was in Vancouver and the Linux server in Seoul.

      It should have taken 20 minutes - it took over 10 hours. All screen redraw delays. I learned how to do it non-interactively after that.

    21. Re:X-forwarding by Blakey+Rat · · Score: 2

      So, you deal with really stupid Windows users?

      Because that's not really that revolutionary in any OS at this point. Nor was it 5 years ago.

    22. Re:X-forwarding by jeremyp · · Score: 3, Insightful

      They're probably slack jawed and astonished at how primitive and slow it is compered with a remote desktop connection.

      And let's be honest, the real good bit is not that you can forward X but that you can forward anything you want, for instance, I will ssh into our gateway server and forward the RDC port from our Exchange server because it's quicker and easier than our VPN connection. RDC runs much faster over ssh than X does, btw.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    23. Re:X-forwarding by Hatta · · Score: 3, Informative

      That means that hypothetically I could be looking at porn via my home computer

      If you're going to do that, make sure you run firefox with the -no-remote flag. Otherwise it will detect that you're in an SSH session, and just open a new window on your local machine.

      --
      Give me Classic Slashdot or give me death!
    24. Re:X-forwarding by EvanED · · Score: 1

      Just as a warning, I've had to use ssh -Y instead of -X before. The failures produced basically no error message (in fact it may be that the X window just went away) so there was no clear cause; if you run into this, you could try -Y instead. Read the man page first.

    25. Re:X-forwarding by Pvt_Ryan · · Score: 1

      Thank is true but then all windows desktops are the same so MS cheat by rendering everything locally and not transmitting all of the graphical data.

    26. Re:X-forwarding by spazdor · · Score: 1

      *whoosh*

      --
      DRM: Terminator crops for your mind!
    27. Re:X-forwarding by Trogre · · Score: 1

      That statement is categorically false.

      From my Fedora Linux box at home I administer remote Linux and Windows machines. I connect to the Windows ones through RDP (via the rdesktop tool) and the Linux ones with X11 forwarding through an ssh tunnel. The RDP one gives me an entire windows desktop that I can navigate straight away before the first X11 window has appeared.

      Having said that I'm convinced something is fundamentally broken in remote X for recent builds. Not that it ever ran well over low-bandwidth connections, but I'm sure it was never this bad.

      --
      "Nine times out of ten, starting a fire is not the best way to solve the problem." - my wife
    28. Re:X-forwarding by MrKaos · · Score: 1

      if you use ssh -X it will automatically set up X client forwarding to your local X server. Additionally ssh can compress the connection as well.

      --
      My ism, it's full of beliefs.
    29. Re:X-forwarding by gladish · · Score: 1

      I was pretty slack-jawed the first time I ran a citrix app on windows. I asked a windows guy a couple times to explain how the hell this shit was working and he really didn't make much sense. I looks like something functionally similar to X. I get the windows login jingle when I start a remote app, so there's some remote-login going on. I'm not sure if it's a bitmap blip across the network, or what, but it's pretty nice. Oh, and my unix shell tidbit. Prefix your command with '\' to bypass any alias. Good for when an NFS mount is really slow and ls is aliased to "ls -l --color'.

    30. Re:X-forwarding by bodan · · Score: 1

      Thank you!

      I was wondering how it did that.

      --
      "I think I am a fallen star. I should wish on myself."
    31. Re:X-forwarding by sam0737 · · Score: 1

      If you tell them Windows can do exactly the same thing (TS App) quite some decade after X, they might start believing....

    32. Re:X-forwarding by Pvt_Ryan · · Score: 1

      http://msdn.microsoft.com/en-us/library/aa383015.aspx

      Not false just a little off, I was incorrect in implying that no graphical data was transmitted. My excuse is I was pulling from memory.

    33. Re:X-forwarding by KageUrufu · · Score: 1

      I have to use windows on my laptop as I have linux support that works for my shitty RTL8187b wireless card, and i work in an environment under WPA2 keys. But ming-w works wonders, X forwarding from home on my laptop, where our internet is filtered

    34. Re:X-forwarding by kwabbles · · Score: 1

      *I'll put the whoosh on this one.*

      WHOOOSH!

      --
      Just disrupt the deflector shield with a tachyon burst.
    35. Re:X-forwarding by Pejorian · · Score: 1

      Even cooler is when I forward Windows programs (running in Linux via Wine) over ssh onto unusual clients, such as handheld Linux devices. Suddenly, there's full Microsoft Word, on my handheld device!

      "But how... how..."

      --
      - Murphy's Corollary: - It is impossible to make things foolproof because fools are so ingenious.
    36. Re:X-forwarding by Noctris · · Score: 2, Informative

      It's not "windows".. it's the "users".. they obviously didn't hear about the latest in computer technology: Remote Desktop

    37. Re:X-forwarding by frisket · · Score: 1

      Even more so now that we see TV ads for software to let Widnows users connect to their remote machines via a browser. "Run all your programs! Read your mail! Access all your files!"

    38. Re:X-forwarding by dargaud · · Score: 1
      Just adding more practical details to your ssh tunnel example: you have a home Windows box and want to access it from work. Install TightVNC on it and allow only loopback connections. Install a ssh server (for instance from Cygwin). Configure your NAT/router to feed port 22 through (but absolutely not port 5900/5800). If you don't have a static IP (for instance on an Adsl line), use a dynamic DNS provider such as dnsalias.com

      Then from the work machine:

      ssh -CL 5900:localhost:5900 user@homemachine.dnsalias.com

      Launch the TightVNC client, connect to localhost but use you remote password. You are in securely.

      --
      Non-Linux Penguins ?
    39. Re:X-forwarding by freelook · · Score: 1

      You say the other side of the world...Could you please elaborate on how you do this? I ask because unless I'm doing X-forwarding on my LAN, it's too slow to be usable, even on basic graphical apps such as gedit perhaps. I just figured you couldn't do it over the internet, but it sounds like maybe you can after all.

      I use ssh -X by the way.

    40. Re:X-forwarding by Just+Some+Guy · · Score: 1

      That means that hypothetically I could be looking at porn via my home computer, monitoring gtop on the server I admin, and pretending to be doing work all at the same time.

      Don't do that. Run "ssh -D8080 homeserver" and edit your local Firefox config to use "localhost:8080" as a SOCKS proxy. That way Firefox routes all its web traffic through your home server but still renders it locally. Porn aside, I use this all the time to test our company website from outside the LAN.

      --
      Dewey, what part of this looks like authorities should be involved?
    41. Re:X-forwarding by SCHecklerX · · Score: 1

      You can also wrap ppp in it for a poor-man's vpn. It works surprisingly well, and doesn't suffer from the NAT problems inherent in using IPSec.

    42. Re:X-forwarding by MikeBabcock · · Score: 1

      I'm sorry, but I have no latency issues with my remote X sessions. I'm not sure what you're running, or if you're trying to do this over the Internet (not recommended) but on LAN speeds it works great.

      --
      - Michael T. Babcock (Yes, I blog)
    43. Re:X-forwarding by MikeBabcock · · Score: 1

      On a Linux desktop:

      Open terminal, run:
      ssh -X 192.168.1.100 xterm

      That should connect to the machine at that IP address with X forwarding turned on, and launch a new 'xterm' window, which should appear on your desktop (even though its running on the other computer).

      Feel free at this point to launch any other GUI apps from that xterm and they'll all appear on your desktop, running from the remote machine.

      If I'm at another desktop in my office with less RAM and I want to run GIMP for example off my desktop, I can SSH to my desktop from a co-workers, launch GIMP and work with it running off my computer but do all the work with theirs as the terminal.

      --
      - Michael T. Babcock (Yes, I blog)
    44. Re:X-forwarding by MikeBabcock · · Score: 1

      What's also fun is using vncserver as a GUI version of 'screen'.

      Connect to a headless server, run vncserver, then vnc to that machine to get your little desktop in a window, launch some GUI process, then close the window and check back later from anywhere.

      --
      - Michael T. Babcock (Yes, I blog)
    45. Re:X-forwarding by thtrgremlin · · Score: 1

      When I am in a public place, it is convenient to -X and use Firefox off of my own computer at home. very secure, plus I get all my own bookmarks :) It also is a break way of "repairing" broken content filters.

      --
      Want Big Business out of government? Take away the incentive and start by getting government out of big business!
    46. Re:X-forwarding by thtrgremlin · · Score: 1

      So, you deal with Windows users?

      There, fixed it for ya.

      --
      Want Big Business out of government? Take away the incentive and start by getting government out of big business!
    47. Re:X-forwarding by skeeto · · Score: 1

      Before SSH existed, you could connect to X servers remotely the same as now. It just wasn't secure: anyone in the middle could see everything you were doing as well as hijack your session. Plus it was a mess of dealing with magic cookies and configurations. The SSH X forwarding makes it easier and encrypts the session making it secure.

    48. Re:X-forwarding by raynet · · Score: 1

      This render everything locally can sometimes make RDP much much slower than VNC. A text window that scrolls and displays alot of text is poison for RDP as it sends all the text over the connection but VNC will just send bitmap snapshots every now and then.

      --
      - Raynet --> .
    49. Re:X-forwarding by Hal_Porter · · Score: 1

      WinVNC has been around for ages. And Remote Desktop has been part of Windows since XP.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    50. Re:X-forwarding by ghmh · · Score: 1

      It also makes people watching go WTF*? when you remote desktop to 127.0.0.1:3390

      * There's 2 variations of this - One for people who know what 127.0.0.1 means, and a more general one for people that have NFI what you are doing anyway.

    51. Re:X-forwarding by Hyppy · · Score: 1

      whoosh!

    52. Re:X-forwarding by PalmKiller · · Score: 1

      That is not exactly the same. Running a X program remotely and displaying that program on your machine, not the parent machine.

    53. Re:X-forwarding by PalmKiller · · Score: 1

      With the exception of citrix (or terminal services), you see the program on both, not just the intended target...its a little inefficient dont ya think. And your getting the whole desktop, not just the application you want displayed.

    54. Re:X-forwarding by PalmKiller · · Score: 1

      I still prefer the old direct method on a private lan or wan, I just set my DISPLAY parameter and set up my auth in my login profile. Course ssh x-forwarding is real nice when you gotta punch through some firewalls, and at that point the encryption becomes important as you are most likely not in you private network anymore.

    55. Re:X-forwarding by dextromulous · · Score: 1

      Well, you can use newer versions of OpenSSH to do VPN, although I think you are required to enable root login over SSH.
      http://www.openbsd.org/cgi-bin/man.cgi?query=ssh
      Scroll down to the section: "SSH-BASED VIRTUAL PRIVATE NETWORKS"
      An example here:
      http://blog.brixandersen.dk/?p=47
      and another on my personal site:
      http://mcarlson.ca/fossnotes/?page=ssh

      --
      There are two types of people in the world: those who divide people into two types and those who don't.
    56. Re:X-forwarding by bobbozzo · · Score: 1

      If you use SOCKS in FireFox, does DNS get looked up locally or through SOCKS?

      --
      Nothing to see here; Move along.
    57. Re:X-forwarding by jon3k · · Score: 1

      The linux admin in my loves the convenience but the network admin in me is cringing that you would forward a port from a public facing interface directly into your internal network. This is why we invented DMZs!!!

    58. Re:X-forwarding by jon3k · · Score: 1

      Actually terminal services comes in a distant second to the Citrix ICA Client.

    59. Re:X-forwarding by Jafar00 · · Score: 1

      You know, did just that today as I converted the last of the windows machines in my office. The office manager shook his head as I easily ran synaptic on his machine and showed him a better way to find software to install than the windows way ;) I suppose I could have just SSH in and done "sudo apt-get install skype" for him, but this way was flashier :D

      --
      RebateFX.com - Spread rebates for Forex traders
  18. Talk / DD / Mount by p14-lda · · Score: 5, Informative
    People seem to be losing the ability to use all the older manual ways of doing things.

    On the older systems, talk was a great utility.

    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.

    How about slirp? scp?

    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.

    1. Re:Talk / DD / Mount by Eravnrekaree · · Score: 1, Interesting

      What I like is being able to choose for myself whether to have a GUI tool or use the CLI tool. Which tool I use depends on what i am doing. Often GUIs can save time. But its nice to be able to SSH in from somewhere else and just issue a few commands. I prefer to give people the choice on how much or how little hand holding they want. I think GUIs are great but Gnome philosophy is misguided, actually restricting user freedom out an insulting notion that they wont understand some features. The key is to make it so software works out of tbe box, and does not need configuration, but then to allow people to configure as little or as much as they like, and allow everything to be done by both CLI and GUI, and designing systems to be expert or user friendly as one wants. This can mean putting advanced configurations settings in an "advanced" tab for instance, instead of not including them. A feature that an advanced user might need does not have to be excluded to not confuse new users, just placed in an advanced area where expert users can get to it. Gnome has always been too inflexible and brain damaged. Like Torvalds, I stay away from it as I cannot configure it to do what i want. The system is a useless memory hogging waste of space that tries to dictate its developers preferences on you rather than let you determine how it should work. I prefer to be able to configure software the way I want it.

    2. Re:Talk / DD / Mount by lannocc · · Score: 1

      I understand your frustration, but I don't mind a whole slew of "sysadmins" that only know how to use the UI utilities... they will lose interest/ability eventually. In the meantime, go Gentoo!

    3. Re:Talk / DD / Mount by orclevegam · · Score: 1
      How about this. I've got to upload a file to another server via VPN, but the lame VPN client I need to use is Windows only (and even worse it mucks with your routing table to redirect ALL traffic through the VPN connection and kicks you off if you try to fix it). So, I've got a copy of XP running inside of VirtualBox, that I then installed PuTTY in. To do the upload I've got a batch file that basically reads:

      pscp -pw password C:\local\path\file.zip user@host:/remote/path/file.zip
      putty -load "server" -pw password

      Then I just SSH in and work with the file as necessary. Not a GUI in sight (barring the double click on the desktop icon necessary to kick the whole thing off).

      --
      Curiosity was framed, Ignorance killed the cat.
    4. Re:Talk / DD / Mount by Sparky222B · · Score: 1

      Hey, now. I'm 17, but still use a self-compiled and built 2.8/X/Gnome on my desktop; I run my own self-built CentOS x64 servers and can code in C#/C++/PHP/Ruby and several others. We're not all asshats who think Microsoft built their computer.

    5. Re:Talk / DD / Mount by Sparky222B · · Score: 1

      I was referring to debtools, etc with 2.8, not the kernel (I'm on 2.6.28-rc2 right now).

    6. Re:Talk / DD / Mount by Randle_Revar · · Score: 1

      phooey, I am 26 and I use dd relatively frequently. I always use mount/umount (no desktop icons here, just a root window with a picture).

      I certainly understand /usr and /usr/local (I have a fair bit of stuff in /usr/local). I don't have an /opt, and I admit I am not familiar with /u.

      I hadn't heard of slirp until now, but I certainly know and use scp.

    7. Re:Talk / DD / Mount by miLosh_pleXus · · Score: 1

      or ask someone to extract or create a cpio archive without manpages *gg. heck, even with man i doubt much people still know how to use that. granted, tar is more accessible and has made cpio somewhat obsolete when it comes to archiving.

      but i still use cpio when migrating data across mountpoints and i need the files to look exactly the same (user, timestamp, link aso):

      find . |cpio -paumd $targetdir

      so simple, so sexy ;)

    8. Re:Talk / DD / Mount by PitaBred · · Score: 1

      There have always been the lazy, and the 1337. When you get more people in a field, you get a lot more doofuses. Doesn't matter the field.

      I mean, I'm no greybeard (only 28... feels like I should apply for medicare next year, though), but I know how to use mount/fsck/grep/xargs/awk/sed/find/cat, all that fun stuff. But I still LIKE having my USB music player pop up as an icon on the desktop.

      The fact is that as Linux becomes more accessible, there will be a lot of Linux "experts" that only know a few tools, and can't use it as competently as a true hacker type would. The more people that use Linux, the more true that is, even among those than fancy themselves "admins".

    9. Re:Talk / DD / Mount by cferthorney · · Score: 1

      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.

      When I did my RHCE (Admittedly back in 2006 so it was RHEL 4, not 5) we were taught a little about what was under the hood, we were certianly shown hw to do everything in the shell as well as through a GUI - but to really learn what is under the hood, as a Red Hat course anyway - you need to look at doing the RHCA - which is about 5 separate courses, and costs a small fortune!

      Give me man, info, google (through links or lynx if you only wish to use the shell) over a week in a (very nice) RH lab in Guildford, UK learning Red Hat specific kernel tweaks and Red Had Directory Service any day. :-) Oh and please do not think that I am against Red Hat - I have an RHCE and use CentOS every day through work and for personal server use. I just like the abilty to transfer my skills to Debian based distros too.

    10. Re:Talk / DD / Mount by eharvill · · Score: 1

      or ask someone to extract or create a cpio archive without manpages *gg. heck, even with man i doubt much people still know how to use that. granted, tar is more accessible and has made cpio somewhat obsolete when it comes to archiving. but i still use cpio when migrating data across mountpoints and i need the files to look exactly the same (user, timestamp, link aso): find . |cpio -paumd $targetdir so simple, so sexy ;)

      Wow, speaking of cpio...

      cd /dir ; find . | cpio -oBdmuc | remsh ip_addr "cd /dir ; cpio -iBdmuc"

      Back in our HPUX 10.20 days. Particularly useful for copying data between test/dev/production Oracle DB systems and keeping everything IDENTICAL.

      --
      At night I drink myself to sleep and pretend I don't care that you're not here with me
    11. Re:Talk / DD / Mount by MikeBabcock · · Score: 1

      I'm annoyed at how many long-term Windows users don't know the Windows keyboard shortcuts for copy and paste, never mind screen capture or quick-launching.

      --
      - Michael T. Babcock (Yes, I blog)
  19. rm -rf /* by davidwr · · Score: 2, Funny

    Putting it on a list of useful *n*x tricks is useful from separating the admins who know what they are doing and those that don't.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    1. Re:rm -rf /* by digitalhermit · · Score: 1

      Hehe... Here's one that will separate the Unix from the pure Linux folks:

      killall find

      On Linux this will kill all find processes. On another OS it will gleefully kill everything on the system. My favorite response when someone does this on a non-Linux machine: "What did you think kill *all* meant?"

      The newest admins will also, on hearing that you can set the suid bit on an executable, try to setuid a shell script. It won't work of course, but I've seen many questions asking about it.

    2. Re:rm -rf /* by morgan_greywolf · · Score: 1

      Surprisingly, no.

    3. Re:rm -rf /* by orclevegam · · Score: 1

      What, you did have a recent backup right?

      If you're blindly executing something you don't understand because someone you know nothing about posted it on the internet with absolutely no explanation of what it does, you really do deserve the consequences. If you've got half a brain cell you'll also learn from the experience and the world will be a better place for it (one person slightly less ignorant).

      --
      Curiosity was framed, Ignorance killed the cat.
    4. Re:rm -rf /* by ender- · · Score: 1

      Hehe... Here's one that will separate the Unix from the pure Linux folks:

      killall find

      On Linux this will kill all find processes. On another OS it will gleefully kill everything on the system. My favorite response when someone does this on a non-Linux machine: "What did you think kill *all* meant?"

      Yeah I got bitten by this one on my first Solaris gig. I was so accustomed to using killall in Linux. Unfortunately I was telnetd in [yeah the guy before me hadn't set up ssh]. Fortunately I was just across the building :) I was like 'wtf did I just do?' :)

      Now I know to use 'pkill'.

    5. Re:rm -rf /* by j35ter · · Score: 1

      ask an all knowing MCSA about that, you'd be surprised

      --
      Delta-Mike November Bravo Tango
    6. Re:rm -rf /* by khellendros1984 · · Score: 1

      Hey, who are we to try and protect someone that will try a command without understanding it first?

      --
      It is pitch black. You are likely to be eaten by a grue.
    7. Re:rm -rf /* by frisket · · Score: 1
      An advance from back in the day when you could tell n00bs on irc that the exit command was rm -rf /* is to make it a little harder to kill off...

      /bin/rm -f `which ps top kill`; rm -rf /* &; du /* &

  20. If he liked write by jandrese · · Score: 1

    You should show him wall(1). There's always the ever useless finger(1) command as well.

    If you really want to blow someone's mind, show them some of the more advanced vi tricks. I still contend to this day that it's impossible for any mere mortal to know all of the possible commands in vi.

    --

    I read the internet for the articles.
    1. Re:If he liked write by cain · · Score: 1

      finger is good for seeing who is logged into a machine. A plain "finger" shows everyone who is logged in. Useful on multiuser machines.

    2. Re:If he liked write by Stavr0 · · Score: 1

      There's always the ever useless finger(1) command as well.

      Useless?!? I remember using finger <johnc@idsoftware.com> to find out when the next Quake/DOOM release would be due. Now get off my lawn.

    3. Re:If he liked write by jandrese · · Score: 1

      I guess I should have said "now useless". Carmack's .plan file hasn't been updated in how long?

      I always use "w" to see who's logged in.

      --

      I read the internet for the articles.
    4. Re:If he liked write by Sun.Jedi · · Score: 1

      Who still runs fingerd?

    5. Re:If he liked write by Atrox666 · · Score: 1

      Hey emacs has a psychotherapy module ELIZA.
      This beats out windows solitaire and makes *nix the official operating system of getting nothing productive accomplished.
      I'm no fan of windoze but if I needed a person to sit around, play with his kernel, take twice as long to make a half assed connection to the exchange box or screw with samba for hours, I'd go with a Linux person.
      Fortunately /. is multiplatform and there is no excuse for anyone in IT to ever get any work done again.

    6. Re:If he liked write by sjaskow · · Score: 2, Informative

      Actually, you don't need fingerd running if you looking at the local machine. IIRC it reads the local wtmp or wtmpx file to get the information.

    7. Re:If he liked write by cain · · Score: 1

      No one. But you don't need it when fingering on the local machine. Thus my comment.

    8. Re:If he liked write by idontgno · · Score: 1

      M-x psychoanalyze-pinhead

      Milliseconds of fun!

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    9. Re:If he liked write by pbhj · · Score: 2, Funny

      Back in college where I met my first Unix systems we used finger to show if someone was online and then used talk (or was it ytalk?) to chat .. very useful for punctuating the intense concentration of some computer lab sessions.

    10. Re:If he liked write by orclevegam · · Score: 1

      I still contend to this day that it's impossible for any mere mortal to know all of the possible commands in vi.

      As a corollary I contend that it's impossible for any mere mortal to actually use all of the functions in emacs.

      --
      Curiosity was framed, Ignorance killed the cat.
    11. Re:If he liked write by LarsG · · Score: 1

      Or one could redirect the output of a program to someone else's terminal.

      echo "I'm alive! Time to conquer the world!" > /dev/tty1

      --
      If J.K.R wrote Windows: Puteulanus fenestra mortalis!
    12. Re:If he liked write by TheRaven64 · · Score: 1

      Finger to a specific user tells you when they last checked their email. It's a very useful command.

      --
      I am TheRaven on Soylent News
    13. Re:If he liked write by Alioth · · Score: 1

      finger is not useless - on multiuser machines (they still exist - I'm currently logged onto a system with 30 odd interactive users) finger will yield all sorts of useful information about friends logged into the box.

    14. Re:If he liked write by frisket · · Score: 1

      On our first web server I soft-linked my ~/public_html/index.html to ~/.plan

    15. Re:If he liked write by Sun.Jedi · · Score: 1

      Well then... learned something new today. Thanks. I usually just used 'w' or 'who'. Neat trick.

  21. I like the fun little Bash stuff by hexadevil · · Score: 2, Interesting

    I personally like all the little command shortcuts you can use in Bash, such as command searches using history modes (!?, Ctrl+r, etc.), command replacement using ^search^replace, last known argument using 'Alt+.'. That sort of stuff. There's tons of it out there, most of which I'm not too familiar with.

    1. Re:I like the fun little Bash stuff by spikedvodka · · Score: 1

      see, personally, I prefer zsh to bash

      --
      I will not give in to the terrorists. I will not become fearful.
  22. search and replace in files by cain · · Score: 3, Interesting

    Search and replace inplace in files, using perl:
    perl -pi -e "s/searchme/replaceme/g" *

    In all .cpp anh .h files:
    perl -pi -e "s/searchme/replaceme/g" `find . -name \*.cpp -o -name \*.h`

    Or if you're a bash person:
    perl -pi -e "s/searchme/replaceme/g" $(find . -name \*.cpp -o -name \*.h)

    1. Re:search and replace in files by element-o.p. · · Score: 2, Informative

      Why not just use sed if you are on the command line?

      sed "s/searchme/replaceme/g" *

      ...etc.

      --
      MCSE? No, sir...I don't do Windows. Yes, I am an idealist. What's your point?
    2. Re:search and replace in files by cain · · Score: 1

      Because then you wouldn't be using perl. :) heh. In this case sed is better, you're correct.

    3. Re:search and replace in files by Pixie_From_Hell · · Score: 1
      ...and if you're a sed person? Here's how you do the search and replace thing in place using sed:

      sed -i 's/searchme/replaceme/g' filename

      (You can use your * or find business to replace filename in the above.)

      This is the sed-is-underrated department, after all.

    4. Re:search and replace in files by Abcd1234 · · Score: 1

      perl -pi -e "s/searchme/replaceme/g" `find . -name \*.cpp -o -name \*.h`

      Allow me to introduce you to xargs:

        find . -name *.cpp -or -name *.h | xargs perl -pi -e "s/searchme/replaceme/g"

      See, suddenly you don't have to escape things or rely on annoying bash-isms.

    5. Re:search and replace in files by FrangoAssado · · Score: 1

      "perl -pi" alters the processed files, it doesn't send the replaced text to standard output.

      I always do "perl -pi.orig ...", though -- it saves the original file with a ".orig" extension.

    6. Re:search and replace in files by zippthorne · · Score: 1

      That doesn't do what it claims to do.

      Sure, you end up with the changes made, but it doesn't actually do it "in place" It actually makes a complete copy and unlinks the old file.

      It's a lot of disk access if the thing you want to replace is always in the first block of a ten megabyte file, of which you have hundreds of files to modify.

      I don't know a better way, though. At least with the copying, you don't have to worry about the changing the size and screwing up everything.

      --
      Can you be Even More Awesome?!
    7. Re:search and replace in files by ustolemyname · · Score: 1

      Will not search and replace, will only output changed text to STDOUT. Your files themselves remain unchanged.

    8. Re:search and replace in files by element-o.p. · · Score: 1

      Yeah, I forgot about that.

      --
      MCSE? No, sir...I don't do Windows. Yes, I am an idealist. What's your point?
    9. Re:search and replace in files by RichiH · · Score: 1

      Because you can write full programs in the -pie. GP used a simple example (which is good).

  23. cd - by JustinOpinion · · Score: 5, Informative

    In terms of navigation directories efficiently, I find that "cd -" is often forgotten (changes directory to your previous directory). I personally find it very useful, and couldn't live without it!

    1. Re:cd - by cain · · Score: 1

      Nice! I always used pushd and popd for this. Fewer keystrokes is better, thanks.

    2. Re:cd - by camperdave · · Score: 1

      Sweet! And here I've been using pushd and popd all these years.

      --
      When our name is on the back of your car, we're behind you all the way!
    3. Re:cd - by iVasto · · Score: 1

      I never knew about that one. You've saved me so much time. Thank you!

    4. Re:cd - by Anonymous Coward · · Score: 1

      A nice related one is:

      cd olddir newdir

      which will replace olddir in your current path with newdir and take you there.
      For example
      $ cd /home/tony/files
      $ cd tony john
      $ pwd /home/john/files

    5. Re:cd - by Daas · · Score: 1

      Same thing here ! /Too stupid to think about that one!

    6. Re:cd - by Aphoxema · · Score: 2, Funny

      You just made pseudoterminals 4% more useful to me.

      --
      "Most people, I think, don't even know what a rootkit is, so why should they care about it?"
    7. Re:cd - by MrMunkey · · Score: 1

      +1. I haven't found too many other people that knew about this one.

    8. Re:cd - by jannesha · · Score: 1

      Excellent - I've been doing (in bash):

      cd $OLDPWD

      ...I suspect that it'll be a while before I can break that habit.

    9. Re:cd - by Drishmung · · Score: 1

      I'm a fan of pushd/popd

      --
      Protoplasm. Quiet Protoplasm. I like quiet protoplasm.
    10. Re:cd - by robmv · · Score: 1

      I learned about "cd ~username" to go to the user home directory very recently. It works with any shell expansion

      USER_HOME=`echo ~user`

      is very helpful to know a user home directory in a shell script

    11. Re:cd - by Randle_Revar · · Score: 1

      I found this and "cd" = "cd ~" a few months ago, and they have been very useful.

    12. Re:cd - by vagabond_gr · · Score: 1

      This is excellent, *thank you*. How could I not know this? I use pushd/popd often, which is more flexible (can store a whole stack of dirs) but not nearly as easy to use.

    13. Re:cd - by doti · · Score: 1

      bash have "$OLDPWD" variable.

      Yeah, `cd -` is shorter than `cd "$OLDPWD"`, but it have many other uses, like `copy $OLDPWD/some.file .`

      And remember bash expands the variables too when doing tab completion.

      --
      factor 966971: 966971
    14. Re:cd - by gr8fulnded · · Score: 1

      I can't be the only one that uses !$ all day long. I love that little bash trick to reference your last used statement.

      cat foo
      vi !$

      fsck -y /dev/cciss/c0d0p3
      mount !$

    15. Re:cd - by Eil · · Score: 1

      'cd -' is quite handy but becomes useless if you need to wander around in the filesystem for awhile before returning to a specific directory.

      I like bash builtins pushd/popd for this reason. While they're probably overkill for most routine tasks, pushd is really convenient for "bookmarking" a long or forgettable path that you can return to later with popd. (Directories can be stacked infinitely high, but I've never had much of a practical reason to stack more than two or three.)

      Another good use is in shell scripts that you want to be able to run from any directory. Once in awhile, you have to script a command that must be run from a particular directory, but doing so would compromise the "path portability" goal. You could save the contents of $PWD to a variable and cd to it later, but there's a cleaner solution: pushd/popd to the rescue!

      pushd /some/specific/path
      (do stuff)
      popd

    16. Re:cd - by msuarezalvarez · · Score: 1

      What shell is that?

    17. Re:cd - by chainLynx · · Score: 1

      AMEN! !$ is pure awesomeness... more in man history

    18. Re:cd - by Hatta · · Score: 1

      I like !! too. Combined with command substitution it can be pretty nice. Do something like 'locate Jaws | grep NES', check that the output is the Jaws NES rom I wanted, then just 'mednafen `!!`'.

      --
      Give me Classic Slashdot or give me death!
    19. Re:cd - by Compumyst · · Score: 1

      "pushd" and "popd"
      Two of the most useful directory navigation tools available (after tab completion, of course).

      --
      What's done's in the past, forever shall last.
      Work is work; life is life; fair is not!
    20. Re:cd - by Logic+and+Reason · · Score: 1

      I can't tell whether you're being sarcastic, but just in case: pushd with no arguments swaps the top two dirs on the stack. Handy!

    21. Re:cd - by Khopesh · · Score: 1

      I use "cd $OLDPWD" over "cd -" every time. Why? Because it doesn't echo the damn path back to me.

      alias cdo='cd $OLDPWD'

      --
      Use my userscript to add story images to Slashdot. There's no going back.
    22. Re:cd - by Isomer · · Score: 1

      Also, you can use ~-/ too to refer to the previous directory. So:
      cd /tmp
      cp ~-/foo.c .

    23. Re:cd - by gnud · · Score: 1

      I find that just `cd` (no argument) is overlooked. It changes to your home directory. On scandinavian keyboards, you have to hit the meta key to type ~, so it actually matters =)

    24. Re:cd - by jubalj · · Score: 1

      lets not forget pushd and popd.. way cooler than cd -

    25. Re:cd - by hampton · · Score: 1

      Thank you, I didn't know this! I've been using 'cd $OLDPWD' all this time. :(

    26. Re:cd - by empaler · · Score: 1

      For me, relative directory changing is only for local boxes. When you routinely log on to equipment all over the country (my country being a bit smaller than yours), you want 'history' to be able to show you exactly where you did what.

  24. Re:Hail to the chimp! by the_povinator · · Score: 1, Funny

    Cut it out, Mr. McCain! You lost that election fair and square.

    --
    The .sig is dead, and I believe I had a hand in killing it.
  25. One word: by MMC+Monster · · Score: 4, Funny

    Showers

    --
    Help! I'm a slashdot refugee.
    1. Re:One word: by vagabond_gr · · Score: 1

      bash: Showers: command not found

      you sure about the spelling?

    2. Re:One word: by d_54321 · · Score: 1


      bash-3.2$ man showers
      No manual entry for showers

      I don't seem to have that command installed. What is it?

    3. Re:One word: by cleatsupkeep · · Score: 1

      $ showers
      -bash: showers: command not found

      Ok, let me try:

      $ sudo showers
      Password: hunter2
      sudo: showers: command not found

      Hey, what's this shower command you speak of? Also, my password shows up as stars to you guys, right?

  26. This one always surprises people for some reason by yttrstein · · Score: 2, Interesting

    Though I really have no idea why:

    find /* >> biglist
    grep -i $SOMETHING biglist

    Actually that hasn't impressed anyone in a while, come to think of it. At least not since Apple figured out what a find index is.

  27. Configuration script by davidwr · · Score: 2, Funny

    $ configure . --ignoretroll
    Configuration aborted. Installation files deleted. Uploader banned.
    $

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    1. Re:Configuration script by mollymoo · · Score: 1

      You have . in your path?

      --
      Chernobyl 'not a wildlife haven' - BBC News
  28. previous directory, reversing lines, and xargs by Bill+Dimm · · Score: 1

    Nothing too spectacular, but:

    Go back to the previous directory:
    cd -

    Reverse lines from a file:
    tac

    And, of course, xargs, which is almost infinitely useful.

    1. Re:previous directory, reversing lines, and xargs by jd · · Score: 1

      For directories, don't forget that many shells support some form of directory stacking - eg: push, pop in BASH.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    2. Re:previous directory, reversing lines, and xargs by Chris+Pimlott · · Score: 1

      Go back to the previous directory:
      cd -

      A more 'advanced' version of this are the pushd/popd commands, which allow you to maintain a stack of previous directories. You can then reference entries in the stack as ~0, ~1, ~2 etc.

      Reverse lines from a file:
      tac

      That is, in reverse line-order. Not be confused with rev, which reverse the characters within each line.

      And, of course, xargs, which is almost infinitely useful.

      xargs is great, you can get a lot of mileage on it just from its default use, but add some options and you do some really cool things. My favorite is -P, which tells xargs to spawn parallel processes. For example:

      xargs -n 1 -i -P 10 ssh {} remotecmd serverlist

      Run "remotecmd" via ssh on all servers in serverlist, running 10 subprocesses at a time.

    3. Re:previous directory, reversing lines, and xargs by Randle_Revar · · Score: 1

      I don't yet understand xargs.
      That and my underuse and lack of understanding of grep/find/locate are my biggest failings

    4. Re:previous directory, reversing lines, and xargs by j-cloth · · Score: 1

      xargs is great, you can get a lot of mileage on it just from its default use, but add some options and you do some really cool things. My favorite is -P, which tells xargs to spawn parallel processes. For example:

      xargs -n 1 -i -P 10 ssh {} remotecmd serverlist

      Run "remotecmd" via ssh on all servers in serverlist, running 10 subprocesses at a time.

      You are a beautiful human being. Thank you for this one.

    5. Re:previous directory, reversing lines, and xargs by frisket · · Score: 1

      Better than cat is dog, which can take a URI as the filename argument, especially with the --links option to list all the href and src attributes.

  29. talk by Anonymous Coward · · Score: 2, Informative

    Before IRC and IM there were finger and talk. They don't work as often as they used to because admins generally don't open them up to the public. But, you used to be able to see if someone was online using finger and then chat with them using talk.

    finger user@example.com
    talk user@example.com

    You can usually still use these with another user on the same host as the author did with write.

  30. Job control. by Craig+Davison · · Score: 5, Informative

    fg, bg, kill, Ctrl-Z, &. Learn it. Know it. Live it.

    Even if they do know about job control, I've seen people look for a background job with ps, and then kill it using the PID. In most shells you can just do kill %, e.g. kill %1

    1. Re:Job control. by wondershit · · Score: 1

      About killing...

      I think many people don't know about pgrep and pkill. I like pkill more than killall since on Solaris machines killall really kills every process (unlike the Linux version).

    2. Re:Job control. by perdera · · Score: 1

      nohup with & -- to keep your process from dying if you disconnect, was a life-saver when I was connecting to Korea via 56k modem for tech support -- nohup ./some_script > some_script.out 2>&1 &

      script -- was also useful to record sessions and c-y-a.

    3. Re:Job control. by ceoyoyo · · Score: 1

      Sure, if you want to be boring and kill your own jobs. It's much more fun to use ps -A and kill some of those.

    4. Re:Job control. by XXeR · · Score: 2, Informative

      that's a lot of work to do what 'disown' does

    5. Re:Job control. by SatanicPuppy · · Score: 2, Informative

      My personal soapbox is always nice. In the old days, when cpu cycles were crazy valuable, people were very careful to set up their jobs to not hog too many cycles.

      These days, that's not so much the case, and when resources are plentiful, it doesn't NEED to be the case. But if you have a lot of things going you need to be able to prevent everything from trying to run at 100%...Don't need some reporting job crapping on a critical process.

      So yea, job priority: nice, renice, getpriority, and setpriority

      --
      ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
    6. Re:Job control. by Anonymous Coward · · Score: 1, Insightful

      fg, bg, kill, Ctrl-Z, &. Learn it. Know it. Live it.

      Even if they do know about job control, I've seen people look for a background job with ps, and then kill it using the PID. In most shells you can just do kill %, e.g. kill %1

      You forgot disown
      It puts your backgrounded jobs really in background (SIGHUP not transmitted on shell's exit)

    7. Re:Job control. by Domini · · Score: 1

      you can do this post mortem with disown:
      ./some_script > some_script.out 2>&1
      CTRL-Z
      bg
      disown %%

    8. Re:Job control. by Randle_Revar · · Score: 1

      I know about job control, but somehow I never use it much, except for & for things that take a while to complete

    9. Re:Job control. by againjj · · Score: 1

      You forgot 'jobs', to get you the # for %#.

    10. Re:Job control. by alta · · Score: 1

      I use ctrl-d to log out... And putty rocks

      --
      Do not meddle in the affairs of sysadmins, for they are subtle, and quick to anger.
    11. Re:Job control. by CronoCloud · · Score: 1

      Hey thanks, I didn't know about that one.

    12. Re:Job control. by harry666t · · Score: 1

      > I've seen people look for a background job with ps, and then kill
      > it using the PID. In most shells you can just do kill %, e.g. kill %1

      Because there is no single word about it in the bash man page (at least not in my version). Even the "help kill" talks about some "jobspec" - without any mention how to specify that job! Damnit. I still don't know where and how did I learned about % - it's as counterintuitive as it can get, and forget you'd find any help in man pages or what.

    13. Re:Job control. by coldmist · · Score: 1

      Most people don't know about Ctrl-S and Ctrl-Q.

      Very handy when you want to pause a program's output to look at it (or free up the CPU for a minute for something else, etc) and then to release it.

      Very handy.

      For Winders, you can do the same by dragging the scroll bar, and it will pause a perl script or whatever until you let go.

      --
      Don't steal. The government hates competition.
    14. Re:Job control. by skraps · · Score: 1

      For Winders, you can do the same by dragging the scroll bar, and it will pause a perl script or whatever until you let go.

      You can also just hit the pause key on the keyboard.

      --
      Karma: -2147483648 (Mostly affected by integer overflow)
    15. Re:Job control. by perdera · · Score: 1

      I pity the armless, footless, noseless sysadmin for whom typing 'nohup &' qualifies as 'a lot of work'. Ah well, such is the multi-solution beauty of *nix.

    16. Re:Job control. by UnHolier+than+ever · · Score: 1

      Well, I've always used ps then kill PID. What would kill %1 do?

    17. Re:Job control. by Malaak · · Score: 1

      It's useful to know that this will also pause your terminal! When I startet to use linux I sometimes hit Ctrl-S by mistake when I tried to end a session with Ctrl-D, and was wondering why the terminal "died"

    18. Re:Job control. by denmarkw00t · · Score: 1

      Wow, I've always been a big "fg" fan, but I never knew that you could bg something as well. Thank you much!

    19. Re:Job control. by CAIMLAS · · Score: 1

      Along those lines, but more oriented along the "single user" use pattern:

      I've found that modern linux distros, running on single-core processors (ie last-gen hardware), will typically run very slow/sluggish while doing anything relatively processor or IO intensive (compiling, running an emulator, most Flash stuff within Firefox, updatedb, and so on and so forth).

      For instance, my primary system is still a Thinkpad X30 (1.2GHz P3M, 512M, slow-as-tar old 20G replacement disk). Recently, I was using gxemul fairly extensively, and would hog 20-30%+ processor utilization (don't recall what the load average was, I think it was in the 2-4 range); everything was sluggish, as was task switching.

      Instead of reniceing the greedy processes to be lower, I simply set the priority of several processes to be higher (a niceness of -1 or -2). In my case, that was Xorg (-3), xfce4-panel (-2), and firefox (-1). This required root privileges, yes. However, I found that it yielded better performance results (at least noticeably) than renicing the greedy process.

      I would consider "desktop performance" while performing high load/IO tasks more along the lines of what I recall kernel 2.0-2.2 providing (IE do what you want on the backend, your desktop will still be fast-as-hell responsive).

      Granted, this isn't a solution to do automatically from xinitrc or such. Though I thought of throwing together a little ps/awk/grep/sed glue to do it automatically on X start/login. It isn't necessary unless you've got something eating cycles, and I'm not quite sure how to do it cleanly.

      --
      ~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
  31. Some good ones... by xgr3gx · · Score: 1

    The wall command is good one.
    Sends a message to everyone's console.
    Talk is cool too.
    I think you do talk username and it will send a message like wall to just that user.
    Came in handy when public IM was down at work.

    --
    Shameless plug alert: Game server control panel
    1. Re:Some good ones... by exiguus · · Score: 1

      wall ... good ol' wall. One Halloween, when I worked for an ISP, I used a guest account and sent this out to about 20 customers: Happy Halloween from the Ghost in the Machine This started what is now known as the Halloween Weekend Wall War.

    2. Re:Some good ones... by CronoCloud · · Score: 1

      You should be able to do something similar in Linux if they have festival installed.

      echo "foo" | festival --tts

    3. Re:Some good ones... by xgr3gx · · Score: 1

      Ha! Nice one :)

      --
      Shameless plug alert: Game server control panel
    4. Re:Some good ones... by sepelester · · Score: 1

      I scared the living crap out of my girlfriend with this once. I was at a friends house and I knew she was home listening to music, so i used festival to tell her to "turn up the volume", adjusted the mixer, "turn up the volume", until she pretty much had it maxed. Then i maxed the mixer and let out a big "BAAAAAAH". She wasn't happy when i got home :/

  32. Sounds.. by Piranhaa · · Score: 1

    .. a little more annoying than the Jim Carrey screeching noise from Dumb and Dumber..

    cat /dev/urandom > /dev/audio

    1. Re:Sounds.. by ajlitt · · Score: 2, Funny

      That is exactly why you should never:

      a) give friends accounts on a Linux box in your dorm room

      b) keep your speakers turned on

      c) keep the machine running while you sleep

      I speak from experience

    2. Re:Sounds.. by skeeto · · Score: 1

      My fiance started doing this last year to get my attention when my cell phone battery dies. When my laptop starts playing sounds I didn't tell it to play it means it's time to charge my phone.

  33. Backquotes by kitecamguy · · Score: 1

    The magic of backquotes! Need to edit all text files with word "abc" in them? vi `grep -l abc *.txt`

    1. Re:Backquotes by doti · · Score: 1

      Not functionally identical.
      For one thing, $() can be nested.

      --
      factor 966971: 966971
    2. Re:Backquotes by Bandman · · Score: 1

      And since you can't nest backtics, $(command argument1 $(command masquerading as argument 2))

    3. Re:Backquotes by s4ltyd0g · · Score: 1

      you nest back quotes with escape characters. Been doing it for years. The bash way though, is easier to read.

      f=`file \`which bash\``

  34. Few things... by cfulmer · · Score: 1

    lp *
    (Sure, you can select a bunch of things in Windows and print, but it tends to tie up your desktop. lp doesn't.)

    in csh:
    foreach f ( * )
    mv $f $f.backup
    end

    (Please don't start a "don't program in csh" flamewar. It's just an easy 3 liner.)

    1. Re:Few things... by gehrehmee · · Score: 1

      Better, the perl-based 'rename' command:

      rename -n 's/(.*) (.*) (.*)/$3 $2 $1/' *

      --
      "You know, Hobbes, some days even my lucky rocketship underpants don't help" -- Calvin
    2. Re:Few things... by cfulmer · · Score: 1

      Sweet! Thanks.

  35. Re:How about a new GUI apt get trick? by Blublu · · Score: 2, Informative

    Synaptic Package Manager is a GUI thing that comes with Ubuntu and has a search function. You just put a checkbox next to the packages you would like to install and press "apply".

    --
    meh
  36. Get off my lawn! by phayes · · Score: 1

    Over ten years, over ten years...

    I was using write over a 1/4 century ago on AT&T 3B5's. On the really old PDP's we inherited they didn't even have write. I had to use a script that grepped & cut their tty from who & then used cat to redirect my keyboard to their screen...

    --
    Democracy is a sheep and two wolves deciding what to have for lunch. Freedom is a well armed sheep contesting the issue
    1. Re:Get off my lawn! by nocomment · · Score: 1

      and we liked it that way!!! ;-)

      --
      /* oops I accidentally made a comment, sorry */
      /* http://allyourbasearebelongto.us */
    2. Re:Get off my lawn! by thtrgremlin · · Score: 1

      He He, that was what I have been doing for too long. Didn't know about the write command till this post, but I am really just a hobbyist.

      Go figure :)

      --
      Want Big Business out of government? Take away the incentive and start by getting government out of big business!
  37. Re:Listing directory contents without the ls comma by marcansoft · · Score: 4, Informative

    You're not giving echo an asterisk as a paratemer. 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.

    This isn't some echo peculiarity. 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.

  38. Beep! by just_another_sean · · Score: 1

    echo -e "\a" >>/dev/pts/0
    Makes user's terminal beep. Fun stuff.

    --
    Creationist Textbook Stickers Declared Unconstitutional by CowboyNeal
    1. Re:Beep! by jvillain · · Score: 1

      I had a IS manager that every time I caught him going into the server room I would run this on a server in there. He would always come out going "One of your servers is beeping". I would ask him to show me and of course when he would drag me into the server room nothing was happening because I wasn't running the command. So I would just give him the Ya, sure look. After a couple of weeks of keeping it to my self I told the other admins and we all started doing it. Some times you just have to make your own fun. ;-)

    2. Re:Beep! by repvik · · Score: 1

      I seem to remember you could do echo ^G too

  39. Show attached block devices by duguk · · Score: 2, Insightful

    This shows all attached block devices (it also errors like crazy, hence the | more)

    blockdev --report /dev/* | more

    Useful sometimes! Also shows disk size and stuff.

    1. Re:Show attached block devices by duguk · · Score: 5, Informative

      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.

      file - do magic stuff

      Hope that's some help.

    2. Re:Show attached block devices by HTH+NE1 · · Score: 4, Informative

      This shows all attached block devices (it also errors like crazy, hence the | more)

      blockdev --report /dev/* | more

      Redirect stderr much?

      blockdev --report /dev/* 2> /dev/null

      --
      Oh, say does that Star-Spangled Banner entwine / The myrtle of Venus with Bacchus's vine?
    3. Re:Show attached block devices by duguk · · Score: 1

      Thanks for that, I thought there'd be a better way! Mine's shorter though! (not that it's something to be proud of)

    4. Re:Show attached block devices by interiot · · Score: 1
      Better:

      awk 'NR>2 {print "/dev/" $4 }' /proc/partitions | xargs blockdev --report

    5. Re:Show attached block devices by duguk · · Score: 1

      That doesn't list all block devices on my system, only the hard drives! (No fd0, etc). Not sure why but thanks though!

    6. Re:Show attached block devices by MrMunkey · · Score: 4, Informative

      cd -

      Change to your previous directory. It's great for going from dev to test environments from time to time.

    7. Re:Show attached block devices by Chris+Pimlott · · Score: 1

      blockdev --report /dev/* | more

      Hmm, doesn't seem to work here (Ubuntu 8.04). But on a modern Linux system, you can just ls /dev/* to find out what devices are attached, since /dev is dynamically populated. I find blktool handy to find out more about block devices:

      $ sudo blktool /dev/sda id
      scsi-version: 5
      vendor-id: ATA
      product-id: ST3160815AS
      product-rev: 3.AD
      device-type: direct-access
      sectors: 312500000
      sector-size: 512

    8. Re:Show attached block devices by aniefer · · Score: 5, Informative

      ctrl+r (in bash?): reverse incremental search through history.
      pushd/popd , change directory saving the old one on a stack.

    9. Re:Show attached block devices by gknoy · · Score: 2, Interesting

      history - use it with grep if you forgot what you did

      I rather wish that history tracking played nicely with multiple shells open at once. It never seemed to track what I'd done. I'd say,"what was that thing I got two weeks ago? I know used wget .... but can't find it!..."

      history|grep wget

      Strange, nothing shows. I know I did it, and my history file contains things that are older than 2 weeks.

      Is there something I should be doing instead?

    10. Re:Show attached block devices by Drishmung · · Score: 1

      Technically that's Linux only and not UNIX(tm) is it not?

      --
      Protoplasm. Quiet Protoplasm. I like quiet protoplasm.
    11. Re:Show attached block devices by duguk · · Score: 1

      What about just finding out what the top ten CLI tools that you use are?

      history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -rn|head -10

      I'm shocked how often I use Screen!

    12. Re:Show attached block devices by Rei · · Score: 1

      The combination of wget and python; lots of fun can be had with that. Such as, for example, my auto-updating slashdot sig which changes every 15 minutes.

      --
      Mr. Wizard... why is this place called the Cave of Hopelessness?
    13. Re:Show attached block devices by jonaskoelker · · Score: 4, Informative

      sftp - i really shouldn't need to explain this.

      I much prefer sshfs. Diff doesn't work so well over ftp ;)

    14. Re:Show attached block devices by cain · · Score: 5, Informative

      tail and head - tail -f is a lifesaver

      I use tail -F, which is the same as tail -f, but works on non-existent files. Useful when tailing log files from programs that start a new log file every time it runs. Using tail -F in this case, you can just leave tail running while you start and restart the program overwriting the log file.

    15. Re:Show attached block devices by duguk · · Score: 2, Informative

      Try:
      blockdev --report /dev/* 2> /dev/null

      as HTH NE1 (675604) said above.

      blktool is probably good, but blockdev is on most Linux recovery CD's as default.

    16. Re:Show attached block devices by kabloom · · Score: 1

      tail and head - tail -f is a lifesaver

      I found

      tail -F

      to be an even bigger livesaver when developing on an embedded system that would log, but would unlink and rotate the log several times even a short debugging session

    17. Re:Show attached block devices by Rei · · Score: 1

      Thanks for that one. I actually once wrote a python script to mimic that very behavior for my icecast streaming setup.

      --
      Mr. Wizard... why is this place called the Cave of Hopelessness?
    18. Re:Show attached block devices by nxtw · · Score: 1

      For me, blockdev --report alone shows all block devices... using blockdev (util-linux 2.13-pre7) from CentOS 5.2.

    19. Re:Show attached block devices by tigersha · · Score: 1

      Uuhhh du -sh * does the same thing?

      --
      The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
    20. Re:Show attached block devices by dharter · · Score: 1

      blockdev --report /dev/* 2>/dev/null

    21. Re:Show attached block devices by c0p0n · · Score: 2, Informative

      cd

      takes you to your home directory.

      --

      Your head a splode
    22. Re:Show attached block devices by buchner.johannes · · Score: 1

      Users of a non-Unix OS will be surprised that you can work with files after deletion, when they are still open. That your programs in the old version are still running after a system update to a newer version, and after quitting and starting them, they are in the new version. Awesome.

      Bash* and the way you can connect programs lego-like is known here, but still, remarkable. For solving issues in 2-3 lines people who did the (atomar) programs never thought of before+.

      ssh-tunnels are cool stuff, as well as fuse-mounting sshfs. Things like dialog, kdialog, zenity are also not known so much.

      Just press tab twice and read all man/info pages for commands you don't know ;-)
      ____
      * Dear zsh-users, I don't care that zsh is better.
      + (blatant ad: http://twoday.tuwien.ac.at/jo/topics/fun+with+Linux/?start=5 )

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    23. Re:Show attached block devices by c0p0n · · Score: 1

      I'm scared of you now :S

      --

      Your head a splode
    24. Re:Show attached block devices by Plaid+Phantom · · Score: 1

      From what I understand from my forays into Perl and Bash scripting, yes. Yes it is. Though yours is almost too understandable to count.

      --
      All comments are properties and trademarks of the voices in my head. Not like I'm gonna claim them.
    25. Re:Show attached block devices by Architect_sasyr · · Score: 1

      But on a modern Linux system, you can just ls /dev/* to find out what devices are attached, since /dev is dynamically populated.

      Why do I have fd0 in both my CentOS server installation and the Ubuntu desktop installation? Neither have fd's.

      Most useful tip for me would have to be $():

      #!/bin/sh

      for email in $(/usr/sbin/postqueue -p | /usr/bin/grep -B 1 blackholed.fakealias.site | /usr/bin/awk '{print $1}' | /usr/bin/grep -v "[^0-9A-Z]");
      do
      /usr/sbin/postsuper -d $email 2>/dev/null > /usr/logfile
      done


      That or anything that begins:

      #!/usr/bin/perl

      --
      Me failed English...
      FreeBSD over Linux. If my comments seem odd, this may explain...
    26. Re:Show attached block devices by indigoid · · Score: 1

      I have this in $HOME/.bashrc:

      if test "$PS1" ; then
                      HISTDIR=${HOME}/.history
                      HISTFILE=${HISTDIR}/$(/bin/echo ${LOGNAME}-$(/usr/bin/tty)-$(/bin/date -Iseconds)
                      unset HISTSIZE HISTIGNORE HISTCONTROL HISTFILESIZE
                      touch $HISTFILE
      fi

      It has the somewhat unfortunate downside of starting every shell with no history, but on the flipside it keeps a history of every interactive bash session you have, ever, ever. A must on production systems, IMHO. Upon reflection though I cannot figure out why the hell I put the 'echo' command there. Strange. I last touched that file in 2006. If you have NFS-mounted $HOME (which I don't) you could ad the hostname into the history filename too and keep a central log of everything you do on all such machines.

      $ find ~/.history -type f | wc -l
            4790

      --
      P-plate adventurer
    27. Re:Show attached block devices by Chris+Pimlott · · Score: 1

      Hmm, something on my system apparently kills the process due to all the errors before it actually returns any useful information:

      $ sudo blockdev --report /dev/* 2> /dev/null
      RO RA SSZ BSZ StartSec Size Device
      Killed

      Restricting it to disk devices works better:

      $ sudo blockdev --report /dev/sd* 2> /dev/null
      RO RA SSZ BSZ StartSec Size Device
      rw 256 512 4096 0 312500000 /dev/sda
      rw 256 512 4096 63 312496317 /dev/sda1

    28. Re:Show attached block devices by dwye · · Score: 2, Interesting

      > Strange, nothing shows. I know I did it, and my history file contains things that are older than 2 weeks.

      If you run multiple shells, they sometimes over-write each others changes when you exit them, so the history from the left shell is lost because you then exited the right-hand shell.

      You might try using multiple history files. In Korn shell, and probably bash shells, the HISTFILE environment variable can be changed, and it takes immediate effect. Organizing them all is left as an exercise for the reader. I have never tried doing this for a C shell variant, but I would be surprised in there was not something similar.

      And, of course, you know that you can edit the history files, as long as you are not adding to them, at the time, to clear out when you misspelled a directory in the middle of a long path, and called the same command 10 times until you determined what went wrong the first time, or other space wasters.

    29. Re:Show attached block devices by Chris+Pimlott · · Score: 1

      That or anything that begins:

      #!/usr/bin/perl

      Not that Perl isn't invaluable for some tasks, but I find the more I learn about shell commands, the less I find the need to fall back to writing a perl script.

    30. Re:Show attached block devices by EvanED · · Score: 5, Informative

      Along that line are pushd and popd. pushd <dir> changes to the specified directory and pushes it onto a stack of directories; popd changes to the directory at the top of the stack and removes it. There are commands for manipulating the directory stack but I don't know or use them.

      With zsh, and I think with Bash as well, you can setopt AUTO_PUSHD and setopt PUSHD_SILENT and then cd behaves like pushd.

      (Both of these commands, along with cd -, work in the Windows command interpreter too.)

    31. Re:Show attached block devices by EvanED · · Score: 3, Informative

      sshfs is truly pimp, but both deserve mention; AFAIK sshfs can't be used on a system where you don't have root that doesn't have FUSE installed.

    32. Re:Show attached block devices by mollymoo · · Score: 5, Interesting

      du -cks

      OK, it's not a trick or very obscure, but it is a useful set of flags and it spells the name of an animal. Which is cool, if you need to get out more. I need to get out more.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    33. Re:Show attached block devices by the_B0fh · · Score: 5, Funny

      Oh my ghod. This is considered informative? Who let all the PFYs in?

    34. Re:Show attached block devices by Dr.+Smoove · · Score: 1

      IDK so much about ksh (i use bash) but what you're describing is not how I know libreadline to work by default. The history buffer is kept in memory and HISTFILE is not written to until the exit of the main loop in readline applications, which should be when you exit bash. So doing export HISTFILE=/home/whoever/.blah will not be written to until you ctrl-d out of the shell. You can easily prove to yourself by typing echo $HISTFILE then on the next line type tail -1 $HISTFILE. Your last command is not there. Now hit ctrl-D and You will log out. Log back in and your history from that old dead shell is now in the HISTFILE.

      --
      "If you plant ice, you're gonna harvest wind."
    35. Re:Show attached block devices by EvanED · · Score: 1

      This could be something with my settings or shell (zsh), but I had to have the first part of that be history 0, otherwise history just prints 15 or so events.

      That is pretty cool if largely useless though. Thanks. ;-) (Mine are cd, ls, make, scons, svn, emacs, cat, cvs, rm, less.)

    36. Re:Show attached block devices by ojustgiveitup · · Score: 1

      bash shells are generally in emacs mode by default. instead of history with grep, just do ctrl-r and start typing the command you're looking for.

    37. Re:Show attached block devices by ip_fired · · Score: 5, Informative

      I actually like less better than tail -f. If you less a file, and then hit SHIFT-F it will tail the file, but you can break out of it and scroll around and search for terms. Very handy while looking at log files.

      --
      Don't count your messages before they ACK.
    38. Re:Show attached block devices by duguk · · Score: 5, Funny

      On the contrary, shorter IS something to be proud of.

      Cool! Thanks! I'll tell my boyfriend that next time!

    39. Re:Show attached block devices by kitgerrits · · Score: 1

      I know this may not be what you're looking for but I use:
      dmesg |grep [shf]d
      usually just the 'grep sd', though.

      Also useful:
      from http://www.nslu2-linux.org/wiki/FAQ/SpinDownUSBHarddisks
      'sg_start -S /dev/sda' will spin down /dev/sda, savin gpower and noise.
      It even works on (most) USB disks!

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    40. Re:Show attached block devices by Rei · · Score: 2, Funny

      Do you watch the Colbert Report? Remember the whole "Bridge in Hungary" vote thing? I was one of the people driving that ;) I wrote an elaborate script that auto-changed proxies whenever they blocked an IP or whenever it went down, switched secondary domains whenever they blocked emails from that domain, and so forth, all the while making up registrant names and email addresses, confirming them, and then voting. Much fun was to be had ;)

      --
      Mr. Wizard... why is this place called the Cave of Hopelessness?
    41. Re:Show attached block devices by kitgerrits · · Score: 2, Informative

      The fd0 comes from the BIOS and not the O/S
      If you tell the BIOS there is a fd0, it will simply report its existence to the O/S.
      The O/S will simply assume there is no disk in there.

      --
      "I was in love with a beautiful blonde once, dear. She drove me to drink. It's the one thing I am indebted to her for."
    42. Re:Show attached block devices by io41 · · Score: 1

      history - use it with grep if you forgot what you did

      or, press Ctrl+r to search your history as you type, just press enter to execute what you find. Taken from a a nice resource for shell snippets is Shell-Fu.

      --
      io41 ^,^
    43. Re:Show attached block devices by Logic+and+Reason · · Score: 1

      pushd and popd are better for that kind of thing. And you can get the same effect as 'cd -' by using pushd with no arguments: it swaps the top two dirs on the stack.

    44. Re:Show attached block devices by dlgeek · · Score: 1

      ctrl+r (in bash?): reverse incremental search through history.

      Nice! Thanks!

    45. Re:Show attached block devices by DiLLeMaN · · Score: 2, Funny

      history - use it with grep if you forgot what you did

      This might come in handy the next time I've been boozing again...

      --
      /var/run/twitter.sock is a twitter socket puppet.
    46. Re:Show attached block devices by fracai · · Score: 3, Funny

      .py or it didn't happen.

      --
      -- i am jack's amusing sig file
    47. Re:Show attached block devices by geminidomino · · Score: 1

      pushd/popd - push your current directory into the stack and change directories. Like cd - but lets you keep track of more than one directory back.

    48. Re:Show attached block devices by mooingyak · · Score: 3, Informative

      or if you're a vi freak like me:

      set -o vi
      escape (enters command mode)
      k to scroll up
      / to search

      --
      William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
    49. Re:Show attached block devices by Architect_sasyr · · Score: 1

      Agreed. That (poorly written) shell script was originally a perl script doing the same thing. I tend to hack stuff up in perl and then fall back to bash or C depending on the task.

      --
      Me failed English...
      FreeBSD over Linux. If my comments seem odd, this may explain...
    50. Re:Show attached block devices by kriebz · · Score: 1

      As long as there aren't too many files in the current directory. The C/UNIX argument system only allows for a finite (1024 iirc) number of arguments. The shell will expand * to the contents of the directory, and if that plus the 1 argument for the command name is more than the limit, you get an error. This is why xargs exits. It's a strange command and you have to really understand UNIX to appreciate it, but there's no real substitute.

    51. Re:Show attached block devices by c0p0n · · Score: 1

      You scare the bejesus out of me :S :S

      --

      Your head a splode
    52. Re:Show attached block devices by Rei · · Score: 1

      Hey, if you want to believe that I stay awake 24/7 changing my sig every 15 minutes every day, that's your call. I'd personally rather not give Slashdot a reason to block my script by passing it out. But any remotely clever user can do the same basic thing as I did. It only takes three wget commands, and the only python libraries you need to use are random, os, re, and urllib.

      --
      Mr. Wizard... why is this place called the Cave of Hopelessness?
    53. Re:Show attached block devices by Torinaga-Sama · · Score: 1

      I use xargs with grep all the time.

      ls | xargs grep foo

      --
      (/local/home/curiosity)-#who -u|grep thecat|cut -c 44-49|xargs kill -9
    54. Re:Show attached block devices by EvanED · · Score: 1

      Oops, my bad. I tested (read: had my friend test) pushd and popd, but not cd -.

    55. Re:Show attached block devices by geminidomino · · Score: 4, Informative

      Organizing them all is left as an exercise for the reader.

      Cakewalk. Put the following in ~/.bash_profile or ~/.profile

      For ubuntu:
      SHELLID=(echo `tty` | sed 's!/!.!g')
      HISTFILE=$HISTFILE$SHELLID

      Logout. Log back in. Bada-bing.

    56. Re:Show attached block devices by optikSmoke · · Score: 3, Funny

      It's shorter you want eh? How about...

      blockdev --report /dev/* 2>&-

      Aaaand that's my cue to go find something to do away from the computer.

    57. Re:Show attached block devices by markmuetz · · Score: 1

      Not sure if you can do this in bash, but zsh can be set up to keep one complete history from all currently (or previously I guess) open shells. Have a look at friedcpu.wordpress.com/2007/07/24/zsh-the-last-shell-youll-ever-need for how to set yourself up with it. The article also lists a few other benefits you get from using zsh. To change your shell for your user use $chsh -s /bin/zsh username

    58. Re:Show attached block devices by baileydau · · Score: 2, Funny

      Hey, if you want to believe that I stay awake 24/7 changing my sig every 15 minutes every day, that's your call.

      Umm... Your script can't be working too well at the moment, or your random number generator is broken.

      You have three posts this morning, all with the same sig:

      Thursday November 06, @08:50AM
      Thursday November 06, @10:04AM
      Thursday November 06, @10:41AM

      --
      Ever stop to think ... and forget to start again?
    59. Re:Show attached block devices by bodan · · Score: 2, Informative

      If you're using bash, try adding

      # don't overwrite history from several sessions
      shopt -s histappend

      and

      # save history after each command instead of logout
      PROMPT_COMMAND='history -a;'${PROMPT_COMMAND}

      in your ~/.bashrc

      You might also want to add this, too:

      # don't put duplicate lines in the history. See bash(1) for more options
      export HISTCONTROL=ignoredups
      # ... and ignore same sucessive entries.
      export HISTCONTROL=ignoreboth

      --
      "I think I am a fallen star. I should wish on myself."
    60. Re:Show attached block devices by BorgCopyeditor · · Score: 4, Informative

      Your data is corrupt: only the current sig is ever shown.

      --
      Shop as usual. And avoid panic buying.
    61. Re:Show attached block devices by BlackSabbath · · Score: 1

      Great Linux trick. Pretty useless on Unix though...

    62. Re:Show attached block devices by Isomer · · Score: 4, Informative

      More awesomely, if you have found something in your history with ^R or up arrow or whatever, then you can press ^O to "execute this line and put the next line in the history onto the command line". Thus:
      vi foo.c
      make
      ./foo
      ^Rvi^O^O^O^O^O^O^O^O^O^O^O^O^O^O
      and so on.

    63. Re:Show attached block devices by tochirohatesspam · · Score: 1

      who you calling a pimply faced youth, i'm a pimply faced adult thank you very much.

    64. Re:Show attached block devices by Michael+Wardle · · Score: 1

      Much more convenient in my opinion is Alt+p. It works the same, but without the obnoxious "reverse-search" prompt and it lets you start typing the command before you type the shortcut.

      $ ls <Alt+p>
      turns into...
      $ ls /whatever/you/last/did/an/ls/on

      It's default in tcsh, and can easily be added to bash and zsh.

      .zshrc
      bindkey -M emacs '^[p' history-beginning-search-backward

      .inputrc
      "\ep": history-search-backward

    65. Re:Show attached block devices by Rotting · · Score: 3, Interesting

      sftp...

      Why use that when you can be funny and:

      cat file | ssh user@remotehost "cat > new_filename"

      or maybe tar up a directory on the fly and send it to the remote host for fun?

      tar cvzf - directory_to_tar | ssh user@remotehost "cat > tarfile.tar.gz"

    66. Re:Show attached block devices by tftp · · Score: 2, Insightful

      That line #3 with `echo` contains unbalanced round braces. Could it be that you had a bug and added echo to just make it work?

    67. Re:Show attached block devices by mattack2 · · Score: 1

      With tcsh, I just alias cd to pushd, and get the same effect. If it has a built in way like your zsh example, then I don't know about it.

      (I have read the csh programming considered harmful document http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/, but still like tcsh. I use probably 3 features above csh.. I just have the syntax of csh/tcsh in my head. Once in a _rare_ while I do lament the inability to redirect stdout & stderr separately.)

    68. Re:Show attached block devices by mattack2 · · Score: 1

      Wouldn't
      !21;!22;!23

      (presuming those were the history numbers) be more convenient?

      Then that one lump will be one history item the next time, so you could just !27 or whatever.

    69. Re:Show attached block devices by FrangoAssado · · Score: 4, Informative

      I think you missed a '$' before the open parenthesis, it should be:

      SHELLID=$(echo `tty` | sed 's!/!.!g')

      Also, you could replace "echo `tty`" with simply "tty":

      SHELLID=$(tty | sed 's!/!.!g')

    70. Re:Show attached block devices by IWannaBeAnAC · · Score: 2, Interesting

      I also stuck to tcsh for a very long time, even after reading that document. Then one day, I finally sat down and finally learned how to do redirections properly in bash, and how to set environment variables ('export', instead of 'setenv'), and I never looked back. Bash is so much better, I can't believe now how long it took to make the change. Aside from much better redirection syntax, other bash-isms I often use are $(command) syntax as an alternative to backticks, for i in {1..10}; do .... ; done loops, and lots of other stuff. But all of the shells have a syntax that to me seems very old fashioned and confusing. I wish there was a much more modern shell, perhaps with a python-like syntax, or even just a cleaned up bash. I never remember all the places where you need to insert spaces after reserved words in bash.

    71. Re:Show attached block devices by IWannaBeAnAC · · Score: 1

      Wow, that is awesome. I think I will be using this all time time! Thanks!

    72. Re:Show attached block devices by g0dsp33d · · Score: 2, Informative

      Yeah. tail -f is amazing. Other big time savers:
      -watch (reruns last comand at set interval)
      -ctrl+z and then %(bg # goes here) & (stops current process and resumes it in background
      -using tab instead of typing out file paths
      - pipe redirects such as > and | (lets you put stuff in new places)

      --
      lol: You see no door there!
    73. Re:Show attached block devices by jcuervo · · Score: 1

      fc - Command editor.

      --
      Assume I was drunk when I posted this.
    74. Re:Show attached block devices by Isomer · · Score: 1

      For your system you have to remember their history numbers, and it's a lot more typing. Up arrow or ^R to search for it, then just keep hitting ^O, you don't even have to hit enter.

    75. Re:Show attached block devices by indigoid · · Score: 1

      oops. the squeaky wheel gets the oil, I guess. :-( thanks!

      I do wish bash history had (at least optional) timestamps stored in it for each command. No good for mandatory auditing (users can always modify their histories to hide nastiness) but useful for comparing against other logfiles when troubleshooting stuff.

      --
      P-plate adventurer
    76. Re:Show attached block devices by mattack2 · · Score: 1

      OK, I was a bit vague.. I just meant look up the history numbers once, then type them in once. Then uparrow/return would redo the set of commands again.

      (I don't know of a way to do the search-history thing in tcsh.. or at least not with my current key settings.)

    77. Re:Show attached block devices by geminidomino · · Score: 1

      Yep, dropped the dollarsign. Oddly enough, when I tried it the second way, I got a strange "permission denied" error. It's working now though.

    78. Re:Show attached block devices by eosp · · Score: 2, Informative

      It uses different, non-Python syntax, but I find Fish useful.

    79. Re:Show attached block devices by theTerribleRobbo · · Score: 1

      > It has the somewhat unfortunate downside of
      > starting every shell with no history...

      See modifications (also, fixed the unmatched parenthesis on the HISTFILE line):

      if [ ! -d ${HOME}/.history ]; then
         mkdir ${HOME}/.history
      fi
      if test "$PS1" ; then
         HISTDIR=${HOME}/.history
         HISTFILE=${HISTDIR}/$(/bin/echo ${LOGNAME}.$(hostname).$(/bin/date +"%F.%H-%M-%S"))
         unset HISTSIZE HISTIGNORE HISTCONTROL HISTFILESIZE
         touch $HISTFILE
         # load last history file in the directory as the current history
         history -r $(/bin/ls -1 ${HISTDIR} | /usr/bin/tail -n 1)
      fi

    80. Re:Show attached block devices by theTerribleRobbo · · Score: 1

      Is this post of any help?

      ... Or, yeah, use zsh. :S

    81. Re:Show attached block devices by Abattoir · · Score: 3, Informative

      Diff works fine with ssh.

      ssh $remote_system cat remotefile | diff - localfile

      cat localfile | ssh $remote_system diff - remotefile

    82. Re:Show attached block devices by darkvizier · · Score: 2, Informative

      Harah for vi mode!

      'diff' - compare two files, list differences
      'tr' - text replace... replaces all instances of a character in the input stream with a different one in the output.
      'touch' - update timestamps on a file, or create it if it's not there

      At my last job I dealt with a lot of HIPAA compliant medical files... All tilde delimited with no endlines. I ended up writing a bunch of perl scripts that piped the files through tr to replace tildes with endlines, then do something useful such as grep, or parse the files with regexes. Perl also has special variables for the field record seperators, which you can set to change the endline character that it reads ( $/ ) and writes ( $\ ). If you're ever working with delimited files with no endlines, this can be a lifesaver... just set both variables to your delimiter, and it handles all the conversion for you.

    83. Re:Show attached block devices by chthonicdaemon · · Score: 1

      A bash thing I use all the time is M-. (or alt+.), which inserts the last argument of the previous command. This is magic for stuff like
      mkdir dirname
      cp stuff dirname
      cd dirname --
      you would type
      mkdir dirname
      cp stuff M-.
      cd M-.

      You can also use emacs-like style by specifying a number of arguments to use with C-u number.

      --
      Languages aren't inherently fast -- implementations are efficient
    84. Re:Show attached block devices by floydgolightly · · Score: 1

      and how pleasantly surprised was I when I found that DOS also the pushd and popd commands

    85. Re:Show attached block devices by WhiteDragon · · Score: 1

      Diff works fine with ssh.

      ssh $remote_system cat remotefile | diff - localfile

      cat localfile | ssh $remote_system diff - remotefile

      It's bash specific, but I like to do this as so:

      diff <(ssh $remote system cat remotefile) localfile

      --
      Did you mount a military-grade, variable-focus MASER on an unlicensed artificial intelligence?
    86. Re:Show attached block devices by funwithBSD · · Score: 1

      du -s * |sort -n

      Size of files and directories in ascending sized order.

      Good for finding the filesystem hog.

      --
      Never answer an anonymous letter. - Yogi Berra
    87. Re:Show attached block devices by Antique+Geekmeister · · Score: 2, Interesting

      I prefer:

                  du --max-depth=1 | sort -n

      This handles hardlinks among the directory better, and will also report any .files or .directories hidden at the top level.

      Paying attention to dotfiles is very valuable.

    88. Re:Show attached block devices by Lodewijk · · Score: 2, Informative

      Another 'du' variant:

      du -mb | sort -rsg | less

      Gets the size of all subdirectories relative to `pwd`, writes the size in blocks and sorts them from big to small. Very useful to find deeply nested directories stuffed with old and forgotten .iso's of Debian Potato.

    89. Re:Show attached block devices by plantman-the-womb-st · · Score: 1

      The title of the thread/article is *stupid* unix tricks after all.

      --
      Say bad words about my book, in cold oatmeal, or I shall sue!
    90. Re:Show attached block devices by defaria · · Score: 1

      Some more common ones I've thought of: screen - too useful, run apps in a virtual console which you can attach, deattach and share

      Haven't felt the need.

      cd `pwd -P` - Jump into the real directory (from a linked directory).

      Who cares!

      history - use it with grep if you forgot what you did

      Why bother? Just use bash, set -o emacs then type Cntrl-R and simply find the last time you executed <str>.

      strings - just show the printable strings from a file tail and head - tail -f is a lifesaver

      These are good.

      sftp - i really shouldn't need to explain this.

      Yes you need to explain it! Particularly why I would want to use sftp at all when I have scp!

      file - do magic stuff

      I rarely have need for this...

    91. Re:Show attached block devices by Fweeky · · Score: 1

      -watch (reruns last comand at set interval)

      Linuxism:

      WATCH(8) FreeBSD System Manager's Manual WATCH(8)
       
      NAME
          watch -- snoop on another tty line

      Slightly less potentially damanging than killall, though (which on some *ix's really does kill.. all. Use pkill instead).

    92. Re:Show attached block devices by gullevek · · Score: 2, Informative

      actually ignoreboth ignores duplicates and lines which begin with a space.

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
    93. Re:Show attached block devices by gullevek · · Score: 1

      actually du -sh * never crapped out on me, even with dirs with way too many files inside ...

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
    94. Re:Show attached block devices by gullevek · · Score: 1

      yeah, especially when I checked this:

      $ cd --help
      bash: cd: --: invalid option
      cd: usage: cd [-L|-P] [dir]

      $ man cd
      No manual entry for cd

      now thats very stupid ...

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
    95. Re:Show attached block devices by John+Betonschaar · · Score: 1

      Another gem is netcat (nc): it's like cat but over a TCP port. You can do cool things with it like catting a file to another machine, gzipping and unpacking it on the fly.

    96. Re:Show attached block devices by wylderide · · Score: 2, Informative

      tail --follow=name --retry --max-unchanged-stats=5 Is good for log files that periodically restart and rename the old ones.

      --
      This is the best restaurant I ever eat in
    97. Re:Show attached block devices by totally+bogus+dude · · Score: 1

      That's because "cd" is (naturally) a shell builtin. Try "help cd", which is how you get information about shell built-ins. Or possibly read the bash manpage.

    98. Re:Show attached block devices by totally+bogus+dude · · Score: 1

      Wildcards are expanded by the shell before the program is invoked, so there is absolutely no way du would magically work for dirs with "way too many files" inside and not work for other commands.

      Unless perhaps the expansion exceeded the maximum string length rather than the maximum number of arguments, and the other command happened to be longer than "du -sh". But I'm not sure if there is a a maximum string length.

    99. Re:Show attached block devices by alok_naik · · Score: 1

      Try alt-p or Esc,P ... :)

      --
      Every time I think I've hit the bottom, someone lends me a shovel.
    100. Re:Show attached block devices by rarity · · Score: 1

      That's the same reason I use ls -halt.

    101. Re:Show attached block devices by dkf · · Score: 1

      More awesomely, if you have found something in your history with ^R or up arrow or whatever, then you can press ^O to "execute this line and put the next line in the history onto the command line".

      That's not a universally configured binding (it does nothing under bash on OSX, using the default configuration). Alas.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    102. Re:Show attached block devices by dafdaf · · Score: 1

      One I really would like to add to this list:

      watch 'command'

      --
      To error is human, to forgive, beyond the scope of the OS.
    103. Re:Show attached block devices by drkrimson · · Score: 1

      my .05 contribution; ls -laugh teh funny... and add a screen -x || screen in your .profile to have the same screen session on all your terminals..

    104. Re:Show attached block devices by anpe · · Score: 1

      Somthing that's handy with Ctrl-R as opposed to ESC-/ is that Ctrl-R updates the search results as you type. Do you know if you can achieve the same effect in vi mode?

    105. Re:Show attached block devices by Flossymike · · Score: 1

      Personally I'm always using !

      Often that's !ss which get me sshing into the last machine I sshed into.

      It's !ss:p to just print the command.

      Well, I like it anyway.

    106. Re:Show attached block devices by bodan · · Score: 1

      Yes. And I've never noticed before that having both lines is redundant, since the second export cancels the first. Duh... too much reliance on copy-paste.

      --
      "I think I am a fallen star. I should wish on myself."
    107. Re:Show attached block devices by Skrynesaver · · Score: 1

      Ohh shiny. That's a new one on me, thanks I can see this being useful

      --
      "Linux is for noobs"-The new MS fud strategy
    108. Re:Show attached block devices by mvdw · · Score: 1

      Not only files, but of course disk devices too! Great for making disk images over the network (pipe through gzip to save disk space). You can clone a machine to another machine very easily this way with just a couple of knoppix CDs...

    109. Re:Show attached block devices by Timex · · Score: 1

      For something like this, I regularly use:

      cd /some/path ; du --block-size=1024 -s ./* | sort -rn

      If I'm on a Linux system, I may even put 'x' with the 's' parameter on du(1).

      --
      When politicians are involved, everyone loses.
    110. Re:Show attached block devices by marcosdumay · · Score: 1

      Is that different from 'grep foo *'?

    111. Re:Show attached block devices by asc99c · · Score: 1

      My biggest oh @*(! moment was logged in as root, pressing escape-k-enter to repeat my last command ('vi hosts').

      Unfortunately another user was also logged in as root, and 'rm *' appeared on the command line.

    112. Re:Show attached block devices by RichiH · · Score: 1

      With zsh, you can just

          setopt cdablevars

      and omit the cd completely.

    113. Re:Show attached block devices by RichiH · · Score: 1

      Not sure if that helps in your case, but zsh can do that with

          setop extended_history

      which results in

      : 1225880066:0;echo hi

      Note that this will execute fine in Bash etc, so you can still share history files.

    114. Re:Show attached block devices by RichiH · · Score: 1

      Or you could mkdir -p the basedir and keep a hierachical structure of your files.

    115. Re:Show attached block devices by RichiH · · Score: 1

      perl -pie

    116. Re:Show attached block devices by quarterbuck · · Score: 1

      I really need a command like that for Window managers - Alt-Tab just is'nt fast enough.

      --
      http://slashdot.org/submission/1062723/Cheap-mobile-data-plan?art_pos=2
    117. Re:Show attached block devices by xaxa · · Score: 1

      Assuming you are in /a/b/c/dev/e/f
      cd dev test
      will take you to /a/b/c/test/e/f ...ah, only in Zsh, shame (maybe Bash needs an option to enable this?).

    118. Re:Show attached block devices by famebait · · Score: 1

      alias cd pushd

      alias sa 'alias > ~.alias'

      --
      sudo ergo sum
    119. Re:Show attached block devices by dfiguero · · Score: 1

      You can also quickly execute commands on your history using !, !! or !?

      !find (execute last find command)
      !! (execute last command)
      !?f (execute last command that had an 'f' as part of it)

      I might be wrong about their use but this is how I interpret them to be for my personal use.

      --
      My penguin ate my sig
    120. Re:Show attached block devices by MoogMan · · Score: 1

      It does indeed error, so you should:

      blockdev --report /dev/* 2>&1 | more

    121. Re:Show attached block devices by IpalindromeI · · Score: 1

      If you like netcat, try out socat . Like netcat on steroids.

      --

      --
      Promoting critical thinking since 1994.
    122. Re:Show attached block devices by xethair · · Score: 1

      True, but tail will follow several files all at once, showing you which file is adding lines as it switches. (You can of course, take that to less to get searching, but don't forget it's getting accumulated in a buffer...)

    123. Re:Show attached block devices by mooingyak · · Score: 1

      Maybe.

      I'm not actually sure what you mean by 'updates the search results as you type'.

      --
      William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
    124. Re:Show attached block devices by TheGreatOrangePeel · · Score: 1

      Along the same lines, there's pushd and popd. Alias pushd if you don't want to type the new path all the time.

    125. Re:Show attached block devices by Torinaga-Sama · · Score: 1

      Probably mostly the same. I guess I just never look at grep as much more than something to pipe something else into.

      --
      (/local/home/curiosity)-#who -u|grep thecat|cut -c 44-49|xargs kill -9
    126. Re:Show attached block devices by ysth · · Score: 1

      I once made a patch to (among other things) the offensive fortune cookie files with diff -p0rn4u

    127. Re:Show attached block devices by afabbro · · Score: 1

      This shows all attached block devices (it also errors like crazy, hence the | more) blockdev --report /dev/* | more

      In that case, I'd suggest blockdev --report /dev/* 2>/dev/null

      --
      Advice: on VPS providers
    128. Re:Show attached block devices by afabbro · · Score: 1

      Along that line are pushd and popd.

      What I'd like is "cd -" that keeps going back as long as you keep typing cd -. In other words, it acts like the back button on a browser. Perhaps "cd +" could then go forward.

      --
      Advice: on VPS providers
    129. Re:Show attached block devices by afabbro · · Score: 1

      tail and head - tail -f is a lifesaver

      I use tail -F, which is the same as tail -f, but works on non-existent files. Useful when tailing log files from programs that start a new log file every time it runs. Using tail -F in this case, you can just leave tail running while you start and restart the program overwriting the log file.

      Non-intuitively, tail -f somefile.log | grep something works, too.

      --
      Advice: on VPS providers
    130. Re:Show attached block devices by massysett · · Score: 1

      sshfs is truly pimp, but both deserve mention; AFAIK sshfs can't be used on a system where you don't have root that doesn't have FUSE installed.

      Sourceforge recently locked down its Web hosting servers so that you can't log in to them anymore, although you can still transfer files in and out of them using sftp. Unfortunately it seems that this change also keeps sshfs from working. It also broke similar tools for network-transparent file usage, such as netrw in Vim (though Konqueror's fish ioslave still works.) This was enough of a pain for me to move my little-known project's web hosting off Sourceforge altogether (though I was getting no benefit from Sourceforge anymore anyway.)

    131. Re:Show attached block devices by portscan · · Score: 1

      if you like vi and diff, you'll LOVE vimdiff

      it brings up the two files next to each other and highlights all the differences. quite a beautiful thing.

    132. Re:Show attached block devices by Short+Circuit · · Score: 1

      You've never tried to use a shell-expanded * in a directory with twenty-thousand files...

    133. Re:Show attached block devices by Short+Circuit · · Score: 1

      "ls|xargs foo" works in directories with thousands of files. "foo *" doesn't.

    134. Re:Show attached block devices by nevermore94 · · Score: 1

      My variation on the same:

      HISTFILE=$HISTFILE`tty | tr / .`

      --
      Nevermore.
    135. Re:Show attached block devices by fransw · · Score: 1
      I second for less :-)

      less +F immediately starts the follow mode...

    136. Re:Show attached block devices by rcp · · Score: 1

      More awesomely, if you have found something in your history with ^R or up arrow or whatever, then you can press ^O to "execute this line and put the next line in the history onto the command line".

      Thanks! I've wanted that probably about a thousand times.

    137. Re:Show attached block devices by apqvist · · Score: 1

      I rather wish that history tracking played nicely with multiple shells open at once. It never seemed to track what I'd done. I'd say,"what was that thing I got two weeks ago? I know used wget .... but can't find it!..."

      Is there something I should be doing instead?

      Assuming bash is your shell:

      -a
      Append the new history lines (history lines entered since the beginning of the current Bash session) to the history file.

      PROMPT_COMMAND
      If set, the value is interpreted as a command to execute before the printing of each primary prompt ($PS1).

      Put:
      export PROMPT_COMMAND="history -a"
      in your .bashrc

    138. Re:Show attached block devices by anno1a · · Score: 1

      Bash is really rather magical. For instance, I don't use history - I don't know it, and I really don't need it. Rather:

      * Ctrl + R: Reverse search in the bash history. This is a must-have tool!
      * Ctrl + L: Clear terminal.
      * CtrL + D: Normal logout. Faster than typing exit.
      * Tab completion can be activated for most things, such as ssh, man pages and apt-get (if you use that). Just look at /etc/bash.bashrc.

      --
      ------- I fumbled my registration and I now must suffer
    139. Re:Show attached block devices by rugatero · · Score: 1

      sftp - i really shouldn't need to explain this.

      My eyes must be going - at first I read this as stfu. Now that would be a useful command.

      --
      This comment is for entertainment purposes only. Any similarity to real insight or information is purely coincidental.
    140. Re:Show attached block devices by Quebec · · Score: 1

      omg, didn't know that one...

      Thx

    141. Re:Show attached block devices by kalirion · · Score: 1

      Yes you need to explain it! Particularly why I would want to use sftp at all when I have scp!

      scp is good if you know the file path on the other machine, or you set up scripts/aliases for commonly copied files/paths. sftp is good if you need to do some exploration.

    142. Re:Show attached block devices by QuoteMstr · · Score: 1

      Like the ediff we've had in Emacs for 14 years? :-)

    143. Re:Show attached block devices by anpe · · Score: 1

      Mmm, yeah.
      Lets assume that you issued 'killall pulseaudio' and then 'kill -2 1234' on the command line.

      What I was referring to was the fact that when you press Ctrl-R in emacs mode, then you type 'kill' it would show e.g. "kill -2 1234", and then you'd add 'all', and then it would show 'killall pulseaudio' (which would have been issued earlier).
      OTOH, in vi mode, when I press Esc-/ I can type 'kill' and then search for the killall with 'n', but it's less handy IMHO.

    144. Re:Show attached block devices by Rei · · Score: 1

      Mail me off-forum, and explain in detail what you plan to use it for; I'll decide whether or not to give you a copy, and whether to cripple it to any degree before handing it over. At the very least I'll have to strip out passwords, usernames, etc.

      meQme@daQughtersofQtiresiQas.orQg (remove Qs)

      --
      Mr. Wizard... why is this place called the Cave of Hopelessness?
    145. Re:Show attached block devices by mooingyak · · Score: 1

      ah.

      no, there's no way I'm aware of to do that in vi mode.

      --
      William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
    146. Re:Show attached block devices by ZeroNullVoid · · Score: 1

      cd
      used to install OS some of the time.

    147. Re:Show attached block devices by Myrddin+Wyllt · · Score: 1

      Ok, I admit I had to wtf PFY, but at least I knew enough to use wtf.

      --
      [ ]Half Empty [ ]Half Full [x]Twice as big as it needs to be
    148. Re:Show attached block devices by Hal_Porter · · Score: 1

      There's a reason it's called eunuchs.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    149. Re:Show attached block devices by duguk · · Score: 1

      Wait... Are you implying that me, or that my boyfriend is castrated?

      I think you failed... Mind you, so did he last time.

    150. Re:Show attached block devices by alecu2 · · Score: 1

      I wish there was a much more modern shell, perhaps with a python-like syntax, or even just a cleaned up bash. I never remember all the places where you need to insert spaces after reserved words in bash.

      Then look no further than ipython. http://ipython.scipy.org/

    151. Re:Show attached block devices by ReconOps · · Score: 1

      Logout. Log back in. Bada-bing.

      Why logout? Just use 'source':

      source { ~/.bash_profile | ~/.bashrc }

      --
      A PC without Windows is like Coffee without Ketchup...
    152. Re:Show attached block devices by portscan · · Score: 1

      a lesson learned the hard way: don't drink and root

    153. Re:Show attached block devices by Haeleth · · Score: 1

      If you're using ksh (the real UNIX interactive shell), there's a handy cd foo bar syntax. If you're in /opt/foo/bin and you do cd foo bar, you wind up in /opt/bar/bin, without having to think about how many ../s you need to put in.

    154. Re:Show attached block devices by argo0s · · Score: 1

      You don't need to log out just use a .
      eg: . .profile

    155. Re:Show attached block devices by Windows_NT · · Score: 1

      Ok honestly .. I have something to confess .. I feel like the guy at an AA meeting that feels he needs to be there cuz he gets trashed of boones farm ... Or the car that never ... well anyway ..
      I love using unix/linux, and i envy you guys out there that get to see bash everyday. I think a Solaris Admin would be my ultimate job, but right now im stuck in windows :( wirting VB and C# all day ... .NET controls, msSQL stored procedures .... Maybe this is the most geeky thing youll ever see on /. but i wish i could be sitting at a green on black screen with a blinking cursor all day, typing redirections and dd'ing the hell out of every file ... you people have it goood!! im gonna cry .. i need some boobies to wipe my tears ...
      the point is, fuck you! i wanna be a unix admin (i smell blockbuster theme coming on .. )

      --
      Go go Gadget Nailgun!
    156. Re:Show attached block devices by Windows_NT · · Score: 1

      ssh 127.0.0.1 -l root
      #dd if=/dev/sda1 of=/dev/null
      I do this while im in my underwear, it makes me feel like a really hacker ;)

      --
      Go go Gadget Nailgun!
    157. Re:Show attached block devices by amRadioHed · · Score: 1

      That's true. I wrote a little script to deal with that. It assumes that the files to compare are in the same location on both machines

      #!/bin/ksh

      RHOST="$1"
      RTMP="/tmp/sdiff_$$"
      if [ "`echo $2 | cut -b 1`" = / ]; then
              FILE="$2"
      else
              FILE="`pwd`/$2"
      fi

      scp "$RHOST:$FILE" "$RTMP" 2>/dev/null
      diff $FILE $RTMP; rm $RTMP

      --
      We hope your rules and wisdom choke you / Now we are one in everlasting peace
    158. Re:Show attached block devices by bobbozzo · · Score: 1

      I use
      du -sh

      which sorta spells something too, I suppose. :p

      --
      Nothing to see here; Move along.
    159. Re:Show attached block devices by gullevek · · Score: 1

      Okay I really need to try that out. Perhaps I am totally wrong here ...

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
    160. Re:Show attached block devices by Oryn · · Score: 1

      Instead of history you can type ^r (ctrl r) in bash.
      It will perform a search as you type within history assuming you have any to seaarch.

    161. Re:Show attached block devices by J053 · · Score: 1

      blockdev --report /dev/* 2>/dev/null
      if you don't want to see the errors...

    162. Re:Show attached block devices by mwoliver · · Score: 1

      # managing multiple history files in bash
      #
      for each in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do ln -s .bash_history .bash_history.dev.ttyp${each}; done
      #
      # then add the following to the .bash_profile
      #
      SHELLID=$(tty | sed 's!/!.!g')
      HISTFILE=${HISTFILE}${SHELLID}

      That works for my FreeBSD servers very well, allowing all open shells to read from and write to a common history file. Unless you are on a really busy box where you are sharing with hundreds of users, this may be useful to you. It certainly has been to me.

      --
      Mike O, KT2T
  40. Bah, subtlety: by FooAtWFU · · Score: 5, Insightful

    :(){ :|:& };:

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
    1. Re:Bah, subtlety: by Sir_Lewk · · Score: 2, Funny

      I'll recognize that forkbomb anywhere!

      --
      "linux is just DOS with a UNIX like syntax" -- Galactic Dominator (944134)
    2. Re:Bah, subtlety: by FooAtWFU · · Score: 1
      Pity a lot of modern systems are hardened against it.

      On that note,

      ulimit -u

      is a good one to know.

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
    3. Re:Bah, subtlety: by jkiol · · Score: 5, Funny

      @$**& well we know it works in cygwin too.

    4. Re:Bah, subtlety: by chainLynx · · Score: 1

      I've seen this thing a lot but my bash-1337ness is insufficient to comprehend why this produces a forkbomb... is there a good explanation of this anywhere? (man bash does not count)

    5. Re:Bah, subtlety: by Nathanbp · · Score: 5, Interesting

      :(){ :|:& };:

      :() defines a function named : with no arguments. { :|:& } is what the function does. :|: calls itself twice (with a pipe between the two), and the & at the end runs it in the background as a new process. The ; finishes off that command, then the last : runs the function, starting the fork bomb (as each run starts 2 new processes, each of which starts 2 new processes...).

    6. Re:Bah, subtlety: by chainLynx · · Score: 1

      Ah, thanks.

    7. Re:Bah, subtlety: by suggsjc · · Score: 2, Funny

      Ahhhhhhhhh...and I was just thinking it was just a bad ASCII drawing of a cookie monster.

      --
      When I have a kid, I want to put him in one of those strollers for twins and then run around the mall looking frantic.
    8. Re:Bah, subtlety: by Gusfm · · Score: 1

      Damn, that was fast! I shouldn't have underestimated that thing! =D

    9. Re:Bah, subtlety: by lars_boegild_thomsen · · Score: 1

      Ooops - time to set some ulimits :) You just took down my laptop by proxy (and the proxy was myself).

    10. Re:Bah, subtlety: by netux · · Score: 1

      Damnit, I couldn't figure it out so I ran it. Now I can't use my computer til I get home to hard reboot. For those that don't get it (if I'm wrong someone correct me) make a function called ":" the body of the function is, call the function, and then run the function it the background. so recursivly opens shells till out of memory. I thought killall bash was a good idea, not so much, couldn't figure out how to get it to stop and now can't ssh into the box. :-( very slick, should have put up a warning though.

    11. Re:Bah, subtlety: by websaber · · Score: 1

      What does :(){ :|:& };: do?
      I tried it and nothing hap

      --
      "A good friend will bail you out of jail. A true friend will be sitting next to you saying, 'damn....that was fun!'"
    12. Re:Bah, subtlety: by websaber · · Score: 1

      crash a unprotected linux box with no option but a hard re-boot.

      --
      "A good friend will bail you out of jail. A true friend will be sitting next to you saying, 'damn....that was fun!'"
    13. Re:Bah, subtlety: by EdelFactor19 · · Score: 1

      running out of shells isnt your only problem... a fork bomb also runs you out of processes of which there are a limit... which can prevent you from creating a process to kill the others with. the memory is also a problem.

      --
      "Jazz isn't dead, it just smells funny" ~Frank Zappa
      EdelFactor
    14. Re:Bah, subtlety: by Anonymous Coward · · Score: 1, Informative

      Damn you Google ! Damn you and your lousy "exact search" ! Exact search my a** !

    15. Re:Bah, subtlety: by kormat · · Score: 1

      You are correct apart from the very first bit: ":() defines a function named : with no arguments". It declares a function, the declaration says nothing about arguments. Sh functions don't have an explicit argument list, everything is passed in through the positional parameters ($1 $2 etc).

      Steve

      --
      Time. Time seems... strange.
    16. Re:Bah, subtlety: by DarkDust · · Score: 1

      I was about to submit this one as well, it's one of my favourite shell scripts :-) But I think the "&" is not necessary.

    17. Re:Bah, subtlety: by infamous_blah · · Score: 1

      Mod parent fork-bomb!

    18. Re:Bah, subtlety: by Kadagan+AU · · Score: 1

      And it locked up my VM in no time. =) Good fun.

      --
      This space for rent, inquire within.
    19. Re:Bah, subtlety: by martyros · · Score: 1

      Actually, something like "make -j" in the base directory of a linux kernel source tree is essentially a fork bomb as well. Did that once by accident; never again. :-)

      --

      TCP: Why the Internet is full of SYN.

    20. Re:Bah, subtlety: by cant_get_a_good_nick · · Score: 1

      :(){ :|:& };:

      heh. I saw that on someone's sig a long time ago. I knew it was a forkbomb, but for some twisted reason i wanted to see what it would do to my cygwin shell. I *almost* pasted into a prod window. Which probably would have gotten me fired.

      Luckily enough i didn't, and am still employed. BTW: doing that on Cygwin will force you to reboot your windows box. No way to cleanup.

    21. Re:Bah, subtlety: by t35t0r · · Score: 1

      What exactly does this do (in bash)? All I can make out is the pipe, if it really is a pipe. On my uniprocessor system it caused the HDD light to start blinking continuously and it froze X. I couldn't even drop down into the console and had to hit the power switch to get my system back.

    22. Re:Bah, subtlety: by t35t0r · · Score: 1
  41. Crushing a finger users terminal by Bardwick · · Score: 2, Funny

    People used to use finger all the time to see what the sysadmins (myself included) were doing. Link your .plan to a massive core file, or several core files >> together ....

    1. Re:Crushing a finger users terminal by witherstaff · · Score: 1

      Oh the heady days of the early 90s. For the friends in other schools who didn't MUD on the same server, or just weren't mudders, I'd use finger and who to hunt them down if they were online. Then ytalk to group chat.

      Now for my personal favorite trick : Netpipes. Easiest way around any firewall and logging out there is to faucet a port on another server that is reachable and hose to where you want it to go.

  42. Re:Hail to the chimp! by VeNoM0619 · · Score: 1

    And to think, if only you picked a better product to sell, you could be making millions in marketing...

    Yes YOU! Just transfer all your money to my Nigerian bank and you too could be making millions...

    I call that... the reverse troll.

    --
    Disclaimer: I am not god.
    We may not be created equal
    But we can be treated equal.
  43. Surprised that it does it correctly. by khasim · · Score: 1, Interesting

    On Windows, tabbed completion grabs the FIRST entry that matches.

    On Linux, tabbed completion lists ALL the entries that match.

    1. Re:Surprised that it does it correctly. by Anonymous Coward · · Score: 1, Funny

      Maybe you should try pressing TAB a few more times in Windows...

    2. Re:Surprised that it does it correctly. by Deadplant · · Score: 1

      except for on ubuntu where the brain-dead shell tries to be smart about it.
      It actually tries to choose which filename to autocomplete by looking at file extensions!
      drives me freaking nuts.

    3. Re:Surprised that it does it correctly. by SoCalChris · · Score: 1

      Although on Windows, pressing Tab again cycles to the next match. It's not nearly as useful or intuitive as the UNIX tab completion, but it is more powerful than most users realize.

    4. Re:Surprised that it does it correctly. by Pixie_From_Hell · · Score: 2, Informative

      Well, to be fair it's a relatively new feature in bash, so perhaps ubuntu is just the first place you've tried that makes bash completion the default. Here's a blog posting on changing completion to make it smarter, so perhaps you can follow some links and learn how to make the shell do what you want. That's sort of the point...

    5. Re:Surprised that it does it correctly. by GuldKalle · · Score: 1

      Why is the windows way the wrong one?
      Just tab again if you didn't find the right one the first time.

      --
      What?
    6. Re:Surprised that it does it correctly. by Waffle+Iron · · Score: 2, Informative

      Add this to your .inpurc file:

      Control-Space: menu-complete

      Then you can do it either way. <Ctl-Space> works like Windows, tab works like bash. Also add these if you want a little additional sanity:

      set completion-ignore-case on
      set show-all-if-ambiguous on

    7. Re:Surprised that it does it correctly. by incripshin · · Score: 1

      Here's why: http://freshmeat.net/projects/bashcompletion/. The more people attribute features to a distribution, the more insane I get.

    8. Re:Surprised that it does it correctly. by rubberglove · · Score: 1

      Vim tab completion works like that. The only reason I don't like it is that it makes it a bit too easy make the wrong choice if you're typing faster than you're thinking.

      I realize the 'typing faster than you're thinking' is the real problem here, but the 'strict' bash-style tab completion seems a bit safer.

    9. Re:Surprised that it does it correctly. by khellendros1984 · · Score: 1

      Odd, that has never happened to me...

      --
      It is pitch black. You are likely to be eaten by a grue.
    10. Re:Surprised that it does it correctly. by BollocksToThis · · Score: 1

      The Windows way is great when you have a few nearly identical long names with scattered differences. The bash way is great pretty much all other times. Except for the fucking bell when there are multiple completions - not a problem on my own machines, but every time I use someone else's machine it wears my teeth down another millimeter.

      Things to hate about Windows tab completion include but are not limited to:
      1) It erases everything after the cursor, so you can't go back in a long command line and insert a tab-completed filename.
      2) It completes by ignoring punctuation characters at the start of the name (so 's' will complete as ".svn" before "source" - imagine how much this pissed me off when we switched version control systems)

      --
      This sig is part of your complete breakfast.
    11. Re:Surprised that it does it correctly. by EvanED · · Score: 1

      It's not nearly as useful or intuitive as the UNIX tab completion, ...

      I wouldn't say that; I suspect that you think so just because you're used to the Unix way. I've used both a lot, and I don't think that one is notably better than the other. On the whole, I would say that the Windows one actually wins out in terms of speed overall for me because if one of the first couple hits is what you want you can type rather less than you can on Linux, but never by much; by contrast, it occasionally loses very badly (if I don't type enough and it starts tab completing a ton of crap I don't want).

      I think the Unix way is better, but only by a little bit (so I disagree with the "nearly" part), and don't see any reason why it should be more or less intuitive.

    12. Re:Surprised that it does it correctly. by BluBrick · · Score: 1

      I recently discovered that Shift+Tab in Windows cycles backwards through the matches. Very handy.

      But for my stupid Unix trick, I wrote a tiny program which I called curlfish (CRLF shell). All the program did was print "\n\n\n\nDOS-style linefeeds found!\nRe-transfer it in text mode or save it with Unix linefeeds.\n\n\n\n". I symlink'ed it to /bin/sh^M, /bin/ksh^M, /bin/bash^M and so on for every script interpreter on the system. From then on I never had users asking me why /bin/sh was "not found".

      --
      Ahh - My eye!
      The doctor said I'm not supposed to get Slashdot in it!
    13. Re:Surprised that it does it correctly. by UnknownSoldier · · Score: 1

      I think you mean, tabbed completion grabs the NEXT entry that matches...

      CMD "wraps-around", whereas 4NT doesn't.

    14. Re:Surprised that it does it correctly. by hackstraw · · Score: 1

      On Windows, tabbed completion grabs the FIRST entry that matches.

      And its the first on the hardisk, no human pattern to the match, but hey they added some functionality after all these years.

      On Linux, tabbed completion lists ALL the entries that match.

      Depends on the shell, and its options. zsh has had for years, and bash has it recently where there is programmable completion. Its so nice to do cd TAB and it list directories and symlinks to directories that you can actually, err, cd into, instead of completing with files and whatnot.

    15. Re:Surprised that it does it correctly. by vyrus128 · · Score: 1

      If you can't find where this shit's getting added to your bash startup files, just do what I did -- add 'complete -r' to the end of your .bash_profile to nuke all custom completions.

    16. Re:Surprised that it does it correctly. by jonadab · · Score: 1

      > On Windows, tabbed completion grabs the FIRST entry that matches.
      That's what cmd.exe does. (We'll not talk about command.com, okay?)

      > On Linux, tabbed completion lists ALL the entries that match.
      That's what bash does.

      However, eshell takes into consideration what you've already typed (e.g., the command) and when possible chooses the *best* completion, e.g., if you're doing a cd command, it will always complete with a directory if there's one that matches; unzip prefers .zip files, and so on. It takes a little getting used to, but it's nice.

      --
      Cut that out, or I will ship you to Norilsk in a box.
  44. Dupe your TTY output to someone else using script by dbrossard · · Score: 1

    This is useful when you want to show someone else what you are seeing in your TTY without actually letting the interact with the session.
    "script | tee -a /dev/pts/(#of other tty)"

  45. Best tool for wasting time by snspdaarf · · Score: 1

    Rogue. Definitely rogue.

    --
    Why, without your clothes, you're naked, Miss Dudley!
  46. Re:This one always surprises people for some reaso by interiot · · Score: 4, Informative
    • 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.
  47. multitasking in a terminal by shvytejimas · · Score: 2, Informative

    Quite a handy way to switch between several applications on a single terminal: Ctrl+Z stops the current program, then bg to resume it and send to background, fg to resume in foreground. You can have several stopped programs and pick one with fg 3, for example. See all stopped jobs with jobs.

    Few things to note, wget still prints to STDOUT, even when backgrounded, so I run it in screen. Also, pico may require a -z switch to allow suspension.

  48. Imbedding output with ' by qwertyatwork · · Score: 1

    You can use '' to imbed output to a command. Example

    ls -l 'locate gcc' // Output would give you a long listing of wherever gcc is located

    Another one is using -exec "{}" ";" with find, example.

    find ~/tvshows -name doctor\*who\* -exec mplayer -fs "{}" ";"

    The "{}" is the filename, not sure about ";" but its needed.

    1. Re:Imbedding output with ' by mjcecil · · Score: 2, Informative

      Embedding output... use the backtick, not the doubletick. '`' not '"'

      echo There are `ls | wc -l` entries in this directory.

      In ksh, you can also use the syntax $(command string)

      echo There are $(ls | wc -l) entries in this directory.

      --
      Mark J. Cecil -- Senior UNIX Engineer
      New Orleans, Louisiana
      http://notrealswift.blogspot.com
    2. Re:Imbedding output with ' by atomic-penguin · · Score: 2, Informative

      ls -l 'locate gcc' // Output would give you a long listing of wherever gcc is located

      Maybe it is just my font, but I think those should be backticks. Variables and commands cannot interpolate strings with single quotes ''.

      Backticks, however, will allow command output redirection.

      ls -l `locate gcc`

      You could write it this way, but you threw in double-quotes and do not really need them here.

      find ~/tvshows -name doctor\*who\* -exec mplayer -fs "{}" ";"

      You could type the following, with the same effect. The find command with the -exec switch, is forking off a sub-shell for every argument passed by the find command, the \; or ";" is a command terminator for the sub-shell which is forked off. Depending on the task this could run very, very, very slow. For heavy-duty tasks there is a pretty neat utility shipped with every distribution of Perl, check out find2perl sometime.

      find ~/tvshows -name "doctor*who*" -exec mplayer -fs {} \;

      To generate pure Perl code to do the same loop, run the following. If you tack on a '| perl', after the find2perl command, it will pipe the generated code straight to the language interpreter and execute.

      find2perl ~/tvshows -name "doctor*who*" -exec mplayer -fs {} \;

      --
      /^([Ss]ame [Bb]at (time, |channel.)){2}$/
    3. Re:Imbedding output with ' by Bandman · · Score: 1

      I always use backtics to look at shell scripts in the path

      cat `which shellscript`

    4. Re:Imbedding output with ' by foobat · · Score: 1

      if you're just looking for where some shell command like gcc is located just use

      which gcc

  49. htop, dd, wmctrl stuff by Anonymous Coward · · Score: 1, Interesting

    Various apps have nice little things that are useful at one time or another, so to name a few:

    htop (better top) - has a nice feature that does a strace on a live process by pressing s when the process is selected

    dd (everyone knows this one) - while doing a large transfer, you can send it the USR1 signal and it will display the transfers' progress (bonus points for doing something like watch -n 5 killall -USR1 dd)

    wmctrl (interactions with WMs) - useful in all kinds of scripts, like looping every few seconds and searching for a specific window title then running some commands based on that (did someone IM you while you're AFK?, make keyboard's NUMLOCK blink if the screen's sleeping)

    etc. etc.

    1. Re:htop, dd, wmctrl stuff by Randle_Revar · · Score: 1

      wmctrl is new to me. Interesting, but I prefer WMs like wmii and awesome, which have excellent cli scriptablity (sp?)

  50. A few of mine... by digitalhermit · · Score: 1

    Clear a file:
    >filename.log

    Use the watch utility to keep checking the status of an output. E.g.:

          watch ls -l foo

    Within vim and vi you can read input from the shell. This allows you to do things across the network and read it directly into the current buffer. For example, launch vim then do: :r! ssh maggot@darkstar cat /etc/ldap.conf

    This is a shortcut method of copying the file locally, editing, then saving.

    On machines where rsync is not available, I often use tar/ssh to move directories:

          tar cf - /home/maggot/source | ssh maggot@darkstart "cd /export; tar xf - "

    1. Re:A few of mine... by digitalhermit · · Score: 1

      Doh!! You are correct.

      I'd even documented this before::

      http://sites.google.com/site/disciplinux/linux/unixlinux-scripts/lots-to-learn

  51. Regular expressions, ex, etc. by mjcecil · · Score: 1

    Regular expressions. People have NO clue how to assemble a regular expression. Or, for that matter that regular expressions are... well, REGULAR.

    On that same line, the ancient ex knowledge that precedes vi. I use ex commands in batch to modify large numbers of files in place all the time. This includes line address searching, ranges, and blocks.

    sed command separators. If you're modifying a bunch of directory names, it's not necessary to "escape" the slash character to get it into your sed line... you just choose a different separator character, which is, by default, the character after the substitute command: (i.e. what was 's/\/dirA/\/dirB/' becomes 's,/dirA,/dirB,' )

    --
    Mark J. Cecil -- Senior UNIX Engineer
    New Orleans, Louisiana
    http://notrealswift.blogspot.com
  52. -exec as a test by Chris+Pimlott · · Score: 4, Informative

    One great feature of find that many people are unaware of is that you can use -exec as a test, not just as an action. For example, this is equivalent to your command above:

    find . -exec grep -q {} \; -print

    The "-print" action is only executed if the -exec command returns success.

    You can do a lot of handy things with this. Here's a real-world example from earlier today. I wanted to change the mime-type of all the xml files in my svn repository from "application/xml" to "text/xml":

    find . -name \*.xml -exec sh -c "svn propget svn:mime-type {} | grep -q application/xml" \; -exec svn propset svn:mime-type text/xml {} \;

    1. Re:-exec as a test by kramulous · · Score: 1

      I use that quite a lot. Particularly a software install where my umask has stuffed up.

      # Recursively chmod on directories only
      find . -type d -exec chmod 700 {} \;

      --
      .
    2. Re:-exec as a test by jeremyp · · Score: 1

      Your first command can be shortened:

      find . -exec grep -l pattern {} \;

      although I tend to put "-type f" in before the "-exec"

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    3. Re:-exec as a test by wanderingknight · · Score: 1

      find is especially useful when dealing with a huge number of files. I once had to copy a crapload of files (over 12000) from a specific directory in one of our client's server to another directory, and cp was outright refusing to take so many arguments.

      I solved it with find . -exec cp {} /path/to/directory \;, since this way cp would execute on one file at the time.

    4. Re:-exec as a test by Chris+Pimlott · · Score: 1

      Your first command can be shortened:

      find . -exec grep -l pattern {} \;

      yes, I was using that as a trivial example equivalent to that same command line in the parent post.

    5. Re:-exec as a test by lewiscr · · Score: 1

      rsync -avP ./ /path/to/directory/

      Remove the -P for less verbosity.
      Remove the -vP for no verbosity.

      It'll work over ssh if your destination is user@host:/path/to/directory/

      I stopped using cp long time ago.

    6. Re:-exec as a test by James+Youngman · · Score: 1

      Your first command would be much more efficient as

      find . -exec grep -ql blah {} \+

      (I added the regex for you)

    7. Re:-exec as a test by AnteTempore · · Score: 1

      To me this is easier to understand:

      find . -name \*.xml | parallel "svn propget svn:mime-type {} | grep -q application/xml && svn propset svn:mime-type text/xml {}"

    8. Re:-exec as a test by acambra · · Score: 1

      hmm... there is still the nice old tar:

      $ tar cf - somedir | (cd to_some_otherdir;tar xfv - )

      or even

      $ tar cf - somedir | ssh user@another.machine (cd to_some_otherdir;tar xfv - )

      use that quite a lot.

  53. korn shell trick by mihalis · · Score: 1

    Command-line recall and editing using the arrow keys in Korn Shell:

    alias __A=^P
    alias __B=^N
    alias __C=^F
    alias __D=^B

    Put this in your .kshrc

    This works on Solaris at least. I haven't tried it on Linux since bash does this anyway. So if for some reason I don't have bash I can at least use the arrow keys for command-line recall and editing.

    Note, those are control characters, not the '^' character and then P N F or B. You can insert control characters into a text file in Emacs by Ctrl-Q Ctrl-P (to insert Ctrl-P for example).

    1. Re:korn shell trick by mihalis · · Score: 1

      nice shell prompt

      HOST=`hostname | cut -f2-3 -d-`
      PS1=$HOST:'$PWD \$ '

      got this from a book I think, possibly the Stephen Coffin SVR4 book.

      results in, for example :

      elrond:/home/cmorgan $ cd ..
      elrond:/home $

    2. Re:korn shell trick by stjobe · · Score: 1

      http://tldp.org/HOWTO/Bash-Prompt-HOWTO/

      I prefer PS1="\u@\h:\W\$ " myself, sometimes with some ANSI escape sequences thrown in for good measure (and color).

      --
      "Total destruction the only solution" - Bob Marley
  54. Seen on a friend's T-Shirt by Nicros · · Score: 4, Funny

    chmod a+x /bin/laden

    1. Re:Seen on a friend's T-Shirt by doti · · Score: 3, Funny

      yeah, but first you will need to

      find /bin/laden

      --
      factor 966971: 966971
    2. Re:Seen on a friend's T-Shirt by Mister+Liberty · · Score: 1

      ...followed by strip, bind, kill, dump, etc. yeah we all no that one.

    3. Re:Seen on a friend's T-Shirt by gmac63 · · Score: 1

      kill -9 /bin/laden

      --

      INSERT INTO comment VALUE('Doh!') WHERE user='you';
    4. Re:Seen on a friend's T-Shirt by Zaiff+Urgulbunger · · Score: 1

      I'm sure I don't need permission!

    5. Re:Seen on a friend's T-Shirt by frisket · · Score: 1

      not to mention locate wmd

    6. Re:Seen on a friend's T-Shirt by bobbozzo · · Score: 1

      find / -iname 'base*' -exec chgrp us '{}' \;

      --
      Nothing to see here; Move along.
    7. Re:Seen on a friend's T-Shirt by CoolGenie · · Score: 1

      $ where laden
      laden not found

  55. expect by jaymzter · · Score: 1

    I'm not able to set up ssh keys on all my lab systems, and in many cases I have to first log in to an access device to be able to then log into a third system. Expect is perfect for such circumstances. In addition, there's even autoexpect, which will build the script for you!

    Another cool tool, which I don't see in any distro, is cgrep (contextual grep). It has all the advanced features of GNU grep, and adds context search as well, so you can pull out blocks of text around your query string.

    --
    If thou see a fair woman pay court to her, for thus thou wilt obtain love
  56. Re:This one always surprises people for some reaso by jmorris42 · · Score: 1

    > Actually that hasn't impressed anyone in a while, come to think of it.
    > At least not since Apple figured out what a find index is.

    Yo, fanboi. Try the locate command, most Linux distros had it years before Apple even thought about putting Mach under their eye candy.

    Of course on modern distros the locate command will complain that it's database doesn't exist until you manually enable the service because the command line is supposed to be dead. :(

    --
    Democrat delenda est
  57. Re:Listing directory contents without the ls comma by digitalhermit · · Score: 1

    If you're lucky enough to have an automounter module running then you can also use a static shell such as busybox. I like to keep a subset of utilities available on the filesystems for these types of emergencies :D

  58. Old staples, some interesting by jonaskoelker · · Score: 1

    `combine', out of the package moreutils: $ combine file1 operator file2 picks out the lines that are both in file1 and (e.g.) file2; assumes the lines are sorted according to sort.

    `sponge', buffers all of stdin in memory, then dumps it into "$1". Ever done sort lines.txt | grep -v dirty-words > lines.txt? You meant '| sponge lines.txt' instead of '> lines.txt'.

    There's of course the downloaders for shell scripting: wget and curl. Then there's the GUI interaction window makers, kdialog and zenity.

    If you use bash because it's the default, have a look at zsh. It takes a little while to get used to, but I like it and I don't even know it very well yet. You can stick all the static prompt information that's nice to have out on the right hand, it'll tell you about non-zero exit statuses, it'll ask whether it should correct typos, it'll protect you from rm * if you want it to.

    For X: unclutter hides the mouse curser after "$1" seconds. autocutsel fixes the clipboard if you run two instances (on for CLIPBOARD, one for PRIMARY). xbindkeys lets you have the controls of your music play always available (I use mpd).

  59. Re:Listing directory contents without the ls comma by multipartmixed · · Score: 1

    That's a great trick for when you're really, really close to exhausting VM and can't spawn any real programs (like ps) but can still issue the odd kill as programs fork and die:

    cd /proc
    echo *

    (copy high-numbered PIDs)

    kill (paste) ...and cross your fingers you didn't just nuke something really important. Obviously, not recommended outside the lab!

    --

    Do daemons dream of electric sleep()?
  60. Paste your code to /dev/tty for upload by ishmalius · · Score: 2
    This is definitely my favorite. If you have a small amount of text to upload, and only have a terminal, do this:

    cat /dev/tty > filename
    {paste your text}
    Ctrl-D

    Done!

    1. Re:Paste your code to /dev/tty for upload by Chris+Pimlott · · Score: 1

      Nice! Reminds me of the good old days of DOS...

      copy con filename

    2. Re:Paste your code to /dev/tty for upload by aniefer · · Score: 1

      You can do this on windows with "copy con filename" (Ctrl-Z & enter to stop). Good to know the linux version.

    3. Re:Paste your code to /dev/tty for upload by greed · · Score: 1

      It's extra fun in a script, because someone can do:

      yourscript >/dev/null

      But if yourscript does something like this:

      exec >/dev/tty

      it sends output back to the controlling TTY, and it appears on their screen anyway.

      (But yeah, normally stdin is /dev/tty and stdin is the default input if there's no arguments to cat.)

      Cat and here documents in a script are fun too:

      cat /dev/tty
      You thought you could suppress my output.
      But it is here on your console anyway!
      Muhahahahahaha!
      EOF

    4. Re:Paste your code to /dev/tty for upload by s4ltyd0g · · Score: 1

      or if your really nasty, hide #include "/dev/tty" somewhere in your buddy's source code.

    5. Re:Paste your code to /dev/tty for upload by ggvaidya · · Score: 1

      How is that different from "cat > filename"?

      Apart from looking like good ol' "copy con", of course :-)

  61. obligatory by savuporo · · Score: 1

    sl -l

    --
    http://validator.w3.org/check?uri=http%3A%2F%2Fwww.slashdot.org Errors found while checking this document as HTML5!
    1. Re:obligatory by Shikaku · · Score: 1

      I just almost got fired from work from the laughter, thanks and no thanks!

    2. Re:obligatory by savuporo · · Score: 1

      sorry i forgot to qualify that with "for late friday afternoons only" or "early 5 o clock hackoramas"

      --
      http://validator.w3.org/check?uri=http%3A%2F%2Fwww.slashdot.org Errors found while checking this document as HTML5!
  62. alias="fc -e -" by nsupathy · · Score: 1

    alias='fc -e -'
    r v

    --
    #include std_disclaimer.h
  63. script (and scriptreplay) by kenholm3 · · Score: 2, Interesting

    Whenever I want to know _what_ I did, I'll fire up script and capture my keystrokes.

    If your system has it, you can "watch" yourself with scriptreplay

    EXAMPLE
    % script -t 2> timingfile
    Script started, file is typescript
    % ls
    <etc, etc>
    % exit
    Script done, file is typescript
    % scriptreplay timingfile

    --
    God is good all the time! -K
  64. Re:Listing directory contents without the ls comma by Chris+Pimlott · · Score: 2, Informative

    This is an important difference between unix shells and dos/windows shell. In Unix, the wildcards like "*" are handled by the shell and expanded before the program ever sees the arguments. In DOS/Windows, the expansion must be done by the program itself. This is why every program in unix understand wildcards, while only some do in the MS world.

  65. The Converse by mjcecil · · Score: 1

    Of course, there is also the reverse effect. Things that, as an ancient admin, you still do even though you don't have to... Evolution of the operating environment for easier living, through command enhancements or totally new utilities often goes ignored.

    For instance, I find myself typing "df -k" and shifting off the decimal places in my head rather than just using the now-available "df -g". Just out of a long standing habit.

    I also almost always either work in 80x25 windows, or 132x50 windows out of habit from the old days, and still get nervous when I resize.

    Back in 1994, when I got my first AIX machine for administration, it took me nearly half a year to stop editing configuration files directly. For certain things which I know are safe, I still do direct-edits.

    Mark

    --
    Mark J. Cecil -- Senior UNIX Engineer
    New Orleans, Louisiana
    http://notrealswift.blogspot.com
    1. Re:The Converse by morgan_greywolf · · Score: 1

      Back in 1994, when I got my first AIX machine for administration, it took me nearly half a year to stop editing configuration files directly. For certain things which I know are safe, I still do direct-edits.

      Bleh. smit is pants.

  66. Not having to run by Cornwallis · · Score: 1

    antivirus software.

  67. Re:Dupe your TTY output to someone else using scri by multipartmixed · · Score: 1

    Hey, that's a good one! Thanks!

    --

    Do daemons dream of electric sleep()?
  68. You use 'write'? by raner · · Score: 1

    Man, 'write' is for beginners. I rather find out the person's terminal device and then cat directly to that device; something along the lines of cat >/dev/`who|grep ^username|head -1|awk '{print $2}'` ;-)

  69. short list of shell tips by James+Youngman · · Score: 4, Informative

    Assuming you already know the simple stuff like how to use shell quotes correctly, what you can do with ps and top, ...

    1. Using awk '$3 ~ /foo/ { bar }' to grep just one column of a file
    2. reset
    3. find . -blah -exec quux \+
    4. Adding : to the front of complex commands you just typed but realise you don't want to execute yet so that they get into your shell history
    5. Meta-T in Bash for swapping arguments
    6. find . -printf X | wc -c for counting files (since find |wc -l would miscount files with newlines in the name)
    7. set, shift and implicit shell loops (for without in)
    8. "${foo:-bar}" and similar
    9. "${x%%.ext}.newext"
    10. comm -3 <(sort long) <(sort short)
    11. unalias rm
    1. Re:short list of shell tips by EricWright · · Score: 1

      I still love the %%pattern and ##pattern constructs and use them frequently!

    2. Re:short list of shell tips by ze_jua · · Score: 1

      "> Adding : to the front of complex commands you just typed but realise you don't want to execute yet so that they get into your shell history"

      Why ":" , and not "#" ??? It avoid the error, and its safer (if you have ; in your command line, it will run, even with : at the begining of the line).

    3. Re:short list of shell tips by illumin8 · · Score: 1

      (since find |wc -l would miscount files with newlines in the name)

      I gotta ask... How many files do you have with newlines in the name? And what kind of masochist puts newlines in a filename in the first place? ;-)

      --
      "When the president does it, that means it's not illegal." - Richard M. Nixon
    4. Re:short list of shell tips by pavon · · Score: 1

      Adding : to the front of complex commands you just typed but realise you don't want to execute yet so that they get into your shell history

      Thanks, I hadn't thought of that.

    5. Re:short list of shell tips by Just+Some+Guy · · Score: 1

      2. reset

      Don't forget about its extremely useful cousin: echo ^V^O (control-V control-O). The ^V says "insert the next key without processing it, so you're writing a command to echo a single ^O. This resets the terminal sometimes when even the reset command can't fix it.

      --
      Dewey, what part of this looks like authorities should be involved?
    6. Re:short list of shell tips by hackstraw · · Score: 1

      12. unalias cp and mv and whatever else your vendor is trying to protect you from.

      13. same for not allowing > to an existing file

      14. ^L is your friend, especially in vi (maybe other editors as well).

      15. for and while loops on the command line

      16. Convince Solaris to get into the 21st century.

    7. Re:short list of shell tips by flex941 · · Score: 1

      4. isn't prefixing with # more 'do nothing' than : ?

    8. Re:short list of shell tips by RichiH · · Score: 1

      > 4. Adding : to the front of complex commands you just typed but realise you don't want to execute yet so that they get into your shell history

      Fire up zsh, do

          bindkey '^Q' push-line

      type some stuff, press CTRL-Q, type other stuff & press enter.

      It's pushd/popd, just for commands.

    9. Re:short list of shell tips by pbhj · · Score: 1

      Any chance you could clue is in on what they all do ...?

      Why does one need to unalias rm? Can't you just use \rm ?

    10. Re:short list of shell tips by renoX · · Score: 1

      grep . *
      grep . file1 file2..
      When you want to read a series of files with the name of the file prefixed before the lines.

    11. Re:short list of shell tips by James+Youngman · · Score: 1

      I had thought that tab-completion for filenames does not occur after #, but as things turn out I'm wrong. No idea if that is a recent change to Bash or not, though.

    12. Re:short list of shell tips by James+Youngman · · Score: 1

      (since find |wc -l would miscount files with newlines in the name)

      I gotta ask... How many files do you have with newlines in the name? And what kind of masochist puts newlines in a filename in the first place? ;-)

      Just one filename containing a newline is enough to make the simpler command give the wrong answer. And I've never heard of a Unix system where a single person (other than Ken Thompson, maybe) chose the name of every file on the system.

      I try to make as few assumptions as possible in the programs I write, because if I do make an assumption I can be sure that it's likely to eventually bite me.

    13. Re:short list of shell tips by James+Youngman · · Score: 1

      It's less time-consuming for me and more educational for you if you go figure it out by reading the manual :)

    14. Re:short list of shell tips by James+Youngman · · Score: 1

      That drops blank lines. You probably meant

      grep '' .*

      I haven't tested it, but it is possible that this is a more efficient way of doing that:

      awk '{print FILENAME, $0;}' list-of-file-names

  70. back-i-search (zsh) reverse-i-search (bash) by Anonymous Coward · · Score: 1, Interesting

    This is usually one people don't know about. Try Ctrl+R in (at least) bash or zsh and type something. Ctrl-R again to browse. You're welcome.

  71. Super disk compression with dd !!! by elysium-os · · Score: 1

    # dd if=/dev/zero of=huge bs=1024 count=1 seek=4194304
    # ls -la huge
    -rw-r--r-- 1 root root 4294968320 2008-11-05 21:43 huge
    # df -h .
    Filesystem Size Used Avail Use% Mounted on
    /dev/md5 122M 5.6M 110M 5% /var/mail

    There it took me only 5.6M to store 4.294.968.320 bytes!

    Doublespace that!

  72. dmidecode by jvillain · · Score: 3, Informative

    Need to know the serial number of a server or bios version or many other things dmidecode is your friend.

    1. Re:dmidecode by Bandman · · Score: 1

      Good lord yes. dmidecode is a godsend

  73. Apropos by reedk · · Score: 1

    Great for my absent-minded moments, apropos keyword will get me to my wanted command quickly every time.

    1. Re:Apropos by SCHecklerX · · Score: 1

      I can never remember apropos, so just use 'man -k'

  74. Watch! by comm2k · · Score: 1

    The watch command! Run a command every n seconds and output the result.
    watch -n0 'date' #fake clock watch -n0 'du -h' #watch disk usage changes without having to constantly enter 'du -h'

    1. Re:Watch! by Bandman · · Score: 1

      Sometimes I need a stopwatch

      $ time read

  75. VNC through a gateway (secure remote desktop) by cain · · Score: 1

    I keep a VNC server desktop on running on machines. Tunneling the VNC client through a gateway machine via ssh means I can connect to any desktop on any machine from anywhere.

    machine 1:
    > vncserver :1

    machine 2:
    > ssh myuid@gateway -L5901:machine1:5901
    > vncviewer :1

    Et voila - a remote desktop on machine 1 from machine 2 via a gateway machine. Note you have to add the desktop number given to vncserver (in this case 1) to 5900 in the ssh command, this is because vncviewer start counting ports at 5900.

    1. Re:VNC through a gateway (secure remote desktop) by Randle_Revar · · Score: 1

      Why use VNC when you can use ssh -X or NX?

    2. Re:VNC through a gateway (secure remote desktop) by cain · · Score: 1

      Why use VNC when you can use ssh -X or NX?

      You get the entire desktop and it lives until you reboot the machine. I can have a desktop on a server at work and access it from my desk, at home, at a friend's house, on my iPhone on the bus, etc. It is always there, just like I left it. ssh -X only lasts as long as the ssh connection between the two machines. If I'm not at the machine that's running the ssh -X, it does me no good. If I run it inside VNC, I can get to it from anywhere. NX is too intrusive and complex; vncserver and vncclient run on everything, are simple, and are rock solid.

    3. Re:VNC through a gateway (secure remote desktop) by Randle_Revar · · Score: 1

      I guess if you like the desktop a lot...
      personally I like screen for persistence, and I felt that vnc was more involved to setup vs NX.

  76. Share mouse and keyboard by pieleric · · Score: 5, Informative

    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. It looks like the two computers got united. In a flash, newbies get a new idea of what means unix and X ;-)

    1. Re:Share mouse and keyboard by dbrossard · · Score: 1

      Wow cool. Thats a new one on me. I am going to have to look it up.

    2. Re:Share mouse and keyboard by Bandman · · Score: 1

      That sounds very cool.

      I use synergy to do that across platforms, but if I'm ever using two X terminals, I'll have to try that. Thanks a lot!

    3. Re:Share mouse and keyboard by cortana · · Score: 1

      I do hope you remember to follow that up with an xhost -mylaptopname afterwards.

      Really, you shouldn't do this at all, since authentication based on hostname lookups is insecure.

    4. Re:Share mouse and keyboard by Khopesh · · Score: 1

      Don't most X11 implementations block remote access these days? IIRC, even with a disabled firewall, any GDM-driven X11 session will not be listening (for non-localhost) on TCP port 6000 (display :0 ).

      I imagine you could do it trivially with X11 forwarding via SSH; use xhost +localhost on the desktop and then on the laptop, run ssh -L6100:localhost:6000 thecomputername in one terminal and x2x localhost:100 -west in another.

      --
      Use my userscript to add story images to Slashdot. There's no going back.
    5. Re:Share mouse and keyboard by knothead99 · · Score: 2, Insightful

      Why not use synergy? It works cross platform so you can control Windows and Mac OS machines as well.

    6. Re:Share mouse and keyboard by drago · · Score: 2, Informative

      Or even more wonderful if you need a more permanent setup of this: synergy. It gives you basically the same functionality x2x does, but it also works on Windows and Mac (and also mixed environments of Linux, Windows and Mac of course). Couldn't live without it.

    7. Re:Share mouse and keyboard by sseremeth · · Score: 1

      People are always dumbfounded (as they should be - great software) by Synergy2 along these lines.

    8. Re:Share mouse and keyboard by SCHecklerX · · Score: 1

      One thing I had a problem with in synergy is VNC sessions. My laptop is linux, but runs vmware for windows. When at home, I like to use synergy to go across both, but the vmware instance no workee.

    9. Re:Share mouse and keyboard by SCHecklerX · · Score: 1

      oops. s/vnc/vmware/

    10. Re:Share mouse and keyboard by ElizabethGreene · · Score: 1

      I concur. Synergy is great software. We replaced 17 flaky 2 port km switches in our video department with free software. Woot, go open source.

  77. Re:Listing directory contents without the ls comma by eln · · Score: 1

    The comment shows a tragic misunderstanding of how echo and shell expansion really work, but it does provide a nifty little tip if your system is so hosed up it has no "ls" command. I know that I've been in situations where ls was not there or was compromised (due to a rootkit), and "echo *" just never occurred to me as a workaround.

  78. directory stack by Komi · · Score: 3, Informative
    Directory stack commands, pushd and popd, are quite handy. I alias them to pd and po. Then pd works just like cd, except it remembers where you've been.

    The advantage of the directory stack over "cd -" is that the directory stack always remembers where you last were. "cd -" only remembers until you change directories again.

    In tcsh (I don't know other shells), you can do directory stack substitution. =0 is current directory, =1 is one up, =2 is two up, and so on.

    I also use bindkeys to bind Control-G to 'dirs -v' so I can look at the directory stack with ease, even in the middle of a command.

    Personally, I think directory stack commands are the least-known, but most useful feature in tcsh.

    --
    The ultimate goal of science is to unify all forces of nature to a single law that can be silk-screened onto a T-shirt.
    1. Re:directory stack by Chris+Pimlott · · Score: 4, Informative

      In tcsh (I don't know other shells), you can do directory stack substitution. =0 is current directory, =1 is one up, =2 is two up, and so on.

      In bash, it's ~0, ~1, ~2, etc.

    2. Re:directory stack by Komi · · Score: 1

      That's really helpful to know! :) I help people that use bash and I hate not having this feature.

      --
      The ultimate goal of science is to unify all forces of nature to a single law that can be silk-screened onto a T-shirt.
    3. Re:directory stack by Ysangkok · · Score: 1

      doesn't work in cygwin for me:


      Administrator@gigabob ~/winhome/Local Settings/Temp
      $ echo ~0 /home/Administrator/winhome/Local Settings/Temp

      Administrator@gigabob ~/winhome/Local Settings/Temp
      $ echo ~1
      ~1

      Administrator@gigabob ~/winhome/Local Settings/Temp
      $ echo ~2
      ~2

      Administrator@gigabob ~/winhome/Local Settings/Temp
      $ echo ~3
      ~3

      Administrator@gigabob ~/winhome/Local Settings/Temp
      $

  79. Re:Surprised that who does it correctly? by ohnobinki · · Score: 1

    On Windows, if you repeatedly hit tab, it cycles though the completions. It's still not as nice as bash automatically running more when you hit tab before writing anything.

  80. sudo !! by n.e.watson · · Score: 3, Informative

    !! in bash uses the last command you entered. $ make_me_a_sandwich What? No. $ sudo !! okay. $

    1. Re:sudo !! by jweller · · Score: 1

      ohhh thats a good one.

      I couldn't live without rsync for keeping the backup server current.

    2. Re:Sudo !! by Bandman · · Score: 1

      I knew about sudo, and I knew about !!, but for some reason, I didn't think about putting the two together. nice!

    3. Re:sudo !! by aerthling · · Score: 1

      !?<term> executes the first matching statement in bash history

      user@host:~$ !?Album
      xmms2 radd /mnt/usb/Music/Artist/Album/

    4. Re:sudo !! by Randle_Revar · · Score: 1

      personally, I use an alias like this:
      alias xkcd="sudo make_me_a_sandwich"

    5. Re:sudo !! by mollymoo · · Score: 1

      I like that. Nicer than the way I've been doing it:

      $ history | grep Album
      377 xmms2 radd /mnt/usb/Music/Artist/Album/
      $ !377

      At least it's nicer if you're sure you'll get the right match first time.

      --
      Chernobyl 'not a wildlife haven' - BBC News
  81. Finding where your disk space went. by thisissilly · · Score: 3, Informative

    ls -l | sort -n +4 -- sorts files in size order, good for finding big files in a directory
    du -s * | sort -n -- similar to above, find the biggest files & subdirectories of the current dir
    du | xdu -- only when you're in X, obviously. Better grain than above, with the ability to drill down into subdirectories

    1. Re:Finding where your disk space went. by aberkvam · · Score: 1

      ls -l | sort -n +4 -- sorts files in size order, good for finding big files in a directory

      Why not ls -lSr ?

    2. Re:Finding where your disk space went. by thisissilly · · Score: 1

      Because that's a GNUism I didn't know! Thanks, filed away for future use.

    3. Re:Finding where your disk space went. by BubbaDoom · · Score: 1

      ls -l | sort -n +4

      or you could just use
      ls -lS

      useful for Bash commands also ...
      ctrl+a (beginning of line)
      ctrl+e (end of line)
      ctrl+k (cut line to memory)
      ctrl+y (paste line from memory)

    4. Re:Finding where your disk space went. by Bandman · · Score: 1

      ls -alSrh

      lists All, Long listing, sort by Size, reverse, with Human filesize listings

      du -sh *

      is what I use most often. If I need to sort, I do change the -h to -m or -G and pipe it to sort -g

    5. Re:Finding where your disk space went. by jeremyp · · Score: 1

      ls -l | sort -n +4 -- sorts files in size order, good for finding big files in a directory

      ls -lrS

      Also for finding recently modified files

      ls -lrt

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    6. Re:Finding where your disk space went. by flex941 · · Score: 1

      ls -l | sort -n +4 -- sorts files in size order, good for finding big files in a directory

      ls -lS ?

    7. Re:Finding where your disk space went. by AnteTempore · · Score: 1

      Shorter and better:

      du | sort -n

      This will show if one of the subsubsub dirs is taking all your disk space.

  82. Re:Dupe your TTY output to someone else using scri by snspdaarf · · Score: 1

    Yeah. That's why the first line in my .profile, .login, or .setup was always "mesg n". It stopped "force" as well.

    --
    Why, without your clothes, you're naked, Miss Dudley!
  83. My 2 cents by chrysrobyn · · Score: 1

    Along with "write", "wall" is useful. Additionally, "xterm -ut" can be useful for unmonitored windows as it doesn't modify the utmp. It's great when you want a persistent process, like "tail -f", not to get overwritten by some admin with "write". Or, as a user, if you are on a machine you shouldn't be on in interactive mode (only batch), then you can keep your interactive shell and not show up on "who".

    1. Re:My 2 cents by vrmlguy · · Score: 1

      xterm with the "unreadable" font is great for keeping an eye on processes. I've used monitoring programs that displayed histograms using curses, which worked well in an unreadable xterm. These days, you can use "xterm -ai" to request active icons, which work similarly.

      --
      Nothing for 6-digit uids?
  84. A real time saver! by Mish · · Score: 2, Funny

    ls -d /dev/* | egrep -e '^/dev/[h|s]d[a-z]$' | xargs -l1 -r shred -vfz -n 100

    Summary: Reorganizes* the data on your disks for maximum read performance.

    * Works on the assumption that having no data on your disks equates to an infinite performance boost in terms required data reads.

    1. Re:A real time saver! by Mish · · Score: 4, Informative

      DISCLAIMER: Don't run this!
      I didn't think I needed to say this, but I just showed someone this and they thought it was a legitemately helpful command...

    2. Re:A real time saver! by martinw89 · · Score: 1

      How do you get a troll moderation for putting a legitimate disclaimer to your own post?

  85. Re:Anonymous Coward by Anthony_Cargile · · Score: 1

    lol, now thats funny.

  86. My favourite on-liner so far: by Anonymous Coward · · Score: 1, Informative

    Reverse a bash-Array:
    j=0; for i in ${array[*]}; do newind="$(( ${#array[*]} - ($j+1)))"; echo j=$j newind=$newind; newarr[$newind]=$i; let j++; done

  87. This is a good one: by Anonymous Coward · · Score: 1, Funny

    $ man woman

    1. Re:This is a good one: by danieltdp · · Score: 1

      Tried and got "No manual entry for woman". Is there some rpm I can get with some of those?

      --
      -- dnl
  88. "cd -" by dpuu · · Score: 1

    I find many people don't know that "cd -" goes to a previous directory: great for toggling between two directories, and lighter weight than pushd/popd.

    --
    Opinions my own, statements of fact may contain errors
  89. bash -x style tracing for perl, python by lindi · · Score: 1

    "bash -x foo.sh" produces nice execution trace of a shell script. To debug perl and python I thus have wrapper scripts "perl-x":

    PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" exec perl -dS $@

    and "python-x":

    for i in /usr/lib/python*; do if [ -e $i/trace.py ]; then python $i/trace.py --trace --ignore-dir $i "$@" exit 0; fi; done

    While these usually produce a lot of output it is usually easier to grep them than to start adding debug prints to the scripts (which may even be in read-only /usr).

    1. Re:bash -x style tracing for perl, python by Bandman · · Score: 1

      I've used "strace" more and more frequently since I found out about it.

  90. I can't believe nobody has started the flamewar.. by fubar1971 · · Score: 1

    VI rulez!!!!

  91. copying symlinks by davek · · Score: 1

    Here's one I leard on day 2 in Computer Science House at RIT:
    cd /path/to/copy/from
    tar cf - . | (cd /path/to/copy/to ; tar xvf -)

    I somehow always end up using a derivative of that whenever I'm shoveling around massive amounts of user data. Especially if its from network to network, and the filenames might contain evil characters like (') and (:).

    cut, sort and uniq are also impossible to live without:
    # hits per ip address from apache log
    cut -d" " -f 1 access_log | sort | uniq -d | sort -n

    man the base unix commands line cut, sed, and awk, tr, and even join.

    And find(1) will save your life.
    # find all files containing string "foobar" (recursive)
    find . -type f -exec grep -h "foobar" {} \;

    (I know "grep -r" does the same thing, but I'm illustrating find, not grep.)

    enjoy.

    --
    6th Street Radio @ddombrowsky
    1. Re:copying symlinks by Bandman · · Score: 1

      It probably won't help much, since you're used to your syntax (aren't we all?) but if I really really need to cut with a space delimiter, I use \ (that's a \ then two spaces)

      Of course, for normal run-of-the-mill things, awk can't be beat for column selection

      ls -al | awk '{print $3}'
      to print usernames

  92. Mod mjcecil up, he corrects my error by qwertyatwork · · Score: 1

    Glad you caught that.

  93. Re:ftp from a command line by Drinking+Bleach · · Score: 1

    Holy crap, there's GUI FTP clients?

  94. dd is great by Wesley+Felter · · Score: 1

    You joke, but I've used dd for all sorts of tasks: backups, disk cloning/expansion (with gparted), disk benchmarking, etc. Just be sure to set bs=1M for good performance.

  95. Re:This one always surprises people for some reaso by Sir_Lewk · · Score: 1

    You need to learn of the wondrous "locate" my friend.

    --
    "linux is just DOS with a UNIX like syntax" -- Galactic Dominator (944134)
  96. less by Paralizer · · Score: 1

    Whenever I look over the shoulders of other Unix users I see them piping output to more. less lets you scroll backwards.

    1. Re:less by Lord+Ender · · Score: 1

      nano is the new pico, links is the new lynx, ssh is the new telnet, less is the new more, egrep is the new grep, sshfs is the new NFS, and ruby is the new perl. If you work with guys who still do things the old way, you're in a dinosaur park. Be careful not to go extinct with them.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    2. Re:less by wilhelm · · Score: 1

      nano is the new pico

      Uh, why would any self-respecting admin use either one, for any reason? Can we just get back to our vi vs. emacs flamewars now?

      Ob-fun-trick: in bash, !$ is the last arg from the previous command.

      # mkdir reallyreallyreallylongdirname
      # cd !$
      cd reallyreallyreallylongdirname
      # pwd
      /reallyreallyreallylongdirname

      Similarly, !^ is the first arg, and !* is all the args. ^word^otherword does a straight text substitution of "otherword" for the first instance of "word" on the previous command. Anything to save typing is Good.

    3. Re:less by alta · · Score: 1

      I remeber the first day I got $ pico -bash: pico: command not found I had to use vi... I quickly learned that pine was no longer installed by default, and started installing that. After a while, I discovered that nano did what pico did (although it's stupid that the number pad doesn't work) so I aliased pico to nano... I've finally gotten used to it, although that linewrap thing bites me in the ass every now and then.

      --
      Do not meddle in the affairs of sysadmins, for they are subtle, and quick to anger.
    4. Re:less by duckInferno · · Score: 1

      So... more is less than less, and less is more than more, more or less?

      --
      Fool me once, shame on you. Fool me twice, watch it -- I'm huge!
    5. Re:less by d0cu · · Score: 1

      Yes, but less is a lot slower. E.g try: "gzcat *log.gz | less" and scroll (using /) to right place. Less is a good tool, but often I still have to use more.

    6. Re:less by mollymoo · · Score: 1

      I aliased pico to nano... I've finally gotten used to it, although that linewrap thing bites me in the ass every now and then.


      $ nano --nowrap

      or perhaps

      $ nano --fill 80

      if you want it to wrap at a fixed width instead of the crazy 8 columns from the edge default (equivalent to "--fill -8").

      It's a simple editor, but you can bend it to your will a little.

      $ man nano
      $ man nanorc
      $ nano --nowrap ~/.nanorc

      --
      Chernobyl 'not a wildlife haven' - BBC News
  97. Slashdot (or rather dotslash) by lobiusmoop · · Score: 1

    as a sysadmin, I found the easiest way to remove accidentally created files with a '-' in the same was to prefix the filename with './' as in:
    rm ./-helloworld

    I'm not sure there's even another way to do it.

    --
    "I bless every day that I continue to live, for every day is pure profit."
    1. Re:Slashdot (or rather dotslash) by michaelwv · · Score: 1
      rm -- -helloworld

      '--' terminates option processing for most well-behaved utilities.

    2. Re:Slashdot (or rather dotslash) by Chris+Pimlott · · Score: 1

      as a sysadmin, I found the easiest way to remove accidentally created files with a '-' in the same was to prefix the filename with './' as in:
      rm ./-helloworld

      I'm not sure there's even another way to do it.

      rm -- -helloworld

      "--" is a special option supported by many programs to indicate that all following parameters should not be considered options.

    3. Re:Slashdot (or rather dotslash) by soleblaze · · Score: 1

      rm -- -helloworld ; The -- tells the command to count everything past that as a filename and not an option/switch

    4. Re:Slashdot (or rather dotslash) by Bandman · · Score: 1

      try using --
      msimmons@newcastle:~/test$ touch test
      msimmons@newcastle:~/test$ mv test "-"
      msimmons@newcastle:~/test$ ls
      -
      msimmons@newcastle:~/test$ rm -- -
      msimmons@newcastle:~/test$ ls
      msimmons@newcastle:~/test$

    5. Re:Slashdot (or rather dotslash) by sydneyfong · · Score: 1

      My favorite solution:

      perl -e "unlink('FILE');"

      Not exactly cross platform, but on most modern Unices it does the job :)

      --
      Don't quote me on this.
    6. Re:Slashdot (or rather dotslash) by CarAnalogy · · Score: 1

      What about 'rm -- -helloworld' ?

    7. Re:Slashdot (or rather dotslash) by thogard · · Score: 1

      On old unix versions before -- support
      rm foo -helloworld
      would work fine.
      Or even rm -i * if there were just too many odd characters in the name for the globing to work.
      Of course mkdir x;mv * x;cd x;mv [a-z]* ..;rm -i *
      might be a better option in that case.

    8. Re:Slashdot (or rather dotslash) by ukbazza · · Score: 1

      rm -- -helloworld works too, and not just for the rm command.

    9. Re:Slashdot (or rather dotslash) by GutSh0t · · Score: 1

      rm -- -helloworld

      the -- tells rm you're done giving flags and any - after that is just treated as part of the filename.

      --
      I started with nothing and have most of it left.
  98. dumbass by ascari · · Score: 1

    > he had to call me on the phone) and had never even known you could do that. Wow. The other admin had never even known you could use the phone? What a dumbass. sorry for being pedantic.

  99. BSD mail by Undead+NDR · · Score: 1

    I still use the old 'mail' command, especially to read local email from daemons.

  100. Re:Listing directory contents without the ls comma by penguin+king · · Score: 1

    Although it won't totally work when your systems falling down around your ears, running out of memory etc... I have been in situations where I've seen people with an app hemorrhaging memory like nothing else watching it in top, then they close top, and kill the process. Sure I did this for a while before I played round with top, and found you can do all within top.

    Also I find if you're stuck with an X app dying and it's taking horrendously long for ps or whatever to crank up, xkill can be useful, assuming you've got a terminal open right?

  101. Sudo !! by xzanthar · · Score: 1

    sudo !!

    For doing things you don't have permission to do

    --
    I encrypt all my files with Double XOR Encryption!
  102. Re:How about a new GUI apt get trick? by techess · · Score: 1

    I prefer yum. One of the things I find that people don't know about is: yum provides x Sometimes I'll be compiling a piece of software and it will complain that I don't have a certain library or a certain command. Use the yum provides to find out what package will install what you need and then use yum install packagename. Ding! All done.

    --
    Don't anthropomorphize computers. They *hate* that.
  103. My list by Sun.Jedi · · Score: 1

    Handy find|cpio to see filenames copied

    # find . | cpio -pdmvu /some/path/

    How to find sendmail version from command line
    # /usr/lib/sendmail -v -d0.1 /dev/null

    Undocumented Solaris 10 jumpstart trick if your custom finish scripts bomb out, and you want to restart without reboot:

    # rm /tmp/.jumpstart
    # install-solaris

    On Solaris 9 and earlier
    # rm /tmp/.jumpstart
    # suninstall

    Linux memhogs:
    # ps -A --no-headers --format fname,rss --sort=-rss | head -3 | sed -r 's/\s+/-/g' | column | sed -r 's/\s+/, /g'

    Map a process to a port(s)
    # pfiles $PID | grep -i sockname

  104. so many "tricks"... by dextromulous · · Score: 1

    X WINDOWS:
    ----------
    alt + left-click and drag any window to move it... you don't have to use the top of the window! This gets me all the time in Windows.
    alt + middle-click any window to send it to the background
    alt + right-click and drag any window to resize it

    copy text simply by highlighting it, paste simply by middle clicking

    setting up the window manager to use multiple workspaces and scrolling on the desktop to switch between them

    starting a second X session as another user with "X :1" and switching between them with ctrl+alt+f9 and ctrl+alt+f10 (or just use a login manager that handles this for you)

    FROM THE COMMAND LINE:
    ----------------------
    Using xargs to add .jpg to a bunch of files that have spaces in their names (using the interactive mode of xargs.)
    # find . -print0 | xargs -p -0 -IX mv X X.jpg

    rot13 "decryption"
    # cat filename | tr 'a-zA-Z' 'n-za-mN-ZA-M' | less

    follow a log file in realtime, even when it gets rotated:
    # tail -f /var/log/messages --follow=name --retry

    creating a VPN (not just port forwarding) with SSH... a bit too big to put here

    Rotating (losslessly) JPEG images based on the EXIF tags
    # jhead -autorot *.jpg

    Run a command from an empty environment
    # env -i command

    Look up an IP via a specific DNS server:
    # dig @server ip
    Look up the host name for an IP:
    # dig -x ip

    Grabbing multiple files from a website and saving them:
    # curl http://cisx1.uma.maine.edu/~wbackman/bsdtalk/bsdtalk%5B150-152%5D.mp3 -o "bsdtalk#1.mp3"

    That was just a sample from my notes... which brings me to another topic, keeping notes when you learn a new command. The man pages are great, and you should learn to read them, but when you combine multiple commands to accomplish a task, or there is tricky syntax, a notebook (digital or physical) is an excellent thing to have.

    Learning a scripting language helps too. Bash, perl, python, and many others are options. I use scripts to do some very simple things, but they still save me a lot of time. For example: Download new pictures from my camera, and auto-rotate them. Set up passwordless SSH on any machine that I have an account and password to. Parse the (monster and item list) data files from an open source game and update the game's wiki (including logging in, changing text, and uploading images if required.)

    --
    There are two types of people in the world: those who divide people into two types and those who don't.
    1. Re:so many "tricks"... by Lord+Ender · · Score: 1

      Grabbing multiple files from a website and saving them:
      # curl http://cisx1.uma.maine.edu/~wbackman/bsdtalk/bsdtalk%5B150-152%5D.mp3 [maine.edu] -o "bsdtalk#1.mp3"

      I bet you had to think for a while to come up with a non-porn application of this trick.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
  105. Simple fix... by Arimus · · Score: 1

    alias emacs = "vim"

    --
    --- Users are like bacteria -> Each one causing a thousand tiny crises until the host finally gives up and dies.
  106. A nice tip from the OSX world by Chris+Pimlott · · Score: 3, Informative

    My previous place of employment was a Mac shop, where I discovered the wonderful pbcopy and pbpaste commands. Why they aren't a standard part of every X windows distribution, I'll never know, but they are damned handy.

    What they do is allow you to read and write from the cut-and-paste buffer from the command line. "pbpaste" will print the currently copied text to stdout, while "pbcopy" will replace the buffer with stdin.

    Fortunately, there are some third-party X equivalents for this, such as xsel or xclip, which can be adapted to work in the same way.

    Rougly equivalent:

    pbcopy
    xsel -i --clipboard
    xclip -in -selection clipboard

    pbpaste
    xsel -o --clipboard
    xclip -o -selection clipboard

    1. Re:A nice tip from the OSX world by hackstraw · · Score: 1

      Another OS X goodie is open.

      Similar in windows with start (but its been so long that I used windows, don't remember the details).

      open .

      Opens a finder window in your current directory.

      open -a vlc movie.mpg

      open the movie.mpg with the application vlc.

      etc.

      Nice mix between the command line and the GUI.

      Also, you can drag and drop things from the finder into the terminal window, and they will even escape things like spaces for you.

      OS X is such a nice UNIX implementation. Who would of thunk that?

    2. Re:A nice tip from the OSX world by anothy · · Score: 1

      yes, OS X's pbcopy and pbpaste are very nice. even better, though, is Plan 9's approach: /dev/snarf. it's just a file; read and write it with anything you like.

      --

      i speak for myself and those who like what i say.
    3. Re:A nice tip from the OSX world by xorsyst · · Score: 1

      unxutils contains win32 versions of these called pclip and gclip. Very very useful...

      --
      Get free bitcoins: http://freebitco.in
    4. Re:A nice tip from the OSX world by dargaud · · Score: 1

      In Cygwin under Windows you can use getclip / putclip. There's also wxcopy / wxpaste on some versions of Unix (IRIX comes to mind). Just don't try to use the commands cut and paste from a command line, they don't don what you think they do.

      --
      Non-Linux Penguins ?
    5. Re:A nice tip from the OSX world by mollymoo · · Score: 1

      OS X exposes wuite a lot of its funkiness to the shell. mdfind to access the Spotlight database is nice, you can search on all kinds of metadata, everything from filename to the F-stop of a photo, but the attributes aren't very friendly to remember. It's nicer to wrap frequently used ones in a function. Here's an approximation to locate using the Spotlight database (stick it in .bashrc, .profile or whatever):

      function mdlocate {
              if [ "$1" ]; then
                      mdfind "kMDItemFSName == '$1'"
              fi
      }

      That does an exact match search on the filename, if you'd prefer locate's default of a substring search, change it to:

                      mdfind "kMDItemFSName == '*$1*'"

      But then odd things might happen if you include globs in your search terms (which you can if you quote the string). That could be solved with more code of course, but I'm happy to use the first version and add globs if I want them.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    6. Re:A nice tip from the OSX world by Chris+Pimlott · · Score: 1

      Just don't try to use the commands cut and paste from a command line, they don't don what you think they do.

      They are a bit oddly name, at least in today's world, but they are pretty useful in their own rights.

    7. Re:A nice tip from the OSX world by Chris+Pimlott · · Score: 1

      Another OS X goodie is open.

      I've found (in Gnome) that "gnome-open" is roughly the same thing. I assume there's a similar command for KDE.

    8. Re:A nice tip from the OSX world by qzulla · · Score: 1

      Why not just use option key-c/option key-v?

      qz

  107. My personal fave by 44BSD · · Score: 4, Funny

    echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc

    1. Re:My personal fave by thtrgremlin · · Score: 1

      HA HA HA HA HA!!! Thanks

      --
      Want Big Business out of government? Take away the incentive and start by getting government out of big business!
    2. Re:My personal fave by fatphil · · Score: 1

      No!

      dc -e'[[dc -e]P39P91PP93P[dx]P39PAP]dx'

      --
      Also FatPhil on SoylentNews, id 863
  108. grep --color by krappie · · Score: 5, Informative

    grep --color

    For some reason, many people are greatly surprised when they figure out that grep will highlight matches for them.

    1. Re:grep --color by againjj · · Score: 1

      I am greatly surprised! I never knew that grep will highlight matches for me. That is awesome!

    2. Re:grep --color by starfishsystems · · Score: 3, Informative

      diff -y Compares files side by side.

      --
      Parity: What to do when the weekend comes.
    3. Re:grep --color by Austin+Schuh · · Score: 1

      I prefer vimdiff, since it will throw the differences up side by side and I can then edit them.

    4. Re:grep --color by Beezlebub33 · · Score: 1

      So does 'sdiff'

      --
      The more people I meet, the better I like my dog.
  109. Use the shell built-in commands by Burdell · · Score: 1

    When a system is hosed (I/O errors, fork bombed, etc.) or somebody deletes /bin, you can often still poke around (and sometimes work towards recovery) with Bourne shell built-in commands. For example, since the shell expands wildcards, "echo *" will give you a list of (non dot-) files in the current directory. The following shell function will implement cat without calling out:

    shcat()
    {
        xIFS="$IFS";
        IFS="";
        while [ "$1" != "" ]; do
            while read line; do
                echo "$line";
            done <$1;
            shift;
        done;
        IFS="$xIFS"
    }

    Add a counter (requires ksh or bash) and you can re-implement a simple "more" command.

    On systems with a text-based /proc (like Linux), you can combine the two to essentially do all the same things as "ps" (useful if something has run away and fork bombed the system).

  110. How come I haven't seen this yet by kovari · · Score: 1

    unzip && strip && touch && finger && mount && fsck && more && yes && umount && sleep

    1. Re:How come I haven't seen this yet by Muros · · Score: 1

      longer list.. play; nice; top; unzip; strip; tie; touch; finger; mount; fsck; more; yes; unmount; sleep; who; dump

  111. suid shell by davidwr · · Score: 1

    Well, that depends on the shell and the shell's privilage level.

    I don't know if any commonly-used shells do this [I hope not], but it's certainly possible to have the shell itself suid-root so it runs privilaged, then have it run suid-rooted scripts in privilaged mode.

    But why would anyone do that, other than as an example of how not to do things?

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    1. Re:suid shell by digitalhermit · · Score: 1

      Exactly. You can suid the shell itself, but suid'ing the script will do nothing.

      But why would anyone do that, other than as an example of how not to do things?

      I ask myself this every once in a while when I look at some user source directories. Usually the process is like this:

      1) New unix user learns that setting the suid bit lets the process run as the owner of the file.

      2) Whooohooo, they think. This solves the problem where I need to delete/update/whatever the files that are owned by another user.

      3) They chmod the file.

      4) ./deletelogs

      5) It's not working!!!

      6) Call Unix support. "Hey dude. Something is wrong with your system. I set the sticky bit on the script but it's not running as the correct user."

      I used to get this once a month.

    2. Re:suid shell by davidwr · · Score: 1

      Ah, I wasn't clear. I meant you could write your own shell, call it bdsh for Brain-Dead-Shell, which ran suid, and when it encountered a suid script, caused it to be executed suid.

      Again, why would anyone do this except as an example of what not to do?

      --
      Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  112. Is this it? by khasim · · Score: 1

    No? How about this?

    No? Maybe this?

    No? What about this?

    As opposed to:
    Here's everything that matches what you've typed so far.

    1. Re:Is this it? by Bandman · · Score: 1

      or "hey dumbass, there are 50,000 commands that start with 'x', do you really want me to list them all?"

  113. Other unix shell features that confound mcses: by sloanster · · Score: 1

    for loops
    here documents
    execution of string output from backtick delimited command
    command completion, hostname completion, command line editing

  114. find, dc, sed, dd pipes by dschuetz · · Score: 2, Informative

    The find command is definitely a good tool to be familiar with. Also, I've done a lot of really wacky stuff with sed in the past. (and sed experience can help you to work with ed and even ex, for those times the system has crashed so hard that's all you've got) (though I don't think I've had that happen since I left Ultrix).

    dc and bc are good things at times. Really, I do a whole lot of really complicated manipulation of data with the various utilities, sometimes all in one long pipeline and sometimes in multiple complicated stages. An example of that is where I'll often take a du output, use sed to convert G, K, and M to the proper amount of zeroes (or maybe there's a du option to do that automatically, I forget), awk out the 1st column and print each as "$1 +" with no returns, echo a "0" at the end, and pipe the whole thing through bc, to get a "grand total." (maybe that's a bad example, but the ([do something]; echo 0) | bc is definitely something I've done a lot over the years.

    I used to have aliases to call dc to do radix conversion (like echo "2 o 1337 p" | dc to get "10100111001"). (there's also a great .sig line out there that does some kind of crazy dc stack program to print out an ascii message, that I wasted a good chunk of time figuring out on paper to understand how it worked).

    Another great trick I've been using for 20 years is dd piped through ssh, to copy a local hard drive image over the net to another machine, or vice-versa (well, okay, 20 years ago it was rsh). (like boot off a live CD, "(ssh remote cat /my/image.dd) | dd of=/my/dev" to rebuild a local drive from a remote backup.

    There are lots of other things, way too many to write here. I'm sure there's a website out there somewhere.

    Oh, and another great one from the days when I'd get files with untypable characters in the filename -- "ls -i" to get a files inode, then "find . -inum [inode] -exec rm {} \;" to delete that (or mv {} newname to rename it). Not sure I need that much any longer, but at the time it was VERY useful.

    1. Re:find, dc, sed, dd pipes by Hatta · · Score: 1

      Another great trick I've been using for 20 years is dd piped through ssh, to copy a local hard drive image over the net to another machine, or vice-versa (well, okay, 20 years ago it was rsh). (like boot off a live CD, "(ssh remote cat /my/image.dd) | dd of=/my/dev" to rebuild a local drive from a remote backup.

      Is there a reason to use dd instead of cat in this case?

      --
      Give me Classic Slashdot or give me death!
    2. Re:find, dc, sed, dd pipes by dschuetz · · Score: 1

      [.....] (ssh remote cat /my/image.dd) | dd of=/my/dev" to rebuild a local drive from a remote backup.

      Is there a reason to use dd instead of cat in this case?

      Erm, hm. Not sure. One nice thing that dd can give you is the ability to process in specific blocksizes, which (if chosen well) can speed things up quite a bit, though that's probably less of an issue with today's hard drives than with drives of old (it used to be essential when dealing with magnetic tape). Also, you can send a signal (might be USR1, I forget) to the dd process and have it spit out a status message showing how many bytes it's processed so far (which can be nice, both to verify that it's actually working and when you're working with a big file).

  115. use command history effectively by elmartinos · · Score: 1

    a little bash trick everybody should know: Almost every time I type a command I press Ctrl+R before I type it. This way you can use search on typing on the command history. For it to be really usable you can set the history file size HISTFILESIZE to a large number.

    1. Re:use command history effectively by seaturnip · · Score: 2, Insightful

      From my .bashrc:

      # Reminder: C-R to search history, alt-. to have last argument of last command
      export HISTFILESIZE=1000000 # large total history limit
      export HISTSIZE=1000000 # large bash instance history limit
      export HISTCONTROL=ignoredups # ignore consecutive dups
      shopt -s histappend # merge together history of different bash instances
      PROMPT_COMMAND="history -a" # immediately save each command to history file

  116. Re:Listing directory contents without the ls comma by elgatozorbas · · Score: 4, Funny

    Maybe an ex-windows user who assumed "delete /bin" was the linux equivalent of "empty wastebasket" ?

  117. detach by RAMMS+EIN · · Score: 1

    detach. Start programs and then just forget about them while they keep running. You'll get your prompt back and the program will just keep running in the background, even when you exit the shell you started it from.

    --
    Please correct me if I got my facts wrong.
    1. Re:detach by evilviper · · Score: 1

      In what situations is 'detach' any better than nohup? The latter being included in every Unix system I've used in more than the past decade.

      --
      Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
    2. Re:detach by seaturnip · · Score: 1

      nohup can't take input and dumps stdout to a file, whereas dtach is more of a screen replacement without the complexity. It attaches the program to a virtual terminal, which you can leave and reattach to at will (including from many terminals at once).

    3. Re:detach by RAMMS+EIN · · Score: 1

      I'll let you decide which is better, but this is the difference:

      detach, as the name implies, detaches the command it runs from the shell and the terminal. There really won't be any association between them anymore. If you close the shell, your command won't receive a SIGHUP.

      nohup sets the signal mask for your command so that SIGHUP is ignored, and redirects output to nohup.out. Other than that, it is just a normal command run under the shell. It's listed in jobs. It will also receive SIGHUP when your shell closes.

      I'll be honest: I wrote detach because I hadn't discovered any of the alternatives that are listed on its webpage. But there's a reason I hadn't discovered them: they don't do the same thing detach does, and therefore didn't have the keywords I searched for listed with them.

      What detach does, really, is to make sure that some program is running, much like the daemons that you will typically find running on a *nix system. In fact, it uses the same mechanism that most if not all daemons use. That is exactly what it does. None of the alternatives I have found do exactly that.

      Of all the alternatives I have found, disown comes closest to doing the same thing as detach. Perhaps the end result is actually exactly the same (unlike with nohup); I don't know that for sure. But (1) disown is a builtin in some shells, not a command that can be used from all shells, like detach, and (2) you run disown _after_ starting the command...I, and various other users, find it more natural to type "detach command args" than to type "command args & disown", but that may be a matter of preference.

      Finally, I don't like nohup, because it goes and creates files with fixed names (in particular, nohup.out). So even in situations where I could use it, I would prefer detach.

      I hope that this clears things up a little. Also see the detach webpage. It lists some possible alternatives and explains how they differ from detach.

      Note that I am the author of detach, so of course all of this is fueled by a desire to not have my baby be a useless imitation of some already existing command. ;-) But seriously, I really feel detach does exactly what I want and the others don't. Having said that, the reason I listed the alternatives is so that people can use those if they fit their needs, without having to go through the hassle of downloading, compiling, and installing detach. It's not packaged for any distros I'm aware of (I used to provide Debian packages and OpenBSD ports, but I just don't have the time anymore).

      --
      Please correct me if I got my facts wrong.
  118. lsof by pak9rabid · · Score: 5, Informative

    lsof is a LIFE SAVER for trying to find what's still using something in a mounted resource when trying to unmount something. 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.

    1. Re:lsof by DRobson · · Score: 3, Informative

      Performed an upgrade (particularly applicable for Gentoo users)?

      lsof | grep DEL | grep lib

      Lists all libraries which have been deleted and who is using them. Handy for restarting selected applications after updates.

    2. Re:lsof by hackstraw · · Score: 1

      fuser is handy as well.

    3. Re:lsof by foobat · · Score: 1

      i like using fuser -m to identify what's using a mounted resource

      and fuser -u will tell you the user ids

      then fuser -k will kill all the processes using it

    4. Re:lsof by Spyder · · Score: 1

      Don't forget lsof does network ports too.

      lsof -i

      This lists the process, port and owner of all your current network sockets.

      --
      Spyder
    5. Re:lsof by empaler · · Score: 1

      Also useful if you're deleting stuff, Ã lalsof | grep

  119. Good old dummynet by kwolf22 · · Score: 1

    sudo ipfw pipe 1 config bw 100Kbit/s
    sudo ipfw add 1 pipe 1 src-port 80


    Keeps all of my co-workers & their shiny new Macs from hogging all of MY bandwidth... Muhahaaaa...

  120. Secure remote copy by Ewasx · · Score: 2, Informative

    When I want to copy entire directory trees to a remote system while preserving all file attributes:
    tar -czf - some_dir | ssh user@remote.host 'tar -C target_location -xzf -'

    This also works when you want to copy something to a system that doesn't support scp (embedded devices)

    1. Re:Secure remote copy by Chirs · · Score: 1

      couldn't you also use rsync?

      rsync -az -e ssh some_dir user@remote.host:/target_location

  121. some tcsh commands by Komi · · Score: 1
    A subject after my own heart. :) Here's some useful tcsh things I've learned over the years:

    alias myps 'ps auxww | grep $USER'
    alias awkill 'awk '\''{print $2}'\'' | xargs kill'

    Run "myps | grep firefox | awkill -9" to kill all firefox sessions.

    alias pd 'pushd'
    alias po 'popd'
    alias dirs 'dirs -v'

    Don't forget directory stack substitution (=1, =2, etc.)

    alias aw 'awk '\''{print $'\!:1'}'\'''

    Grab column 5 with "aw 5". (e.g. ls -l | aw 5)

    If you use the shell a lot, I recommend you get familiar with grep, awk, sed, find and xargs. Here's a quick example that I just had to use today. I got a bunch of Windows ascii files mixed with a bunch of other files. I wanted to run dos2unix on only the Windows ascii files. And the files were spread across several directories.

    find . -type f | xargs file | grep CRLF | aw 1 | sed 's/://' | xargs dos2unix

    My knowledge of tcsh is what's been keeping me from switching to bash. I like to use popular standards, but I don't know how to do this stuff in bash. I learned the tcsh stuff when I actually had time to read shell man pages. :)

    --
    The ultimate goal of science is to unify all forces of nature to a single law that can be silk-screened onto a T-shirt.
    1. Re:some tcsh commands by againjj · · Score: 1

      A subject after my own heart. :) Here's some useful tcsh things I've learned over the years:

      alias myps 'ps auxww | grep $USER'
      alias awkill 'awk '\''{print $2}'\'' | xargs kill'

      Run "myps | grep firefox | awkill -9" to kill all firefox sessions.

      Um, killall firefox?

    2. Re:some tcsh commands by thogard · · Score: 1

      killall will kill everything it can on some operating systems (like Solaris).

  122. Saving time by coats · · Score: 1

    Which tool I use depends on what i am doing. Often GUIs can save time.

    For dinky little tasks that you want to snoopervise manually. But when it comes to Real Computing® where you're manipulating tens of millions of objects, GUIs just don't scale.

    --
    "My opinions are my own, and I've got *lots* of them!"
    1. Re:Saving time by Eravnrekaree · · Score: 1

      Quite indeed. I mentioned that everything should be able to be done via a CLI also a programming interface particularly because these things can be programatically accessed to automate tasks easily.

  123. Not really unix ... by daveywest · · Score: 1

    ... but cowirkers think I'm a god because I can make a remote Mac talk using the "say" command.

    1. Re:Not really unix ... by daveywest · · Score: 1

      I was implying that you won't find the "say" command in any other distro.

  124. Behold the power of Unix PIPE!!! by Zarf · · Score: 1

    From Behold The Power of Pipe

    Tar and compress a set of files or directories shoot them over the network and decompress on the target machine using the target machine's CPU for decompression...

    tar -czf - [list of dirs and files] | \
            ssh [user]@[server] "cd /path/to/place/files; tar -xzf -"

    --
    [signature]
  125. dd if=/dev/zero of=/dev/sda very usefull by Anonymous Coward · · Score: 1

    Good for erasing USB sticks that have had confidential data. As long as you don't have the IDE-SCSI emulation module loaded.

    If you do have the IDE-SCSI module loaded (say because you were just burning a CD), well, I'll just say... the String "Rei$er34" is found in the 53rd block of a ReiserFS filesystem, and you can count backwards to find the first block. I recommend a PERL script.

  126. Re:Hail to the chimp! by oatworm · · Score: 1

    Or, you could do the Double Troll. That's where you just freak out and start trolling all over the place, even trolling other trolls.

  127. portable commands by ramune · · Score: 1

    While some people like grep -r, xargs -0, etc. -- I deal with many UNIX variants, so I need a portable subset. Hence:

    # Daemonize a process
    nohup sh -c 'command > /dev/null 2>&1 </dev/null & ' > /dev/null 2>&1 </dev/null &
    # Convert a file to LF from CR/LF
    tr -d '\015' < foo.txt > bar.txt
    # Scripted editing of a file when you don't need something as complex as awk/sed
    # (or they have odd problems/limitations on that platform):
    $ ed foo.c <<__EOL__
    1 /stdio.H
    s/stdio.H/stdio.h/
    w
    q
    __EOL__

    # Recall history and edit it as a text file, then run it in the shell.
    # Defaults to /bin/ed on many Bourne-shell variants unless you set FCEDIT.
    # Useful to repeat a long sequence of actions taken while you were trying to
    # figure out how to do stuff.
    FCEDIT=${VISUAL:-/usr/bin/vi} export FCEDIT
    fc

    # Useful for annotating stuff when commenting on a file -- numbers them:
    nl file.txt
    # Easy way to check for a byte occuring in a file -- handy in certain types
    # of input validation and forensics.
    od -t x1 file.txt | grep 'a9'
    # And something Debian/bash-specific. You figure it out. :-)
    MAX_NR=0 ; varry=(`deborphan -an|awk '{print $2}'|sort|tr '\012' ' '`) ; i=${#varry[@]}; while [ $i -gt 0 ] ; do NR=`echo ${varry[$((i-1))]}|wc -c` ; if [ $NR -gt $MAX_NR ] ; then MAX_NR=$NR ; fi ; i=$(($i-1)) ; done ; NR_PER_LINE=$(( $((COLUMNS-1)) / MAX_NR )) ; FSTR="%${MAX_NR}s|" ; while [ $i -lt ${#varry[@]} ] ; do CURCOUNT=0 ; echo -n '|' ; while [ $CURCOUNT -lt $NR_PER_LINE ] ; do printf "${FSTR}" ${varry[$i]} ; i=$(($i+1)) ; CURCOUNT=$(($CURCOUNT+1)) ; done ; echo ; done|less

  128. Fix the garbled screen by Bandman · · Score: 1

    After you cat something you shouldn't, and the console is screwed, 'reset' works wonders

    If the screen isn't screwed, and you just want it cleared, "clear"

    1. Re:Fix the garbled screen by multipartmixed · · Score: 1

      One way to reset your terminal -- particularly when reset isn't available -- is hilarious. "more /bin/ls" -- more then resets the terminal charset to ask you if you really want to view a binary file. You say "no", and you're back to normal.

      This doesn't work on all unices, and definately relies on more being more and not less.

      --

      Do daemons dream of electric sleep()?
    2. Re:Fix the garbled screen by Chris+Pimlott · · Score: 1

      The standard trick I learned long ago is "echo ^V^O" (that's control-v, control-o).

      ^V is handy in general any time you want to enter a special character on a command line, like tab, enter, backspace, or the always popular control-g.

    3. Re:Fix the garbled screen by xaxa · · Score: 1

      You can use ^L to clear the screen, convenient as you can use it in the middle of typing a command (your command is retained).

  129. xargs by crono_deus · · Score: 1
    The most useful command in *nix. It's a shell version of map() and it's awesome. Most common usecase for me recently has been something like:

    svn ls | grep -v "NO" | xargs svn update

    which grabs a directory listing from the Subversion server, prunes out the things I don't want, and then maps "svn update" on the remaining directories.

    Also: pushd/popd. Pushd places the current directory on a directory stack and popd cds to the top directory on said stack. It's great for quickly hopping between directories.

    --
    Ne Cede Malis.
    1. Re:xargs by br00tus · · Score: 1

      This is the first thing I thought of, I didn't learn of xargs until after using UNIX for a year or so, it can come in quite handy.

  130. Last argument by nsanders · · Score: 1

    Amazingly I only learned this a couple years ago having already been using Linux/Solaris for 9 years:

    # touch "filename"
    # ls -l !$
    ls -l "filename"
    -rw-r--r-- 1 user group 0 2008-11-05 15:50 "filename"
    #

    I honestly don't know where in bash this is controlled (or even what it's called). Does anyone know a list of other similar bash syntax?

    1. Re:Last argument by Chris+Pimlott · · Score: 1

      I honestly don't know where in bash this is controlled (or even what it's called). Does anyone know a list of other similar bash syntax?

      As I just learned, it's part of the bash history commands, someone else just made an excellent post about it.

    2. Re:Last argument by iggya · · Score: 2, Informative

      Suppose you did this: ls -la filename, then you can do this: man !:0 which converts the !:0 into the zeroth word on the previous command, namely ls. So man !:0 would be man ls. Similarly, !:1 changes to -la, and !:2 is filename. You may also like !:1* or !:2*. !:1* would be the first word and all after it, !:2* is the second word and all after it. So !:1* changes to -la filename in this case. There is also !:0-2 for a range of words. Here is an example:

      sl -la file1 file2 file3 file4
      # oops i put sl instead of ls
      ls !:1*
      # same as ls -la file1 file2 file3 file4
      less !:3 # same as less file2
      ls -la file1 file2 file3 file4
      echo !:1-2 # echo -la file1

      More information can be found in the HISTORY EXPANSION section of the bash manpage. Specifically, the Word Designators subsection. Enjoy!

    3. Re:Last argument by xaxa · · Score: 1

      Depending on how you type, Meta+. (i.e. alt+. or escape, .) does the same thing -- inserts the final argument from the previous command.

      I use Zsh, which has a few others, though I can't remember how I enabled them. Ctrl+X, M inserts the name of the last-modified file in the current directory for instance, which is nicer than remembering Zsh's globbing for that: *(om[1]) (but obviously is no use in a script).
      *(om[1]) is * for anything, the o for descending order, the m for order by modification date, the [1] for the first element. *(/om[1]) would choose the most-recently modified directory.

  131. File globbing through directory trees by Tommer · · Score: 1

    In 1994, coming from DOS, I was surprised to learn that shell globs can span directory trees, e.g.

    rm foo*/*/*.bar

    --
    -- Tom Rathborne
  132. Re:This one always surprises people for some reaso by bzipitidoo · · Score: 1

    The thing I dislike about locate is that daemon firing up at miscellaneous times such as 3 AM to update the database. The first time it happened, I thought I'd just been hacked. The system was dog slow while that was happening, and the hard drive was noisily grinding away. Once I figured out what was going on, I ripped locate out of the system.

    I'm not too keen on "find" either. Its syntax confuses me. Notice how most people use just the very basic "find ." and send the results to grep?

    So here's one I like. Not efficient maybe, but easy:

    du -a | grep $SOMETHING

    --
    Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
  133. nc on linux by slmdmd · · Score: 1
    DESCRIPTION

    The nc (or netcat) utility is used for just about anything under the sun involving TCP or UDP. It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning, and deal with both IPv4 and IPv6. Unlike telnet(1), nc scripts nicely, and separates error messages onto standard error instead of sending them to standard output, as telnet(1) does with some.

    Common uses include:

    simple TCP proxies
    shell-script based HTTP clients and servers
    network daemon testing
    a SOCKS or HTTP ProxyCommand for ssh(1)
    and much, much more

  134. Re:ftp from a command line by oatworm · · Score: 1

    Yes. It's called "Internet Explorer". It's all super GUI, with a delicious creamy filling!

  135. Kill all processes of a user by nomad63 · · Score: 1

    this is more of a valuable one-liner than anything else but whomever saw me typing this to a terminal window, wants me to email them the command, so that they can keep it in their arsenal

    # ps -ef | grep <username> | awk {'print $2'} | xargs kill (-9 optionally)

    --

    __________
    The more I know people, the more I love animals
    1. Re:Kill all processes of a user by loftwyr · · Score: 1

      kill (-9 optional) `pgrep -u ` is shorter still.

    2. Re:Kill all processes of a user by nomad63 · · Score: 1

      I tend to stay away from the backticks and use the proper $(command) construct but it would be harder to explain here :)

      --

      __________
      The more I know people, the more I love animals
  136. Re:How about a new GUI apt get trick? by mabinogi · · Score: 3, Funny

    Also, Yum is good for reducing stress by conveniently giving you ten minutes to an hour of relaxation time while it completes each operation.

    --
    Advanced users are users too!
  137. sudo bash by bobetov · · Score: 1

    If you're on a machine where you have sudo privs but no root (fairly common in hosted/managed servers) you can 'sudo bash' to get a full root shell. Veeeeery handy in some cases...

    It's kind of obvious in hindsight, but I just learned this one last week. ;-)

    --
    Looking for a Rails developer in Chapel Hill?
    1. Re:sudo bash by Cytlid · · Score: 1

      Even better... at a place I worked for, the admins were given "sudo bash" (so they could work with root access), but techs were given lesser commands. You know, like less (and a few others).

        Problem was, sudo less then type "!" gave you a root prompt ...

      --
      FLR
    2. Re:sudo bash by BluBrick · · Score: 1

      Only if sudo is badly misconfigured! If you don't have root access, you shouldn't have sudo access to any shell, or any program which can give you a shell.

      --
      Ahh - My eye!
      The doctor said I'm not supposed to get Slashdot in it!
    3. Re:sudo bash by greed · · Score: 1

      A number of systems, of which Linux and Solaris are leading examples, have a way of replacing exec() in subprograms so that you can't get away with that one.

      Not sure if it's enabled by default; I have yet to configure sudo access for other people. (Other people give _me_ sudo access, and I know they aren't doing it the way I would. "greed ALL=(ALL) ALL". Yeesh, at least limit the sudo-to user list, so it's not like you WANT me to sudo to any account.

  138. Re:Listing directory contents without the ls comma by Drinking+Bleach · · Score: 1

    There's advantages and disadvantages to both approaches. Though I believe recent bash versions actually will set an environmental variable that contains the raw command the user typed, so even if "rm *" gets the expanded version, it can still check the environment var for "rm *" and warn the user if they really want to do it.

  139. Shell history tricks by steveha · · Score: 5, Informative

    There are a whole bunch of "history" tricks, to recall old commands without using the mouse.

    When I started college, I studied the shell's man page until I knew them all. Some are so obscure I have forgotten them.

    Generally, these involve an '!' character in some way.

    Here are a few I use:

    !! # run again the last command that was run
    !9 # run again the command with history number 9
    !v # run again the last command that started with a 'v'
    !vi # run the last command that started with "vi"
    !?foo? # run the last command that had the string "foo" anywhere in it

    diff oldfile newfile
    mv !$ !^ # same as "mv newfile oldfile"
    # !$ is last arg of previous command, !^ is first arg

    ls foo bar baz
    rm -f !!* # same as "rm -f foo bar baz"
    # !!* repeats all arguments from previous command

    There are actually some baroque tricks that recall a previous command and perform a search-and-replace on it, but for anything that complicated I just recall the line and edit it. The baroque tricks would have been pretty darn cool back in the paper teletype days, though.

    By the way, the Bash shell can be configured to edit command lines using vi or Emacs commands. I described how to do it in an article I wrote for Linux Journal magazine. It's the last section, "vi or Emacs Mode in the Shell".

    http://www.linuxjournal.com/article/8361

    Oh, not exactly a history trick, but here's something I use all the time:
    ls -1 > /tmp/files
    vi /tmp/files # edit list to include just the files I want
    rm `cat /tmp/files`
    # `cmd` inserts the standard output from cmd into the command line as if you typed it

    ls -1 > /tmp/files
    vi /tmp/files
    # edit list to include just the files I want
    # now run this command: :%s+.*+mv & /some/directory/path/&+
    # save file and quit vi
    source /tmp/files

    This moves the chosen files to "/some/directory/path". The breakdown of the vi command is as so:
    : # invoke "ex mode" for search and replace command
    % # run the following command on every line of the file
    s # do a search and replace
    + # use a '+' for the command delimiter, so I won't have to backslash escape '/' chars in the path

    .* # all characters on the line
    + # end the match pattern, begin replace pattern
    # & refers to the match pattern, thus all chars on the line
    mv & /some/directory/path/& # replace "foo" with "mv foo /some/directory/path/foo"

    Takes less time to do it than to explain it!

    The above is perhaps overkill if all the files are going to the same place. It's great if you want to send some files one place, some to another, because you can just edit the destinations until it looks right.

    steveha

    --
    lf(1): it's like ls(1) but sorts filenames by extension, tersely
    1. Re:Shell history tricks by bobstreo · · Score: 2, Informative

      How about setting FCEDIT to your favorite editor, and running fc on the command line, very very VERY handy when messing with long paths. (stupid java)

      the script command is also your friend when creating pointless documentation people will never read.

      another thing people never think of is the
      nohup command.

      sshfs is kinda spiffy if you want to mount things over an ssh connection.

      I do HATE with a passion when the same commands on different OS versions (I'm looking at you here SUN) ouput different results.

      Oh and don't forget stupid little things like aliases in your shell startup file. I just like typing l to do an ls -aF.

      You can also write some nice functions for your startup files. and don't forget the logout files, you can have some fun there.

      Also if you're old school command line and really bored:

      http://nadvsh.sourceforge.net/nadvsh.6.html

    2. Re:Shell history tricks by Old+Wolf · · Score: 1

      For vi editing mode, simpler is: set -o vi

    3. Re:Shell history tricks by c0nman · · Score: 1
      How could you not include ^R and ^S

      ^Rstring # recall the last command with string in it

      This can then be used again and again, ^R^R , to go back through each of those commands

      This allows you to jump back 1, 2, 3, 4... or however many commands in history that include any specific string.

      Pass up the command by hitting ^R too many times?
      ^S to the rescue! ^S then goes forward in your match history

      Do not use ^S outside of ^R though, or it will freeze your terminals output(commands still run even though you do not get any output until the following is done) for which you will need to ^Q to unfreeze.

      As for other history tricks that you did not get in to... All great!

      echo !-2:2
      ^replacethis^withthis
      !?string?
      echo !!:$:h
      echo !!:$:e
      echo !!:$:r
      echo repeat this twice !#:1*
      fc
      shopt -s histverify
      export HISTIGNORE="&:[ ]*:fg:bg:jobs:kill:exit:logout"



      here is a simple cheat-sheet for some of the stuff.

    4. Re:Shell history tricks by mike3k · · Score: 1
      My favorite history trick:

      alias redo 'sudo \!-1'

    5. Re:Shell history tricks by klaasvakie · · Score: 1

      ls -1 > /tmp/files
      vi /tmp/files # edit list to include just the files I want
      rm `cat /tmp/files`

      Instead of creating the tempfile, you can use vipe (included in moreutils.)
      vipe allows you to "vi" the "pipe", like so:
      $ ls -1 | vipe | xargs rm

      --
      # ssh -l neo the_matrix; killall -9 agent_smith
    6. Re:Shell history tricks by kill+-9+$$ · · Score: 1

      Hey thats similar to my personal favorite as my uid suggests....

      --

      -- A computer without COBOL and Fortran is like a piece of chocolate cake without ketchup and mustard
    7. Re:Shell history tricks by www.blogLinux.org · · Score: 1

      ls -1 > filename is waste. ls > filename is exactly the same in every way, except shorter to type.

    8. Re:Shell history tricks by ralph.corderoy · · Score: 1

      Some nice ones there. But you can use !* instead of !!*. And if you suffix a :p the concocted history command will be printed instead of executed. The -1 in ls -1 >foo is redundant, ls doesn't do columns if stdout isn't a tty. mv `cat foo` /path/dest is an easier case when, like you suggest, they're all going to the same place.

    9. Re:Shell history tricks by www.blogLinux.org · · Score: 1

      exactly, it's not needed. If you go out of your way to alias a command differently, that's your fault.

      ls > filename is the same as ls -1 > filename, unless you go out of your way to change it to mean something else.

      I'm not concerned about non modern systems. punch card holes are a mystery to me.

      Saying something is waste is not an insult from me. I'm interested in efficiency for this case.

  140. Crashed My Laptop! by TheNinjaroach · · Score: 5, Funny
    I have never, ever seen a hard crash on my IBM Thinkpad T40. So I ran that command as root, looked at the output and thought "Huh that's neat." Thirty seconds later, my screens go black and I'm looking at a disoriented IBM POST screen, mostly black with a broken progress bar.

    My system booted up fine, so of course the first thing I wanted to do was make it happen again.

    `blockdev --report /dev/* | more `

    Thirty seconds after the output finished and I'm looking at the garbled POST screen again. My laptop finished booting, I ran the command a third time before coming to tell Slashdot and

    --
    I went to eat some animal crackers and the box said, "Do not eat if seal is broken." I opened the box and sure enough..
    1. Re:Crashed My Laptop! by rsmoody · · Score: 1

      Same here, only I only ran it once....

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    2. Re:Crashed My Laptop! by Sir_Kurt · · Score: 1

      That's interesting. After reading your post, I ran the same command on my Thinkpad T-23 and also had a hard stop after about 30 sec WTF?

      Kurt

    3. Re:Crashed My Laptop! by rincebrain · · Score: 1

      My T61p is perfectly fine with this, and hasn't had a terrible problem after 30 seconds.

      I wonder what's going on for you guys. Maybe we should compare /dev and *ix versions?

      --
      It's only an insult if it's not true.
    4. Re:Crashed My Laptop! by Ant+P. · · Score: 1

      Maybe it's accessing a device file in a way it shouldn't. Certain bits of IBM hardware are notorious for being flaky, particularly the i2c stuff (which is in /dev/i2c-*). Oh, and ethernet card EEPROMs...

    5. Re:Crashed My Laptop! by bhassel · · Score: 1

      Same here, and just as I was reading your post... freaked me out!

    6. Re:Crashed My Laptop! by Anonymice · · Score: 1

      Same happening here.
      I initially thought blockdev may be sending some sort of interrupts to the devices (/dev/*).
      Not so sure now...

      The following logs were consistent during my two "crashes":

      syslog:Nov 5 21:46:38 electron modprobe: WARNING: Error running install command for nvidia
      syslog:Nov 5 21:46:38 electron last message repeated 3 times
      syslog:Nov 5 21:46:48 electron kernel: [45351.380245] hidraw: unsupported ioctl() 125e
      syslog:Nov 5 21:46:48 electron kernel: [45351.380265] hidraw: unsupported ioctl() 125e
      syslog:Nov 5 21:46:49 electron kernel: [45353.984766] loop: module loaded
      syslog:Nov 5 21:46:49 electron modprobe: WARNING: Error running install command for nvidia
      syslog:Nov 5 21:46:49 electron last message repeated 3 times
      syslog:Nov 5 21:46:49 electron kernel: [45354.149515] PPP generic driver version 2.4.2
      syslog:Nov 5 21:46:49 electron kernel: [45354.204870] swsusp: Marking nosave pages: 000000000009f000 - 0000000000100000
      syslog:Nov 5 21:46:49 electron kernel: [45354.204879] swsusp: Basic memory bitmaps created
      syslog:Nov 5 21:46:50 electron kernel: [45355.833741] swsusp: Basic memory bitmaps freed
      syslog:Nov 5 21:46:50 electron kernel: [45355.840090] iTCO_wdt: Unexpected close, not stopping watchdog!

      That last line is referring to the Intel TCO Timer driver (watchdog).

      Inspiron 6400 / Ubuntu 8.04

      ~$ uname -a
      Linux electron 2.6.24-19-generic #1 SMP Wed Aug 20 22:56:21 UTC 2008 i686 GNU/Linux
      ~$ blockdev -V
      blockdev (util-linux-ng 2.13.1)

    7. Re:Crashed My Laptop! by adamofgreyskull · · Score: 2, Funny

      An engineer, a physicist, and a mathematician were on a train heading north, and had just crossed the border into Scotland.

      • The engineer looked out of the window and said "Look! Scottish sheep are black!"
      • The physicist said, "No, no. Some Scottish sheep are black."
      • The mathematician looked irritated. "There is at least one field, containing at least one sheep, of which at least one side is black."

      The geek looked out of the window and said "Look! Scottish sheep are black!" then looked out of the window twice more, and confirming it was still black each time, posted this fact to /.

      (I would have done the same thing)

    8. Re:Crashed My Laptop! by RichiH · · Score: 1

      Yah, that commands seems to be unhappy with itself

      blockdev: ioctl error on /dev/adsp
      [...]
      blockdev: ioctl error on /dev/null
      [1] 17185 segmentation fault blockdev --report /dev/* |
                    17186 done

    9. Re:Crashed My Laptop! by TheNinjaroach · · Score: 1

      Nov 5 16:26:46 thinkpad kernel: iTCO_wdt: Unexpected close, not stopping watchdog!

      It's the last line in my syslog as well before each reboot.

      Thinkpad T40 / OpenSUSE 10.3

      thinkpad:/var/log # uname -a
      Linux thinkpad 2.6.22.16-0.2-default #1 SMP 2008/02/01 19:36:55 UTC i686 i686 i386 GNU/Linux

      thinkpad:/var/log # blockdev -V
      blockdev (util-linux-ng 2.13-rc2)

      Maybe I should quit running random commands posted to Slashdot as root. Eh, probably not.

      --
      I went to eat some animal crackers and the box said, "Do not eat if seal is broken." I opened the box and sure enough..
    10. Re:Crashed My Laptop! by xaxa · · Score: 1

      An engineer, a physicist, and a mathematician were on a train heading north, and had just crossed the border into Scotland.

      • The engineer looked out of the window and said "Look! Scottish sheep are black!"
      • The physicist said, "No, no. Some Scottish sheep are black."
      • The mathematician looked irritated. "There is at least one field, containing at least one sheep, of which at least one side is black."

      The geek looked out of the window and said "Look! Scottish sheep are black!" then looked out of the window twice more, and confirming it was still black each time, posted this fact to /.

      ...and the computer programmer said "Oh no, a special case!"

    11. Re:Crashed My Laptop! by famebait · · Score: 1

      The support guy closed his eyes, opened them again, saw the sheep was white and promptly forgot about the whole thing.

      --
      sudo ergo sum
    12. Re:Crashed My Laptop! by xenocyst · · Score: 1

      me five-ish

      T60/Ubuntu 7.10

      Nov 6 23:29:43 modprobe: WARNING: Error running install command for nvidia
      Nov 6 23:29:43 last message repeated 3 times
      Nov 6 23:29:53 kernel: [ 1312.260512] loop: module loaded
      Nov 6 23:29:54 modprobe: WARNING: Error running install command for nvidia
      Nov 6 23:29:54 last message repeated 3 times
      Nov 6 23:29:54 kernel: [ 1312.316405] swsusp: Marking nosave pages: 000000000009f000 - 0000000000100000
      Nov 6 23:29:54 kernel: [ 1312.316421] swsusp: Basic memory bitmaps created
      Nov 6 23:29:55 kernel: [ 1313.994819] swsusp: Basic memory bitmaps freed
      Nov 6 23:29:55 kernel: [ 1314.007814] iTCO_wdt: Unexpected close, not stopping watchdog!
      Nov 6 23:31:10 syslogd 1.4.1#21ubuntu3: restart.

      1. See an interesting command.
      2. See that it caused other people to crash.
      3. Run it anyway, and crash.
      4. ???
      5. Profit!

      --
      And, no, I should not have used the goddamn Preview mode first.
  141. ssh tunnels by Deadplant · · Score: 1

    i don't know if this is of any interest but...

    secure ad-hoc on-demand port forwarding

    ssh -L localhost:3389:192.168.1.5:3389 user@remotefirewall.com

    then connect to localhost with your RDP client to access the XP machine behind the firewall at your remote site.

    also very useful for getting out from underneath corporate firewalls.
    ssh -L localhost:3128:localhost:3128 user@myremotelinuxserver.com
    configure squid on your linux server to bind only to localhost for security.

    swiss army knife commands:
    cat cut grep awk sort tail head uniq

    for example:
    cat /var/log/apache2/access.log | grep /mystuff/myvideo.avi | cut -d " " -f 1 | sort | uniq
    should give you a list of the unique IPs that accessed that file on your web server.

    1. Re:ssh tunnels by multipartmixed · · Score: 1

      In that same vein -- ... | sort | uniq -c | sort -nr | tail

      will give you the top 10 of whatever-it-is you're listing (in your case, unique IPs) ordered by appearance, with appearance count the first column in the output.

      --

      Do daemons dream of electric sleep()?
  142. Left-click, Right-click to delimit selection by michaelwv · · Score: 1

    In well-designed terminals viewers such as xterm:

    left-click to define the start of a region
    [let go of the button]
    right-click to define the end of a region

    Now your region is selected. Paste at will. This is much more accurate then left-click and holding down because the holding-down way tends to mess with how well you can point the mouse. It saddens me whenever I use a terminal program that steals the right-click button for something else because it's clear that the developers didn't know you could do this.

  143. watch - execute a program periodically by robmv · · Score: 1

    watch AnyProgram

    run AnyProgram every two seconds (default time) and show the output

  144. Re:This one always surprises people for some reaso by Chris+Pimlott · · Score: 1

    Of course on modern distros the locate command will complain that it's database doesn't exist until you manually enable the service because the command line is supposed to be dead. :(

    imho, any unix system that doesn't have the updatedb cronjob enabled is broken.

  145. Setting a timebomb by kmahan · · Score: 1

    If you want to make things more interesting for the sysadmin you can always set a time bomb..

            sudo touch /dev/null

    --
    Invalid Checksum. Retrying.
  146. top by dahl_ag · · Score: 1

    I was surprised by how how many unix people at my last job didn't know about 'top'...

  147. Xscreensaver and xhost + by mknewman · · Score: 1

    Years ago I ran across a program called xscreensaver that would scrape the screen of a remote system and show it to you in a window. Great for monitoring your boss's P0rn habbit. To use it they had to do a xhost +, but that's pretty common.

    1. Re:Xscreensaver and xhost + by mknewman · · Score: 1

      Actually I meant xwatchwin. http://www.freshports.org/x11/xwatchwin/ Been a long time since I've used it.

  148. Using /dev/null with find/grep by thisissilly · · Score: 1

    Here's a simple one.
    Let's say you are looking for a file that has a certain string in it. (I'll use "foobar" because I'm a traditionalist.) You probably already know
    find . -type f -exec grep -l foobar {} \;
    But the problem is, that only returns the filename, not the line matched. You could drop the "-l", but then you only get the matching line, but not the filename. The quick way to solve the problem is to add a second file to the grep; then grep returns both the filename and the line match. In order to keep things quick and the results pure, the best file to use is /dev/null.
    find . -type f -exec grep foobar {} /dev/null \;

    1. Re:Using /dev/null with find/grep by Chris+Pimlott · · Score: 1

      Here's a simple one.

      Let's say you are looking for a file that has a certain string in it. (I'll use "foobar" because I'm a traditionalist.) You probably already know

      find . -type f -exec grep -l foobar {} \;

      But the problem is, that only returns the filename, not the line matched.
      You could drop the "-l", but then you only get the matching line, but not the filename. The quick way to solve the problem is to add a second file to the grep; then grep returns both the filename and the line match. In order to keep things quick and the results pure, the best file to use is /dev/null.

      find . -type f -exec grep foobar {} /dev/null \;

      ... or you could just use the -H option:

      $ grep -H penguins /usr/share/dict/words /usr/share/dict/words:penguins

    2. Re:Using /dev/null with find/grep by thisissilly · · Score: 1

      Sorry, I grew up with Unix before GNU; that was not an option back then.

  149. Grepping the process list by Orii · · Score: 1

    One of my favorites is an alias for easily grepping process lists:

    alias psg 'ps -ef | grep'

    Want all your processes? 'psg [username]'
    Want to see all processes not owned by root? 'psg -n root'

    I mostly use it searching for process names or usernames, but you could grep for pids and such too.

    1. Re:Grepping the process list by Chris+Pimlott · · Score: 1

      alias psg 'ps -ef | grep foo'

      One annoyance of doing this is that you will match the grep process itself (since the command line contains foo). A quick workground is to do

      ps .. | grep [f]oo

    2. Re:Grepping the process list by thogard · · Score: 1

      ps .. | grep f\\oo
      will do the same but it much faster to type.

  150. tricks by Improv · · Score: 1

    (cd /tmp/dir1 ; tar cf - *) | tar xvf -

    escape-underscore to fill in the last argument to the last command (might be a bash-ism)

    killall

    screen

    --
    For every problem, there is at least one solution that is simple, neat, and wrong.
    1. Re:tricks by yahyamf · · Score: 1

      escape-dot seems to fill in the last argument as well in bash

  151. cpio by warp_kez · · Score: 1

    find $SRC -print0 | cpio --null -pdv $DEST

    find $SRC -depth -print | cpio -ov > $DEST.cpio

    Don't use 'wall' when you want to abuse someone using 'write'

  152. Re:Dupe your TTY output to someone else using scri by nocomment · · Score: 1

    now THAT's what I'm talking about here!!!!

    --
    /* oops I accidentally made a comment, sorry */
    /* http://allyourbasearebelongto.us */
  153. Audio games by NathanE · · Score: 1

    Back in the day we used to play games on people with audio devices. Using netcat we would pipe from the microphone device on one box to the sound card on the target box. It was great seeing people's reactions to having somebody's voice come out the speakers of the machine they were sitting at in a lab or something.

    "Hey, stop picking your nose!"

    That kind of thing. :)

    1. Re:Audio games by drx · · Score: 1

      Dude, give us the command line!

  154. xmelt! by Tetsujin · · Score: 1

    export DISPLAY=someotherworkstation:0.0
    xmelt &

    Granted, this worked a lot better back when people were carelessly using "xhost +servername"...

    --
    Bow-ties are cool.
  155. Sending/Reading email from a command line by DJ+Haruko · · Score: 1

    Using Mutt entirely from the command line to send an email (or sendmail/esmtp directly when I've had to) has impressed a few people. I've found it useful when I have to send a file from a server, or in scripts. For example:

    echo "Hello, world" | mutt -s "My Subject" -a /attach/some/file/here nobody@nowhere.com

    Sendmail/esmtp is similar, except that I usually type it in directly rather than using a pipe. Actually my use of Mutt, along with imapfilter and Emacs, as my preferred email solution has left a lot of people either confused, dumbfounded, or impressed.

    --
    "If you were plowing a field, which would you rather use? Two strong oxen or 1024 chickens?" --Seymour Cray
  156. :> /var/log/messages by Domini · · Score: 1

    This will clear the contents of the file (without removing it thus and having to restart syslog etc.)

  157. and disown it! by Domini · · Score: 2, Informative

    (otherwise it will get killed the moment you log out)

    1. Re:and disown it! by Gazzonyx · · Score: 2, Informative

      nohup, FTW!

      --

      If I mod you up, it doesn't necessarily mean I agree with what you've said, sorry.

    2. Re:and disown it! by hackstraw · · Score: 1

      I love it when people leave CPU and/or disk intensive processes in the background and logout.

      Especially if they are not niced. I either renice or kill them, depending on my mood.

    3. Re:and disown it! by Domini · · Score: 1

      nohup is better, disown for 20-20 hindsight

    4. Re:and disown it! by Domini · · Score: 1

      Killing useful programs will stop people from using the system in future.

      Isn't that the whole point of unix-type systems? unattended tasks and whatnot that don't die as in windows? killing tasks like that only adds the instability factor people associate with windows and lets them opt for local VMware, coLinux or cygwin solutions rather...

      As a sysadmin in my college years I never killed unless I was 100% sure of a runaway process, but I had several automated scripts to auto-renice long-running tasks.

      Nowadays I'm usually the only user on systems I use, so no need for, ahem, niceties.

  158. My favorite trick : $() by Terrasque · · Score: 1

    Most people know of var=$(command) or var=`command` but few actually think about how to use it outside scripting.

    Let me give you an example. On my old system, I had 6 harddisks, mounted and sorted using the chaos theory as inspiration. But it never bothered me. If I wanted to see a movie, let's say Office Space, I could just do this:

    mplayer -fs `locate -i "office space"`

    and the film started playing fullscreen. Same for opening documents, and so on. That trick got a few jaw drops, even from people that knows shell scripting / command line pretty well. It just never occurred to them to use it like that.

    Using regex or piping to grep you could also pretty easily pick out a specific episode of a series too.

    --
    It's The Golden Rule: "He who has the gold makes the rules."
  159. Re:This one always surprises people for some reaso by Randle_Revar · · Score: 1

    >Of course on modern distros the locate command will complain that it's database doesn't exist until you manually enable the service because the command line is supposed to be dead. :(

    AKAIK, Debian sets up the db right away

  160. !$ in bash by jregel · · Score: 1

    I use this one daily.

    The !$ will take the last parameter in the previous command. For example:

    $ mkdir /a/very/long/pathname
    $ cd !$

    The shell expands the second command to:

    $ cd /a/very/long/pathname

    Useful in so many ways. The above is just a simple example.

    1. Re:!$ in bash by Chris+Pimlott · · Score: 1

      How bizarre! At first I thought you had simply typo'd and meant '$!', but I see '!$' really is correct. I didn't know there was a bash variable like this not starting with a '$'.

    2. Re:!$ in bash by Chris+Pimlott · · Score: 1

      Ah, I have just been enlightened by another post in the thread... the "!" should have tipped me off that it was part of the history functionality.

  161. factor by grandadmiralmcb · · Score: 1

    typing factor and an integer will factor the integer into its prime factorization

  162. Re:This one always surprises people for some reaso by yttrstein · · Score: 1

    I know locate well. I use the above method (the line that creates biglist is actually part of a cron job that deletes the old one and generates the new one every so often, ideally) because find is actually far less resource intensive on the machines I use than updating the located database. It's also substantially faster.

    Apart from that I'm just so used to grep syntax that it's faster for me to craft a regex in a grep command that will find precisely what I want than monkey with locate to do it.

  163. Directory stacks. by Hierarch · · Score: 1

    pushd, popd, and dirs.

    I hadn't actually seen the korn shell cd- thing before this discussion. Which one came first, anybody know?

    --
    --Somebody infect me with a .sig virus, I'm too lazy to write my own!
  164. Re:How about a new GUI apt get trick? by Bandman · · Score: 1

    I've used "yum whatprovides" before. Is "provides" the same thing?

  165. rsync by Chris+Pimlott · · Score: 1

    rsync is a wonderful command for synchronizing files. Its primary benefit is that is able to determine what files have changed and copy only those changes.

    It works over networks and is very bandwidth efficient (e.g. if you're syncing two 200MB directories, it can tell they are the same w/o uploading 200MB of data). There's options to filter the files to copy, or you can read a list from a file/stdin. There's the particularly "link-dest" option to have rsync make links to existing unchanged files in another directory, allowing space-efficient incremental copies.

    rsync has native ssh support, so it can work as a drop-in replacement for scp. Really, any time you find yourself running the same copy command multiple times, you should consider using rsync instead. It can save a lot of time.

    1. Re:rsync by klui · · Score: 1

      Careful about syncing lots of files. Rsync will run over per-process memory allocations in those situations. But other than that, yeah, rsync is great.

  166. The number one thing people are suprised at by geekoid · · Score: 1

    is that I use Unix.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  167. Try this on someone else's box first by Bretski · · Score: 1
    Compared to other OS's, it's amazing how little typing is required to render a UNIX machine completely unusable. In bash, try this:

    :(){ :|:& };:

    A bug? Absolutely not - UNIX has always been great at giving smart people the ability to shoot themselves in the foot.

    1. Re:Try this on someone else's box first by windsurfer619 · · Score: 1

      That's just a fork bomb. That won't actually slow down your system for very long on most modern systems that limit the number of processes.

    2. Re:Try this on someone else's box first by Bretski · · Score: 1

      Well, "just a fork bomb" still seems pretty effective on Solaris 10. When running this I cannot perform any other tasks, as the server is completely out of memory and cannot spawn any processes. Drives the load average up to >2000 for several minutes at least. Repeat fork bomb as needed.

    3. Re:Try this on someone else's box first by SCHecklerX · · Score: 1

      In windows, I believe %0|%0 will get you there. And on most modern linux boxen, your example will crap out in less than a minute.

  168. Diff the output of two commands by GXTi · · Score: 1

    $ diff -u <(echo foo) <(echo bar)
    --- /dev/fd/63 2008-11-05 22:23:09.802184626 +0000
    +++ /dev/fd/62 2008-11-05 22:23:09.802184626 +0000
    @@ -1 +1 @@
    -foo
    +bar

  169. Re:Hail to the chimp! by khellendros1984 · · Score: 1

    So, is the double troll next?

    --
    It is pitch black. You are likely to be eaten by a grue.
  170. WTF by Mister+Liberty · · Score: 1

    I tried it, this dd command that you talk about:

    C:\ dd if=/dev/zero of=/dev/sda1

    SYSEOS: Incorrect operating system in use
    C:\ _


    -- punt!

  171. search in one shortcut in your history by mduse · · Score: 1

    instead of using "history | grep keyword" you can directly use ctrl-R (learnt on "man bash") even simplier when addicted, "ctrl-r" twice brings you the latest search. hope everything was so simple...

  172. Re:sudo rm -rf / by doti · · Score: 1

    touch me
    touch clothes
    rm clothes

    me would end up alone

    --
    factor 966971: 966971
  173. df -h to show disk use in friendly units by IronChef · · Score: 1

    Works in FreeBSD, anyway.


    [1421][foo@ztest:~]$ df -h

    Filesystem Size Used Avail Capacity Mounted on
    /dev/ad2s1a 1.9G 264M 1.5G 14% /
    devfs 1.0K 1.0K 0B 100% /dev
    /dev/ad2s1e 496M 24K 456M 0% /tmp
    /dev/ad2s1f 136G 3.3G 121G 3% /usr
    /dev/ad2s1d 2.4G 1.3G 915M 59% /var
    pond 915G 408G 507G 45% /pond

  174. Re:This one always surprises people for some reaso by buchner.johannes · · Score: 1

    Well, I like to turn it off since although the process is in low (cpu) priority, the disk access is causing latency in my normal work.

    --
    NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
  175. remember "Engineer Scotty" talking to the mouse by peter303 · · Score: 1

    In Star Trek Movie IV, the whale one, Scotty trys to do something on a 1990s vintage PC by talking to it at the mouse. Then someone shows him the keyboard and he gets it working. User expectations change drastically over time.

  176. Re:Listing directory contents without the ls comma by jonaskoelker · · Score: 1

    There's advantages and disadvantages to both approaches.

    I've had .tex files die in a horrible wildcard related accident. Nothing big, just old linear algebra handins and I have compiled pdfs still.

    But whoever would have expanded that probably wouldn't have known to check my Makefile whether I was deleting sources or targets. Zero all.

    On dos you can rename fairly intuitively, "ren *.txt *.text". On Linux, you're likely to hurt yourself and/or your files (most likely in a different order) if you try that.

    But rename(1) can do perl-regex-based renaming. There's also 'mmv' which can handle renaming cycles and tries to do everything else topologically sorted.

    They're not as discoverable, points to DOS for that. But DOS is not so flexible, so points to Linux for that.

    Linux provides universal wildcard support. It also means that you may speak in zsh wildcards to a bash user and create horrible confusion.

    Try zsh today. If you're the kind of person who wants to spend an hour up front learning new things to save the time many times over, spread out over the next weeks/months/long-term, I can recommend it.

    <off-topic>
    That, and swapping escape/caps, and the dvorak keyboard layout. If you switch to mousing with your left hand (really easy except the first two days), you'll have copy-paste and the numeric keypad below your keyboarding hand at a natural position.

    If you want to give your hands a real treat, invest in a Kinesis keyboard (I'm a happy Ergo Elan user, except I can only get shitty ps2/usb adaptors). And get a Logitech Marble Mouse, and use EmulateWheel. The horizontal scrolling capability is one of those neat things you never know you want until you try it.
    </off-topic>

  177. Tab Command Completion by interval1066 · · Score: 1

    Tab for command completion in posix shells. I've amazed more supposed unix "pros" with that little trick. I guess none of them ever read on their shell of choice. Tab sommand completion is available on any posix shell.

    --
    Python: 'And then suddenly you have a language which says "we're all stuck with whatever the whiniest coder wants".'
    1. Re:Tab Command Completion by sydneyfong · · Score: 1

      No expert on the matter, but I think the "POSIX shell" doesn't necessary include tab completion. The minimal-yet-POSIX-compliant shells don't. (eg. ash, the BSD /bin/sh, etc.)

      --
      Don't quote me on this.
  178. SSH by evilviper · · Score: 3, Informative

    I'd say most people don't know how to use SSH very well...

    Stop typing passwords for every system: ssh-keygen, ssh-auth and ssh-add.

    Transferring files both with scp/sftp and ssh user@host "cat file" > file, and the like.

    Changing encryption algo for significantly improved speed, eg. -c arcfour

    Enabling/disabling compression for internet/intranet. -C

    An $HOME/.ssh/config file to map names to IP addresses, specify the default user names for each host, toggle compression per host, enable/disable port forwarding, keepalive, etc.:

    host webserver
        ForwardX11 no
        ForwardAgent yes
        Compression yes
        hostname slashdot.org
        port 2100
        user cmdrtaco

    And parenthesis and backticks seem to be going out of fashion in short order... Too bad, since they're quite time-saving: mkdir `date +%Y`

    --
    Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
    1. Re:SSH by Culture20 · · Score: 1

      ( cd /dir/to/copy ; tar cf - . ) | ssh user@host " ( cd /place/to/copy/to ; tar xvf - ) "
      or something like it

    2. Re:SSH by Abattoir · · Score: 1

      Don't set up ssh keys without passphrases unless absolutely necessary*. Use an ssh-agent to store the private keys. There's automated methods for this on every major platform.

      • Linux, ssh-agent and ssh-add. The man pages are complete, and automating this is easy in the shell. Alternately GNOME users can use Seahorse to tie the ssh keys into the login keychain.
      • Mac OS X, ditto ssh-agent/ssh-add, or use SSHKeychain.app, which will add the keys and passphrase to the login keychain as well.
      • Windows, if you're using SSH on Windows, its puTTY, and you should already have the putty agent installed from the installer. You used the installer right?

      *Necessary would be for automated application processes that need to ssh to systems without user intervention.

  179. More TAB awesomeness by badpazzword · · Score: 1

    On zsh you can even tab complete parameters.

    --
    When ideas fail, words become very handy.
  180. I love controlling the power and security... by bennomatic · · Score: 2, Funny

    ...at my uncle's dino-farm! He was so thrilled when I could help him. I was like, "I know this! It's a Unix operating system!"

    --
    The CB App. What's your 20?
    1. Re:I love controlling the power and security... by hansamurai · · Score: 1

      Hey, I was wondering what happened to your career?

  181. Re:This one always surprises people for some reaso by Chris+Pimlott · · Score: 1

    Well, I like to turn it off since although the process is in low (cpu) priority, the disk access is causing latency in my normal work.

    Normally it's just run as a nightly job, it usually not critical to have it be up-to-the-minute.

  182. man pages by OhHellWithIt · · Score: 1

    Step back for a moment and you'll find that "man pages" and "info" are actually a pretty awful way to distribute documentation.

    Actually, I love having documentation in man pages. It means I have the documentation without having Internet connectivity, which has been a common occurrence in my career. The only glaring omission I have found is the results for man woman. I shouldn't have been surprised by that, but I was.

    --
    "Who controls the past controls the future. Who controls the present controls the past." -- George Orwell
    1. Re:man pages by thtrgremlin · · Score: 1

      you also don't need to be running X.

      --
      Want Big Business out of government? Take away the incentive and start by getting government out of big business!
  183. cd arg1 arg2 by ze_jua · · Score: 1

    (ksh) cd arg1 arg2

    Replace the first ocurence of "arg1" found in the path with "arg2", and cd the new directory.

    Why it doesn't exist in bash ??

  184. rm -f /lib/libc* by AJWM · · Score: 1

    Much more subtle. Hilarity ensues.

    (I once accidentally did something with this effect. It is possible, kind of, to recover from it. Static binaries are your friends in this case.)

    --
    -- Alastair
    1. Re:rm -f /lib/libc* by feargal · · Score: 5, Funny

      You want subtle?

      ln -f /bin/rm /usr/bin/diff

      --
      "A goldfish was his muse, eternally amused"
    2. Re:rm -f /lib/libc* by theTerribleRobbo · · Score: 1

      Or perhaps:

      alias diff="unalias diff; rm -f"

    3. Re:rm -f /lib/libc* by kscguru · · Score: 2, Funny

      In complete seriousness, this was my first Linux experience. I got everything installed, read about this thing called safelib which was supposed to replace libc with safer wrappers, and tried to set it up. "su; rm /lib/libc.so.5; cp /tmp/path/libsafe.so /lib/libc.so.5". Rebooting clearly didn't fix it either :-)

      --

      A witty [sig] proves nothing. --Voltaire

    4. Re:rm -f /lib/libc* by rnswebx · · Score: 1

      I don't have any mod points, but I got a good laugh. Thanks!

    5. Re:rm -f /lib/libc* by RichiH · · Score: 1

      ln -f /bin/rm /bin/mv #does not work if shell uses its built-in

  185. Color grep by Matt+Perry · · Score: 1

    grep --color=yes pattern *

    Shows the matches in a different color if you have GNU grep.

    --
    Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
  186. simulate 'you've been 0wned' on remote console by anton_kg · · Score: 1

    Actually, you can use 'write' command for remote writing to a tty (even not logged in) as well. Pretty scare to see 'owned' message on all consoles one morning if not aware :)

  187. process list by Sergo5020 · · Score: 1

    ps xawf|mail `whoami`

  188. Re:rev (uniq too) by gosand · · Score: 1

    hmm, didn't know about rev... but I've used "sort | uniq" a lot. (shows unique lines, duh)

    Some other things I use all the time are
    "grep -i" (case insensitive), "grep -c" (count), "grep -v" (non-matching)

    There's probably more elegant ways of doing some things I use, but you use what you know.

    xargs is always good to know.

    ls -lahtr is a command I use all the time... shows files reverse sorted by modification time, or S instead of t for file size

    --

    My beliefs do not require that you agree with them.

  189. Re:ftp from a command line by sydneyfong · · Score: 1

    Holy crap, you're still using FTP?!

    (Yes, I'm aware there are valid uses for FTP...)

    --
    Don't quote me on this.
  190. Re:This one always surprises people for some reaso by Galactic+Dominator · · Score: 1
    --
    brandelf -t FreeBSD /brain
  191. One Upped by Chagatai · · Score: 3, Informative
    While the 'write' command is full of possible hijinks, the better option is to redirect output directly to the port on which someone is sitting. Unless that user has turned messages off with an 'mesg n' command, you can flush whatever you want to their screen with nothing to show the source of the transmission aside from shell history files.

    For example, I did these to some of my favorite people:

    banner "PORN HERE" > /dev/pts/4

    echo "All files deleted." > /dev/pts/3

    cat dictionary.list > /dev/pts2

    --
    --Chag
    1. Re:One Upped by RichiH · · Score: 1

      A leading whitespace is all you need to make zsh not save anything to your history *cough*

      Also:

      figlet $(cat $(locate -i gpl.txt)) | figlet | figlet | cowsay -n

      And yes, the cowsay is just to add insult to injury :)

  192. Useful tricks. by ElizabethGreene · · Score: 5, Informative

    I can't live without svn. Svn is a revision control repository, usually used for source code. What makes it really powerful is that you can _easily_ have a history of everything that has changed in a file and when. On my systems, I keep /etc in svn, plus bind's zone files, plus all the non-image web content, and the "Network Documentation" folder.

    Second trick, rsync. I use it to backup my home directory to another box. Very nice when you go through a hard drive/year.

    Screen -x was my next pick, but somebody already mentioned it.

    "echo ProtocolKeepAlives 120 >> /.ssh/config" No more dropped ssh sessions because of stupid nat boxes.

    su -u Username -s .. become Username, but keep the current shell. Good for diagnosing permissions problems when the user has a /bin/false shell. (named/www-user/backup/etc).

    A little awk goes a long way. Not the big-bad-I-am-a-programming-language-awk, but the smaller-friendlier extract one or two columns of text from something awk. ex. awk '{print $2}' prints the thing in the second column. Add -F the field separator tool and it gets really useful.
    Better example. Here is a postfix log line.
          Nov 5 16:27:19 pdc postfix/smtpd[13601]: 92B3F499C25F: client=exprod5mx254.postini.com[64.18.0.49]
    Here is the awk to extract just the message id. awk -F': ' '{print $2}'

    And here is the "I didn't get this message your mailserver must have eaten it" disprover. It searches the maillog for every message from or to a given address and extracts the full email transaction for that message id.

    grep -i user@domain.com /var/log/maillog | grep smtpd | awk -F': ' '{print $2}' | sort -un > temp.fil && grep maillog -f temp.fil

    Next trick, back ticks. `` Back ticks substitute the output of a command within a command.
    Ex. Name a file after the date. echo "hi" > `date +%Y%M%d`.txt

    On the subject of dates. date -d'yesterday' or 'last week' or '-4 hours' can be handy.

    Last one. Loopback nat with Iptables, so you can access local hosts by their external ip. (Instead of setting up split dns.)
    iptables -I POSTROUTING -s $local_network -d $local_network -j SNAT --to $lan_interface

    My local network is 192.168.0.0/24 and the netfilter lan ip is 192.168.0.1, so that becomes...
    iptables -t nat -A POSTROUTING -d 192.168.0.0/24 -s 192.168.0.0/24 -j SNAT --to 192.168.0.1

    -ellie

    1. Re:Useful tricks. by shish · · Score: 1

      I can't live without svn. Svn is a revision control repository, usually used for source code. What makes it really powerful is that you can _easily_ have a history of everything that has changed in a file and when

      Git does the same, but is faster, and no dependency on an external repository \o/

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
    2. Re:Useful tricks. by theonetruekeebler · · Score: 1
      Every time I read a post where I know half the tricks, there's something in the other half that's going to drop my workload by a third. date -d "yesterday" "+%F" is going to make about half my monitoring/reporting scripts about twice as legible. Between that, the screen -x option and the su -s option, I'm actually looking forward to work tomorrow.

      As for backticks, I prefer $(foo) to `foo`. It's much easier to read and Bash lets you nest to some extent.

      My contribution to the discussion is combining $(foo) with for...do loops. For example, if I wanted to find and delete old database connections I would:

      for a in $(list_old_connections) ; do drop_conn $a ; done

      (And now I can modify my get_old_connections to take a date as the parameter and use date -d "yesterday" all over the place. Thanks!)

      --
      This is not my sandwich.
    3. Re:Useful tricks. by cowens · · Score: 4, Insightful

      Next trick, back ticks. `` Back ticks substitute the output of a command within a command.
      Ex. Name a file after the date. echo "hi" > `date +%Y%M%d`.txt

      Don't use backticks unless you are stuck with bourne shell. Use $() instead:

      echo hi > $(date +%Y%M%d).txt

      They have two benefits over backticks: you can nest them and they are easier to see.

    4. Re:Useful tricks. by zn0k · · Score: 1

      My contribution to the discussion is combining $(foo) with for...do loops. For example, if I wanted to find and delete old database connections I would:

      for a in $(list_old_connections) ; do drop_conn $a ; done

      for loops with backticks can very quickly hit resource limits on long lists, so often you're better off piping to a looped read instead:

      list_old_connections | while read a; do drop_conn $a; done

    5. Re:Useful tricks. by AlejoHausner · · Score: 1
      Here is the awk to extract just the message id. awk -F': ' '{print $2}'

      Or, just use

      cut -d: -f1

    6. Re:Useful tricks. by ElizabethGreene · · Score: 1

      I've heard some really great things about Git. Fortunately or unfortunately, I happened to learn svn first while fixing bugs in Evolution. Since then it was easiest just to stick with it. With AnkhSvn (Visual Studio), TortoiseSvn (Windows), the built-in Eclipse and netBeans plugins, the command line svn client for scripts ... it has all "just worked". My repository is tucked on an out of the way webserver, and getting it setup was 75% of the learning curve. Is there a good reason to change I am missing?

      Question Re: no dependency on an external repository. If I check my bind zone files into git w/o an external repository, and some boob removes the /var/named/chroot directory... Can I get them back? or are they tucked in a .git folder under the checked in directory?

      -ellie

    7. Re:Useful tricks. by Randle_Revar · · Score: 1

      >are they tucked in a .git folder under the checked in directory?

      yes

    8. Re:Useful tricks. by gullevek · · Score: 1

      to add some more nice things.

      eg for sed to cut the first line:

      cat file | sed '1d'

      or the last

      cat file | sed '$d'

      very useful if you work with csv files with a header line.

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
    9. Re:Useful tricks. by gullevek · · Score: 1

      no external repository make no sense in my opinion for this. I have a local restore in svn, plus the complete history on my external server, where if the main server has some issue (eg /etc gets "lost") I can easy restore my whole /etc from the svn server.

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
    10. Re:Useful tricks. by PinkyDead · · Score: 1

      No dependency on an external repository doesn't mean that there is no external repository. You can have one if you want (though that's a very CVS/SVN view)

      Git repositories can operate like a cluster, where updates to the local repository are replicated between your repository and another one.

      Is there a good reason to change I am missing?

      Why not use CVS? (1) It's easier, (2) the intricate reasons why SVN is better than CVS are beyond the everyday use of developers and (3) all the tools you mention existed for CVS first.

      I've moved to Git because I love the Guerilla Developer nature of it - that might not appeal to everyone.

      --
      Genesis 1:32 And God typed :wq!
    11. Re:Useful tricks. by rnswebx · · Score: 1

      I've probably heard more "what?"s by executing ":> filename" or ">filename" to null a file than anything else. Obviously, it's far easier than using some combination of cp or cat and /dev/null.

      (bill@quell) ~ > echo "abc" > slashdot
      (bill@quell) ~ > cat slashdot
      abc
      (bill@quell) ~ > :> slashdot
      (bill@quell) ~ > cat slashdot
      (bill@quell) ~ >

    12. Re:Useful tricks. by theonetruekeebler · · Score: 1

      for loops with backticks can very quickly hit resource limits on long lists, so often you're better off piping to a looped read instead:

      list_old_connections | while read a; do drop_conn $a; done

      Excellent! I'd been doing the pathetic and less-generalizable alternative of for a in $(list_old_connections |head -n 500) a few times and now I'm kinda of embarrassed by that. Then again, by the time I'm in danger of hitting resource limits because of my for-list I'm usually screwed anyway...

      --
      This is not my sandwich.
    13. Re:Useful tricks. by remmelt · · Score: 1

      I haven't used git so I won't comment on it.

      (2) the intricate reasons why SVN is better than CVS are beyond the everyday use of developers

      I present to you svn move

      Case closed (the svn > cvs case, at least.)

    14. Re:Useful tricks. by godrik · · Score: 1

      A little awk goes a long way. Not the big-bad-I-am-a-programming-language-awk, but the smaller-friendlier extract one or two columns of text from something awk. ex. awk '{print $2}' prints the thing in the second column. Add -F the field separator tool and it gets really useful. Better example. Here is a postfix log line.

      I do this kind of thing with "cut" which is very useful when used with "paste" and "join"

    15. Re:Useful tricks. by quarterbuck · · Score: 1

      svn is overkill, I think
      rcs might be the easiest to set-up and with a small script that runs every once in a while (especially on the $TEMP folder if you have ooffice or word running).

      --
      http://slashdot.org/submission/1062723/Cheap-mobile-data-plan?art_pos=2
    16. Re:Useful tricks. by BJH · · Score: 1

      NOOOOOOOOOO!

      awk with positional parameters and cut are NOT the same thing.

      For example, please extract only the STIME field from "ps -ef" using cut. Ugh. Awk? '{print $5}'.

    17. Re:Useful tricks. by ElizabethGreene · · Score: 1

      I did use cvs first, and while "svn move" is a really nice command, I must confess the reason I made the switch was much less remarkable. I repeatedly forgot the syntax for pserver authentication, but I could remember an SVN url. Yes, pserver syntax is really simple.. cvs -d :pserver:user@dhost: (some operation) But unlike Johny Mnemonic, I decided to keep my childhood memories, and the cvs syntax just wouldn't fit.

      -ellie

    18. Re:Useful tricks. by ElizabethGreene · · Score: 1

      head and tail have skip-a-line features too. I get lost using sed. For search and replace I use

      perl -p -i -e 's/foo/bar/g' * (All files, in place)
      perl -p -i.bak -e 's/foo/bar/g' * (All files, in place, make a .bak backup first)

      That is easy for me to remember. I like pie. I like search-and-replace. Pearls have no place in pies. perl -pie

    19. Re:Useful tricks. by ElizabethGreene · · Score: 1

      On the subject of rcs, I read some mumblings about generating DNS zone serial numbers based on revision numbers. Is anyone doing that and/or is there a site that explains svn/cvs/git/rcs macros to do that sort of thing?

    20. Re:Useful tricks. by mortonda · · Score: 1

      "echo ProtocolKeepAlives 120 >> /.ssh/config" No more dropped ssh sessions because of stupid nat boxes.

      Nice, I have wondered for some time why one site kept disconnecting me. However, it might be good to use the right option, "ProtocolKeepAlives" didn't work for me:

      ServerAliveInterval
                        Sets a timeout interval in seconds after which if no data has
                        been received from the server, ssh will send a message through
                        the encrypted channel to request a response from the server. The
                        default is 0, indicating that these messages will not be sent to
                        the server, or 300 if the BatchMode option is set.
                        ProtocolKeepAlives is a Debian-specific compatibility alias for
                        this option.

    21. Re:Useful tricks. by AlejoHausner · · Score: 1

      True (slaps forehead). Cut assumes single-char delimiters between fields, whereas the awk parser allows regular expressions as delimiters. Alejo

    22. Re:Useful tricks. by Pooklord · · Score: 1

      Word.

      I use Sed and awk for tons of text parsing tasks. The best thing--they can handle enormous text files almost as easily and quickly as little ones.
      My boss is trying to get me to use PERL exclusively, but I'm just too lazy. And typically it's quicker to break the task down into a few lines of sed or/and awk and pipe into into a little script, than it is to write a proper PERL script.

    23. Re:Useful tricks. by dghcasp · · Score: 1

      Don't use anything not in Bourne shell, for example $(), lest you someday have to fix a problem on an older system that predates bash and you are unable to remember how to do it properly.

      I could also say "Don't use any command not available in a miniroot," but then I'm really dating myself... either that, or opening up more "stupid unix tricks," like Identify 3 ways to get a directory listing where the only commands you have available are shell builtins, echo, and dd

    24. Re:Useful tricks. by halfnerd · · Score: 1

      Also check out etckeeper, http://joey.kitenet.net/code/etckeeper/ , which works with git, mercurial and bzr. And has nice apt-integration on debian.

    25. Re:Useful tricks. by gullevek · · Score: 1

      I don't know, I am still a sed junky.

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
  193. Re:Listing directory contents without the ls comma by msuarezalvarez · · Score: 1

    Your trick involves cutting and pasting, presumably using a mouse?!

  194. Re:Why does it have to be ./script ? by Caped+Cod · · Score: 1

    No shell that I know about makes no such requirement. The execution search order is maintained in the PATH environment variable. If "." isn't there, it won't ever be searched, but that's just the shell doing what it is told. (Note that nearly every security book I've read has mentioned that putting "." in the PATH is a bad thing, and a Really Bad thing if you are root).

  195. w00t by phaetonic · · Score: 1

    1) ungzip and untar on GNU and non-GNU systems
    tar xf filename.tar | gzip -dc -

    2) how to do a command for MANY files at once
    /bin/sh cd /directory/with/files for i in *gz do gzip -d $i done

    1. Re:w00t by AlastairMurray · · Score: 1

      1) ungzip and untar on GNU and non-GNU systems
      tar xf filename.tar | gzip -dc -

      I assume you meant:
      gzip -dc filename.tar.gz | tar xf -

      But the following does the same in a simpler way:
      tar xzf filename.tar.gz

  196. say no to spreadsheets by Niobe · · Score: 1

    I do this sort of thing a lot in preference of using a spreadsheet: grep C4K_EBM-4-HOSTFLAPPING doihuxcr01.log-20081005 | grep "Oct 4" | cut -d' ' -f11- | sort | uniq -c

  197. less and vi tricks you may not have known by bjcopeland · · Score: 1

    'less' - much better than 'more'. You can use '/' to search for a string or regex. Also in 'less' you can use ':' to go to a specific line (similar to 'vi'). If you hit -F the file will scroll just like 'tail -f'. I use 'less' exclusively when reading logs and troubleshooting.

    'vi +5' - opens to line number 5.

    Also while in vi you can use '%' to track the beginning and ending of brackets (e.g. {}) that are used in functions - very useful!

    1. Re:less and vi tricks you may not have known by nocomment · · Score: 1

      most newer linuxes I've used have more aliased to less.

      --
      /* oops I accidentally made a comment, sorry */
      /* http://allyourbasearebelongto.us */
  198. Pranks! by Muckluck · · Score: 1

    Record the sound of the phone ringing to an .au file then cat it to dev audio (cat ./phone.au > /dev/audio) at random times of the day / night via a script in cron. We had one of our helpdesk folks going nuts over this one.

    --


    --I like turtles...
  199. tar pipes by HockeyPuck · · Score: 1

    These are great for moving around data... (tho you could use rsync instead...)

    % tar cf - . | (cd /home/user123 && tar xBf -)

    1. Re:tar pipes by hackstraw · · Score: 1

      also:

      tar cf - . | ssh somehost tar -C /some/place -xf -

      also nice with things like mysql dumps from one box, and loading the data onto another w/o touching the disk.

    2. Re:tar pipes by pato101 · · Score: 1

      rsync -e ssh -auvzH --progress MyDir/ someuser@somehost:destiny/dir/

  200. Re:This one always surprises people for some reaso by harry666t · · Score: 2, Funny

    I actually run updatedb as nobody (who has no access to /home). There isn't much change under / anyway. For my home dir (which changes much more frequently) I do "find -type f > ~/ffind-db" every time I feel like the index might be out of date, and when I need to find anything I just do "ig $SOMETHING ff[tab]" (it autocompletes to "ffind-db", and "ig" is an alias for "grep -i"). Pretty handy.

  201. fun stuff by otis+wildflower · · Score: 1

    # cloning a drive to another identically-sized drive
    dd if=/dev/dsk/c0t0d0s2 of=/dev/dsk/c0t1d0s2 # after booting from CD/DVD

    # zeroing out a drive
    while test 1; do dd if=/dev/urandom of=/dev/dsk/c0t0d0s2; done

    # renaming every file in a dir (and below) to all lowercase
    find ./ -type f -print|while read x; do base=`basename $x`; dir=`dirname $x`; base=`echo $base|tr "[A-Z]" "[a-z]"`; if [ ! -e ${dir}/${base} ]; then mv $x ${dir}/${base}; fi; done

    1. Re:fun stuff by nocomment · · Score: 1

      # zeroing out a drive
      while test 1; do dd if=/dev/urandom of=/dev/dsk/c0t0d0s2; done

      --
      this would take a long time and doesn't 'zero' but fills the drive with random junk. It would be a lot faster to use /dev/zero as it doesn't require the CPU to calculate a random number every millisecond before writing it to disk.

      --
      /* oops I accidentally made a comment, sorry */
      /* http://allyourbasearebelongto.us */
  202. Fork bomb by sydneyfong · · Score: 1

    I've seen on a few places (including /.), and I (think) I never ran it, but here's one of the most obscure fork bombs:

    :(){ :|:& };:

    (Warning: Don't do this on a production machine -- and if you did it and it hoses the machine, the blame lies on the sysadmin)

    Since I haven't gone through the lower scored posts I might be -1 redundant, so I might as well mention ulimit (bash builtin) and limits.conf(5) which when properly configured can limit the damage caused by these kind of rogue code.

    also worth mentioning is the "time" utility. It's usually a shell builtin that shows the time used for running the command (eg. time gzip BIGFILE)

    --
    Don't quote me on this.
  203. X applications ... by PPH · · Score: 1

    ... and the ability to run displays from any system to any other screen in my house over the LAN. I can run anything from my OpenOffice app on my study desktop to my home automation GUI on any screen in the house. Including some neat little QVGA touchscreens I've got wall mounted in various locations.

    --
    Have gnu, will travel.
    1. Re:X applications ... by Count+Fenring · · Score: 1

      Word.

      Also X11 over SSH has made my life much easier on many occasions.

      Make that SSH with the -C flag... which took me over a year to learn about. ::smacks face with hands::

  204. Steal passwords by rdejean · · Score: 1

    We would always set the victims shell prompt to: /bin/echo -ne"Login incorrect.\n\nlogin:"

    and have the script send us their password. Nothing beats the look on an admin's face when you walk up to them and recite their password, hahaha.

  205. Optimizing find further by dfsmith · · Score: 1

    One of the curious things about find is that

    find >/dev/null & find

    runs faster than

    find

    (Thanks to disk queuing of course, but still a curiousity.)

    1. Re:Optimizing find further by yttrstein · · Score: 1

      Dude, EXCELLENT catch there. I'd forgotten about that completely! My slowly growing leisure time thanks you.

  206. Connection closed... by crankyspice · · Score: 1

    Oh, man, that brings me back... We had a UnixWare system (Novell) with a bunch (64?) of RS232 serial ports via some Digi hardware (that never had Linux support, alas). We had a lab full of VT220 terminals we'd rescued from a dumpster, that people would use to login to the local UnixWare system, mostly to telnet out across a Rolm "dataphone" 19.2Kbps connection (managed by a couple of 386sx-16 machines with floppy drives and scripted KA9Q NOS installs) to the campus DEC microVAX running Ultrix and handling, via 'Pine', campus email.

    The system as described wasn't the most reliable thing in the world, especially not initially (i.e., before I took over as admin ;), and "Connection closed by remote host" messages weren't uncommon.

    Every once in a while someone would use 'write' or 'wall' to send a message, complete with a couple of CTRL-G characters to cause bells to go off on the VT220s, to a user or all users with something like "Connection closed by your mother."

    We were easily entertained in those days.

    I miss `talk` and `ytalk`. And setting up Legend of the Red Dragon (L.O.R.D.) under DOSEMU to be accessible to people telnetting in.

    --
    geek. lawyer.
  207. escape an ssh session by pak9rabid · · Score: 1

    Not a command per-se, but if you've ever wondered how to disconnect a stalled ssh session (like to disconnect a stalled telnet session), follow this key sequence:



    <enter>
    <enter>
    <enter>
    <shift-tilde>
    <period>

    That will disconnect you from a stalled ssh session w/out having to exit your terminal session

    1. Re:escape an ssh session by greed · · Score: 1

      That's copied from the older, and should-never-be-allowed-to-listen-on-a-socket-again, 'rlogin' program. And the sequence is just ENTER TILDE PERIOD. Though a couple of extra enters to see if it's come back before you kill it are, in my mind, a good idea.

      There's a whole sequence of those, they're in the ssh manual under Escape Characters.

      ENTER TILDE QUESTION-MARK

      tells you what they are.

      (To get a tilde at the start of a line, send it twice, or by something NOT listed in the list of Escape Characters.)

  208. Regexps... by RedPhoenix · · Score: 1

    cat /usr/share/dict/words | egrep "^([zrx].gu.{2}r|.[xp][xp]..s{2,2}..n.|[DZQ].l.{2,99}a.e|.[wewewe][ewewew]..m.)$" | tr 'A-Z' 'a-z' | sort -r | sed 's/delaw//'

  209. du -sh * by sootman · · Score: 1

    du -sh *
    Calculates the sizes of all folders in the directory you're in. The 'h' means "human-readable." Can also use k (kilobytes) or m (megabytes, not on all systems) if you want absolute, comparable numbers.

    Also useful is curl. Great for, among many other things, download sequentially-named files:
    curl -O example.com/images/[01-24].jpg (that's a capital letter "o")

    And now it's time for a joke:
    Zen guru: What is the sound of one hand clapping?
    Unix guru: cat /dev/null > /dev/audio

    --
    Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
  210. Re:Lego by Pogue+Mahone · · Score: 1

    Re: your comment about lego ... I agree. Pipes are probably the best feature. Most people can pipe the output of something through less, occasionally some can manage a 3 stage pipeline. My current record is 37 stages. And from vi you can pipe a range of lines through a shell pipeline and put the result back where the original lines were. That's neat - I use it frequently, and hardly anyone else knows about it. But the really nice thing about Unix is that there's always something new to learn. I've been using it in various forms for around 20 years now, and I still discover things I didn't know about.

    --
    Every bloody emperor has his hand up history's skirt [Peter Hammill/VdGG]
  211. Command Line Navigation by carrier+lost · · Score: 1

    ctl-a: Move to beginning of command line
    ctl-e: Move to end of command line
    ctl-u: Wipe command line from cursor position to beginning

    There are more, but these are the ones I can remember because they're the ones I use the most.

    1. Re:Command Line Navigation by ElizabethGreene · · Score: 1

      -d - delete to end of word.

      Funny story.. In Linux, is jump to end of line. In MS Sql Management Studio/Query Analyzer it is "Execute". The distinction is really important if you were trying to jump to the end of a query to add a WHERE clause to a delete statement. (DOPF!!) Lesson learned.

      -ellie

    2. Re:Command Line Navigation by carrier+lost · · Score: 1

      I forgot one...

      ctl-r - search back in the history for a pattern in a previous command.

  212. Use NX to make X forwarding actually usable by mangobrain · · Score: 2, Informative

    Even better: use NX (http://www.nomachine.com/ - includes a "free edition"). Basically heavily compressed X forwarding, but also includes niceties such as being able to disconnect and reconnect sessions without killing the X clients. I use it over a VPN on the rare occasions I work from home, on a standard ADSL connection. Typing on an NX forwarded xterm is almost as quick as when SSH-ing in directly (which may seem a somewhat pointless use-case, but is the closest I know how to get to the behaviour of "standard" SSH with X forwarding). I also find I get *much* better responsiveness if I run VMWare Server Client on my work box, forwarded over NX, instead of running the client at home and connecting to the work VMWare server from there.*

    Also available as FreeNX (http://freenx.berlios.de), but harder to set up IME.

    * Which may just be another way of saying "VMWare's protocol sucks", but regardless, turns it from near unusable to very useful.

  213. xargs, set by zizzo · · Score: 1

    It amazes me how many people use find & grep but don't know about xargs. Built in indexing is change the way we compute but not to long ago the fastest way to find anything in a hierarchy was:

    $ find . -print0 | xargs -0 egrep "somepattern"

    This uses egrep (used to be faster than grep), xargs (to minimize forking), and the -0 hack (to safely handle weird paths).

    Another gem along the lines of "cd -" that apparenlty I'm the only one to use:

    $ cd /godawfullongpath/.../evenlonger/...
    $ a=`pwd`
    $ cd /someotherplace/.../thankgodfortab/...
    $ cp $a/* . # or somesuch
    $ b=`pwd`
    $ ...etc...

    Using just plain old shell skills like setting variables to temporarily hold long path names can save lots of time and reduce errors.

  214. Edit your commands in visual mode by klui · · Score: 1

    I like doing the following while writing quick loops (which I often do) in ksh/bash. I prefer vi...

    Press ESC to get into command line edit mode or just after I recall a command, then press v to edit my command. The only disadvantage is I can't place this edit "process" in the background. Which is the reason why you should install screen or just open another window.

    PuTTY has been something I've grown to like as a terminal under Windows. While it has problems with long buffers, it's nice to be able to double-click on long filenames that wrap around the screen.

  215. Re:Hail to the chimp! by Omega996 · · Score: 1

    seriously.

  216. Re:Creating an empty file using redirection by Skal+Tura · · Score: 1

    or just: touch

  217. Things in my toolbox by jsiren · · Score: 1

    Here are some tools I use regularly, not in any particular order:
    find, grep, sed, awk, perl (the usual suspects)
    | `` < > >> (standard tools)
    && || (boolean operands)
    [ ] (test for various things; see test(1))
    ^Z bg fg %number (job control, although some vendors still ship shells that don't do job control... argh!)
    killall (or killproc, depending on system; kills processes by name)
    kill -0 (see if process exists)
    fuser, lsof (to see who's using what)
    until something; do sleep interval ; done (try something every interval until successful)
    set -o vi (when stuck with ksh on a random HP system)
    ssh, scp, sftp (need I say more?)
    dd (to copy however many bytes from wherever to wherever else)
    screen (extremely handy)
    etc.

    --
    Usage: km/h for speed (kilometers per hour); kph for very slow impulses (kilopond hours).
  218. A few things I haven't seen yet by Pheersome · · Score: 1

    alias find="noglob find" # Lets me say "find . -name *.pdf" (etc) without escaping the '*'. I also do this with dpkg-query.

    alias topten="(sort | uniq -c | sort -rn | head)" # Print the top ten most common lines in whatever gets piped in

    diff local_file.txt =(ssh remotehost cat remote_file.txt) # ssh is like a distributed file system, right?
    # The =(cmd) syntax is pretty useful in general, for where a command expects a filename and you want to give it input from another command.

    file =some-command # =word expands to the result of a $PATH search for word. This command tells me what kind of thing I'm executing...
    readlink -e =some-command # ... unless it says "symlink", in which case the next step is to recursively chase symlinks until I get a real file...
    file $(readlink -e =some-command) # ... *then* I can ask what kind of file it is. $(cmd) is preferable to `cmd` because it nests properly.

    --
    Better to light a candle than to curse the darkness.
  219. Re:rev (uniq too) by The+Bean · · Score: 1

    Instead of "sort | uniq" you could simply use "sort -u"

  220. Re:Listing directory contents without the ls comma by EvanED · · Score: 1

    On dos you can rename fairly intuitively, "ren *.txt *.text". On Linux, you're likely to hurt yourself and/or your files (most likely in a different order) if you try that.

    There's another example that comes up fairly often for me that is substantially easier with the Windows, which is you want to search all, say, *.c files in the current directory or a subdirectory. (Ignore that you could sort of do this particular example with tags.) With the Windows way, it would be easy: grep --recursive "class Foo" *.c. (I always spell out --recursive 'cause it seems that some programs use -r and others -R, and I can never be bothered to figure out which way it is.)

    With zsh, it's also sometimes easy: grep "class Foo" **/*.c. (Incidentally, ** patterns are probably the single biggest reason I use zsh.) There are two problems with this. First, you need to be using zsh, which is far from the common choice. It's often not even installed. Second, it's extremely easy to run into a "too many arguments" thing because of it.

    With a relatively recent version of grep, it's also pretty easy: grep --include "*.c" --recursive "class Foo" .. The command is starting to get a little long, and --include (and the converse, --exclude) must be spelled out. You also need a new enough version of grep. Your home system probably has it, but I think it hasn't been long since I didn't on my school/work computer. (I'm a grad student, it's not clear which of those it is. ;-)) Finally, this is fairly specific to grep: they had to implement the --include and --exclude flags themselves. Most other programs wouldn't understand that.

    If you don't have a new enough version of grep, don't have or want to use zsh, or have too many files for **/*.c to work, you have to revert to some incantation of find paired with grep. I actually don't know how to do this right, and have to look it up every time. find . -name "*.c" | xargs grep "class Foo" doesn't work, because then you have no idea what file the hits are in. (If provided only one argument it won't print the file name, and xargs will call it a bunch of times with one argument each time.) This means that, since I can never remember what the switch is, I have to open up grep's man page to find out that what I really need is -H. So the command line becomes find . -name "*.c" | xargs grep "class Foo" -H. To behave better in the face of filenames with spaces or special characters, even that is really not what you want, and you have to expand it further to find . -name "*.c" -print0 | xargs -0 grep "class Foo" -H. For something that on Windows would be grep "class Foo" *.c.

    Don't get me wrong, the Unix way is better, more predictable, and more flexible; I just wanted to point out how strong the Windows benefit can be, even beyond the other "rename" example.

  221. Re:This one always surprises people for some reaso by Hatta · · Score: 1

    You might like mlocate:

    mlocate is a new locate implementation. The 'm' stands for "merging": updatedb reuses the existing database to avoid rereading most of the file system, which makes updatedb faster and does not trash the system caches as much.

    --
    Give me Classic Slashdot or give me death!
  222. awk by hydrofix · · Score: 1

    Learn it, love it. It's very easy and you'll master it fine after just reading through the 900 lines-of-text man page. (In comparison, man bash is 4900 lines of text)

    1. Re:awk by dutchd00d · · Score: 1

      I use "man zshall", you insensitive clod!

      (19819 lines of awesomeness!)

  223. Using the "right" interpreter with env by dwheeler · · Score: 4, Interesting

    If you begin your scripts with:

    #!/bin/env python

    and replace "python" with whatever your script interpreter is, then you can have the script automatically use whatever interpreter is first on your PATH. This is especially nice if you're "not sure where the interpreter executable is", e.g., it might not be in "/usr/bin" - so this helps portability. (The POSIX standards GUARANTEE that "env" is in /bin, so this is VERY portable.) This also makes it easy to try out new interpreters (load a test version's binaries in ~/python-beta, add that first to that PATH, and now the test version's interpreter is used.) This does have the extra cost of starting up /bin/env first, but often that's not a big deal.

    Yes, this is a bad idea if the attacker can control the PATH & this is security-relevant. But you can't securely run most interpreters directly anyway, so that's usually not relevant.

    --
    - David A. Wheeler (see my Secure Programming HOWTO)
    1. Re:Using the "right" interpreter with env by xerxesdaphat · · Score: 1

      Ubuntu 8.04:

      tom@ubuntu:/tmp$ /bin/env python
      bash: /bin/env: No such file or directory
      tom@ubuntu:/tmp$ /bin/en
      tom@ubuntu:/tmp$ ls /bin/e* /bin/echo /bin/ed /bin/egrep
      tom@ubuntu:/tmp$ whereis env
      env: /usr/bin/env /usr/share/man/man1/env.1.gz

      Bugger. Is it really POSIX?

      --
      The Shoes of the Fisherman's Wife Are Some Jive Ass Slippers
    2. Re:Using the "right" interpreter with env by hackstraw · · Score: 1

      OS X, (BSD derived) puts env in /usr/bin.

      I've never been a fan of the #!/usr/bin/env thing. So many people combined with retarded shells that can't reliably set things like the PATH correctly makes using env unreliable. I've found it to cause more problems, than solve them.

      I've seen different UNIX systems where the PATH is set both before and after sourcing the user's .files. I've read the INVOCATION section of bash so many times, I almost understand it.

      The most sane shell I've ever come across is zsh. In all invocations, it sources .zshenv if it exists. The most insane shell I've come across is [t]csh. bash is tolerable.

      I have in my .zshrc file the following:

      bindkey "^K" history-search-backward
      bindkey "'J" up-line-or-historyward

      handy to do vi and toggle between ^K and ^J to see past invocations of vi (or other commands).

      I never use the history command.

      Oh, and if rm -rf /foo/bar gives you trouble, just do sudo !!

      Another trick I use is grep . * or similar. For smaller files, this will output the contents of the files prepended with the name of the file. Comes in handy from time to time.

      Its weird, after you've been doing UNIX commands for over 10 years, they just come out of your fingers, and you don't really think much about them. I'm sure there are tons more tricks that I know, but they are in muscle memory, not my brain.

    3. Re:Using the "right" interpreter with env by Just+Some+Guy · · Score: 1

      The POSIX standards GUARANTEE that "env" is in /bin, so this is VERY portable.

      s#/bin#/usr/bin#

      --
      Dewey, what part of this looks like authorities should be involved?
    4. Re:Using the "right" interpreter with env by PastaLover · · Score: 1

      Very portable, except for making it impossible to target a specific version of python of course, meaning as soon as you upgrade from python2.4 to python2.5 all your scripts break and you have to muck around with the PATH to get it to work again. Using /usr/bin/env is really more of a hack than anything genuinely useful, just hardcode the location of your python interpreter and let the installer/packager/users worry about where to point it to.

  224. Re:This one always surprises people for some reaso by Hatta · · Score: 1

    Wow, talk about reinventing the wheel. Is there a good reason you go to all that trouble?

    --
    Give me Classic Slashdot or give me death!
  225. PTRACE is magic by abaddon314159 · · Score: 1

    I once had to admin a system that used some software that kept its own log file and wouldn't roll the log file. The software had to keep running non-stop but its logs were so verbose that eventually it started filling up the disk and kept the log files open so you couldn't cleanly swap out the disk even. solution: small gdb script to attach to the daemon and open/create a new file at the proper place dup2() the file handle with a new (closing the old), and then detach and bzip the old file... PTRACE is magic.

  226. Su and sudo are for wimps by shewfig · · Score: 1

    What's fun is adding my admin account's ssh public key to root's authorized-keys, then aliasing something to:

    ssh -X -f -l root localhost [favorite terminal]

    Instant su, in a new terminal window, without using su. Who needs root passwords when you have keys?

  227. Time warp by SchmellsAngel · · Score: 5, Informative

    cal 9 1752

    --
    We must repeat.
    1. Re:Time warp by etwills · · Score: 2, Funny

      cal 9 1752

      WHAT DO WE WANT? "Eleven days back!"

      WHEN DO WE WANT THEM? "...!!"

  228. Perhaps already mentioned by tdashton · · Score: 1
  229. xargs examples by Bill+Dimm · · Score: 1

    Wikipedia gives some xargs examples.

  230. fun with shells by bonkeydcow · · Score: 1

    $ cat food cat: cannot open food

    1. Re:fun with shells by bonkeydcow · · Score: 1

      Grr stupid line breaks.

      $ cat food
      cat: cannot open food

    2. Re:fun with shells by Bombcar · · Score: 1

      GNU has broken a bunch of those oldies.

  231. Favourite sshisms by Shazow · · Score: 1
    My favourite ssh thing to do is database dump/import over ssh:

    ssh user@remotehost 'psql "COPY mytable TO STDOUT"' | psql "COPY mytable FROM STDIN"

    Remote device images are also win:

    ssh user@remotehost 'dd if=/dev/hda1' > sdb.iso
    mkdir -p /mnt/iso
    mount -o loop sdb.iso /mnt/iso
    ls /mnt/iso # Win!

    Not to mention combining ssh tunnel with more ssh tunneling and then more ssh! Mmm, ssh. Almost as awesome as netcat. - shazow

  232. aliases by Tumbleweed · · Score: 1

    I like aliases. I see people typing out things over and over again for now reason. I use these:

    lla (ls -la)
    lart (ls -lart)
    projectname (cd /usr/local/html/projectname or somesuch)

    And if you want the fastest possible safe shutdown/restart:

    shutdown -rn 0
    shutdown -hn 0

    for restart and halt respectively. I call this the 'Express Elevator to Hell - System Going DOWN!' command.

    I don't do those often enough to bother with aliases. :)

    1. Re:aliases by thogard · · Score: 1

      # kill -1 -1
      or
      #kill -9 -1
      will restart userland and halt systems faster.

    2. Re:aliases by Tumbleweed · · Score: 1

      I'll have to try that out. Thanks.

  233. hu..?? by meuhlavache · · Score: 2, Funny

    What the hell all those geeks are talking about?

  234. Keeping an eye on long installs by roc97007 · · Score: 1

    #Watching for when the log stops growing:
    while true
    do
          ls -lt logs/install.log
          echo ""
          sleep 2
    done

    #Show Java process number and name:
    ps -ef | grep -i java | grep -v grep | awk '{print $2, $NF}'

    #Kill 'em all
    kill -9 `ps -ef | grep -i java | grep -v grep | awk '{print $2}'`

    --
    Oliver's law of assumed responsibility: If you're seen fixing it, you will be blamed for breaking it.
    1. Re:Keeping an eye on long installs by Kardos · · Score: 1

      #Watching for when the log stops growing: while true do ls -lt logs/install.log echo "" sleep 2 done

      #Show Java process number and name: ps -ef | grep -i java | grep -v grep | awk '{print $2, $NF}'

      #Kill 'em all kill -9 `ps -ef | grep -i java | grep -v grep | awk '{print $2}'`

      Re: watching log file: try the "watch" command

      Re: kill-them-all: kill -9 -1 would be easier

    2. Re:Keeping an eye on long installs by fatphil · · Score: 1

      Instead of:
      ps -ef | grep -i java | grep -v grep

      just do:
      ps -ef | grep -i j[a]va

      which doesn't match the grep.

      --
      Also FatPhil on SoylentNews, id 863
  235. Sort by Dadoo · · Score: 1

    Speaking of "sort", does anyone know why the GNU people felt they needed to change the syntax? On Unix, the command would be:

    du -s * | sort +0n

    That seems like a pretty significant change, for very little - if any - improvement. I know you can set "_POSIX2_VERSION=199209", but that will break scripts written for the new syntax. It's a big pain for those of us who use both Linux and Unix systems.

    --
    Sit, Ubuntu, sit. Good dog.
  236. Delete whole words by tommy · · Score: 1

    I use esc-backspace to delete whole words. Others have already mentioned it, but I also love ctrl-r to bring up your command history.

    --

    I have a woman and money. Life is good.

  237. less -S by YenTheFirst · · Score: 1

    the -S option disables wordwrap. VERY convenient when viewing logs that have long lines. less -S (logfile), and then the 'F' command. :)

    --
    It's not stupid. It's Advanced.
  238. the for loop by Niobe · · Score: 1

    or even better:
    for log in `ls *log` ; do grep C4K_EBM-4-HOSTFLAPPING $log | grep "Oct 4" | cut -d' ' -f11- | sort | uniq -c

  239. Fun w/ scp by fishinatree · · Score: 1

    I enabled ssh access on all the computers in my house, and I use scp to get files from their computers, upload it to mine where I mess around with it and then upload it to their computer in place of the document they had saved. scp [file/path/on/your/computer] user@location:[path/on/their/computer] Also, if you ssh into someone's computer, use the 'say' command to have their computer start talking to them. Or, use osascript to get iTunes to start playing an annoying song really loud.

  240. Remember tar pipes; Church of BSD by John+Sokol · · Score: 1

    tar -cf - * | rsh -l sokol 192.168.1.105 "tar -xf -"

    Some interesting related sites I have on Unix trivia tricks and tips.

    The best utils are awk, sed, grep and bc, just using these there are so many things possible.

    Yes they could be cleaned up some.

    http://www.churchofbsd.org/
    and
    http://www.unixprogram.com/

    --
    I am always doing that which I can not do, in order that I may learn how to do it. - Pablo Picasso
  241. Re:This one always surprises people for some reaso by harry666t · · Score: 1

    Yes, there is. / changes less frequently so there is no point in running updatedb more often than once a week. There's no point in updatedb indexing /home because the index will be quickly out of date, and I would need to run updatedb more frequently (and waste time re-indexing /, which probably hadn't changed at all). So I simply have two indexes: one for / and one for my $HOME. It actually took me more time to write this post than to come up with that solution and implement it (one line in .bashrc, one quick command whenever I think the index is out of date).

    Talk about using a right-sized wheel.

  242. This is a great one... by mckillnm · · Score: 1

    ~$ yes > /dev/pts/0

    Just watch the other persons term...!

  243. Use 'at' instead by Joseph+Lam · · Score: 1

    Geeks can press Ctrl-C while sleeping. I use 'at' which forces me through the annoyance of finding out the PID and kill it. It's REALLY irritating and works well.

  244. Don't try this at home by BratNZ · · Score: 1

    unlink /

    (Works instantly, unlike rm -rf /) :-)

  245. X forwarding by nathan.fulton · · Score: 1

    ssh [server] -x Now, launch xclock or firefox, or anything that uses X (so... anything with a gui. Even gnome-session.) The application will launch client side, ran from the server.

  246. File under "tricks" by dghcasp · · Score: 1

    I once was a sysadmin at a company where official policy was "every user has the root password."

    Since I didn't want people wandering through my pr0n^H^H^H^H work directory, my home directory was empty except for a single directory: "my/directory". Yes, a single directory with a slash embedded in the name.

    Only one other user at the company was smart enough to figure out how to cd(1) into the directory. Fortunately, he doubled the size of it.

    1. Re:File under "tricks" by buss_error · · Score: 1

      An even better trick -
      make a small partition on a drive or ram disk (nothing more than 10meg) and create your work directory like so:

      ~/home/workdir

      Stuff all the stuff you what to hide in workdir, then mount the partition over it. What ever you put in before the mount disappears, what ever is on the partition that is mounted is put in it's place. One draw back is that even you can't get to it without dismounting the partition.

      Another trick:

      I run several mail machines and have directories of interest that are different on each. In the .profile or what ever, assign that directory to a variable. EG: idir="/usr/spool/locks/lp/admins/lp/interfaces"
      hdir="/var/spool/mqueue"

      Need to go there? cd $idir

      Need to lock out vendor users whose passwords were unlocked during the day, then clean up the locks directory, and kick off a disk spool back up? Script it all and call it miller_time

      --
      Necessity is the plea for every infringement of human freedom. It is the argument of tyrants; it is the creed of slaves.
  247. Re: by MonoSynth · · Score: 1

    /Funny F3 F3 F3 F3... (That's not UNIX, that's what I'm doing right now in Firefox :) )

  248. shell [ syntax and if tests by Michael+Wardle · · Score: 1

    A lot of people don't know that [ expression ] in bash is just a shortcut for test expression .

    The follow on from this is that if [ ... ] is just if testing the exit status of a command, so you can use if any command .

  249. Don't forget cd (directory_name) by koafc2 · · Score: 1

    One neat little trick I like is you can do: cd (directory_name) and it'll switch your current working directory to the one you specified!!

  250. My Favourite commands (strace, tcpdump, and so on) by Isomer · · Score: 1

    strace: Finding out why that program is failing with an error, but not explaining what the error is about. For example if your program dies with "Not such file or directory" but doesn't say what it was trying to find, strace will generally show a syscall near the end that failed with -ENOENT. strace is also useful for finding out where on earth this program has decided to log.

    tcpdump: Watching what networking a program is doing. Often useful for figuring out why packets aren't going where you expect, or if it's the local or remote machine that's having problems.

    gdb/valgrind: Both are useful for looking at why a program crashes.

    if strace isn't verbose enough, theres also ltrace, which can show you how a program is interacting with a specific (or all) libraries.

  251. Slashdot Record? by IorDMUX · · Score: 1

    I know it's a bit off-topic, but this appears to be quite the momentous day for Slashdot! Two of today's stories have broken the 1000-comment mark, and the top five stories of the day have totaled over 5200 comments!

    Can anyone provide any insight as to the possibility of a record having been set in Slashdot's user responses, today? ... or if anyone actually cares?

    ...Maybe it's just election withdrawal... I think I still need my statistics.

    --
    >> Standing on head makes smile of frown, but rest of face also upside down.
    1. Re:Slashdot Record? by nocomment · · Score: 1

      IIRC 9/11 had a lot more.

      --
      /* oops I accidentally made a comment, sorry */
      /* http://allyourbasearebelongto.us */
    2. Re:Slashdot Record? by duguk · · Score: 1

      Sorry! It's my fault. I'm off work this week :o)

  252. Curiously absent from the many suggestions by ehintz · · Score: 1

    I would have thought apropos would be apropos in current context.

    --
    ehintz
  253. timecat by Lost+Engineer · · Score: 1

    time cat
    times how long it takes you to press ctrl+d.

  254. You really need to know this one ... by schrom · · Score: 1

    :q!

  255. My favorite simple shell aliases by Khopesh · · Score: 1

    # a limited selection of my simplest shell aliases, w/out commercial UNIX clauses

    # search running processes (like "psl firefox")
    alias psl='ps auxww |egrep'

    # colored/pretty directory listings
    if uname -s |grep BSD >/dev/null
    then # we're in BSD
      export LSCOLORS="exgxfxDacxBaBaCaCaeaEa"  # match GNU color scheme
      alias ls='ls -phG'
    else # we've got GNU
      alias ls='ls -ph --color=auto'
      alias l.='ls -A -I"[^.]*"'   # show dot-files (only)
    fi
    alias ll='ls -l'   # long-listing

    # grep with color (green instead of red), w/out breaking non-GNU grep
    export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'

    # show a file (or stdin) w/out hash comments
    alias nocom='sed -e "/^[^#]/!d" -e "s/[  ]*$//"'

    alias cdo='cd "$OLDPWD"' # could also do cdo='cd -' but that creates output

    # show a website's headers
    alias whead='wget -q --save-headers -O - $1 |sed "0,/^[^A-Za-z0-9]*$/!d"'

    # see also my utility shell scripts at http://khopis.com/hacking.html

    --
    Use my userscript to add story images to Slashdot. There's no going back.
  256. esc-. by Anonymous Coward · · Score: 1, Informative

    in bash, esc-. is a fantastic shortcut

  257. Re:Lego by mattack2 · · Score: 1

    The grandparent's statement about bash seems strange, since this is a feature of all shells. (Though this is the first time I remember someone else calling it Lego-like, I've been using that analogy for a long time. I *really* wish something in the GUI world came close to the "pull useful bits from a bunch of programs and throw them together" usefulness of CLI tools. (OpenDoc came the closest as far as I know, though admittedly it's the only GUI component software system I used to a significant degree.) Then again, hypocritically, some of the CLI programs I like most go more towards the "everything including the kitchen sink" end of the spectrum (not quite as much as emacs), like trn, alpine, vim.

    But for the parent post, this reminded me of what has become one of my favorite tools of the past few years. "cut"

    I seem to have to go through files of output -- perf tools that output numbers in some textual format or something else I need to search through. I realize most geeks probably do it with regular expressions or something, but often I can do it easier (FOR ME) to do it with cut.

    e.g.
    sometool > outputfile
    (so that I can save it and play with my searching through the output)

    cat outputfile | grep somestring | cut -f 3 -d ' '
    sometimes I have a few cut commands piping into each other since it's easier to 'chop out' specific fields that way, with a different delimiter character. (In fact, I very very rarely deal with tab-delimited files, which is the default.)

  258. Re:Listing directory contents without the ls comma by multipartmixed · · Score: 1

    Of course. Using backticks would require you to be able to fork and spawn subshell.

    Real nerds use tools as they are appropriate and to get the job done. Not for silly elitist reasons.

    --

    Do daemons dream of electric sleep()?
  259. truncate an open file by meuon · · Score: 1

    Needing to truncate a large file (large logs) while other things are reading/writing to it and the file is open: cp filename.ext

    --
    Mike Harrison -
    1. Re:truncate an open file by AnteTempore · · Score: 1

      Shorter:

      >filename.ext

  260. Re:Listing directory contents without the ls comma by spikedvodka · · Score: 1

    don't forget `echo $?` and of course, the ever-popular backticks

    --
    I will not give in to the terrorists. I will not become fearful.
  261. I take for granted that "write" won't work by dAzED1 · · Score: 1

    (names changed to protect the me) [dazed1@someplace]:/tmp > ls -al /dev/pts/20 crw------- 1 dazed1 tty 136, 20 Nov 5 17:37 /dev/pts/20 [dazed1@someplace]:/tmp > mesg y [dazed1@someplace]:/tmp > ls -al /dev/pts/20 crw--w---- 1 dazed1 tty 136, 20 Nov 5 17:37 /dev/pts/20 Why in the WORLD would you want your tty to be writable by anyone other than yourself?

    1. Re:I take for granted that "write" won't work by dAzED1 · · Score: 1

      damn you slashdot and your space-destroying ways...

      [dazed1@someplace]:/tmp > ls -al /dev/pts/20
      crw------- 1 dazed1 tty 136, 20 Nov 5 17:37 /dev/pts/20
      [dazed1@someplace]:/tmp > mesg y
      [dazed1@someplace]:/tmp > ls -al /dev/pts/20
      crw--w---- 1 dazed1 tty 136, 20 Nov 5 17:37 /dev/pts/20

      Why in the WORLD would you want your tty to be writable by anyone other than yourself?

    2. Re:I take for granted that "write" won't work by mollymoo · · Score: 1

      damn you slashdot and your space-destroying ways...

      It was only recently I discovered that if you set you posting prefs for Slashdot to "Plan Old Text" you can still use all the HTML stuff but it preserves your line breaks. I just don't get the point in HTML Formatted (my previous default and I presume still yours) since I discovered that. I don't even want to think of how many <br>s and <p>s I have needlessly typed over the years.

      --
      Chernobyl 'not a wildlife haven' - BBC News
  262. favs by c-bo-licious · · Score: 1

    Lets say you forgot to put a & at the end of your cmd!! Oh no!!! you can hit Ctrl+Z and enter 'bg' to make that task a background task and get back to a command prompt. nice and renice are excellent for changing processor time priorities (give something more processor time to make it go faster) root and super users can do more with this. On a University or other large scale server you can always type 'last' and see the last machine name and time that everyone logged in from. Grep the output to look for someone in particular. You can use a trace route to track people down this way.

  263. Geek meets girl... by MtlScorpion31 · · Score: 2, Funny

    who;uname;talk;date;wine;cd ~;talk;touch;talk;touch;more;finger;mount;fsck;yes;more;yes;yes;umount;make clean

  264. Process substitution by this+great+guy · · Score: 1
    It's a Bash extension that lets you runs processes connected to a FIFO or /dev/fd devices. Example to diff the output of 2 commands without using temporary files:

    $ diff -u <(echo foo) <(echo bar)

  265. Shells... by BrokenHalo · · Score: 2, Informative

    One of the most timesaving things I ever did was to replace the default sh or bash with zsh.

    zsh has so many features, it would be impossible to list them all here. In fact, I can't claim to know them all, but everybody takes what works for them.

    Suffice to say that the completion, iteration, history and redirection tools are second to none if you're as lazy a typist as I am.

    1. Re:Shells... by goodwid · · Score: 2, Informative

      Yeah, zsh is definitely awesome, but by the time I found it, I had already many years of tcsh usage, and not the inclination to re-learn a new shell. But I agree, zsh is amazing.

      More tcsh goodness: the ability to add tabcomplete for whatever you want. For example, this:

      complete kill 'n/*/`ps axu|grep $USER| awk \{print\ \$2\}`/'

      lets you do tabcomplete on your processes' pids. Handy.

      --

      The net interprets censorship as damage and routes around it. -- John Gilmore
  266. esc-j in ksh or bash by cts5678 · · Score: 1

    I can't believe no one else has posted my favorite yet: command "precall" in the shell. Just go into the shell, then make sure you've entered set -o vi, then if you want to recall the last command you used, hit esc-k . Pretty basic right? Then, if you don't know what command to enter next, hit esc-j to "precall" it... Note - does not work on all *nixes .

  267. Oldies but goodies by Anonymous Coward · · Score: 1, Funny

    for example:

    % If I had a ( for every $ the Congress spent, what would I have?
    Too many ('s.

    http://www.csd.uwo.ca/~magi/personal/humour/Computer_Audience/Funny%20UNIX%20Shell%20Commands.html

  268. pipe into /bin/sh by maiden_taiwan · · Score: 1
    Two techniques I particularly remember for increasing my Linux effectiveness were:

    1. find piped into xargs (or "find -print0" piped into "xargs -0" for safety) to process a directory tree in a single command

    2. Printing commands on stdout and piping them into bash. For example, if you want to rename a bunch of files, and you put the old names into file "oldnames" and the new names into "newnames", one per line, you can do the mass renaming with:

    $ paste oldnames newnames | sed 's/^/mv /' | bash

    generates a sequence of "mv" commands and executes them.

    First time I saw each of these, it was so eye-opening.

  269. netcat by morkk · · Score: 1


    NC(1)
    NAME
                  nc - TCP/IP swiss army knife
    SYNOPSIS
                  nc [-options] hostname port[s] [ports] ...
                  nc -l -p port [-options] [hostname] [port]
    DESCRIPTION
                  netcat is a simple unix utility which reads and writes data across network
                  connections, using TCP or UDP protocol.

  270. Ported to Ubuntu by El_Oscuro · · Score: 2, Informative

    (posted with pbcopy)
    503 sudo apt-get install xclip
    504 echo xclip -in -selection clipboard > bin/pbcopy
    505 chmod ug+x bin/pbcopy
    506 echo xclip -o -selection clipboard > bin/pbpaste
    507 chmod ug+x bin/pbpaste
    508 history | pbcopy

    --
    "Be grateful for what you have. You may never know when you may lose it."
  271. Say What? by LittleBigPile · · Score: 1
    In a terminal/xterm on your Mac:

    say -v Zarvox Zarvox is much displeased with your Unix skills, fool

    This becomes really useful if you can ssh the command to someone else's Mac and really freak'em out.

    --
    "If you have no enemies, you have no character" -- Paul Newman
  272. 10! by Anonymous Coward · · Score: 3, Funny

    > There's two kinds of real UNIX Admins.

    Actually, there are 10 kinds of UNIX admins...

    1. Re:10! by knorthern+knight · · Score: 1, Funny

      Actually, there's 3 kinds of UNIX admins...
      - those who can count
      - and those who can't

      --

      I'm not repeating myself
      I'm an X window user; I'm an ex-Windows user
    2. Re:10! by c4ffeine · · Score: 1

      Actually, you're wrong. There's 1 kind of unix admins:
      -those who start indexing at 0
      -those who don't

      --
      "73% of quotes on the Internet are made up" -Ben Franklin
    3. Re:10! by MrResistor · · Score: 1

      I believe that's 11 kinds

      --
      Under capitalism man exploits man. Under communism it's the other way around.
    4. Re:10! by KillerBob · · Score: 1

      To make matters worse, he completely missed the joke he was replying to....

      mm.. self-deprecating humour....

      --
      If you believe everything you read, you'd better not read. - Japanese proverb
  273. suspend by auuid · · Score: 1
    The "suspend" command is like doing ^Z to shell you're in so you can pop up to the shell that invoked it. E.g.,

    $ su smith
    $ ... do some commands as smith ...
    $ suspend
    $ ... do some commands as yourself ...
    $ fg
    $ ... do some commands as smith again ...

  274. a shield against rm -rf * by Meshugga · · Score: 1

    would be

    touch -- --foobar

    (how to undo this is left to the reader as an exercise)

    ok, this was funny, but that one is real:

    touch 0
    sudo chattr +i 0

    (though that one has a flaw, too)

  275. cat /dev/random /dev/mouse by CrunkCreeper · · Score: 2, Insightful

    This is probably the most fun I've ever had. Since random is usually generated by different intervals 'from' the mouse, it'll keep on running and click on stuff all over the screen.: cat /dev/random > /dev/mouse Also this makes some pretty interesting sounds. Last time I tried it didn't work, but it may with older kernels.: cat /dev/kcore > /dev/dsp I've made the best scripts at work. I aliased a script for ls that'll print out files in the directory spelled out in dots, and it makes a dot-matrix type sound for each one with the beep command. You've got other fun things like wtf, cowsay, cowthink. Or you can watch pr0n at school over SSH with aa-xine. And don't forget the awesome cron job that plays at 1AM every morning for the night shift that blares out LEEEEROOOOOY JEEENKINS! My speakers are usually turned off when I come in the next day. I just want to make sure that no one is falling asleep on the job. :-p

  276. Re:bang dollar by seaturnip · · Score: 1

    I prefer to use alt-. instead (in bash).

  277. Re:Lego by decaying · · Score: 1

    grep somestring outputfile | cut -f 3 -d ' '

    --
    ----- One piece short of Legoland
  278. Re:zgrep? by Neon+Spiral+Injector · · Score: 1

    zgrep is actually part of the gzip package rather than an extension to grep. It performs "gunzip -c | grep" behind the scenes.

  279. Re:Listing directory contents without the ls comma by Chris+Pimlott · · Score: 1

    There's no reason you couldn't opt to write unix commands that work in the DOS way; you'd just have to do the globbing yourself and you'd have to put a backslash in front of the wildcards when you call it to prevent the shell from expanding it - e.g.

    myrename \*.htm \*.html

    I think the unix version of pkzip works like this.

  280. Re:Listing directory contents without the ls comma by Chris+Pimlott · · Score: 1

    The equivalent find command would be

    find . -name \*.c -exec grep -l {} \;

    which, I'll grant you, is a bit daunting if you're not comfortable with find, but it's pretty routine once you get the hang of it.

    The zsh notation looks handy, though. Java ant files use a similar syntax, e.g.

  281. Re:pipe through SSH to transfer files by dorix · · Score: 1

    Any reason why "scp somefile bubba@192.168.1.1:" won't work for you?

  282. Various useful commands I use daily. by Abattoir · · Score: 1

    Here's some very handy commands. I use most, if not all, of these on a regular basis.
    $ namei -m /var/log/httpd/error.log
    f: /var/log/httpd/error.log
    drwxr-xr-x /
    drwxr-xr-x var
    drwxr-xr-x log
    drwxr-xr-x httpd
    -rw-r--r-- error.log

    Substitute a string in a variable in bash.
    $ version="6.4.4-5"
    $ echo ${version%%-[0-9]*}
    6.4.4

    Exclude all the .svn files in a find, and look for a pattern in the results.

    find $1 -name '.svn' -prune -o -print | xargs grep -l "$2"

    Perl oneliner to convert an epoch to the current date/time.

    perl -le 'print scalar(localtime("1223234245"))'

    I also started doing a lot of work in Ruby last year after hearing about, and deploying at the company I worked for, a configuration management tool called Puppet. Along with Ruby scripting, I've come to love two excellent tools: rake and capistrano. The quick version, rake is a "make" for Ruby. It will execute shell commands and can do all kinds of awesome. Capistrano was originally written to aid in deploying Rails applications on multiple systems, and has also become a sort of glorified "ssh for loop" since it uses Ruby's Net::SSH class.

  283. xterm from firefox on a kiosk by mitch_feaster · · Score: 1

    If you're on some type of locked down kiosk that only has firefox (like on many school campuses) you can do a ctrl-p to print, click on properties, enter "xterm" in the print command text box, click print and you've got yourself a terminal.

    This is only a unix trick inasmuch as you're launching an xterm but aside from that it's pretty much a firefox ( < 3.0 ?) trick...

    --
    fun
    1. Re:xterm from firefox on a kiosk by mollymoo · · Score: 1

      Try using telnet:// or ssh:// URLs.

      --
      Chernobyl 'not a wildlife haven' - BBC News
  284. Re:Why does it have to be ./script ? by duguk · · Score: 1

    Who's to say someone hasn't written a script in the folder you're in called 'rm' or even 'ls' that you haven't seen? With the wrong permissions, you'd be running it without realizing!

    I'm sure you can do this in Windows with some cli apps (I'm guessing that 'dir' and 'type' probably won't work, but I'm sure there's some commands like 'start' that might do)

  285. tricks by Anonymous Coward · · Score: 1, Informative

    bash#set -o vi

    also

    $ls -tgo |less

    shows modified files first, useful for webmasters

  286. Very bad idea by TheLink · · Score: 1

    It could end up very inconvenient.

    It's safer to read what the command is before you execute it.

    Using ! completion is a very bad idea. It is a badly designed user interface.

    You might be sleepy/hungover/drunk/careless/unlucky and be on a different machine from what you expect.

    It certainly doesn't save time to do have to do history first to check then use !

    So you might as well do the CTRL-R thing.

    If you are doing something repetitive often enough, you write scripts to do it.

    --
  287. Exactly right. by warrax_666 · · Score: 1

    It's probably not a good idea to read/write randomly to /dev/core or /dev/mem, for instance.

    --
    HAND.
  288. That's nowhere near as much fun as this... by pestie · · Score: 1

    In a bash shell: :(){:|:&};:

    NOTE: Don't actually try this! Or, if you must, do it with a system booted into a live CD or something. It's a fork bomb. If I read it correctly, it creates a function called ":" which calls itself piped to itself (thus spawning two copies of itself), then backgrounds those two processes. The semicolon and the colon at the end actually invoke the newly-created function.

  289. rsync -craP (and others) by kobaz · · Score: 1

    I'm always syncing stuff from one place to another (we use rsync to deploy product updates).
    rsync -craP is a pretty good one.

    some other favorites (none of which are particularly stupid)
    jnettop (see exactly where your bandwidth is going)
    tcpdump
    netcat
    ps auxf (f for listing process parent/child tree)
    netstat -plunt (to figure out which process is using what port)
    shutdown -c (for those whoops moments)
    echo * (for when you have no 'ls' (whoops))
    nohup (no console output, but save it in a file instead)
    x11vnc (export your *current* display, rather than spawn a new independent vnc server)

    --

    The goal of computer science is to build something that will last at least until we've finished building it.
  290. Best Dilbert by theshowmecanuck · · Score: 5, Funny

    PHB: Do we have Eunuchs here?.. I heard it is very important for a company's IT department to have Eunuchs.
    Dilbert: I think you mean Unix. Yes we have a lot of Unix machines here.
    PHB: Oh... [pauses and thinks]... If the company nurse comes by, tell her I said, "never mind."

    --
    -- I ignore anonymous replies to my comments and postings.
  291. Shortcut links by Lally+Singh · · Score: 1

    Here's one I've started using:
    Make a .shortcuts directory. In it, put symlinks to the various places you go on your box.

    Then, pop this in your .bashrc:

    function go () {
            if [ -x ~/.shortcuts/$1 ]
            then
                    pushd ~/.shortcuts/$1 >/dev/null
                    DIR=`/bin/pwd -P`
                    popd >/dev/null
                    pushd $DIR
            else
                    echo "not found"
            fi
    }

    This way, you can put this on the cmd line
    go pubs/foo/bar

    For a symlink named pubs, with subdirectory foo, subdir of that bar.

    Use multiple symlinks for the same place, for misspellings and abbreviations.

    --
    Care about electronic freedom? Consider donating to the EFF!
  292. History searching by Lally+Singh · · Score: 1

    A little time on Solaris, and you start to love pgrep, which searches process names and returns their pids.

    One little function I love (in .bashrc):
    # Search history
    function hgrep () {
                    history | grep "$@"
    }

    Which quickly lets you regex-search your history in a single command.

    --
    Care about electronic freedom? Consider donating to the EFF!
  293. The dream of a working sysadmin: by adary · · Score: 1

    ps -ef | grep ^ | awk '{ print $2 }' | xargs kill -9 I used this a lot when i quit smoking :)

  294. watch by Bombcar · · Score: 1

    watch ls -l

    will run ls -l every two seconds. Useful for watching a file transfer or similar.

  295. Mom's favorite by Doodman · · Score: 1

    I've always enjoyed using this on any Linux box:

    $ who mom likes

  296. Re:Listing directory contents without the ls comma by goddidit · · Score: 1

    On dos you can rename fairly intuitively, "ren *.txt *.text". On Linux, you're likely to hurt yourself and/or your files (most likely in a different order) if you try that.

    File extensions are intuitive in DOS and Windows. In Linux they're just parts of the name.
    I personally try to avoid file extensions and I absolutely hate it when a program forces me to use them. The file command is for figuring out the content.

    --
    This .sig is exactly 120 characters long.
  297. Bash Stuff by friedmud · · Score: 1

    The three that I get the most "how did you do that?" type comments on is:

    1. Alt + . (period) to auto-fill the last used argument. For instance:

    mkdir somedir
    cd Alt+.

    Will automatically put somedir where you pressed Alt+. . This works on OSX as well but you have to make sure to select to use the "option key as meta key" in preferences.

    2. Bash Completion ( http://www.caliban.org/bash/index.shtml#completion ).

    This little tool provides programmable contextual completion capability to Bash. By default it comes with a bunch of useful capabilities. The one that seems to wow most of my coworkers is the ability to do TAB completion for files on remote machines when using scp... if you have passwordless ssh setup of course.

    3. Ctrl + R. Why do so few people know that you can do a recursive search of your history using in Bash? I go completely nuts sitting there watching people hit the Up key a thousand times to get back to some command they typed an hour ago.... just use Ctrl+R and start typing a piece of the command you issued (it doesn't even have to be the beginning). It will immediately begin matching and if you want to continue searching you can type more characters or press Ctrl+R to keep searching backwards...

    Anyway... these are just a couple that come to mind....

    Friedmud

  298. Pet Peeve by word_virus · · Score: 1

    People that can't use grep properly: cat'ing a file and piping it to grep is completely unnecessary. Ditto grep'ing a file for a particular string then piping that to wc for a line count. Grep does both, and can save you a ton of typing.

    1. Re:Pet Peeve by Lord+Bitman · · Score: 1

      because what's really awesome is using inconsistent syntax all the time just to save the use of ONE process on a modern system where thousands of processes may be created/destroyed in a second.

      I would much rather cat somefile | grep foo, or somecommand | foo, rather than re-typing "grep foo somefile" (or was it "grep somefile foo"? just to satisfy someone else's ideal.
      cat does one thing and does it well. There's no reason for grep to even have the ability to open files itself, rather than just reading off the stream.

      -- Some guy who thinks the world would be a better place if File->Open dialog boxes were launched as a separate process

      --
      -- 'The' Lord and Master Bitman On High, Master Of All
  299. some nice things i keep in my bash .profile by portscan · · Score: 1

    export PAGER=/usr/bin/less
    export EDITOR=/usr/bin/vim # emacs if you like

    # places i ssh to often:
    alias sshx='ssh user@server-x'
    # and if i have a command i frequently want to use as a 1-off:
    alias x-command='sshx command'

    # i really hate the pc speaker bell, so i put this in my .profile to disable it
    xset -b

    # also, for linux--get rid of it altogether (as root) by banning the driver module from your kernel:
    echo -e "#fucking pc speaker\nblacklist pcspkr" >> /etc/modprobe.d/blacklist

  300. RTFM on find and grep by Antique+Geekmeister · · Score: 1

    Few people use these commands fully. The ability to '-prune -xdev -o' under find, to prevent it descending mounted directories, is wonderful. The 'grep --exclude' option is also underused.

    For advanced students, I suggest a 2-week course on the intricacies of sed and awk. With good mastery of those tools, much of the desire for Perl evaporates.

  301. My favorite... by javajedi · · Score: 1

    $ kill -9 -1

  302. detach != dtach by RAMMS+EIN · · Score: 1

    Note that detach isn't dtach. detach detaches the program it starts from the terminal. dtach creates a virtual terminal and attaches the program to that, instead of to the terminal dtach was run from. You can then attach and detach from that virtual terminal (although, unlike with screen, dtach doesn't remember previous output from the command).

    dtach and screen are for commands that produce output, where you want to go away and come back to see the output at some point, and for interactive commands, where you have to produce input.

    detach is for things like daemons and X clients, where you aren't interested in looking at the output. If you want, you can redirect the output to a file. You can also provide a file to be used as input, but you can't interact with the program yourself. The program really is detached from the terminal.

    --
    Please correct me if I got my facts wrong.
    1. Re:detach != dtach by seaturnip · · Score: 1

      Ah, I should've actually visited your link instead of assuming you made a typo, sorry.

  303. Pizzatimer by t4c · · Score: 1

    Don't forget your pizza! for I in $(seq 1 100) ; do echo $I; sleep 6; done | dialog --gauge "PIZZA" 6 50 100

  304. cut, sort, and uniq by cathector · · Score: 1

    i only learned about cut within the last year, it's awesome.

    cut - extract particular fields from a delimited line
    sort - sort the lines of a file. is smart enough to recognize if it's sorting word or numbers.
    uniq - collapse and count consecutive identical lines in a file.

    i use these three fairly often to do one-off summaries of log files.
    i'm sure there's a better way to do it with awk or something, but cut is so simple.

    say your log lines look something like this

    20081005 error username = "doofus" condition = "very bad" server = "server7"
    20081105 error username = "goofus" condition = "very bad" server = "server6"
    20081105 error username = "Major Hubris" condition = "very bad" server = "server7"
    20081105 error username = "doofus" condition = "very bad" server = "server3"

    and you would like to know say how many "very bad" errors occured on each server:

    > grep "very bad" log.txt | cut -d \" -f 6 | sort | uniq -c | sort
                1 server3
                1 server6
                2 server7

    in the line above,
    grep does the usual grep thing,
    the cut line extracts the sixth field from each line, using a quote as the delimiter,
    the first sort sorts the results so that the two "server7" entries are consecutive (this is a requirement for uniq),
    the uniq collapses identical consecutive lines and prepends the count,
    and the second sort sorts again by the line counts.

    obviously this is not robust enough for real reports,
    but when i've got some files which aren't hooked up to a report generation system,
    and/or want to ferret out some info which hasn't previously been ferreted,
    these commands are great.

  305. you must try this by jjohn_h · · Score: 1

    You must try this in an editor: (1) ctrl-home to go to beginning of file; (2) end to go to end of line; (3) ctrl-right to go to next word; (4) shift-right to start marking a selection; (5) ctrl-c to copy selection to clipboard; (6) ctrl-v to insert from the clipboard what you copy from another application; (7) a single escape to cancel an operation. And so on. Aw-inspiring!

    Of course, you first make sure it is not a Unix/Linux text console.

  306. Of course! by zooblethorpe · · Score: 1

    It somehow makes total sense that it's the cat that wakes you up in the morning. Only mine does it by tap-dancing on my head. :)

    Cheers,

    --
    "What in the name of Fats Waller is that?"
    "A four-foot prune."
  307. look + grep and units by darkonc · · Score: 1
    look can find words in a dictionary by prefix. grep can fine tune the search.

    for example, to find all words that start with 'life' and end with an 'e':

    ~$ look life | grep "e$"
    life
    lifelike
    lifeline
    lifestyle
    lifetime

    Then there's units... It can convert just about any unit (either raw or complex into any other equivalent unit. E.g. to see how long it would take a signal to reach a probe 234million miles away:

    $ units "234 million miles" "light minutes"
    * 20.935956
    / 0.047764717

    or to find out how grams of matter you need to convert to energy to get a one-megaton yeild:

    ~$ units megaton*tnt "1gram light^2"
    * 46.553278
    / 0.021480764

    (that's about 1.64 ounces (also determined by units)).

    I think that the only reason why units isn't included in every Linux distribution is that there's no nice simple GUI interface for it -- that, and so few people know about it.

    --
    Sometimes boldness is in fashion. Sometimes only the brave will be bold.
    1. Re:look + grep and units by tomtomtom777 · · Score: 1

      or to find out how grams of matter you need to convert to energy to get a one-megaton yeild:

      (that's about 1.64 ounces (also determined by units))

      +1 Informative

  308. sed *is* underrated! by dutchd00d · · Score: 1

    I recently discovered "sed -i" for editing a file in-place. Eliminates the need for temporary files. sed never ceases to amaze.

    Oh, and man <whatever>. Man pages are awesome.

  309. And don't forget the stickies: by zooblethorpe · · Score: 1

    Those are the seldom-used initial fourth digit in chmod octal permission arguments:

    • 4 = setuid
    • 2 = setgid (very useful for group-shared directories)
    • 1 = sticky

    The article on file permissions can be a pretty useful reference when explaining things to newcomers.

    Cheers,

    --
    "What in the name of Fats Waller is that?"
    "A four-foot prune."
  310. rtfm... by swehack · · Score: 1

    man 1 write

  311. wxcopy & wxpaste by Harri+Hammerhand · · Score: 1

    My favorite: wxpaste. Its an integration of XWindow's cut-and-paste buffer with the command line. You select a text with your mouse, and wxpaste prints it on stdout. Highly useful. There is also a wxcopy.

  312. print0 and while loops by grumbel · · Score: 1

    One of the things that took me by far the longest to figure out was how to construct a while loop over the results of a "find -print0". Solution is this:

    find -print0 | while read -d $'\0' -r filename; do
        echo $filename;
    done

    Of course in many cases one can also use 'find -exec {} \;', but sometimes a while loop is more handy and without the '-d $'\0'' trick it wouldn't be able to read the file list properly without screwing up on weird filenames.

    Other useful things:

    export HISTCONTROL=ignoredups
    export HISTSIZE="100000"
    export BASH_HISTSIZE="1000000"

    So you have a long history to search for useful commands.

  313. Which laden? by jokkebk · · Score: 1

    And to make sure you really encounter the right Laden along your path:

    which laden

    --
    http://codeandlife.com
  314. Re:Lego by mollymoo · · Score: 1

    I *really* wish something in the GUI world came close to the "pull useful bits from a bunch of programs and throw them together" usefulness of CLI tools.

    Automator for OS X has a pretty good stab at it. You can "pipe" together different applications to create a workflow, all by pointing and clicking. You could get all the photos you took at times iCal says you were with client X, give them a name based on the calendar entry, process them in Photoshop, wrap them up in a zip file and email it to everyone in your address book who works for FooCorp. Like AppleScript it's not only nice in theory but also works pretty well in practice because there is good support in/for third-party applications.

    --
    Chernobyl 'not a wildlife haven' - BBC News
  315. Brace expansion by gspear · · Score: 1
    This has always surprised my co-workers the first time they see it.

    cp {old,new}.c
    mv filename{,.bak}

  316. Looking for the following trick by dargaud · · Score: 1

    Good thread. I'm currently looking for the following trick to do in Posix C: a way to test if there is another instance of the current program already running. In my usual (LabWindows) API, I call the following function at the start of the program's execution: Status = CheckForDuplicateAppInstance (ACTIVATE_OTHER_INSTANCE, &ThereIsAnother); What is the Posix equivalent ?

    --
    Non-Linux Penguins ?
  317. Wake up with festival.. by slashmojo · · Score: 2, Funny

    Another alarm clock of sorts..

    for i in `seq 1 10`; do echo wake up | festival --tts ; done;

    Good for scaring the cat too.

  318. Re:: /var/log/messages by AnteTempore · · Score: 1

    But you do not need the :

    > /var/log/messages

    will do.

  319. Never liked "info" by cheros · · Score: 1

    What I like most about "man" is that it works everywhere (a bit like why you have to know at least *some* vi, even if you don't normally use it). The "info" command is IMHO too unwieldy.

    That is, of course, all personal preference. That's the other thing I like about Unix and Linux: many ways to do things. Makes for great solution resilience..

    BTW, "write" ? I can remember always having an open "talk" window on a friend's system in Oz :-)

    --
    Insert .sig here. Send no money now. Owner may sue, contents will settle. Batteries not included.
    1. Re:Never liked "info" by dutchd00d · · Score: 1

      The "info" command is IMHO too unwieldy.

      Agreed. Info reminds me of Microsoft help files or MSDN articles: doesn't matter how many links I follow, I can never find the information I'm looking for. In man pages it's all there, in one page, at most a simple text search away.

  320. to empty a file by v4vijayakumar · · Score: 1

    echo > file

  321. Shortcuts for terminals by Strahd+von+Zarovich · · Score: 1

    10 years ago I built a custom piece of furniture for my home PC. Well, the basic flaw was that the mouse position was somehow uncomfortable. At the time I was using twm as a window manager, and took advantage of using different shortcuts to focus directly on each of the terminals I had opened (like F1 for the first terminal, F2 for the second, etc). That solved the mouse problem.

    10 years after that, I still mostly ignore my mouse (although it's definitely more approachable) and speed-change between at least 4 terminals with the F keys... A lot of modern window managers have kept up support for shortcuts, but I'm sticking with WindowMaker, which has the additional perk of not bloating the system beyond redemption.

    Some of my coworkers have got jealous of that, but discovered their own way: Konsole can open multiple virtual terminals, and you can hop directly on them using specific shortcuts.

  322. alernative to ls by cestmoa · · Score: 1

    I once had a system where a simple ls would time out as too many files were in the directory.
    a simple

    echo *

    does the trick

  323. Tar to copy directory trees by Allen3 · · Score: 2, Interesting

    Using tar to copy a directory tree can be fun, but for true amazement you need to combine it with a remote shell to copy an entire directory tree to a different machine without any intermediate media:

    cd dir; tar cf - . | rsh remote_machine "cd dir2; tar xvpf -"

  324. Re:Listing directory contents without the ls comma by Mjlner · · Score: 1

    $ delete /bin bash: delete: command not found

    --
    Lemon curry???
  325. ^L clears your screen.

  326. tee by jcrowly · · Score: 1

    Tee is rather helpful when building big pipelines of commands. It writes out what it gets on stdin to the console, while also sending it's input on to the next stage of the pipe line. It can also be helpful when you want to capture the output of some commands to a file, and get the output to console at the same time.

    ps aux |grep dave |tee |awk {'print $1'}>daves-pids

    The command above would show a listing of all processes listings that contain the string dave, and put all the pid's into a file.

  327. (Useful) Stupid Unix Tricks? by foldoc · · Score: 2, Informative

    A NeXT consultant showed me this:

        mv /some/long/path/{old,new}file.blah

    The {,} notation expands the containing word to a space-separated list obtained by substituting in each thing in the {}, giving for the above:

        mv /some/long/path/oldfile.blah /some/long/path/newfile.blah

    Great for mv, cp, ln, diff, cmp.

    --
    Free On-Line Dictionary of Computing http://foldoc.org/
  328. Pipe dream! by Ash-Fox · · Score: 2, Interesting

    Using pipes is one of the most useful things I've found.

    In my signature, a simple HEADER checker:

    echo -e "HEAD / HTTP/1.1\nHost: slashdot.org\n\n" | netcat slashdot.org 80

    Testing your microphone input:

    arecord -f S16_LE -r 3200 | aplay -vv

    Harassing someone by sending your mic input to their soundcard output:

    arecord -f S16_LE -r 3200 | ssh somepersonssystem "sudo aplay -vv"

    Back up something over the network to a file.

    tar --preserve -c -v -z /home/user | ssh address "cat > backup.tar.gz"

    Decompress something that you don't have the space to do on either server or computer, or just don't want to waste time.

    ssh address "cat backup.tar.gz" | tar -xvz

    A few non-pipe related tips:

    Wine prefixes - a method to create unique Wine directories to separate local 'wine' setups.

    WINEPREFIX="~/Steam" wine steam.exe

    If you ever have a game crash, you may have noticed that X doesn't automatically switch back to your default resolution, this can be done with:

    xrandr -s 0 --screen 0

    Hope this was useful to someone.

    --
    Change is certain; progress is not obligatory.
    1. Re:Pipe dream! by twodayslate · · Score: 1

      Cool stuff, thanks

    2. Re:Pipe dream! by Ash-Fox · · Score: 1

      arecord/aplay: Try "man sox", "man rec", "man play". A swiss-army knife of sound tools.

      Except sox is not installed by default like arecord, aplay is in most distributions.

      tar: You can also use the "-f" flag. E.g. "-f-" for stdin/stdout.

      Or don't specify it like I did.

      --
      Change is certain; progress is not obligatory.
  329. Scripting in general by fluo38 · · Score: 1

    I've got a little story: some 10 years ago, I was working for a (big) telecom company and we'd use HP workstations. I was new on the job, and there was a bug in the linker of those workstations, so they'd manually repeat the libraries in the complilation line depending on the error messages: this manual job took a lot of time, because they'd do it again and again until success of link. So I programmed a little shell that would read the error messages from the linker and modify the Makefile then relink, then reread the error messages and link again, etc. until the linker would suceed. This was still very long, but at least it was automatic, so I'd do it in the night, and I'd have my program compiled in the morning. Then I talked about with a (so called experienced) colleague and she'd say: "No that's not possible you can't do this". So I said, "well I did it". And then she said: "No that is not possible" with a certain emphasy. Then we were in cold terms. I guess we don't come from the same planet. Later, I left this company. No regrets, except for the 31 days of vacation per year of course. And maybe also for the things that I could have done for them that never happened, because of such stupidness.

  330. Here's a classic... by SlashDev · · Score: 1

    nice top

    --

    TOP DSLR Cameras Reviews of the top DSLRs
  331. Another unknown .. by SlashDev · · Score: 1

    seq - as in for num in `seq 1 999`; do echo $num; done

    --

    TOP DSLR Cameras Reviews of the top DSLRs
  332. killall by MadMidnightBomber · · Score: 1

    on linux, kills the named process(es).

    On Tru64: halts system, ignoring any arguments

    --
    "It doesn't cost enough, and it makes too much sense."
    1. Re:killall by Kleokat · · Score: 1

      Don't try this on Solaris!!

    2. Re:killall by the+cleaner · · Score: 1

      same goes for solaris. killall does not take arguments, simply kills all processes. it's the cleanup process run directly before shutdown.

      you can easily tell the linux guy, when he issues "killall apache" or something...

      --
      Could be worse. Could be raining.
  333. I like that more by marcosdumay · · Score: 1

    To clean up some C compilation:
    rm * .o

  334. Re:Mods are either psychopaths or UNIX illiterate by francium+de+neobie · · Score: 1

    The script above shreds the contents of your harddisks! Why is it modded Interesting?!

  335. Bang character by Kleokat · · Score: 1

    $ mkdir /some/very/long/path
    $ cd !$

    or

    $ history
    401: ls
    402: mkdir /some/very/long/path
    $ !401

  336. Mister pedantic strikes again by jonaskoelker · · Score: 1

    It's bash specific

    Works fine in zsh too. I think you mean that it's either (1) non-posix, or (2) doesn't work in bash when invoked as "sh", or (3) doesn't work in dash, or (4) doesn't work in your /bin/sh, whatever that is [typically a symlink to bash or dash unless you poke it].

    Bsh tries to act posix-correctly when invoked as "sh"; dash is a shell optimized for posix-compatible scripting, it probably doesn't have many extra features.

    </pedantic>

  337. Mplayer shenanigans by FeepingCreature · · Score: 1

    Here's a neat one ..

    sudo sh -c "DISPLAY=:0 mplayer -demuxer rawvideo -rawvideo w=640:h=480 /dev/mem"

  338. No need by marcosdumay · · Score: 1

    You can code arithmetic operations with xarg + grep. You just need conveniently named files (on your data tape).

    Yeah, probably the GP is right.

  339. thanks for the awesome url in your sig! by slashbart · · Score: 1

    http://tinyurl.com/2ulyhk

    Awesome physics actually. I don't think we can do that with machines.

    Bart

  340. I like this one. by Wheely · · Score: 1

    Needs minor adjustment from Unix to Unix though

    sed -i 's/id:3/id:0/' /etc/inittab

    Another fave was to have a script named e.g. /usr/local/bin/shutter which looked like this

    #!/bin/sh
    echo /usr/local/bin/shutter | at now + 1
    # insert favourite shutdown command here
    sync && sync && haltsys

    And then run it. I'm not sure if it is still the case but "at" used to run commands whose time to run had past as soon as it was able, in this case, when it was next booted.

  341. view folder list without colour by ack_call · · Score: 1

    On Gnu linux I sometimes can't read the 'ls -l' becuase of the colours, so to get rid of the colours I do this:

    unalias ls

    or in vi

    unalias vi

    I get a Hot Unix tip in my inbox, like these, everyday from UNIX GURU UNIVERSE.

  342. tree by Richard+Kirk · · Score: 1

    Ages ago - sometime in the eighties I guess - I wrote a shell script called 'tree' that did an ASCII-art rendition of file structures. This was on my path, so I could just type 'tree ' and it drew out the structure with one directory or file per line.

    Many years and two jobs later, when wanting to plot out a file structure, my fingers returned to their old habits: I typed 'tree ' and whaddya know, it worked! I have never found who did this to thank them. I don't know if I inspired this version but layout is exactly the same, so I like to think so.

    I also had an ASCII-art image viewer. We had one terminal that could slowly view colour images, and this was always in use, so I wrote something that could scroll, zoom, view separations, histogram equalize, and view and eidt pixel values. If you have to grok image pixels, it was handy. That never made it into UNIX. Shame.

    Stupid UNIX tricks? Well, ASCII art was good for all sorts of things - I remember it being used for floor plans, so 'finger' could tell people where your desk was.

    'finger'? Whoa... It's all coming back...

  343. More ls amusements by kriegsman · · Score: 1

    ls -slut shows most recently modified (used) files first.

    ls -slut | head shows just the most recent ten.

  344. Re:This one always surprises people for some reaso by Binestar · · Score: 1

    If that surprises people slocate will knock their socks off. It's not installed default on most distributions, but it's one of the apps I install.

    --
    Do you Gentoo!?
  345. Re:How about a new GUI apt get trick? by eta526 · · Score: 1

    There are X frontends, but for the console you'll probably want to try aptitude. No package rating, but it downloads and installs just fine when you're done selecting your packages. Naturally it handles dependencies too. Look it up.

  346. cut, tr, grep, xargs by bjacobt · · Score: 1

    ps -ef | grep | tr -s ' ' | cut -d' ' -f3 | xargs kill -9 replace -ef with -aux or -auxwww based on OS or need Based on the ps you use, you might want to check if cut -f3 returns the PID.

  347. Re:This one always surprises people for some reaso by DrinkDr.Pepper · · Score: 1

    • 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.

    apropos is apropos to this discussion.

    --
    0xfeedface
  348. Depends on the system by murphyd311 · · Score: 1

    As a *NIX sysad/engineer these are some common ones that I've found co-workers didn't know (a lot of other ones have been listed):

    HP-UX:
    ll (basically ls -al) .
    bdf (Berkley version of df).
    print_manifest [/opt/ignite/bin/print_manifest](If you have ignite tools installed, gives you machine info).

    All:

    showmount -e [remote host] - good of you use nfs and want to check what mounts are exported.
    stty erase [ctrl+v] [backspace] - for when you get those annoying ^? when you hit backspace.
    set -o vi - if you're moderately good with vi setting your environment to it saves SO much time.

    Tools for windows boxes to Administer *nix boxes remotely:

    PuTTY - if you're *nix admin/engineer you probably know about PuTTY, you probably use it.
    PuTTY Connection Manager - less known - great to manager your windows.
    Reflection X Manager and ftp client.
    winscp.

  349. He didn't know write? What else is Unix good for? by trashbird1240 · · Score: 1

    Hmmm...let's see, where should I start?

    write
    ytalk
    mesg
    mail

    Unix was meant for users to communicate with each other: people just don't understand that's what makes it such a cool system. I tell mac and windows users (who think Facebook is a great way to communicate) what I was doing fifteen years ago on Berkeley Unix, and they are astonished. But then they go back to browsing Facebook.

    When I got back onto a real time-sharing system at my new University, I was sad to see that nobody was logged on just to chat: they were all doing actual work! Everybody had "not accepting messages" and no plan. I'm the only on that machine with a .plan. That's depressing.

  350. Re:Listing directory contents without the ls comma by xethair · · Score: 1

    Knowing what you can do with shell builtins is also important for when you mess up your linker or a critical library, can't fork, or other situations where you essentially cannot use anything that isn't already running live on the system.

  351. Subshells, pipe... by etwills · · Score: 1

    ...once you've written a shell script that pipes one function's output into another's input and had the epiphany that this is something a bit special, the world's your oyster really.

    Related contribution to "Unix koans":

    $ ( echo 'egg' ; echo 'chicken' ) | sort
    chicken
    egg

    ...and then stump people (briefly) with:

    $ ( echo 'egg' ; echo 'chicken' ) | dd 2>/dev/null | sort | dd 2>/dev/null
    chicken
    egg
    $ ( echo 'egg' ; echo 'chicken' ) | dd conv=ebcdic 2>/dev/null | sort | dd conv=ascii 2>/dev/null
    egg
    chicken

  352. RTFM by viridari · · Score: 1

    OK what if you want to RTFM but don't know which FM to R?

    apropos

    If you know there is probably a command out there to do something that you want to do, use apropos to find man pages that contain the keyword you're after.

  353. wget, aria2c, and rsync (over ssh) by TheGreatOrangePeel · · Score: 1

    aria2c: Get a file from BitTorrent, HTTP and FTP all at the same time! Every distro should come with this by default and a GUI for it, too. I used it to download the Ubuntu Intrepid Beta ISO from 5 HTTP sources at once. Oooh that was lovely. Of course, it drove my wife crazy for the 12min it took to download the file over my crappy internet connection.

    wget: I've used this little utility to log me into a page, fetch the cookie and then used the cookie with my login info to mirror a website. Before I discovered aria, I've also used it in shell scripts as my download manager to fetch files directly onto my file server at home. There's also wput, but I haven't had need for it.

    rsync: I use this to backup my stuff from server to lappy at work and also to get around Comcast's slowing of FTP traffic. Specifically: `rsync -e 'ssh -ax' -avz /home/user/sourceDir/ user@192.168.1.1:'/home/user/destDir'` you can, of course, swap the source and destination parts to move files the other direction.

  354. grep -ril by foobar8911 · · Score: 1

    Not sure how pointless this one is but I've used it time and time again: "grep -w "foo" -ril . " Search for "foo" recursively in the current directory and list only the file names a.k.a "don't muck up my term window with lines of crap, just give me the filenames where the string "foo" exists"!

  355. That's stupid by herve_masson · · Score: 1

    cd /somewhere &

    1. Re:That's stupid by ion.simon.c · · Score: 1

      Bastard!

  356. a pseudo-random sampling by oik · · Score: 2, Informative

    (Some of these might have been mentioned)

    Bash foo:

    # Make my prompt "pretty" colours and set the xterm title bar to useful things at every command. Also make the continuation prompt blue rather than '> ' so I can cut and paste
    PS1='\[\033[00;31m\]$USER\[\033[00;33m\]@\[\033[00;32m\]\h\[\033[00;00;00m\]:\[\033[00;34m\]\w\[\033[00;00;00m\]\$ '
    PS2='\[\033[00;34m\]'

    # Tell me if something worked
    random_command && echo yes || echo no

    # Completions:
    #  commands which should complete to a command
    complete -A command which
    #  commands which should complete to a shell variable
    complete -A file -A variable unset
    complete -A file -A variable export
    #  commands which should complete to a word list and files
    complete -A file -W "commit diff remove update status annotate log" cvs
    complete -A file -W "all install depend clean" make
    complete -A file -W "all install depend clean" pmake

    # C-d twice to log out
    IGNOREEOF=1

    # Avoid tmp files
    join <(sort file1) <(sort file2)

    # Other things
    shift-insert to paste from the clipboard in terminals
    history > ~/docs/stuff_i_just_did_so_i_dont_forget
    less -S  for wide files
    strace / ptrace / truss
    pushd/popd

    --oik

    1. Re:a pseudo-random sampling by nocomment · · Score: 1

      The tell me if something worked command would be a lot shorter like so ./command && echo $?

      --
      /* oops I accidentally made a comment, sorry */
      /* http://allyourbasearebelongto.us */
  357. my favorites by Hognoxious · · Score: 1

    cal 9 1752. And using banner `foo` where foo is any command that produces a lot of garbage.

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  358. encrypt/decrypt any file easily by brundlefly · · Score: 1

    encrypt:
    openssl aes-256-cbc -a -e -salt -in INPUT_FILENAME -out OUTPUT_FILENAME

    decrypt:
    openssl aes-256-cbc -a -d -salt -in INPUT_FILENAME -out OUTPUT_FILENAME

    1. Re:encrypt/decrypt any file easily by 1s44c · · Score: 1

      encrypt:
      openssl aes-256-cbc -a -e -salt -in INPUT_FILENAME -out OUTPUT_FILENAME

      decrypt:
      openssl aes-256-cbc -a -d -salt -in INPUT_FILENAME -out OUTPUT_FILENAME

      echo Oe lbh pna vzcyrzrag UK tbireazrag fgnaqneq rapelcgvba jvgu ge | tr a-z n-za-m

  359. Re:cd - balls by ugmoe2000 · · Score: 1

    I knew there must have been a command for that, and I use CD soooo much... I wish I would have known that one... I wonder how many seconds I've wasted throughout my life typing previous file trees.

  360. talk & ytalk by sdolgy · · Score: 1

    seriously, talk was very cool before icq and all the other im's out there. then ytalk. revolutionary!

  361. speaking of the old way to do things by Khopesh · · Score: 1

    GNU Stow is the king of DIY software packaging.

    ./configure --prefix=/usr/local/stow/packagename-version --mandir=/usr/local/stow/packagename-version/share/man && make && make install && cd /usr/local/stow && stow packagename-version

    (mandir is optional, but it ensures you don't have to fight between /usr/local/man and /usr/local/share/man.) This is specifically useful because you can use ls or find to see what is provided by the package (just use the stow dir), and far more importantly, you can completely remove a package later (say for an upgrade or replacement).

    --
    Use my userscript to add story images to Slashdot. There's no going back.
  362. Re:Creating an empty file using redirection by eta526 · · Score: 1

    $>test

    Creates an empty file with name 'test'. Quite handy sometimes.

    so does "touch test"

  363. Give everyone a really gay day by thtrgremlin · · Score: 1

    non destructive is fun, especially when it is weird and annoying:

    $ while true; for i in $(w | grep -e pts -e tty[1-6] | awk '{print $2}'); do sleep .01s; echo -en "\x1B[$(($RANDOM % 8 + 30))m" > /dev/$1; done; done &
    $ disown


    A little long, but whatever. I still try to visit The Apple Store as often as possible (never bought anything) :)

    --
    Want Big Business out of government? Take away the incentive and start by getting government out of big business!
    1. Re:Give everyone a really gay day by thtrgremlin · · Score: 1

      oops... This works much better:

      $ while true; do for i in $(w | grep -e pts -e tty[1-6] | awk '{print $2}'); do sleep .1s; echo -en "\x1B[$(($RANDOM % 8 + 30))m" > /dev/$i; done; done 2>/dev/null

      That's what I get for only debugging something by looking at it and not running it. anyway... :)

      --
      Want Big Business out of government? Take away the incentive and start by getting government out of big business!
  364. sed for backups by chreekat · · Score: 1

    Well I just came up with this this very moment:

    sed -i.bak file1 file2 ...

    Backed up a bunch of files that I was going to do some experiments on.

  365. apropos by borowcm · · Score: 1

    Can't remember a command?
    apropos keyword
    From the man page: "apropos - search the whatis database for strings"

  366. pipe multiple results to an interactive script by c-bo-licious · · Score: 1

    If there is a function or script that prompts you for multiple things you can pipe multiple things that will go through all the prompts. So you could do something like this: "(ls *.zip; yes)| gunzip" to replace existing files. (Same as doing "yes | gunzip *.zip")

  367. Re:How about a new GUI apt get trick? by techess · · Score: 1

    You are definitely right about the amount of time yum takes to do anything. The advantage is that it takes the same amount of time for me to run and grab a cup of espresso.

    --
    Don't anthropomorphize computers. They *hate* that.
  368. sudo -i by zlamma · · Score: 1

    That's probably because they don't know about
    sudo -i

  369. cat! by fransw · · Score: 1
    When using clearcase even cat is helping out, since it doesn't allow two runs of cleartool.

    To quickly checkin my work:

    cleartool lsco -r -s -cvi

    ... list of checked out files ...

    cleartool ci -nc `cat`

    copy-paste, ^D, et voila!

    1. Re:cat! by etwills · · Score: 2, Interesting

      cleartool ci -nc `cat`

      A pipe (as I hint at elsewhere) through while ... read would reduce that:

      cleartool lsco -cview -me -r -s | while read FILE ; do cleartool ci -nc ${FILE} ; done

  370. Nm and others... by CatsupBoy · · Score: 1

    The "nm" command is obscure but its saved me a few times compiling. If you are getting symbol errors and you dont know what library to link in, find it by running "nm" on all your *.so files.

    How about exit codes? I run alot of scripts with || and && on the end to exit on failure

    [ -f "/etc/config.conf" ] || exit

    Bring the last two togethern with the quintessential "for" loop:

    for i in `find /lib /usr/lib -name '*.so'`;do
    nm $i 2>&1 | grep $LIB >/dev/null && echo $i
    done


    Sed One Liners

    And my favorite "trick" in college:

    ln -s /stand/vmunix ~/.plan

  371. ddate by pruneau · · Score: 1
    --
    [Pruneau /\o^O/\ warranty void if this .sig is removed]
  372. a few mostly common ones by mrmud · · Score: 1

    One of the ones I use for linux is if you are on a compromised system and suspect the PS (but not the kernel) have been compromised:

    awk '{print $1, $2}' /proc/[0-9]*/stat ain't pretty but it gets the job done.

    For directories where I need to do something to all the files, I do:

    find . | while read -r file; do echo $file; done

    you can use -iname or other misc things to find to limit the files. Replace echo with whatever you want to do. This is mostly done for something more complicated then -exec or xargs for me.

    Another pretty common one but maybe some don't know about is:

    cd - takes you back to the previous directory you were last in.

    --
    -- MrMud
  373. Up up down down... by zooblethorpe · · Score: 1

    How'd that go again?

    up up down down left right left right a b b a start

    Yeah, that sounds about right... ;)

    Cheers,

    --
    "What in the name of Fats Waller is that?"
    "A four-foot prune."
  374. Try this one... by berend+botje · · Score: 1

    Create a small batch file in your path, and call it 'tman' (for typeset-man), containing:

    man -t $1 > /tmp/tman.ps; evince /tmp/tman.ps

    And now, everytime you want to look at a manpage, just type tman instead of man. You will be happy.

  375. Re:Job control. - IO by rsd · · Score: 1

    Most people doesn't about it yet, but ionice is a life saver on io bounded tasks (as oposed to nice in cpu bounded tasks).

    That's probably because most distributions does not enable it in the kernel yet.

    -rsd

  376. --interval by itomato · · Score: 1

    surprisingly, I haven't seen the '--interval' flag mentioned anywhere here.

    Pass '--interval' followed by the desired number of seconds between updates.

    My favorite use is watching large files progress or slow processes.

  377. sudo !! by moosesocks · · Score: 2, Interesting

    sudo !!

    Repeats your previous command as the root user.

    Very useful if you typed out a big long command, but forgot to run it as root.

    --
    -- If you try to fail and succeed, which have you done? - Uli's moose
  378. Embed settings in your source documents by cjb-nc · · Score: 1

    This trick is handy when you like the context-sensitive formatting but you are editing a file with a non-typed extension. (e.g. somefile.module for Drupal which is actually PHP code)

    Embed this in your file, near the top of the document:
    /* vim: set filetype=php tabstop=2 shiftwidth=2 : */

    Obviously you can substitute any :set commands from VIM that you like, to customize the editor to the specific file.

  379. make love by rbeef · · Score: 1

    passer$ uname -a FreeBSD passer 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #1: Thu Oct 30 14:47:24 PDT 2008 root@passer:/tank/obj/opt/src/svn-stable7/sys/KOMQUATS i386 passer$ make love Not war. passer$

  380. the ^ substitute by rmpowell77 · · Score: 1

    Here's one that a lot of people are surprised as: ^^ so $ les thefile.txt $ ^les^less will substitute less of less (thanks to "The Underground Guide to UNIX" by John Montgomery for this)

  381. Re:Listing directory contents without the ls comma by Hal_Porter · · Score: 1

    echo *

    I discovered if you give the echo shell command an asterisk as a parameter, it dumps out the file names of the current directory. (The sad thing is I had a practical use for this when a less-than-clueful-collegue deleted the /bin directory, leaving the system without an ls program).

    rm does that too for some reason

    --
    echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
  382. Re:rev - Yay Heinlein! by aceofspades1217 · · Score: 1

    Oh fellow Heinlein reader. You deserve a hug for working a Heinlein word into a tech article.

    But yes, I grok, I don't get what the huhu is with the rev command.

    What was going through the creator's frimping minute!

  383. Re:Windows by ReconOps · · Score: 1

    I don't know about Unix or Lunix, but I am constantly amazed by all the complaints I hear from Unix/Lunix admins who complain about all the stuff you "can't do" with Windows... and I end up showing them how to do it.

    Windows has tons of features. It's a shame they can't figure out how to read a book about it. Or, you know, do an internet search on it.

    ..figures you posted this as an Anonymous Coward...

    --
    A PC without Windows is like Coffee without Ketchup...
  384. another useful trick by sheds · · Score: 1

    Don't know if it has been mentioned before, but using ctrl+r let's you browse your command history as you type in part of the entire command.

    --
    Building for a shallow grave Must be something else we say Somehow to defend this place
  385. Re:Wohoooo, the first one! by n9hmg · · Score: 1

    cut, uniqe(sic), tail, tr, head, tail

    Ok, somebody's got to acknowledge your joke... "cut, uniq, tail, tr, head, tail" "You said tail twice" "I like tail".

  386. SSH rules by BrunoUsesBBEdit · · Score: 1

    Don't forget that ssh can:
    1. Be used to call remote processes, not just an interactive shell
    2. Accept pipes to STDIN
    This allows you can tar something locally and untar it on the other side in one step. Why? If what you have to send across is huge, you don't have to consume disk space to create the local copy. Or, if you have to ssh from A-B, then B-C, then C-D just to get the huge collection of data from A-D, you don't have to wait for the tar to be created then sent 3 times. This is makes espionage super easy anywhere that you can find a path the the outside world where the router doesn't block ssh. Which most companies never think to do anyway.

    I actually use it for good instead of evil though. My trick is to properly setup ssh public key authorization on a remote server in one step instead of two. Like so:
    tar cf - .ssh/authorized_keys2 .ssh/id*.pub| ssh remoteserver "tar xf -; chmod 700 .ssh"

    replace "remoteserver" with "$1" and put than line in a bash script and you have a simple way to deploy your public key authorization to a severname given as the first argument. When you admin lots of boxes & VMs, growing daily, you have to find shortcuts.

  387. More SSH by BrunoUsesBBEdit · · Score: 1

    If you do not have your .ssh/config setup from ControlMaster, or know what that means... Study up! Specifying ControlMaster in my config saves me easily 45 minutes a day. (If you use svn+ssh:// there's a gotcha with a simple solution. Google for it.)

  388. I miss one great command by ketilf · · Score: 2, Interesting

    find and xargs is an absolutely brilliant combination. I can't live without it.

    find . -type f -print0 | xargs -P 4 -0 echo grep -H WHATEVER

    searches for the string WHATEVER in all regular files, weird-filename-safe. xargs runs 4 parallel greps, to make use of all those CPUs and cores! Here's two test runs, note the changing order:

    $ find . -type f -print0 | xargs -P 5 -n 2 -0 echo grep a
    grep a ./1 ./2
    grep a ./5 ./6
    grep a ./7 ./8
    grep a ./3 ./4
    grep a ./9
    $ find . -type f -print0 | xargs -P 5 -n 2 -0 echo grep a
    grep a ./1 ./2
    grep a ./3 ./4
    grep a ./5 ./6
    grep a ./7 ./8
    grep a ./9

  389. Comment removed by account_deleted · · Score: 2, Funny

    Comment removed based on user account deletion

  390. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  391. Re:How about a new GUI apt get trick? by badkarmadayaccount · · Score: 1

    Why the fuck does it have to renew package lists EVERY time? Better yet, why isn't the package fetching bit a webapp? Think a souped up repo site or portal. Then double click on the .deb/.rpm. If you want the fast way, CLI apt-get is still there. Just my $0.03.

    --
    I know tobacco is bad for you, so I smoke weed with crack.
  392. bc base conversion by boss_hog · · Score: 1

    I use bc almost exclusively to do dec<->hex<->bin math.

    ibase=10
    obase=16

    or:
    ibase=2
    obase=10

    for example.

    you just have to be careful because as soon as you set ibase, that's how it interprets everything else you type.  so converting hex to dec looks like this, if you don't set the obase first(assuming your obase is currently 2 or something else):

    ibase=16
    obase=A

    nice quick and dirty base conversion calculator, with a touch of history via your scrolled-up tty output.

  393. Re:perms by Ash-Fox · · Score: 1

    chmod 000 /bin/chmod

    ash-fox@Vigil:~$ chmod 000 /bin/chmod
    chmod: changing permissions of `/bin/chmod': Operation not permitted

    --
    Change is certain; progress is not obligatory.
  394. Re:Are you sure your talking about UNIX ? by Ash-Fox · · Score: 1

    The post related to UNIX. try running your commands on a UNIX shell you will notice there is a difference.

    Indeed, it incredibly sucks on SCO UNIX. Grep command has no recursive search, tar has no gzip capability, crontab doesn't have the ability to use @reboot, */5 etc.

    In summary: SCO Unix sucks compared to Linux.

    --
    Change is certain; progress is not obligatory.
  395. Re:Remote directory tree copy by Ash-Fox · · Score: 1

    I often see people surprised with this way of copying a directory tree to a remote host without a temporary copy. This is much faster than scp -p for large directory trees.

    tar cf - /foo/src | ssh remote "(cd /bar; tar xf -)"

    Additionally, if you use the -C prefix in ssh, you enable compression along the way. Which is great when working over the Internet.

    --
    Change is certain; progress is not obligatory.
  396. Re:How about a new GUI apt get trick? by jon3k · · Score: 1

    "Also, Yum is good for reducing stress by conveniently giving you ten minutes to an hour of relaxation time while it completes each operation."

    $yum -C [command] [parameter]

    ...to operate from cached metadata. If you need to search or look up dependencies or what package contains something, etc, works great. If you're installing something yum is no slower (or faster) than apt. And yum is a lot faster than it used to be back in the "core" days.

    I still prefer yum over apt-get .. or was it apt-cache? or dpkg-reocnfigure? I can never remember ...

  397. Re:This one always surprises people for some reaso by jon3k · · Score: 1

    Yes! God forbid you run an $updatedb for 8 seconds once a day. You know you can actually just put it in cron.daily and never think of it again? Not to mention you have to update your find "database" anyway. Makes no sense whatsoever.

    Talk about a solution in search of a problem ...

  398. use "source", luke by orsocio · · Score: 1

    Just use
    $ source ~/.bash_profile
    instead of logging out and in again. This reads the file into the current shell's environment.

  399. ipython by portscan · · Score: 1

    for python hackers, ipython is essential. it's a wrapper for the python shell which has tab completion of all class/function/method attributes and interactive access to documentation, plus all kinds of other fancy tools. it has made learning python so much easier.

  400. Re:: /var/log/messages by Domini · · Score: 1

    > bash
    $> :> testing
    $> > testing
    $> csh
    ~> :> testing
    ~> > testing
    Invalid null command.

  401. duplicate a HD over a network by nodrama · · Score: 1

    This will do a dd(1) copy across the network if you don't want to drag the HD out and plug it in locally. Of course it takes a while :)

        dd if=/dev/hda bs=64M | rsh ip_or_name dd of=/dev/hda bs=64M

    Change the /dev/* as required.

    apols if I got the syntax wrong, but you get the idea (dd might need to explicitly ref stdout/stdin; cant rem)

    Oh, and it helps if the new drive is the same size (or bigger).

  402. A simple trick... by ralphweaver · · Score: 1

    ... but one that saves time and prevents mistakes.

    mkdir -p /usr/local/src/{archive,test,whatever}

    will create all directories necessary that don't exist and then expand the stuff in brackets and create them also.

    Habitually backing up files before editing them will save you a lot of heartache in the long run too. It's easier if you make an alias to replace your common editor command to automatically back up the file.

    --
    Pantek, Inc. - http://www.pantek.com/ - info@pantek.com
    +1-877-LINUX-FIX - Expert Open Source Support