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?

2,362 comments

  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 Anonymous Coward · · Score: 0

      rm -rf /

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

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

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

    5. Re:rm -rf / by Anonymous Coward · · Score: 0

      Fools seldom differ

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

      Mediocre minds think alike. Great minds are unique.

    7. Re:rm -rf / by Anonymous Coward · · Score: 0

      cp -f /dev/urandom `mount | grep "on / " | gawk '{ print $1 }'`

    8. 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.
    9. Re:rm -rf / by Anonymous Coward · · Score: 0

      I've been meaning to try that one for a while. What's it ddestination host unreachable

    10. Re:rm -rf / by macshome · · Score: 4, Funny

      Pshaw! All 1337 sysadmins just live as root!

    11. 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.

    12. 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

    13. Re:rm -rf / by Anonymous Coward · · Score: 0

      Somehow when I ran this command it messed up my system, what's your phone number so I can call?

    14. 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.

    15. Re:rm -rf / by Anonymous Coward · · Score: 0

      rm -rf /

      If you ere a true solaris admin you'd know that isn't possible.

      bash-3.00# id
      uid=0(root) gid=0(root)
      bash-3.00# rm -rf /
      rm of / is not allowed
      bash-3.00#

    16. Re:rm -rf / by Anonymous Coward · · Score: 0

      rm -rf /

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

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

      cat /dev/urandom > /dev/dsp

    18. Re:rm -rf / by Anonymous Coward · · Score: 0

      Oh hai! That's really nasty. Call it a backdoor script and let all those script kiddies experience it.

    19. Re:rm -rf / by Anonymous Coward · · Score: 0

      Unix? - Check!
      Stupid? - Check!
      Useful? - Absolutely!

    20. Re:rm -rf / by Anonymous Coward · · Score: 0

      Why does some kind of moron always get the first spot?

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

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

      That's my alarm clock.

    22. Re:rm -rf / by Anonymous Coward · · Score: 0

      if "rm -rf /" doesn't work try "sudo rm -rf //"

      or better yet

      dd if=/dev/urandom of=/dev/sda

    23. 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

    24. Re:rm -rf / by Anonymous Coward · · Score: 0

      you are funny. Have a prize.

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

      rm -rf /

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

    26. 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.

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

      Hmm, Mozart's Fifth Symphony...

    28. 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

    29. 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...
    30. 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.)

    31. 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
    32. Re:rm -rf / by EthanV2 · · Score: 2, Informative

      I believe you mean NO CARRIER

    33. 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.
    34. 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
    35. Re:rm -rf / by Anonymous Coward · · Score: 0

      I'll have to try that! ;)

    36. Re:rm -rf / by Anonymous Coward · · Score: 0

      rm -rf /

      sudo srm -rf

    37. Re:rm -rf / by Anonymous Coward · · Score: 0

      Depends on what you mean by "scrub".

    38. Re:rm -rf / by Anonymous Coward · · Score: 0

      Hello there I'm just trying out this new ubunto program for the time and want to try you command but I cant find Start>Run in the menu. Is it under "System" somewhere.? I want to be use linux but if nobody helps me get all this useful tips to work for me I will have to switch back to Windows Me.
      *bump*

    39. Re:rm -rf / by dirtyhippie · · Score: 0

      i'd never seen that one. awesome.

    40. 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!
    41. Re:rm -rf / by fahrbot-bot · · Score: 1

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

      --
      It must have been something you assimilated. . . .
    42. Re:rm -rf / by Anonymous Coward · · Score: 0

      OH MY GOD! I TRIED THAT ON OUR PRODUCTION SOLARIS 10!!!!! WHAT HAVE YOU DONE YOU IDIOT!!!!!!

      ARRGHH!!!!!!

    43. Re:rm -rf / by fr4nk · · Score: 2, Informative

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

      should clear out the MBR.

    44. 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.

    45. Re:rm -rf / by FreeFull · · Score: 0

      Doesn't do anything.

      --
      No ascii art.
    46. 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
    47. Re:rm -rf / by Anonymous Coward · · Score: 0
    48. 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.
    49. 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
    50. Re:rm -rf / by Anonymous Coward · · Score: 0

      you can fix that easily, just use the following code:

      rm -rf /

    51. 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.
    52. 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.
    53. 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! :)

    54. 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.

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

      Hey, I'll have to try th

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

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

    57. 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
    58. Re:rm -rf / by carrier+lost · · Score: 4, Funny
      CARRIER LOST

      Hello?

    59. Re:rm -rf / by Anonymous Coward · · Score: 0

      chown nobody /

      have fun ;P

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

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

    61. 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.
    62. Re:rm -rf / by myz24 · · Score: 1

      THANK YOU

    63. 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.
    64. Re:rm -rf / by Anonymous Coward · · Score: 0

      rm -rf /

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

      Naturally, I do it at work because I'm a professional.

    65. Re:rm -rf / by Anonymous Coward · · Score: 0

      rm -rf /

      /quote

      even better: sudo rm -rf /

    66. Re:rm -rf / by orclevegam · · Score: 1, Informative

      LOL, that's awesome.

      --
      Curiosity was framed, Ignorance killed the cat.
    67. 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.

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

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

    69. Re:rm -rf / by Anonymous Coward · · Score: 0

      infinite monkeys and all that.. it was bound to come up.. you're not special.

    70. Re:rm -rf / by Anonymous Coward · · Score: 0

      The most important: man

    71. 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).

    72. Re:rm -rf / by Anonymous Coward · · Score: 0

      You know, I typed that into my Internet Explorer browser and guess what? NOTHING HAPPENED!

      Absolute anecdotal proof that MS makes more secure products than Lee-nooks after all.

      Who'da thunk it?

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

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

    74. 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.
    75. Re:rm -rf / by Anonymous Coward · · Score: 0

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

      should clear out the MBR.

      Learn something new everyday.

      Thanx, Fr4nk.

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

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

    77. 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...
    78. 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.

    79. 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*

    80. 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
    81. Re:rm -rf / by Anonymous Coward · · Score: 0

      r00t? what you mean underground? Are you 1337 roots of one tree or the collective grouping of 1337 trees' roots? doesn t compute

      bugger -d

      Oh, you think your better than to give advice to those who seek knowledge?

      grep *.soul /

      Sadness

    82. 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)

    83. 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...
    84. 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
    85. 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).

    86. 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.

    87. 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.

    88. 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 - ".

    89. 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...

    90. 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.

    91. Re:rm -rf / by ld+a,b · · Score: 0

      Quick encryption for your terminal, so your wife doesn't find out about your ~/.japaneseporn collection sneaking from behind and scanning your ls output.
      cat /dev/urandom
      Be sure to stop the cat or you might not understand the power of this command.

      --
      10 little-endian boys went out to dine, a big-endian carp ate one, and then there were -246.
    92. Re:rm -rf / by curecollector · · Score: 1

      Read Mail Real Fast!

    93. 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!

    94. Re:rm -rf / by Anonymous Coward · · Score: 0

      lmfao - you'd need root for that to run.

      otherwise, that command is "uprooted"

    95. 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!

    96. Re:rm -rf / by Anonymous Coward · · Score: 0

      Have you ever tried this? It deletes a lot less than you'd think. I had a server I was decommissioning and I was quite disappointed in the results.

    97. 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
    98. Re:rm -rf / by phagstrom · · Score: 1

      PSDoom - very old school console edition.

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

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

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

      What you get for running as root =)

    101. 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.
    102. Re:rm -rf / by Teilo · · Score: 2, Informative

      For recent versions:

      sudo -i

      shorter

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

      Hey, I was thinking the same thing!

    104. 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.

    105. 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..

    106. 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!
    107. Re:rm -rf / by Annymouse+Cowherd · · Score: 1

      su -c :P

    108. 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!
    109. 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.

    110. 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.

    111. 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';
    112. Re:rm -rf / by BrokenHalo · · Score: 1

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

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

    113. 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.

    114. 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.
    115. 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.

    116. 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
    117. 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!
    118. 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).

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

      I think your sentence needs cleaned up.

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

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

    121. 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

    122. 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!
    123. 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?
    124. 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.

    125. 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.
    126. 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.

    127. 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.

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

      deltree /y c:\windows
      I hate pushing keys

    129. 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 :'(

    130. 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!
    131. 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

    132. 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
    133. 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.

    134. 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.
    135. 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.

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

      That's what sudo -i is for.

    137. 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."
    138. 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.

      --
    139. 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 ;).

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

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

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

      Only sissies sudo...

    142. 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
    143. 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
    144. 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.

    145. 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
    146. 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
    147. Re:rm -rf / by hoytak · · Score: 1

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

      --
      Does having a witty signature really indicate normality?
    148. 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
    149. Re:rm -rf / by Pig+Hogger · · Score: 1

      Interesting. Thanks.

    150. Re:rm -rf / by Anonymous Coward · · Score: 0

      rm -rf /

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

      Oh, this is one of those Only-at-work things, huh? ;)

    151. Re:rm -rf / by Anonymous Coward · · Score: 0

      a long time ago a non-techie friend of mine suggested this as a jingle

      "arr emm dash,
        arr eff slash"

      pretty funny especially when you're drunk

    152. 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.

    153. 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.

    154. 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. ::
    155. 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...

    156. 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*

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

      s/phone/fun

      That was an odd typo, eh?

    158. 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.

    159. 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?

    160. 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...

    161. 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
    162. Re:rm -rf / by dna_(c)(tm)(r) · · Score: 4, Funny

      42 ?

    163. 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
    164. 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
    165. Re:rm -rf / by polymerousgeek · · Score: 1

      CTRL+D?

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

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

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

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

    168. 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.
    169. Re:rm -rf / by Anonymous Coward · · Score: 0

      Teilo,

      Just by using the label "n00bs", you have automatically cast yourself into one (or all) of the following categories:

      1) You are 16 years old, and live with your parents (and *hate* your dad enough to wear eyeliner).
      2) As per 1), you are an implicit virgin.
      3) You have a basic grasp of UNIX, although you spend most of your time at Ubuntu "install parties"
      4) You live by the following maxim "i r t3h 1337"

      Now, why don't you stop casting wild assumptions and spewing opinionated conjecture, and I will too.

    170. 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
    171. Re:rm -rf / by pato101 · · Score: 2, Informative

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

    172. 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.

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

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

    174. Re:rm -rf / by Anonymous Coward · · Score: 0

      Why does 'sudo -s' act as the equivalent of 'sudo sh' (or bash or zsh or tcsh or whatever) without logging all subsequent commands the way 'sudo whatever' does? I have an irresponsible fellow admin who insists on doing everything as root, leaving no way to audit her fuckups. Obviously a malicious actor with root can erase his traces, but I'm more concerned with incompetence than malice.

    175. 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.
    176. Re:rm -rf / by ld+a,b · · Score: 0

      This is why you had to break it. Also, you need a terminal of the very broken type. Which means a Linux console or a good emulation thereof. Don't try to run this on xterms or other terminal emulations. I guess some classical terminal had far funnier effects, but in Linux it achieves exactly the effect I advertised.

      --
      10 little-endian boys went out to dine, a big-endian carp ate one, and then there were -246.
    177. 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"
    178. Re:rm -rf / by Pvt_Ryan · · Score: 1

      I hope he slaps you very hard each time :)

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

      cat /dev/zero > /dev/null

    180. Re:rm -rf / by Anonymous Coward · · Score: 0

      I once went to my sysadmin to complain that /tmp was full. Then I watched him do this:

      cd /tmp
      rm -rf *

      Hmmm... still lots of big dot-files...

      rm -rf .*

      It had removed over half of /bin before he realized what he'd done. Now I use it as an interview question.

    181. 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.

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

      a real Ubuntu admin uses sudo bash

    183. 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
    184. Re:rm -rf / by Anonymous Coward · · Score: 0

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

      That's my alarm clock.

      you get 8 hours of sleep!

    185. Re:rm -rf / by MikeDirnt69 · · Score: 2, Funny

      No, that is the answer for the opposite!

      --
      Am I eval()? - http://www.monst3r.com.br
    186. 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
    187. Re:rm -rf / by danieltdp · · Score: 1

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

      --
      -- dnl
    188. 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...
    189. Re:rm -rf / by Anonymous Coward · · Score: 0

      An alternative is

      ac@localhost / # rm -rf /foo/bar/ * ...waiting...

      oops that was a nasty space I inserted there....

    190. Re:rm -rf / by Anonymous Coward · · Score: 0

      IMO useful:
      #The important part being the -exec (execute anything you want against the found file, including e.g script etc.)
      # Remove file with special char (do ls -i first to find out the inum):
      - find . -inum "see above" -mount -exec rm -i {} \;

      #Examples use your favourite manpage man "sth" |less
      - ptree (find parent processes)
      - ldd (your binary)
      - truss "cmd" (what's happening behind the scenes)
      - strace "pid"
      - time "cmd" (there are actually people wanting to optimize and measure execution times ;))
      - sudo (no, you shall not work with root imo)

      #And above use .profile; .bashrc, (whatever it is for your shell...) e.g.
      #Aliases
      alias sth='exec newgrp dummies'
      #Find out if some partition is about 90%
      df -k | sed 1d | awk '$5>90 {print}'
      #Working with sudo (depending on shell) you can include the following example in .bashrc and .profile
      source ~/.common_profile
      #Put all the aliases, PATHS, etc. in the .common_profile

    191. Re:rm -rf / by that+this+is+not+und · · Score: 1

      don't be redundant.

    192. 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!

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

      Read Mail -Really Fast /

    194. 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.

    195. Re:rm -rf / by Anonymous Coward · · Score: 0

      cat /dev/input/mice > /dev/dsp &

      This will encourage you to stick to CLI.

    196. 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. :-)

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

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

    198. Re:rm -rf / by Anonymous Coward · · Score: 0

      A certain unnamed fortune 100 software vendor had an embarrassing upgrade feature exposed some 7 years ago. Entry of a particular series of upgrade options formed the magic "rm -rf /" command.

      I was working level 3 support at the time, difficult to explain that one to a customer who's just lost their entire system.

      Funny, scary, but true.

    199. Re:rm -rf / by Anonymous Coward · · Score: 0

      definitely NOT @ work too!

    200. 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
    201. 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
    202. Re:rm -rf / by Fumus · · Score: 1

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

    203. 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
    204. 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..***
    205. 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.

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

      Do nothing really fast:

      cat /dev/urandom > /dev/null

      --
      sudo ergo sum
    207. 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.

    208. 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
    209. Re:rm -rf / by Anonymous Coward · · Score: 0

      Works even better if you're root user...

    210. 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

    211. 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!
    212. 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
    213. Re:rm -rf / by MoogMan · · Score: 1

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

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

      I laughed.

    215. 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?

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

      rm -rf .. is entertaining too.

      --
      - Michael T. Babcock (Yes, I blog)
    217. 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)
    218. 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.
    219. Re:rm -rf / by Anonymous Coward · · Score: 0

      That was a joke. But my boss executed a script that called:

      rm -rf $1/$2

      without arguments on a production machine. Fortunately, nobody can fire him.

    220. 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.

    221. 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!

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

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

      "sudo su" ?

    223. 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.
    224. Re:rm -rf / by exploder · · Score: 0

      Mathematically I'd have to disagree with that answer, since the empty set is a subset of (included in) every set, including itself.

      But I know a lot less about Unix than math, so there's probably a good reason, just like there are good mathematical reasons for the other.

      --
      Yo dawg, I heard you like the Ackermann function, so OH GOD OH GOD OH GOD
    225. 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.
    226. 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.
    227. 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...
    228. 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....

    229. 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.

    230. 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.
    231. 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.

    232. 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.
    233. Re:rm -rf / by houghi · · Score: 1

      chmod 666 / -R

      --
      Don't fight for your country, if your country does not fight for you.
    234. 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.
    235. 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.
    236. Re:rm -rf / by FreeFull · · Score: 0

      No, not the inverse. I think it would be -42.

      --
      No ascii art.
    237. Re:rm -rf / by 4D6963 · · Score: 5, Funny

      Mediocre minds think alike. Great minds are unique.

      My thoughts exactly.

      --
      You just got troll'd!
    238. 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.
    239. Re:rm -rf / by LucidBeast · · Score: 1

      I think you have pointed out what is problem is.

    240. 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.
    241. 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.

    242. 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.

    243. 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?

    244. 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...

    245. 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.

    246. 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!

    247. 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.

    248. 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.

    249. Re:rm -rf / by n0084ever · · Score: 0

      since this is /. the above statement applies how ?

    250. 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? =-
    251. 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).

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

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

    253. Re:rm -rf / by Anonymous Coward · · Score: 0

      There are at least three methods to delete files starting with special chars like "-".
      The first and most obvious should be relative path like you said i.e. rm ./-rf (and sadly as of now rm actually tells you this when you try to delete the file and fail miserably)
      the other method which was my favorite is to say "options stops here" with -- i.e. rm -- -rf
      The third one is by using inode numbers but right know I can't remember exactly how. (prolly using find)

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

      sudo -s works
      (brings up a shell)

    255. 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.

    256. 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.
    257. 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.
    258. 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*-
    259. 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.

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

      here was my recent o'shit moment.

      at midnight `shutdown -r now`

      That was bad LOL.

    261. 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.

    262. 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.

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

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

    264. 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..

    265. 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.
    266. Re:rm -rf / by Anonymous Coward · · Score: 0

      well, maybe
      sleep $[8*3600];
      will do the job if you are woken after 8 seconds...

      cal #is my favorite calender tool ^^

      some lines from my bashrc which replace those ugly gui-based todo lists mostly housed in taskbar-like things:

      alias todo='echo $[ `wc -l ~/mytodos 2>/dev/null | cut -f 1 -d /` + 1]: >> ~/mytodos '

      alias todos='cat ~/mytodos'

      alias todone="bash -c \"awk -F : -v x=\\\$0 '{if(\\\$1 x) { print (\\\$1-1)\\\":\\\"\\\$2}}' ~/mytodos > ~/.mytodos; mv ~/.mytodos ~/mytodos; cat ~/mytodos\""

      and always make your prompt fancy colored...
      export PS1="\[\033[01;32m\]\u\[\033[01;31m\]@\[\033[01;36m\]\h\[\033[01;31m\]:\[\033[01;33m\]\w\[\033[01;31m\]\$\[\033[00m\] "

      #docJ

    267. Re:rm -rf / by chkn0 · · Score: 1

      ROLLBACK;

    268. Re:rm -rf / by Anonymous Coward · · Score: 0

      Try putting cursor control commands in a file name. It works wonders.

    269. Re:rm -rf / by Anonymous Coward · · Score: 0

      Actually, whether or not you're being cute with the ending slash, you often explicitly want /usr/bin/rm -rf

      Enterprises often have their unix admins alias everyone's rm to variants that will ask you to confirm even if you specify -rf.

      Pathing for /usr/bin/ explicitly, while giving an impression of overkill, can save your bacon versus assuming that shell script you wrote with an rm cleanup, or command you kicked off into the background before shutting off your laptop will actually work.

    270. 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.
    271. 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.

    272. 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!
    273. Re:rm -rf / by jrockway · · Score: 1

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

      --
      My other car is first.
    274. 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.
    275. 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.
    276. 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
    277. Re:rm -rf / by Anonymous Coward · · Score: 0

      So you restarted a box at midnight, big deal. Maybe next time try providing some kind of information as to why it was an "oh shit!" moment...

    278. Re:rm -rf / by Anonymous Coward · · Score: 0

      Especially when you have some other drives mount under /mnt

      "why is it deleting /mnt/c_drive/windows/*? OHHHH bloops"

    279. 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...

    280. Re:rm -rf / by Anonymous Coward · · Score: 0

      sudo apt-get moo

    281. 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.
    282. Re:rm -rf / by JAZ · · Score: 1

      'man test' for more info.

      --


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

      Install cygwin and try again.

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

      @ your sig -

      Sniff a republican, smell an oppressor

    285. 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.

    286. 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.

    287. 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.

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

      Gah!

      --
      "What in the name of Fats Waller is that?"
      "A four-foot prune."
    289. 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.)

    290. Re:rm -rf / by Anonymous Coward · · Score: 0

      how many people would you give root access
      damagement always want root access to everything.

    291. 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.
    292. 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.
    293. Re:rm -rf / by Anonymous Coward · · Score: 0

      Can't tell if it's working... it's just sitting there going chug, chug, chug. I don't get it.

    294. Re:rm -rf / by Anonymous Coward · · Score: 0

      bash: /dev/dsp: Device or resource busy

    295. 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.

    296. 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.

    297. Re:rm -rf / by Anonymous Coward · · Score: 0

      Telling a guy over the phone to type 'rm -rf *anything*' is pretty thick.

    298. 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.

    299. 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...
    300. Re:rm -rf / by Short+Circuit · · Score: 1

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

    301. 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?
    302. 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.

    303. 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

    304. 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.

    305. 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.

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

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

    307. Re:rm -rf / by Anonymous Coward · · Score: 0

      A decent browser would have searched Google...

    308. 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!
    309. 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.
    310. 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.

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

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

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

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

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

      or sudo bash

      --

      krenshala

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

      Ja

      --

      krenshala

    315. Re:rm -rf / by Anonymous Coward · · Score: 0

      # rm -rf /
      rm: cannot remove root directory `/'
      #

    316. 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.
    317. 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
    318. 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
    319. Re:rm -rf / by Anonymous Coward · · Score: 0

      Thanks to your post, I could not stop laughing for half an hour, and everyone in my company thought I am dumb.
      Thanks. ;-)

    320. 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.

    321. Re:rm -rf / by Anonymous Coward · · Score: 0

      So, do you use Ctrl+c or snooze?
      xDD

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

      ... how about "sudo -s"?

    323. 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
    324. Re:rm -rf / by CheShACat · · Score: 1

      No one wants to feed the troll...

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

      PROTIP: shopt -s dotglob

    326. 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
    327. 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?

    328. 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.
    329. 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

    330. 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".

    331. Re:rm -rf / by Anonymous Coward · · Score: 0

      Liked that one!

    332. Re:rm -rf / by Anonymous Coward · · Score: 0

      It will not do anything, unless you add the --no-preserve-root switch.

      # rm -rf /
      rm: cannot remove root directory `/`

    333. Re:rm -rf / by Anonymous Coward · · Score: 0

      cat /dev/mem > /dev/dsp
      Try it :P

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

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

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

      not to mention, su - username -c command

    336. 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
    337. 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*-
    338. Re:rm -rf / by LinusMartensson · · Score: 1

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

    339. Re:rm -rf / by Anonymous Coward · · Score: 0

      I did it!!!!!! worked like charm!!!!

    340. 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.
    341. 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."
    342. 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.

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

      You were using DOS and Windows 3.1 in 1998?

      --
      Sig: I stole this sig.
    344. 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.

    345. 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)

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

      One little thing I use quite a bit is:

      $pgrep [process] | xargs kill

    347. 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.
    348. 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

    349. 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
    350. 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
    351. 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.

    352. Re:rm -rf / by Anonymous Coward · · Score: 0

      > rm -rf /

      fvck you assh0le

    353. 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.

    354. Re:rm -rf / by Anonymous Coward · · Score: 0

      Dig out whatever terminal someone is connected to from the w output, then redirect urandom to it. Great way to piss off specific users.

    355. 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!
    356. Re:rm -rf / by Anonymous Coward · · Score: 0

      You're terrible!

      (If anybody tried the above command, well..you probably wouldn't be reading this)

    357. Re:rm -rf / by Anonymous Coward · · Score: 0

      Please be familiar with some recovery tools before you run this command:

      search disk |grep recovery
      mondo - powerful disaster recovery suite
      mondo-doc - manual for Mondo, a powerful disaster recovery suite
      ras - Adds redundancy files to archives for data recovery.
      testdisk - Partition scanner and disk recovery tool

    358. Re:rm -rf / by Fizzl · · Score: 1

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

      (notice ^space)

    359. 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?
    360. Re:rm -rf / by T-Ranger · · Score: 1

      who are you calling a dollar dollar carrot?

    361. 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).

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

      haahhahahha

    363. 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*-
    364. Re:rm -rf / by Anonymous Coward · · Score: 0

      Wow.

      That's really bad taste.

    365. 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?

    366. Re:rm -rf / by Anonymous Coward · · Score: 0

      rm -rf /

      someone's going to try that just to see what it does

    367. 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.)

    368. 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.

    369. 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.

    370. 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.

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

      Mojo Nixon. Elvis is everywhere!

      [John]

      --
      Shit better not happen!
    372. 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.

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

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

    374. 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 Anonymous Coward · · Score: 0

      That's what I use every morning, from a crontab (followed by an xset dpms force on to give me some light)

    6. 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

    7. 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...

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

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

    9. Re:Well by Anonymous Coward · · Score: 0

      aplay /dev/urandom
      my primary way of testing if sound works ok. not that it is very good at determining if the soundcard actually plays what it should or just generates noise, but it doesn't need some complex mpg/ogg/whatever player.

      speaking of audio:
      echo -e "\e[11;500]\e[10;2350]\a" >/dev/tty0
      i once even hacked together a program to play melodies that way. quite some people in my university's computer lab were quite surprised that one can actually change the tone and duration of that annoying beep.

    10. 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!
    11. Re:Well by Anonymous Coward · · Score: 0

      This almost sounds like ZX Spectrum loading a game!

    12. 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 ;)

    13. 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!

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

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

    15. 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.

    16. Re:Well by Anonymous Coward · · Score: 0

      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.

      That's pretty funny I did the same thing except with cron but the whole point of using it as an alarm is that its anything but relaxing, infact with the volume set to half i remember it making me jump a couple feet out of bed the first time

    17. 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..

    18. Re:Well by Anonymous Coward · · Score: 0

      This completely destroyed my partition, in such a way that my files cannot be recovered.

      Please explain what your command does before you post it.

    19. Re:Well by Anonymous Coward · · Score: 0

      A better alarm would be

      yes wake up >/dev/dsp

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

      Oh God, I hate that.

      Running out of entropy, that is.

    21. 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
    22. 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 :)

    23. 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.
    24. 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?!

    25. 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.
    26. Re:Well by Anonymous Coward · · Score: 0

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

      A more thourough, and faster job would be to do:

      dd if=/dev/zero of=/dev/sda bs=1m

      You can adjust the bs to better make use of your drive, otherwise, its only going to do one char at a time, which takes forever.

    27. 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

    28. Re:Well by Anonymous Coward · · Score: 0

      Funny. I used that to copy a 30GB of data (!?!?). Yeah...
      (oh, that happened twice. after which I gave up on that method)

    29. 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

    30. Re:Well by Anonymous Coward · · Score: 0

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

      I do that regularly. I work in a place with automatic builds starting with PXE boot. The systems are configured to try the hard drive first, then PXE boot. With a zero'd-out boot sector it fails to boot from disk, fails over to PXE then starts rebuilding the box. My version is more like this though:

      sudo dd if=/dev/zero of=/dev/sda1 bs=1K count=1K
      sudo sync
      sudo sync
      sudo shutdown -r now

      Doing the entire first MB might be a little excessive but I know that it works. I frequently do this on virtual machines, especially if access to the console is over a slow link. I guess one person's parlor trick is a significant tool for another.

    31. 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.

    32. 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
    33. Re:Well by SMOKEING · · Score: 1

      cat /boot/vmlinuz >/dev/dsp

      and hear the subliminal message in it.

    34. Re:Well by Anonymous Coward · · Score: 0

      Am I the only one that tried:

      dd if=/dev/sda of=/dev/dsp ?

      Ext3 rocks.

    35. 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.
    36. Re:Well by joeljkp · · Score: 1

      Here's a good one:

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

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

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

    38. 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
    39. Re:Well by DaVince21 · · Score: 1

      Thanks, that works!

      --
      I am not devoid of humor.
    40. Re:Well by Anonymous Coward · · Score: 0

      $ at 6 am
      > mplayer /home/user/alarm.mp3
      ^D
      $

  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 Anonymous Coward · · Score: 0

      We used to have Screen -x wars. Back before pop-up blockers we would see who could render the other machine useless by sending over one website request.

      The further in teh gutter you were the better it was :)

    2. 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.

    3. 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
    4. Re:session-sharing with screen -x by Anonymous Coward · · Score: 0

      Absofreakinlutely. 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? A whole set of detached screens!

    5. 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.
    6. 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
    7. 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

    8. 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.))

    9. 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
    10. Re:session-sharing with screen -x by skis · · Score: 1

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

    11. 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.

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

      nohup if it can run in the background.

    13. 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.

    14. 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
    15. Re:session-sharing with screen -x by Anonymous Coward · · Score: 0

      Screen is great. However, the whole "pair programming" thing is just gay. Really, really gay.

      There are too many stupid "methods" out there now. Sorry, but after 15+ years, I learned that programming, while a team job, is an individual effort. Two people working on the same keyboard/screen/line of code/etc at the same time is gay, really, really gay.

      I am just so glad I don't work for a company that jumps on the latest fad programming junk.

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

      xroach was a classic - great fun!

      --
      Hulk SMASH Celiac Disease
    17. Re:session-sharing with screen -x by Anonymous Coward · · Score: 0

      It just got more awesome for me today because I learned that screen
      can be used instead of minicom for talking on a serial port/modem:

      http://bryan-murdock.blogspot.com/2008/02/screen-as-serial-terminal.html

    18. Re:session-sharing with screen -x by Anonymous Coward · · Score: 0

      All operating systems can handle batches with many choices for queues. Batches suck for interactive stuff, like IRC and vi, which is what screen is for.

    19. Re:session-sharing with screen -x by Macka · · Score: 1

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

    20. 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.

    21. 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!
    22. 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.

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

      I used to torture a coworker w/ xsnow.

    24. 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"

    25. 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

    26. Re:session-sharing with screen -x by Anonymous Coward · · Score: 0

      Yeah, screen is excellent. I tend to use it more for moving console sessions between local logins and from-laptop ssh sessions, but either works.

    27. 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.

    28. 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.

    29. 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
    30. Re:session-sharing with screen -x by yahyamf · · Score: 2, Interesting

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

    31. Re:session-sharing with screen -x by Anonymous Coward · · Score: 0

      (used in my company for doing the agile/extreme "pair programming" think with a remote devloper, among other things).

      screen is awesome.

      I used to be fond of kibitz, which did something similar.

    32. 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
    33. 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
    34. Re:session-sharing with screen -x by Anonymous Coward · · Score: 0

      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'.

      Eject still works with many dvd/cd drives, even on servers. I'd rank how entertaining it can be, but some buzzkill will probably be along any moment to call me a juvenile.

      Like with puns, stuff like this only seems juvenile when you're the target.

    35. Re:session-sharing with screen -x by cinderblock · · Score: 1

      Use eject -T to open AND close the tray.

    36. 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 Anonymous Coward · · Score: 0

      invariably when I ask the young someone to "cd someplace" or whatever, they grab at the mouse. Very few windows users even know that a command window exists, let alone what I mean by telnet

    4. 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.

    5. 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.
    6. 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.
    7. 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.
    8. Re:There is this part ... by Anonymous Coward · · Score: 3, Interesting

      eject cdrom is great for locating poorly labeled machines too!

    9. 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.

    10. Re:There is this part ... by tnk1 · · Score: 1

      You clearly fail to understand the power of Emacs.

      Sorry... I had to.

    11. 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.

    12. 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.

    13. 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.

    14. Re:There is this part ... by Anonymous Coward · · Score: 0

      I've done a similar thing, on purpose to figure out which machine was which in a machine room

    15. 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.
    16. 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.
    17. Re:There is this part ... by Anonymous Coward · · Score: 0

      Now i know why long ago users were asking me why there coffee cup holders were going in and out by themselfs

    18. 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...

    19. Re:There is this part ... by ziggit · · Score: 0

      I have a quasi similar story to this. So one of my friends used to have this bad habbit of saying his passwords while he was typing them, which usually wasn't a problem, but he happened to do it one time while I was on the phone with him, and it happened to be his root passqord... Whoops! Armed with this knowledge, I also realized that he had a subdomain on his site set up to re direct to his home machine so he could access stuff from school. Soo a couple days later, we were chatting online and I feel like messing with him so I went to eject his cdrom a couple times to mess with him. Unknown to me, I accidentally ejected his zip drive instead. The best part was, his desktop was set up so the drive was above his monitor on a shelf, so when I ejected it, the zip disk ended up hitting him right on the head.

    20. 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 */
    21. Re:There is this part ... by Anonymous Coward · · Score: 0

      echo "help" > /dev/pts/0

    22. Re:There is this part ... by Anonymous Coward · · Score: 0

      remember that aux/aux bug on windows, that was a blast as well, back when there were all these anonymous ftp daemons still running on '98 ftp://lamehost/aux/aux talk about an easy dos

    23. Re:There is this part ... by mallumax · · Score: 1

      FTP to desktop ? Which FTP client allows you to type commands like "cd a:" ?

    24. Re:There is this part ... by Anonymous Coward · · Score: 0

      You might want to, you know, RTFM for Dev Studio. It can do regex search and replace.

      It's kind of weird. UNIX people expect to read man pages. Windows people expect everything on a plate. And the same guy can be a UNIX person one minute and a Windows person the next!

    25. 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.

    26. 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.
    27. 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.

    28. Re:There is this part ... by Anonymous Coward · · Score: 0

      i had my leds on keyboard doing disco :)

    29. Re:There is this part ... by Anonymous Coward · · Score: 0

      But now that one line of code could be modified by someone that only lightly understands regex's

      The reason you get the $$$ bill rate is that you 'create' things that can then be handled by the people that only get $$ as a bill rate.

    30. 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.

    31. Re:There is this part ... by Anonymous Coward · · Score: 0

      Gotta do it through ssh... Really scary. Witness.

    32. Re:There is this part ... by Anonymous Coward · · Score: 0

      There is that little checkbox in the Search/Replace dialog in Visual Studio that says "Use Regex"...

    33. 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.
    34. Re:There is this part ... by Anonymous Coward · · Score: 0

      There's something nice about reading a post that is somewhat articulate while at the same time "hits home". However, your usage of "lol" negated everything articulated prior -- in its entirety -- and I'm thoroughly convinced that at this point, your bill rate should be adjusted to something grossly less exorbitant.

    35. 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.

    36. 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)

    37. Re:There is this part ... by Anonymous Coward · · Score: 0

      If you're going to use a search for the OSX example, you might as well do the same for the Windows one. If you're not going to learn how to use Windows, don't bitch about it.

    38. 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;
    39. 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 --
    40. Re:There is this part ... by Anonymous Coward · · Score: 0

      My better half does not understand how I can keep an overview of the information in a terminal.

    41. 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 Vancorps · · Score: 0

      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.

      Back on topic, I think diff is a very powerful tool while troubleshooting a Unix-like boxen. You have a working config and a non-working config, diff em and see what's broken!

    2. Re:Uhhmmm... by Isaac1357 · · Score: 2

      To be fair, X crashing is not the same as the OS itself crashing.

    3. 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
    4. 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.

    5. 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.

    6. 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 :-)

    7. 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.

    8. 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.

    9. 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.

    10. 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.

    11. 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.

    12. 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.
    13. 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.

      --
    14. 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."
    15. 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 Anonymous Coward · · Score: 0

      ... except it's not recursive. 'du -s *' is.

    7. 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.

    8. 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.

    9. 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

    10. 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

    11. 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.
    12. Re:Stupid Tricks by voxner · · Score: 1

      du -sh * | sort -n
      This makes more sense I guess.

    13. Re:Stupid Tricks by portscan · · Score: 1

      try

      du --max-depth=1

    14. 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. ftp from a command line by Anonymous Coward · · Score: 0, Interesting

    People here are so used to using some drag and drop gui that they didnt know you could ftp from a cli....

    1. Re:ftp from a command line by Drinking+Bleach · · Score: 1

      Holy crap, there's GUI FTP clients?

    2. 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!

    3. 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.
  8. 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 Anonymous Coward · · Score: 0

      I don't know that I'm "more modern" since I've been using UNIX since 1992, but I made a conscious decision to learn perl rather than awk. I was a hardcore C/C++ and real-time programmer at the time.

      grep doesn't have enough capability to bother with, egrep is useful, however.

      Oh, and emacs still stands for "eat memory and cores." I had a user ask me to load it for him last week. I told him to use vi and get used to it. If he's nice and takes me to lunch 10 times, I **may** load vim.

      It's good to be the CIO.

      Oh, something useful. alias psg='ps -eaf| grep'
      or use aux on sys5.

    8. 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.

    9. Re:grep and awk by Anonymous Coward · · Score: 0

      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?

      That's sooooo 1980s thinking. These days you can just download gcc binaries for your benighted platform.
      Granted, I don't see binaries from trustworthy sources for some really benighted platforms like DEC Ultrix or A/UX. If you're stuck on those things then you have my sympathy....

    10. 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.

    11. Re:grep and awk by thogard · · Score: 1

      You may find perl is much faster than awk, sed and grep especially when combined.

    12. Re:grep and awk by shaitand · · Score: 1

      I prefer to use all of the above ;)

    13. 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.

    14. Re:grep and awk by TheLink · · Score: 1

      You might find perl's -n switch useful as well.

        -n assume 'while (<>) { ... }' loop around program

      --
    15. 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.

    16. 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.
    17. 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.
    18. 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.
  9. 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 Anonymous Coward · · Score: 0

      I think you mean: grep -r [string] .

    4. Re:Find / Grep by Anonymous Coward · · Score: 0

      the proper term is PIPE

      | is the pipe operator.

    5. Re:Find / Grep by NevarMore · · Score: 1

      locate [string]

    6. 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?"
    7. 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.

    8. 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.

    9. Re:Find / Grep by Anonymous Coward · · Score: 0

      I really like the combination

      find . -name "*.c" -exec grep -H something {} \;

      when I can't remember where "something" in in a file. The -H gives me the filename as well as the context.

    10. 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]

    11. 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?
    12. Re:Find / Grep by mi · · Score: 1

      and they call themselves 'linux admins'?

      Linux is not Unix.

      --
      In Soviet Washington the swamp drains you.
    13. Re:Find / Grep by Anonymous Coward · · Score: 0

      find . -name *string*

    14. 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.

    15. 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.

    16. 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/
    17. 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.
    18. 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?
    19. 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.
    20. 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.
    21. Re:Find / Grep by hazem · · Score: 1

      Why should I need anything besides text?!

      The porn isn't as good?

    22. 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" *

    23. 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
    24. 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.

    25. 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/

    26. 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.

    27. Re:Find / Grep by wanderingknight · · Score: 1

      locate is a wonderful tool. Learn it, use it, love it.

    28. Re:Find / Grep by Anonymous Coward · · Score: 0

      Little known fact: Skynet was accidentally created when a unix hacker piped things through too many levels of grep and sed.

    29. 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
    30. Re:Find / Grep by Pvt_Ryan · · Score: 1

      apparently you left out

      windows is not unix.. :P

    31. Re:Find / Grep by Pvt_Ryan · · Score: 1

      pft with commands like touch, finger, grep yea it is. :)

    32. 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."
    33. 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."
    34. Re:Find / Grep by Logic+and+Reason · · Score: 1

      grep -r

    35. 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.
    36. 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).

    37. 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.

    38. 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.
    39. Re:Find / Grep by gnud · · Score: 1

      You might need to add dc. But then I think you're set =)

    40. 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!"
    41. 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]

    42. Re: Find / Grep by Anonymous Coward · · Score: 0

      People forget the a grep with multiple arguments forces it to print the filename. So,
      find . -name \*.xml -exec grep -i application {} /dev/null \;
      results in filename: pattern match

      It's almost Christmas. Try,
      ar t "Santa Clause"

    43. 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?"
    44. Re:Find / Grep by Anonymous Coward · · Score: 0

      I was told by my pointy hair bosses many times to count the number of lines of code or do such odd things on a set of files in a directory tree. This is where the find + xargs combination used to come handy:

      Count number of lines of every file inside a directory tree: find . | xargs cat | wc -l

      With some adjustment and intelligent use of grep -v, I could remove comments, etc. and I used to have almost accurate data.

      The number of ways find + xargs can be put to good use is limitless...

    45. 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

    46. 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.

    47. Re:Find / Grep by dfiguero · · Score: 1

      For systems without grep -R:

      find . -exec grep -i somestring {} \; -print

      --
      My penguin ate my sig
    48. Re:Find / Grep by Galilee · · Score: 0

      egrep 'foo|bar'

      That will give you every line which contains foo or bar.

    49. 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!!!
    50. Re:Find / Grep by databoi · · Score: 1

      locate [string]

      Without a locate db, this doesn't work!

    51. 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.
  10. 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 Anonymous Coward · · Score: 0

      the xargs trick is more useful when you want to grep a subset of the files.

      incidentally though, you should always pipe using "find -print0 | xargs -0"

    4. Re:grep -R by Anonymous Coward · · Score: 0

      I've always been partial to:

      find . -exec grep -l foo {} \;

    5. 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?
    6. 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?

    7. Re:grep -R by cain · · Score: 4, Funny

      BTW: How does one ork a cow?

      Very, VERY, carefully.

    8. Re:grep -R by Anonymous Coward · · Score: 0

      Oh, come on! I promise there are no files named 'rm -rf /home |' in the directory. Honest!

    9. 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

    10. 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

    11. Re:grep -R by Anonymous Coward · · Score: 0

      find . -type f -exec ls -l {} \;

      find . -type f -ls

    12. Re:grep -R by Anonymous Coward · · Score: 0

      Mod parent up, finally a way to do this easily
      $ grep -R foo files directories
      $ grep --version
        GNU grep 2.5.3
      $ man grep ...
      -R, -r, --recursive
            Read all files under each directory, recursively; this is equivalent to the -d recurse option.

    13. 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.

    14. Re:grep -R by Neon+Spiral+Injector · · Score: 1

      Backticks don't nest, so I've moved to the newer $(...) construct.

    15. 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?
    16. 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.
    17. 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.

    18. 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."
    19. Re:grep -R by 1110110001 · · Score: 1

      With the gnu tools installed use ggrep - also works with other commands, i.e. find becomes gfind, ..

    20. Re:grep -R by Anonymous Coward · · Score: 0

      but that is way slower. you are exec'ing a subprocess for every file.
      the xargs method is better since it allows grep to be run once across may file at a time.

    21. Re:grep -R by Anonymous Coward · · Score: 0

      FYI, backticks are considered harmful; use $( ... ) instead:

            cat $( find . -name 'foo*' )

      The advantage is that you can nest occurrences of $(...) inside one another, whereas you can only nest backticks if you escape the inner backticks (which is tiresome and error-prone).

    22. 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
    23. 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
    24. 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.
    25. Re:grep -R by famebait · · Score: 1

      BTW: How does one ork a cow?

      Threel-egged spool and a tail

      --
      sudo ergo sum
    26. 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)
    27. 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.
    28. 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.

  11. 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 Anonymous Coward · · Score: 0

      You mean he wrote a command to do the same as write user@hostname will do if you have the write daemon enabled on hostname?

    4. 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'.

    5. Re:On to the pranks! by Anonymous Coward · · Score: 0

      I made a comment on this further down but it's pretty easy...

      Get the pid of the user's shell
      echo -e "\nMessage from GeeDub@whitehouse.gov on tty69 at 04:20 ...\nWhat up dbag?\n" >/proc/$PID/fd/1

      You'll need permissions to write to their shell's stdout (root unless you own their shell which isn't likely).

  12. 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 Anonymous Coward · · Score: 0

      I believe that's a feature only of certain shells like bash, not really a unix-wide trick.

    4. 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.

    5. 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
    6. 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!
    7. 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.

    8. 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?

    9. Re:Tab by fimbulvetr · · Score: 1

      It does make ssh connections, at least on the newest ubuntus with pub keys set up.

    10. Re:Tab by skiingyac · · Score: 1

      CTRL-r for reverse command history search, many people don't know that one.

    11. 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.

    12. Re:Tab by 19thNervousBreakdown · · Score: 1

      Also from ~/.ssh/known_hosts.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    13. 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>
    14. Re:Tab by Anonymous Coward · · Score: 0

      and don't forget that bash will tab-complete environment variables in addition to commands and file/directory names.

    15. 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.

    16. Re:Tab by sorak · · Score: 2, Insightful

      How about this?

    17. 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.

    18. Re:Tab by 19thNervousBreakdown · · Score: 1

      Rainbow tables.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    19. 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.

    20. 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!

    21. 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?"

    22. Re:Tab by rubberglove · · Score: 1

      and ~/.ssh/config

    23. 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.

    24. Re:Tab by Anonymous Coward · · Score: 0

      depends on which extra profiles you've got installed in /etc/bash_completion (in debian-derivatives that is..)

    25. 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 ;)

    26. 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.

    27. 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.

    28. 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.

    29. 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.

    30. Re:Tab by Bandman · · Score: 1

      I knew the /etc/hosts, but I had no idea about known_hosts. That's excellent!

    31. 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.

    32. 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.

    33. 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.

    34. 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
    35. 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
    36. 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.

    37. 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.
    38. 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.

    39. 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.

      --
      .
    40. Re:Tab by Anonymous Coward · · Score: 0

      tab completion for ssh also searches ~/.ssh/config

    41. 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!
    42. 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.

    43. 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
    44. Re:Tab by Anonymous Coward · · Score: 0

      Sure, openoffice.org although it uses space or enter for the completion IIRC :)

    45. 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..

    46. Re:Tab by Anonymous Coward · · Score: 1, Funny

      Autocompletion reads your mind! In fact this message was typed entirely by pressing repeatedly.

    47. 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.

    48. Re:Tab by Anonymous Coward · · Score: 0

      Try "set -o vi" to make ksh command line act like vi. It has some tab completion via Esc followed by \ (no equivalent for tab tab that I know of). To browse thru history, Esc then j and k for next and previous; also Esc, /command, Enter searches in history for "command" (after that you use n and N for next and previous :-) ). It acts pretty much like vi; you need Esc to exit from insert mode (?) to command mode. Bash also supports "set -o vi" so you can test it on your system.

    49. 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

    50. Re:Tab by Anonymous Coward · · Score: 0

      the letters 'a' thru 'z'

      You misspelt "to".

    51. 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
    52. 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.

    53. 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...

    54. 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.
    55. 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

    56. Re:Tab by setagllib · · Score: 1

      A lot of the functionality was merged in anyway.

      --
      Sam ty sig.
    57. Re:Tab by Anonymous Coward · · Score: 0

      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.

      Nice! Hey, WTF is lickmyfurrysquirrel.com doing in my hosts file?!?

    58. 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.

    59. 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."
    60. 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

    61. Re:Tab by YtsaeB · · Score: 0

      A better way of doing this would be utilizing a bash function.

      in your .bashrc put the following:

      _complete_ssh_hosts ()
      {
      COMPREPLY=()
      cur="${COMP_WORDS[COMP_CWORD]}"
      comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
      cut -f 1 -d ' ' | \
      sed -e s/,.*//g | \
      grep -v ^# | \
      uniq | \
      grep -v "\[" ;
      cat ~/.ssh/config | \
      grep "^Host " | \
      awk '{print $2}'
      `
      COMPREPLY=( $(compgen -W "${comp_ssh_hosts}" -- $cur))
                      return 0
      }
      complete -F _complete_ssh_hosts ssh
      complete -F _complete_ssh_hosts ping

      This will allow you to ssh tab complete bashed on hosts you have already connected to and accepted their hostkeys. Also works for ping

      -Brad

    62. Re:Tab by Anonymous Coward · · Score: 0

      with tcsh you can custom program your completions. I set mine up to auto complete makefile (or ant) targets, custom commands, options to common commands, etc. Very Useful

    63. 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>
    64. 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
    65. 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
    66. Re:Tab by Anonymous Coward · · Score: 0

      Yes. Please try it using Excel.

    67. Re:Tab by Anonymous Coward · · Score: 0

      And zsh will tab complete from your known_hosts file, too. zsh tab completion is awesome - if you double-tab it can even show you extra arguments you can supply

    68. Re:Tab by Anonymous Coward · · Score: 0

      in ubuntu, you need to set HashKnownHosts no in your /etc/ssh/ssh_config

      and remove .ssh/known_hosts

    69. Re:Tab by Anonymous Coward · · Score: 0

      If you install bash-completion, they don't have to be in the hosts file, it will pull the names from ~/.ssh/known_hosts. But bash-completion completes a lot of commands. It will deal with things like openssl command-line options, or when you do "acroread [tab]" that it will only complete for pdf files. And it is all configurable so you can make it complete whatever you want.

    70. Re:Tab by Anonymous Coward · · Score: 0

      other than fdisk? no.

    71. 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.

    72. Re:Tab by Anonymous Coward · · Score: 0

      In zsh, you can do this to complete remote directories with scp. Very useful in combination with publickey or gssapi/kerberos authentication. scp foo user@host:some/di[tab]

    73. 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.

    74. 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.
    75. Re:Tab by Anonymous Coward · · Score: 0

      it also finds targets in makefiles

    76. 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."
    77. Re:Tab by richie2000 · · Score: 1

      Stop using Word.

      --
      Money for nothing, pix for free
    78. Re:Tab by Anonymous Coward · · Score: 0

      I think this is it for me. I will search out programs that support it (lftp over any other ftp program as 1 example) and I get very bleak when I hit some project or other that does not. Command line learning curve is supposed to be much steeper (and this is hysterical btw) but tab-completion makes it stacks easier to learn and faster once you are an advanced user.

    79. 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

    80. Re:Tab by eta526 · · Score: 1

      This is correct. For example: bash supports it, sh does not.

    81. 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.

    82. 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

    83. Re:Tab by Anonymous Coward · · Score: 0

      it is filled from .ssh/known_hosts indeed; completion also applies to many other tasks as /sbin/service (from `ls /etc/init.d`), rpm (from /var/log/rpmpkgs), kill (ps) and many others, but you wont get it with plain bash, you need bash_completion from caliban.org

      i think its very useful but sometimes gets disappoiting because it wont complete the file for mplayer just because it doesnt end with .mpg

    84. Re:Tab by Anonymous Coward · · Score: 0

      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?

      of course.

      Its 'rm -rf /Applications/Word.app'

    85. 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

    86. 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!!!
    87. Re:Tab by Anonymous Coward · · Score: 0

      ..from ~/.ssh/known_hosts. Truth in advertising.

    88. Re:Tab by Anonymous Coward · · Score: 0

      And if you have ssh pub/priv keys sorted, bash will autocomplete remote paths too!

      Woohoo!

    89. 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.

    90. 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
    91. Re:Tab by Anonymous Coward · · Score: 0

      Try zsh. You get tab completions for almost anything. You can ctrl-r away at ps , ls , anything ...

      zsh > *

    92. Re:Tab by Anonymous Coward · · Score: 0

      escape+escape for tab completion on AIX

    93. Re:Tab by Spug · · Score: 1

      Try ^N and ^P

    94. 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.
    95. 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.
    96. Re:Tab by badkarmadayaccount · · Score: 1

      del C:>WINDOWS

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    97. 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.

    98. 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.

    99. 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.

    100. Re:Tab by Anonymous Coward · · Score: 0

      It didn't happen for me.

    101. Re:Tab by Anonymous Coward · · Score: 0

      Better, though, add a section to your .ssh/config; this lets you change all kinds of things on a per-host basis. (All of my hosts listen on different ports for SSH, for instance.)

    102. Re:Tab by Anonymous Coward · · Score: 0

      Why not use the shortcut for life-completion

    103. 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"

    104. 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)

  13. How about a new GUI apt get trick? by Anonymous Coward · · Score: 0

    apt get is so damned easy...unless you've never seen a command line or don't know what you're looking for.

    Is there a GUI widget you can install which is basically an apt get with a select-from-a-list (might as well be online) for new packages? I spend a month every year thinking I'll switch to linux before I get stuck on something and crawl back to win-only. Call it grandma's attic, or something cute, let the community rate packages, and have an auto-MD5 check.

    Does it exist? If not, it should.

  14. 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 Anonymous Coward · · Score: 0

      I can never remember how to spell that, so instead I just use "man -k". I guess one could also use "whatis".

    11. 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??

    12. Re:I never knew that command by Anonymous Coward · · Score: 0

      man -k

      makes the man pages easier to search.

    13. 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.
    14. 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
    15. Re:I never knew that command by Anonymous Coward · · Score: 0

      Who the heck is Tim Berners-Lee? Al Gore invented the internet. Get your facts straight.

    16. Re:I never knew that command by Anonymous Coward · · Score: 0

      Wow...you must be spoiled. Try using MSDN docs. Javadocs rock.

    17. 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!
    18. 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
    19. 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.

    20. 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
    21. 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.
    22. 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.

    23. Re:I never knew that command by Anonymous Coward · · Score: 0

      [...] a gift from the dieties.

      Are they the ultra-slim super humans I keep hearing about? Or am I confusing them with deadly cocktails??

      dyslexic hippies, would be my guess

    24. 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.

    25. Re:I never knew that command by Creepy+Crawler · · Score: 1

      So Richard Simmons, Weight Watchers, and Jenny Craig made the man pages?

      egads.

      --
    26. 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.

    27. 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.
    28. 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!
    29. Re:I never knew that command by Anonymous Coward · · Score: 0

      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 don't understand, is the second paragraph in support or against the first?

    30. Re:I never knew that command by Anonymous Coward · · Score: 0

      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.

      My own experience is that the *BSDs tend to do better than various Linuxes when it comes to completeness and usefulness of man pages.

      This very issue catches me off guard every time I have to do Linux admin work after having been away from Linux for several months.

    31. 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.

    32. 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
    33. Re:I never knew that command by Anonymous Coward · · Score: 0

      man is awful?
      try MSDN!

    34. 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

    35. 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
    36. 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.

    37. Re:I never knew that command by Anonymous Coward · · Score: 0

      apropos

    38. 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.

    39. 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.

    40. 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."
    41. 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.

    42. 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.

    43. 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).

    44. Re:I never knew that command by Niten · · Score: 4, Funny

      Pretty much anything in here: http://www.openbsd.org/cgi-bin/man.cgi

    45. Re:I never knew that command by Anonymous Coward · · Score: 0

      For permanent relief from crap man pages see http://www.openbsd.org/.

    46. 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
    47. 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.

    48. 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.

    49. 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
    50. Re:I never knew that command by Anonymous Coward · · Score: 0

      I approve of your most accurate description of the state at hand.

    51. 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.

      --
    52. 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)
    53. Re:I never knew that command by Anonymous Coward · · Score: 0

      Don't cast the first stone. Or contribute man pages.

    54. 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'!"
    55. 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'!"
    56. Re:I never knew that command by Anonymous Coward · · Score: 0

      I find the linux devs good with manual pages. Git for example is fully documented via man pages. I have used little else in learning git.

    57. 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.
    58. 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.

    59. 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
    60. 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
    61. Re:I never knew that command by Anonymous Coward · · Score: 0

      That's a Linux problem. Try the BSD manpages - whenever I have to admin Linux systems, I keep a BSD shell open for the man pages.

    62. Re:I never knew that command by Anonymous Coward · · Score: 0

      Got some issues? Frustrations? Oooh.. boiohboi ;)

    63. Re:I never knew that command by Anonymous Coward · · Score: 0

      ytalk...

    64. 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.

    65. Re:I never knew that command by berbo · · Score: 1

      dietIE is Microsoft's new "bloatless browser"

    66. Re:I never knew that command by Anonymous Coward · · Score: 0

      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.

      At my open-plan office our 'l33t' sysadmin decided that it was a good idea not to install help.

      Momentarily distracted by that I immediately googled 'man pages'...

    67. 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
    68. Re:I never knew that command by Lord+Kestrel · · Score: 1

      Why not just "man foo", and then hit / to search?

    69. 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
      $

    70. 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.

    71. 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.

    72. 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.

    73. 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.
    74. 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.

    75. 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.

    76. 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.

    77. Re:I never knew that command by Anonymous Coward · · Score: 0

      Hear hear! Sometimes I am appalled by the "cognoscenti" lack of respect of simple user requests. The only thing that comes close to the dreadful man and help pages are books purporting the secrets of beating the stock-market. They seem to be black holes of knowledge sucking your very life force as you read them.

      Some people have to learn that obfuscation does not equate to intelligence in fact the very opposite is usually true. If someone tries to make things more complicated than they really are it is usually because of lack of substance. Viz a Viz stock market books or man pages. However some of the most beautiful (and complicated) things in science and maths can be explained so simply, such as the de Broglie wavelength of an electron or the equivalence of energy and matter. I could go on but I am glad that someone brings this up!

    78. 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!

    79. 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.

  15. 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 Anonymous Coward · · Score: 0

      It is the best PALINdrome tester I ever saw ere I saw elba.

    12. Re:rev by Anonymous Coward · · Score: 0

      I use rev when I want to process a file all on one line without looking like I'm forcing it ;)
      For example, lets say I have a text file full of filenames of porn that I have archived for historical purposes:

      debby does dallas - 1978
      Debbie Does Dallas Part II - 1981
      deep throat - directors cut - 1998 ...

      If I want to get a list of just the years
      cat pornlist |rev |awk '{print $1}'|rev

      (toss in a uniq -c if you want to figure out which year was your favorite)

    13. 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) }'

    14. 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'

    15. Re:rev by Anonymous Coward · · Score: 0

      > one of the most useless Unix commands I've ever come across

      That would be 'la', which ships - no, apparently used to ship - with OpenBSD. (The man page comments: Chip's staff has very weird ideas about what is funny.)

    16. 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.

    17. Re:rev by Anonymous Coward · · Score: 0

      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.

      very similar to what you've done there, the rev command is useful for grouping domain names (since it will sort by tld first, then 2nd-ld, etc).

    18. 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
    19. Re:rev by Bill+Evans · · Score: 1

      Two words: rhyming dictionary.

      rev | sort | rev

      --
      Oh, this Beta, it is not so good.
    20. 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...
    21. Re:rev by Anonymous Coward · · Score: 0

      For commands that doesn't have a "-y: assume yes" switch.

      A stupid example (because I don't remember a command that asks silly questions and doesn't have a -y switch):

      yes | rm -i *

    22. Re:rev by remmelt · · Score: 1

      yes | mysqladmin drop database

    23. Re:rev by remmelt · · Score: 1

      ....

      mysqladmin -f drop database

      Thanks!

    24. Re:rev by Anonymous Coward · · Score: 0

      How about:

      bash | rev

    25. 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)
    26. 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.

    27. Re:rev by Anonymous Coward · · Score: 0

      Actually, rev _is_ quite useful...
      Let's say you have a file like this:
      a1,a2
      b1,b2,b3,b4
      c1,c2,c3

      and want to have last column only:

      cat file|rev|cut -f1|rev

      Simple? :)

    28. 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`

    29. Re:rev by genner · · Score: 1

      tail -1 filename

      does the same thing and is much simpler.

    30. Re:rev by Anonymous Coward · · Score: 0

      reversing log file order is actually quite usefull when doing analysis.

    31. 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!

    32. Re:rev by Anonymous Coward · · Score: 0

      You even could not imagine, how usefull could it be! I try to install it on every system I have.

      I use it to display numbers, separated in groups.
      I.e. instead of "abc.txt 2909090329 bytes" You will see "abc.txt 2,909,090,329 bytes".
      Sometimes it could save You several hours - just because You can easily see, You have 2Gb, not 20Gb space.

      It looks like the following:
        ll | rev | sed 's/\([0-9][0-9][0-9]\)/\1,/g' | rev | sed 's/\([^0-9]\),\([0-9]\)/\1\2/g;s/^,\([0-9]\)/\1/g'

      and I like it...

      (found it here: http://code.techinterviews.com/rev-function-and-comma-separated-output/6)

  16. 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.

  17. 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 Anonymous Coward · · Score: 0

      instead of all this rubbish: find . -exec grep -l keyword {} \;

      you can do:

      grep -lir keyword .

      to do a recursive case-insensitive search for keyword in all files and spit out the filenames.

      booya

    6. Re:A simple search by Foldarn · · Score: 1

      use this instead: find . | xargs grep -l keyword much faster.

    7. 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

    8. 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?
    9. 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.

    10. 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

    11. 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.

    12. 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.

    13. Re:A simple search by skiingyac · · Score: 1

      search and replace multiple files: perl -p -i -e 's/foo/bar/g' file1 file2 file3

    14. 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

    15. 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.
    16. 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.
    17. Re:A simple search by JohnnyBGod · · Score: 1

      Erm... what was wrong with 'grep -nri keyword *'?

    18. Re:A simple search by Anonymous Coward · · Score: 0

      find . -exec grep -l keyword {} \;

      Same thing but faster:

      find . -type f | xargs grep -l keyword

      AC

    19. 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.

    20. Re:A simple search by Anonymous Coward · · Score: 0

      find . -exec grep -l keyword {} \;

      Works like a charm for finding a file containing a keyword.

      A friend showed me a nice variation of this that runs a bit faster:

      find . -print | xargs grep keyword

      With the parent's version, a new shell is spawned for each file found (hence the -l to list the filename). xargs smooths this out some. Big deal? Probably not, unless you've got thousands of files, then it can be noticeably faster.

    21. Re:A simple search by Anonymous Coward · · Score: 0

      du -u --max-depth=1

      you'll find even faster where your space is going...

    22. 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 */
    23. Re:A simple search by Anonymous Coward · · Score: 0

      More complex, but sort by file size, and paginated... Pipe for the win!

      # du -a | sort -n -r | more

    24. 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

    25. 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.
    26. Re:A simple search by Anonymous Coward · · Score: 0

      find . -exec grep -l keyword {} \;

      Works like a charm for finding a file containing a keyword.

      aw, c'mon, what an opportunity missed!

      surely you mean /.

    27. 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)

    28. 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 \;

    29. Re:A simple search by Anonymous Coward · · Score: 0

      How about 'grep -rl $KEYWORD' instead?

    30. 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...

    31. 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.

    32. 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)

    33. 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.

    34. 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.)

    35. 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

    36. 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.

    37. 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"

    38. 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! :-)

    39. 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)

    40. 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.
    41. Re:A simple search by Anonymous Coward · · Score: 0

      "powers of 1000 not 1024"

      Are you kidding me? What a$$hole decided to add that option. You are a disgrace to computing.

    42. Re:A simple search by Anonymous Coward · · Score: 0

      find . -exec grep -l keyword {} \;

      With GNU grep it's easier to just do

      grep -r keyword .

      It also has less overhead since you only execute a single instance of grep. The -r parameter won't work with Solaris or BSD grep though.

    43. Re:A simple search by Anonymous Coward · · Score: 0

      Or you could use the slightly more memorable -r flag in grep!!

      grep -r 'keyword' .

    44. 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)

    45. Re:A simple search by Anonymous Coward · · Score: 0

      Never use -exec with find. Always pipe output to xargs:
      find . | xargs -- grep -l keyword

    46. 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 .

    47. Re:A simple search by Anonymous Coward · · Score: 0

      find . -exec grep -l keyword {} \;
      Works like a charm for finding a file containing a keyword

      i'd better go with, 'twould be much less stressful

      find . -print0 | xargs -0 grep -l keyword

    48. Re:A simple search by Bandman · · Score: 1

      Doesn't unix tar have -y for .Z ?

    49. Re:A simple search by Bandman · · Score: 1

      If you don't want directories,

      ls -alSr | tail -n 10

    50. 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...

    51. 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. ;-)

    52. Re:A simple search by Bandman · · Score: 1

      du -hs

    53. 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. :-)

    54. 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...

    55. Re:A simple search by jherrick · · Score: 0

      Track down where your space is going:
      (child directories only)

      du -h --max-depth=1

    56. Re:A simple search by Anonymous Coward · · Score: 0

      Might I suggest xargs?

      find . | xargs grep [-l] keyword

      Does the same thing with fewer forks in your system, so if the file list is large will likely be somewhat faster.

      I might also recomend '-type f' to your find. And maybe '-follow'.

    57. 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!
    58. Re:A simple search by Anonymous Coward · · Score: 0

      Mass search and replace:
      find . -type f -exec sed -i 's/findWord/replaceWord/g' {} \;

      find all files in a directory structure and execute an inline sed command on them.

    59. 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!
    60. Re:A simple search by anom · · Score: 1

      Grep has this built in grep -r [-i] "keyword" *

    61. Re:A simple search by Anonymous Coward · · Score: 0

      cat myfile.txt | cut -d \; -f 2 | sort > output.txt

      Tsk. Useless use of cat.

      http://partmaps.org/era/unix/award.html

      That should of course be:

      cut < myfile.txt -d \; -f 2 | sort > output.txt

    62. Re:A simple search by Anonymous Coward · · Score: 0

      Convert all PSDs to PNGs:

      ls *.psd | cut -d . -f 1 | xargs -L1 -i convert {}.psd {}.png

      The rare case where DOS is superior:

      rename *.psd *.png

    63. 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.

    64. Re:A simple search by Anonymous Coward · · Score: 0

      (Me again.)

      Woops -

      rename .psd .png *.psd

      works in unix. Slightly more complicated but could in theory be aliased and be as simple as DOS.

      (too lazy to put that in typewriter text)

    65. 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.

    66. 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.

    67. 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

    68. Re:A simple search by Anonymous Coward · · Score: 0

      grep -R keyword .
      works much better

    69. 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."

    70. Re:A simple search by TREE · · Score: 1

      Yet Another Reason To Use Debian. :)

    71. 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.

    72. Re:A simple search by Bandman · · Score: 1

      Nice. I'm not sure I'd trust it in production, but cool nonetheless

    73. 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.

    74. Re:A simple search by Anonymous Coward · · Score: 0

      Doy. Reading comprehension FAIL.

    75. 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!
    76. Re:A simple search by Anonymous Coward · · Score: 0

      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.

      Doesn't work for me. I have to do <enter>CTRL-D and subtract one, or press CTRL-D twice. Go figure.

    77. Re:A simple search by TheLink · · Score: 1

      I prefer just doing it in one go:

      du -k | sort -nr | more

      --
    78. 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

    79. Re:A simple search by Anonymous Coward · · Score: 0

      Isn't:

      for i in *.psd ; do convert ${i} ${i:r}.png ; done

      simpler? Also, it should scale with a very large
      number of files.

    80. Re:A simple search by MikeBabcock · · Score: 1

      du -ms * | sort -g is even better.

      --
      - Michael T. Babcock (Yes, I blog)
    81. Re:A simple search by Anonymous Coward · · Score: 0

      As for convert you could simply use convert *.jpg *.gif

    82. Re:A simple search by Anonymous Coward · · Score: 0

      personally, i wouldn't use cut but basename for that:

      find . name '*psd' | while read f ; do convert $f `basename $f .psd`.png ; done

      for files with more than dot in their name

    83. 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.
    84. 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.

    85. Re:A simple search by idfubar · · Score: 0

      Given the "Unix philosophy" isn't there something you could use to pipe in all files and return only those files which aren't "irregular"?

      --

      Rishi Chopra
      www.rishichopra.org
  18. 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 CronoCloud · · Score: 0

      I don't use screen, that's what mrxvt is for. (Yes, I know you can detach screen sessions locally and resume remotely, plus all sorts of other neat tricks but I never need to do that.)

    2. 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.

    3. Re:Screen by Anonymous Coward · · Score: 0

      I've used screen for years and years... I was skeptical tho checking out this mrxvt thing it really looks like a cool terminal emulator.

      Thanks!

    4. Re:Screen by dirtyhippie · · Score: 1

      haha, i have the same problem :-)

    5. 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
    6. 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?
    7. Re:Screen by VoidCrow · · Score: 1

      I know what you mean, but screen is usable.

    8. 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!
    9. 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.

    10. 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
    11. Re:Screen by Anonymous Coward · · Score: 0

      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.

      You can set the key binding to whatever you want. Backtick (`) works very nicely; you get to do stuff like `c to make a new window and `1, `2, etc to switch between them.

      Moderators are free to mod this Flamebait or Insightful, depending on personal bias.

      Aren't they always?

    12. Re:Screen by dysprosia · · Score: 1

      So use dtach.

    13. 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."
    14. 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@

    15. 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
    16. Re:Screen by Anonymous Coward · · Score: 0

      I'm a big fan of "disown" (as in "^Z, bg, disown %1") for handling my usual subset of needed screen functionality, namely ensuring a long-lived process continues running without TTY pipes when I'm on a poor remote connection.

      And yes, C-x is far too similar to the GNU beast. I was always quite upset when I hit ^A looking to go to the start of the line and screen just \A'd back at me.

    17. 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.

    18. Re:Screen by RichiH · · Score: 1

      I like the CTRL-A syntax as that keeps the ESC key free for the truly important editors :)

    19. 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.
    20. 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!!".

    21. Re:Screen by Anonymous Coward · · Score: 0

      So I take it you prefer vi and dtach?

    22. Re:Screen by Anonymous Coward · · Score: 0

      That's funny. I use screen from inside emacs.

    23. 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?

    24. Re:Screen by Anonymous Coward · · Score: 0

      The prefix key in SCREEN can be changed though. Since I use emacs a bit, I changed the prefix key to be a less common key, C-] .

        bind ^] other
        escape ^]]

    25. 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.

    26. 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."
  19. 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 Anonymous Coward · · Score: 0

      The comnmand to x-forward is: ssh -X user@ipaddress someguiprogram

    7. 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.

    8. 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.

    9. Re:X-forwarding by Toreo+asesino · · Score: 1

      That wouldn't essentially be remote desktop would it?

      (Just curious)

      --
      throw new NoSignatureException();
    10. 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
    11. Re:X-forwarding by Anonymous Coward · · Score: 0

      Yeah and it's still as slow as it's simple. The latency kinda makes it suck.

      What's funny in much the same way is the amount of "new" and "ooooh, aaah" I see surrounding this desktop stuff that's new for windows vista. Woohoo I can now have a load meter on my desktop. And a clock! Even the weather forecast!

      I really don't know what to say to those people.

    12. Re:X-forwarding by GenP · · Score: 1

      Without the detach option. Kill the connection and the app dies on the remote end.

    13. Re:X-forwarding by Anonymous Coward · · Score: 0

      I've seen windows people do the same when I use VNC to do it on Windows. They thought it was an impossible feature reserved for super computers and movies.

      ssh X forwarding should be part of a basic computer course, I don't think I have ever used anything quite a useful.

    14. Re:X-forwarding by Anonymous Coward · · Score: 0

      For those of us that are new(ish) to the Linux world, would you be willing to describe the commands/process?

      include the switch -X in ssh

    15. Re:X-forwarding by Anonymous Coward · · Score: 0

      I was slack-jawed when I first learned Windows couldn't do this (way back in the days of Win3.1/95/NT, and when you set your X DISPLAY environment variable instead of using ssh.)

      A whole cottage industry evolved around that deficiency on the Win platform (remote desktop s/w, KVM devices, etc) - to think the solution to this nonsense was baked into X by design from the get-go is pretty amazing.

      And yeah, when I first learned one could do that it was very cool...

    16. 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.
    17. Re:X-forwarding by Anonymous Coward · · Score: 0

      ssh -X mylogin@distantcomputer.com
      And then just launch your graphical program such as xemacs, kwrite, gedit, gimp...

    18. Re:X-forwarding by Anonymous Coward · · Score: 0

      Show them port tunneling.

      Such that you can open a tunnel behind a firewall to an internet system. Then from outside you can telnet/ssh/whatever to the system behind the firewall.

      (most) firewall security doesn't stand a chance against ssh tunnels.

    19. Re:X-forwarding by Anonymous Coward · · Score: 0

      Oh how I wish the world was flat...and the users would "shake their heads and walk away" right off the edge of it. Ok maybe not the users, maybe just the marketing department that caused this...
      20 years of remote application execution...down tubes...an entire software industry (citrx) made just to put that functionality in windows...
      multiuser...what do you mean only 3 rdesktops before I run out of licenses...how about 1000's of users for free...
      I still tell people "yes it's free", "no it's not illegal", "yes it's better"...and they still "shake their heads and walk away". Freakin arguing with someone that it really is free and no you dont have to buy it from RH.
      3 rdesktops....3...
      No you don't have to pay per sql connection...yes its uptime is greater...

      How can't RH/IBM/Oracle not simply blow away MS...1 add on TV...simple text...."It's better, proven", "It's free".

      ok enough ranting...
      no wait 1 more...PDA's...own one? run CE? you better convert it...you ungreen polluting wastral...I run firefox on my PDA...not some outdated hobbled browser...all of my tools on my desktop...on my PDA...an industry created by MS collaborating with HW manufactures...buy it, make 1 OS upgrade, no more to force a new sale..."a pc in every home"...no, now the goal is "millions PDA's in landfills"...add cellphones here...if you own a PDA, it's your responsibilty to convert it to linux/bsd...and keep using it.

      Ok enough ranting...

      what's big in this directory so I can delete it....
      df -sk | sort -n

      never mess with export DISPLAY again...run an X session through ssh...
      ssh -X user@host
      or
      ssh -X user@host xterm

      copy /some/directory to here all files even hidden ones oh yeah and preserve permissions
      tar -cf - /some/directory | tar -xvf .

      better yet, how about across machines...yeah baby move entire dir trees from host to host...the power
      ssh user@host tar -cf - /some/dir/on/host | tar -xvf .

      dsh...cluster? look it up

      awk...learn it...
      ls -l | awk '{print $1,$9}'

      I keep forgetting things faster than I can type...I'm going to my sulking about "woohoo greatest thing since sliced bread" lie and of course the PDA bs...

      Bill

    20. Re:X-forwarding by doti · · Score: 1

      Sorry, but X forwarding predates Microsoft's existence.

      --
      factor 966971: 966971
    21. 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
    22. 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.

    23. Re:X-forwarding by Anonymous Coward · · Score: 0

      It's been awhile (HELP! I'm stuck in Winblows land and can't get out!) but let's see if I can remember:

      1. Launch a terminal session on your *nix or Linux box.
      2. Type in 'DISPLAY = :0' and press the ENTER key. Leave off the single quotes, please.
      3. Type in 'export DISPLAY' and press the ENTER key. Again, leave off the single quotes.
      4. Type in the command to run the X-based application that you need, and it will display on the target windows box's desktop.

      The noted above can be a URL or a hostname that your DNS server can resolve into the URL.
      For example, to remote the X display to a windows box named "punchme" with a URL of 192.168.1.50, I could type
      DISPLAY=punchme:0
      export DISPLAY

      or
      DISPLAY=192.168.1.50:0
      export DISPLAY

    24. 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
    25. 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.

    26. 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.

    27. 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();
    28. 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();
    29. 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.

    30. 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.

    31. Re:X-forwarding by Anonymous Coward · · Score: 0

      Actually the performance of X over a high latency link is shit compared with the Windows remote desktop protocol.

    32. 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
    33. 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!
    34. 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.

    35. 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.

    36. Re:X-forwarding by spazdor · · Score: 1

      *whoosh*

      --
      DRM: Terminator crops for your mind!
    37. 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
    38. 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.
    39. 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'.

    40. 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."
    41. Re:X-forwarding by Anonymous Coward · · Score: 0

      It is also possible to create a tunnel without restarting your SSH session

      ~C on a clean $ in ssh will drop you into an area where you can define port forwards

      -L1234:localhost:80

    42. 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....

    43. 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.

    44. Re:X-forwarding by Anonymous Coward · · Score: 0

      Or how long Windows has had remote desktop..

    45. Re:X-forwarding by Anonymous Coward · · Score: 0

      You could easily have an entire Ask Slashdot just on ssh, perhaps the greatest unix command ever invented.

      Because we had a particularly nasty Web(Non)Sense proxy server at work, I used an ssh server(on port 443) and a Squid proxy server at home to create a tunnel to my laptop at work so I could browse the web like I wanted at work right under our Nazi admin's noses. Being mostly from the Windows side, they never knew the difference.

      I wouldn't have done it if they hadn't been so anally retentive about their policies. I can see no web mail, but they blocked blogs, hosting services, and many support websites including Microsoft, all of which I need from time to time when I am looking for help on the web.

    46. 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

    47. Re:X-forwarding by Anonymous Coward · · Score: 0

      Too bad so many people can't see the utility in it, and want to take it away from us again (witness the recent Wayland thread).

      There are more tricks in unix than are dreamt of in your philosophy...

    48. Re:X-forwarding by Anonymous Coward · · Score: 0

      Yes, I've been doing this in 90's. These 'X' applications were so slow and ugly and consumed all the memory. And do you remember having to set up hundred of parameters in order to get the X session to start? I think that could astonish some 'windows' people how difficult it was to work in graphical Unix.

    49. 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.
    50. Re:X-forwarding by Anonymous Coward · · Score: 0

      Idiot. You can make anything on windows via RDP even over 14kbit connection. X sucks.
      And yes, I administer large DC on the other side of the planet earth with rdp for over 5 years.
      Go fuck yourself, lamer.

    51. 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.
    52. 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

    53. 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!"

    54. 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 ?
    55. Re:X-forwarding by Anonymous Coward · · Score: 0

      Even funnier is how far back the X Window System set UNIX UI design (as in decades). Just catching up now. Good old Moore's Law!

    56. Re:X-forwarding by Anonymous Coward · · Score: 0

      I have been logging into windows boxes remotely via remote desktop, citris, pcanywhere, etc for a long time now.... anyone who uses windows who is amazed by running remote software and seeing it on your screen must be only a "casual user" (admittedly, its different with x, but to t end effect is the same, software runs on one machine, displays on another)

    57. 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.

    58. 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?
    59. 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.

    60. 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)
    61. 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)
    62. 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)
    63. 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!
    64. 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!
    65. Re:X-forwarding by Anonymous Coward · · Score: 0

      If you mean 1.3 decades. That's how long SSH has been around.

    66. 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.

    67. 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 --> .
    68. Re:X-forwarding by Anonymous Coward · · Score: 0

      Try looking up ssh's ProxyForward and play with netcat and wet your pants about what fun can be had....

    69. Re:X-forwarding by Anonymous Coward · · Score: 0

      You know that also works for applications running in wine.

    70. 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;
    71. 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.

    72. Re:X-forwarding by Anonymous Coward · · Score: 0

      "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." - by mikeb (6025) on Wednesday November 05, @03:53PM (#25649079) Homepage

      Oh sure, "big trick" (back in 1995 maybe, for Windows' folks):

      So you know - Microsoft has a protocol called RDP (runs on port 3389):

      http://en.wikipedia.org/wiki/Terminal_Services

      That's used by Windows Terminal Server AND Windows' own RDP client for remote desktops, & yes, it works as you describe X does on *NIX.

      RDP is based off Citrix WinFrame/MetaFrame:

      http://en.wikipedia.org/wiki/Independent_Computing_Architecture

      Which also does the job over port 3389, albeit via their "ICA" protocol & it has clients for just about ANY OS under the sun, & yes, that means *NIX clients too, in communication w/ Windows ones) technology that MS licensed.

      (BOTH RDP & ICA allow for full remote desktop capability (with sound & all if required). Either one has "advantages" over the other, in certain use pattern scenarios (RDP vs. ICA)).

      ----

      "Some refuse to believe it, others shake their heads and walk away." - by mikeb (6025) on Wednesday November 05, @03:53PM (#25649079) Homepage

      They probably thought:

      "Ah, go 'fsck' your self - because, we can do that also, since Windows NT 4.0 (via the RDP client in Windows)!"

      APK

      P.S.=> This type of remote desktop multiuser & multisession capability has existed for over 13++ years in Windows, in other words... it was one of the things that *NIX had on Windows for a while there, but, that long since has NOT been the case... apk

    73. Re:X-forwarding by Anonymous Coward · · Score: 0

      The -D options gets me around 99% of all firewalls and content filtering.

      Made some easy cash letting friends surf myspace and facebook at lunch.

      You can make money with Open Source!

    74. Re:X-forwarding by Hyppy · · Score: 1

      whoosh!

    75. 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.

    76. 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.

    77. 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.

    78. 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.
    79. 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.
    80. 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!!!

    81. Re:X-forwarding by jon3k · · Score: 1

      Actually terminal services comes in a distant second to the Citrix ICA Client.

    82. 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
    83. Re:X-forwarding by Anonymous Coward · · Score: 0

      Foxy Proxy plugin handles dns lookups through socks proxy, or you can configure a setting in about:config - on remote terminal so cant check specific key value atm. enjoy!

  20. Anonymous Coward by Anonymous Coward · · Score: 0

    People keep forgetting to empty the bit-bucket, even redhat certified sysadmins.

    1. Re:Anonymous Coward by Anthony_Cargile · · Score: 1

      lol, now thats funny.

  21. 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 Anonymous Coward · · Score: 0

      while talk is great ytalk is greater

    8. 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 ;)

    9. 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".

    10. 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.

    11. 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
    12. 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)
    13. Re:Talk / DD / Mount by Anonymous Coward · · Score: 0

      MOTOMAGX and EZX phones to some extent too.

      I'm being forced to go under the hood to take full advantage of my Motorola A1200i. Great phone...especially with a shell

    14. Re:Talk / DD / Mount by Anonymous Coward · · Score: 0

      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.

      I'd like to object to this statement - As an RHCE, I think it worth noting that while the course touches on the GUI, 90% of what you do is on the command line, very much under the hood. I for one think that the GUI tools are rather hideous (with the notable exception of the install time partitioning GUI which is just yummy).

    15. Re:Talk / DD / Mount by Anonymous Coward · · Score: 0
  22. 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 Anonymous Coward · · Score: 0

      Your a sick, sick human being.

    2. Re:rm -rf /* by Anonymous Coward · · Score: 0

      I would guess even admins who don't know what they are doing would know a simple command like that.

    3. 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.

    4. Re:rm -rf /* by morgan_greywolf · · Score: 1

      Surprisingly, no.

    5. 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.
    6. 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'.

    7. Re:rm -rf /* by j35ter · · Score: 1

      ask an all knowing MCSA about that, you'd be surprised

      --
      Delta-Mike November Bravo Tango
    8. 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.
    9. 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 /* &

  23. 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 Anonymous Coward · · Score: 0

      Carmack's .plan file hasn't been updated in how long?

      It is 3 Years and 278 Days since then

    11. 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.
    12. 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!
    13. 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
    14. 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.

    15. Re:If he liked write by frisket · · Score: 1

      On our first web server I soft-linked my ~/public_html/index.html to ~/.plan

    16. 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.

  24. 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.
  25. 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).

  26. 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 Anonymous Coward · · Score: 0

      Also just by writing "cd" you get to go to your home directory.

    4. Re:cd - by Anonymous Coward · · Score: 0

      In bash, pushd and popd are also very useful. These commands will push the current directory on the directory stack or pop the current directory from the directory stack.

    5. Re:cd - by iVasto · · Score: 1

      I never knew about that one. You've saved me so much time. Thank you!

    6. 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

    7. Re:cd - by Anonymous Coward · · Score: 0

      hey that is a new one to me.
      people also sometimes don't know about ~.

    8. Re:cd - by Daas · · Score: 1

      Same thing here ! /Too stupid to think about that one!

    9. 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?"
    10. Re:cd - by Anonymous Coward · · Score: 0

      pushd .
      popd

      (Push the current directory onto a stack. Pop back to that directory)

    11. Re:cd - by MrMunkey · · Score: 1

      +1. I haven't found too many other people that knew about this one.

    12. 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.

    13. Re:cd - by Drishmung · · Score: 1

      I'm a fan of pushd/popd

      --
      Protoplasm. Quiet Protoplasm. I like quiet protoplasm.
    14. 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

    15. Re:cd - by Randle_Revar · · Score: 1

      I found this and "cd" = "cd ~" a few months ago, and they have been very useful.

    16. 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.

    17. 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
    18. 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 !$

    19. 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

    20. Re:cd - by msuarezalvarez · · Score: 1

      What shell is that?

    21. Re:cd - by chainLynx · · Score: 1

      AMEN! !$ is pure awesomeness... more in man history

    22. Re:cd - by Anonymous Coward · · Score: 0

      Along those same lines, pushd and popd do the same thing but give you a stack of directories instead of remembering just one.

    23. Re:cd - by Anonymous Coward · · Score: 0

      Check out pushd and popd, extremely helpful!

    24. 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!
    25. 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!
    26. 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!

    27. 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.
    28. Re:cd - by Isomer · · Score: 1

      Also, you can use ~-/ too to refer to the previous directory. So:
      cd /tmp
      cp ~-/foo.c .

    29. 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 =)

    30. Re:cd - by jubalj · · Score: 1

      lets not forget pushd and popd.. way cooler than cd -

    31. Re:cd - by hampton · · Score: 1

      Thank you, I didn't know this! I've been using 'cd $OLDPWD' all this time. :(

    32. Re:cd - by Anonymous Coward · · Score: 0

      pushd and popd entirely replace cd for me

    33. Re:cd - by Anonymous Coward · · Score: 0

      pushd and popd are more useful if you want a stack of directories to hop around through.

    34. Re:cd - by Anonymous Coward · · Score: 0

      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!

      ditto for 'pushd' and 'popd'

    35. Re:cd - by Anonymous Coward · · Score: 0

      For bash users: pushd, popd to maintain a stack of directories. dirs to display the current stack.

    36. Re:cd - by Anonymous Coward · · Score: 0

      Also see the bash builtin commands pushd, popd and dirs...

    37. Re:cd - by Anonymous Coward · · Score: 0

      Interesting. Unfortunatelly it has a single level of undo:

      1) cd ..
      2) cd - # go back to 1

      1) cd ..
      2) cd ..
      3) cd - # go back to 2 (there's no way back to 1)

      If you want to travel back and forth between several directories use pushd and popd:

      1) pushd . # save current directory
      2) cd ..
      3) cd ..
      4) popd # go back to 1

    38. Re:cd - by Anonymous Coward · · Score: 0

      In fact, pushd and popd can be nested:

      1) pushd . # save directory 1
      2) cd ..
      3) cd ..
      4) pushd . # save directory 4
      5) cd foo
      6) cd bar
      7) popd # back to 4
      8) popd # back to 1

    39. Re:cd - by jollyhockysticks · · Score: 0

      agreed !! and !$ both rock,

      on osx for example how often i do this...

      user@machost$ apachectl restart
      permission denied
      user@machost$ sudo !!
      sudo apachectl restart
      password:


      or as mentioned,
      mkdir /some/place
      cd !$

      solaris has some fun ones too:

      uadmin 2 0 sync the filesystems and drops system to ok prompt
      uadmin 2 1 sync the filesystems and reboots to multi-user mode
      uadmin 2 2 sync the filesystems and reboots interactively
      uadmin 2 3 sync the filesystems and reboots to single-user mode
      uadmin 2 6 sync the filesystems and powers off the system
      uadmin 1 0 do not sync filesystems and drops system to ok prompt
      uadmin 1 1 do not sync filesystems and reboots to multi-user mode
      uadmin 1 2 do not sync filesystems and reboots interactively
      uadmin 1 3 do not sync filesystems and reboots to single-user mode
      uadmin 1 6 do not sync filesystems and powers off the system

    40. 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.

    41. Re:cd - by Anonymous Coward · · Score: 0

      Thank you very much, sir.

      I've missed something like that for many years. And it was here all the time :)

    42. Re:cd - by Anonymous Coward · · Score: 0

      pushd, popd
      generally better.

  27. 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.
  28. One word: by MMC+Monster · · Score: 4, Funny

    Showers

    --
    Help! I'm a slashdot refugee.
    1. Re:One word: by Anonymous Coward · · Score: 0

      I can't believe I tried googling "Showers" before I realized what you were getting at.

      *sigh*

    2. Re:One word: by vagabond_gr · · Score: 1

      bash: Showers: command not found

      you sure about the spelling?

    3. Re:One word: by Anonymous Coward · · Score: 0

      anyone else besides me just type 'man showers' ?

    4. Re:One word: by Anonymous Coward · · Score: 0

      What is that? (checks man pages)

      $ man showers
      No manual entry for showers

    5. 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?

    6. 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?

    7. Re:One word: by Anonymous Coward · · Score: 0

      hmmm.. couldn't find that command. tried googling for its man page (man showers) and found all sorts of stuff i didn't really know i wanted.

      so much for working today.

    8. Re:One word: by Anonymous Coward · · Score: 0

      bash: Showers: command not found

      I don't get it??

    9. Re:One word: by Anonymous Coward · · Score: 0

      > Showers

      agreed hahahah

  29. 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.

  30. 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
  31. 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 Anonymous Coward · · Score: 0

      TAC was a wonderful find for me ..

      and even funnier was while explaining to the guy next to me what I was looking for ( via IM of course , real admins dont speak to people in the same room )

      I said .. I want a backwards cat I want tac.

      then I did a man tac .. and HOLY SHIT , ITS EXISTS.

    3. 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.

    4. 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

    5. 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.

    6. 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.

  32. 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.

  33. 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 Anonymous Coward · · Score: 0

      you forgot to mention "jobs"

    2. Re:Job control. by Anonymous Coward · · Score: 0

      And, to keep track of them all;

      jobs

    3. 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).

    4. 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.

    5. 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.

    6. Re:Job control. by XXeR · · Score: 2, Informative

      that's a lot of work to do what 'disown' does

    7. 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.
    8. 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)

    9. 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 %%

    10. 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

    11. Re:Job control. by againjj · · Score: 1

      You forgot 'jobs', to get you the # for %#.

    12. 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.
    13. Re:Job control. by CronoCloud · · Score: 1

      Hey thanks, I didn't know about that one.

    14. 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.

    15. 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.
    16. 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)
    17. Re:Job control. by Anonymous Coward · · Score: 0

      Just don't do what a service tech did (as root):

      # kill 1

    18. Re:Job control. by Anonymous Coward · · Score: 0

      To find out which command to do kill % to, use the jobs command:

      > jobs
      [1] Stopped ps -ef (wd: ~)
      [2]- Stopped top (wd: ~)
      [3]+ Stopped ls -lrt

      Note the numbers down the left hand side. The + sign indicates the job that fg will bring to the foreground. The - sign indicates the previous job and can be referenced by %-, e.g.

      fg %-

      When you have a vi session in the background in one of half a dozen terminals, jobs can help you find it.

    19. 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.

    20. Re:Job control. by UnHolier+than+ever · · Score: 1

      Well, I've always used ps then kill PID. What would kill %1 do?

    21. 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"

    22. 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!

    23. Re:Job control. by Anonymous Coward · · Score: 0

      I'de add 'nohup' to that list of job control.
      Also, if using bash: disown
      Also: (./launch &)

    24. Re:Job control. by Anonymous Coward · · Score: 0

      I could not live without it ( since 1986 )

    25. Re:Job control. by Anonymous Coward · · Score: 0

      Just use screen instead and detach/reatach.

      One thing which sucks about the fg, bg, Ctrl-Z thingy is if you are logged on to the box via ssh and need to log off, or the connection breaks at a point, you cannot see the output of your running process anymore unless you redirected it into a file.

      A time ago i forgot to start screen and had a shred process runing for deleting and overwriting like 300GiB of harddisk space. So i tought: "man, it would be cool to be able to put a running process into screen. I need to find an alternative". So i tried the fg, bg issue, logged off the machine and after a relogin i had to check ps if there's a running shred process all the time. That sucked a lot.

    26. Re:Job control. by jollyhockysticks · · Score: 0

      ps -ef | awk '{print $2}' | xargs -t -n1 kill -9 '{}' ...hey where'd my system go?

    27. Re:Job control. by Anonymous Coward · · Score: 0

      agree!!

      screen is over-rated, any decent shell has good enough job control to do most of what is done with screen

      (which is not to say that re-attach and running two interactive programs simultaneously aren't useful features, and no shell has those. course, I personally can't interact simultaneously with two interactive programs, even with screen...)

    28. 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
    29. Re:Job control. by Anonymous Coward · · Score: 0

      Also useful: disown. Spins off a backgrounded job. Ever started something and realized you should have nohup'd it? This is the tool.

  34. 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 Anonymous Coward · · Score: 0

      ytalk is even better, as you can chat with multiple people. fun fun.

    2. 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.

    3. Re:Some good ones... by Anonymous Coward · · Score: 0

      I always enjoyed SSHing into someone's Mac when I saw they had their headphones on. Then I'd start using the "say" command to have the computer starting talking to them. Generally it went something like this:

      *Using one of the OS's female voices*
      "Hello Jim."
      *Wait for them to look around*
      "It's been so long since you caressed me like this."
      *Wait until the start looking for a webpage they left open or turn off their music.*
      "Thats better now you can focus all your attention on me."
      "Why did you leave so early last night? You didn't have to shut me down so forcefully."
      *Watch while they look around in frantically.
      "What did your wife call you home urgently or something?"
      "I think she is starting to get jealous of the time we spend together."
      ect...

      One guy unplugged his headphones as the boss walked around the corner oh a very risky line. So I had to confess it was a prank and that he was not watching pr0n at work. HAHA.

    4. 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

    5. Re:Some good ones... by xgr3gx · · Score: 1

      Ha! Nice one :)

      --
      Shameless plug alert: Game server control panel
    6. 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 :/

  35. 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.

  36. 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 Anonymous Coward · · Score: 0

      More readable and functionally identical(?) to `blah` is $(blah) - your example: vi $(grep -l abc *.txt)

    2. Re:Backquotes by doti · · Score: 1

      Not functionally identical.
      For one thing, $() can be nested.

      --
      factor 966971: 966971
    3. Re:Backquotes by Bandman · · Score: 1

      And since you can't nest backtics, $(command argument1 $(command masquerading as argument 2))

    4. 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\``

  37. 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.

  38. 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
  39. 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!
  40. Re:Wohoooo, the first one! by Anonymous Coward · · Score: 0

    But to be on topic...

    First, you didn't specify for whom you ask...

    Now, command line itself and it's power is what surprises most people... including the "administrators"...

    Then, there is a talk which I haven't used for a long time...

    All the little command line tools like cut, uniqe, tail, tr, head, tail... not so small tools like sed, awk... many people simply do not know for them...

    A yes, '#!' "trick" to make any file executable...

    And while we are at that, many people coming from Windows think that executable has to have .exe extension...

  41. Job Control in Shells by Anonymous Coward · · Score: 0

    A lot of people don't know job control (^Z, fg, bg) and don't know how to switch in a single shell between an editor and some other command (like a compiler) without quitting the editor. For convenience, I like to use the alias z=suspend, which probably also a lot of people don't understand why this is useful. Likewise, people don't know any longer how to suspend a remote shell (using ~^Z).

  42. 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.

  43. 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

  44. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    echo just echoes the names, shell does the expansion and passes the argument list to echo.

  45. 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 Anonymous Coward · · Score: 0

      xargs - use the output of a script as input arguments to another.

      cd /dir
      ls | xargs du -sh

      will give you a du -sh for every directory in /dir

    15. 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.

    16. Re:Show attached block devices by Anonymous Coward · · Score: 0

      cd `pwd -P` - Jump into the real directory (from a linked directory).

      k.i.s.s., at least in pdksh it works:
      cd -P .

    17. 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.

    18. 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

    19. Re:Show attached block devices by Anonymous Coward · · Score: 0

      Don't forget to set your history to record an infeasible large number, then make copious use of ctrl-r...I have 40k entries, and can recall the most obscure piece of shell wizardry in moments.

    20. 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?
    21. Re:Show attached block devices by Henry+Bone · · Score: 0

      bash history can be searched. I have my bash in vi mode so if I want to find that wget I issued 2 weeks ago ...

      $ /^wget

      then 'n' will move through the matches until I see what I'm looking for. Then 'enter' reissues it.

    22. 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.

    23. 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
    24. Re:Show attached block devices by dharter · · Score: 1

      blockdev --report /dev/* 2>/dev/null

    25. Re:Show attached block devices by c0p0n · · Score: 2, Informative

      cd

      takes you to your home directory.

      --

      Your head a splode
    26. 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.
    27. Re:Show attached block devices by c0p0n · · Score: 1

      I'm scared of you now :S

      --

      Your head a splode
    28. 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.
    29. 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...
    30. 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
    31. 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

    32. 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.

    33. 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.

    34. 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.)

    35. 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.

    36. 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
    37. Re:Show attached block devices by the_B0fh · · Score: 5, Funny

      Oh my ghod. This is considered informative? Who let all the PFYs in?

    38. 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."
    39. Re:Show attached block devices by Anonymous Coward · · Score: 0

      On the contrary, shorter IS something to be proud of. My brain can filter the errors from the data fast enough, therefore a shorter command is much more valuable to me then a "correct" command. The correct one is only useful when used as part of a script.

      AC becuase of mod points.

    40. 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.)

    41. 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.

    42. 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.
    43. 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!

    44. Re:Show attached block devices by Anonymous Coward · · Score: 0

      pushd and popd are pretty good too... not many people seem to remember the directory stack!

    45. 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."
    46. 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?
    47. 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."
    48. 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 ^,^
    49. Re:Show attached block devices by Anonymous Coward · · Score: 0

      fucksocks! how did i miss that! thanks!

    50. Re:Show attached block devices by Anonymous Coward · · Score: 0

      (Both of these commands ... work in the Windows command interpreter too.)

      Yup.

      cd - ... work[s] in the Windows command interpreter too.)

      Nope. (Tested in Vista.)

    51. 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.

    52. Re:Show attached block devices by dlgeek · · Score: 1

      ctrl+r (in bash?): reverse incremental search through history.

      Nice! Thanks!

    53. 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.
    54. Re:Show attached block devices by fracai · · Score: 3, Funny

      .py or it didn't happen.

      --
      -- i am jack's amusing sig file
    55. Re:Show attached block devices by Anonymous Coward · · Score: 0

      Instead of history - ctrl-r & ctrl-shift-r will cycle through your history (plus you can start typing as your cycling to narrow it down). I'm can't remember what the requirements are, but it works in bash of modern Linux distros (although ctrl-shift-r doesn't - I think you have to enable it or remap keys).

      Not really an obscure command, but one of my friends also found this helpful:

      alias grep_src='grep --include=*.c --include=*.h'
      Adjust as needed for the source files you work with. Also possible to use environment variables in the alias so that you can dynamically update the alias (i.e. switch between Java & C++).

      Also,

      alias grep='grep --mmap'

      speeds up grep quite a bit if there's lots of files (presumably they have to be over 4K in size).

      In general, alias is very powerful.

    56. 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.

    57. 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.
    58. 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...
    59. 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.

    60. Re:Show attached block devices by c0p0n · · Score: 1

      You scare the bejesus out of me :S :S

      --

      Your head a splode
    61. 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?
    62. 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
    63. 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 -.

    64. 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.

    65. 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.

    66. 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

    67. 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?
    68. 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."
    69. 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.
    70. Re:Show attached block devices by BlackSabbath · · Score: 1

      Great Linux trick. Pretty useless on Unix though...

    71. 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.

    72. 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.

    73. 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

    74. 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"

    75. 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?

    76. 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.)

    77. 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.

    78. Re:Show attached block devices by Anonymous Coward · · Score: 0

      I still can't believe this didn't make it:
      Start up your download, and then run this in another terminal on the local directory.

      $ watch -n1 "du -hcs *"

      Watch the size go up, wow!

    79. Re:Show attached block devices by Anonymous Coward · · Score: 0

      Shop as usual and avoid panic buying.

      Give up!

    80. 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')

    81. 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.

    82. Re:Show attached block devices by IWannaBeAnAC · · Score: 1

      Wow, that is awesome. I think I will be using this all time time! Thanks!

    83. 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!
    84. Re:Show attached block devices by jcuervo · · Score: 1

      fc - Command editor.

      --
      Assume I was drunk when I posted this.
    85. 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.

    86. 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
    87. 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.)

    88. 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.

    89. Re:Show attached block devices by eosp · · Score: 2, Informative

      It uses different, non-Python syntax, but I find Fish useful.

    90. Re:Show attached block devices by Anonymous Coward · · Score: 0

      cd `pwd -P` - Jump into the real directory (from a linked directory).

      cd accepts -P, so a "cd -P ." does the same and is shorter :)

    91. Re:Show attached block devices by Anonymous Coward · · Score: 0

      For those who are too young to get the joke

      http://bofh.ntk.net/Bastard_1996-1a.html

    92. 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

    93. Re:Show attached block devices by theTerribleRobbo · · Score: 1

      Is this post of any help?

      ... Or, yeah, use zsh. :S

    94. 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

    95. Re:Show attached block devices by Anonymous Coward · · Score: 0

      The pwd -P trick can be generalized to work with any file or directory.

              readlink -f file

      Guaranteed to be an absolute, symlink-free path.

    96. 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.

    97. 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
    98. Re:Show attached block devices by Anonymous Coward · · Score: 0

      which gets annoying sometimes when I fat finger the /

    99. 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

    100. 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?
    101. Re:Show attached block devices by Anonymous Coward · · Score: 0

      history - use it with grep if you forgot what you did

      Ctl-R

    102. 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
    103. 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.

    104. 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.

    105. 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!
    106. 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...

    107. Re:Show attached block devices by Anonymous Coward · · Score: 0

      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.

      ls -lotr

    108. 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).

    109. 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
    110. 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
    111. 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
    112. 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.

    113. Re:Show attached block devices by Anonymous Coward · · Score: 0

      "tail -f" is nice.

      "tail -F" is nicer: it will continue to tail the file as it is log rotated (e.g. when "syslog" is moved to "syslog.0" and a new "syslog" file is created).

      (This is GNU coreutils' tail(1), by the way.)

    114. 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
    115. 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.

    116. 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.

    117. 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.
    118. Re:Show attached block devices by rarity · · Score: 1

      That's the same reason I use ls -halt.

    119. 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'!"
    120. Re:Show attached block devices by Anonymous Coward · · Score: 0

      less is more

    121. 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.
    122. 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..

    123. 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?

    124. 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.

    125. Re:Show attached block devices by Anonymous Coward · · Score: 0

      brilliant. you just saved my from the touch $file; tail -f $file construction i had always used

    126. 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."
    127. 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
    128. Re:Show attached block devices by Anonymous Coward · · Score: 0

      Well, as you were so helpful.. your website has a typo.. "new technoligies" on the about us page.

      Hope that's some help, I really shouldn't have to explain that.. ;)

    129. 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...

    130. 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.
    131. Re:Show attached block devices by marcosdumay · · Score: 1

      Is that different from 'grep foo *'?

    132. 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.

    133. Re:Show attached block devices by RichiH · · Score: 1

      With zsh, you can just

          setopt cdablevars

      and omit the cd completely.

    134. 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.

    135. Re:Show attached block devices by RichiH · · Score: 1

      Or you could mkdir -p the basedir and keep a hierachical structure of your files.

    136. Re:Show attached block devices by RichiH · · Score: 1

      perl -pie

    137. 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
    138. 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?).

    139. Re:Show attached block devices by famebait · · Score: 1

      alias cd pushd

      alias sa 'alias > ~.alias'

      --
      sudo ergo sum
    140. Re:Show attached block devices by Anonymous Coward · · Score: 0

      I love to use the less command.

      less [filename]

      Once inside less, hit the F key and it will follow the file just like tail. Only the really cool thing is if you miss something, you can hit CTRL+C and back up. less also has a find function. Do a /whatever (just like vi) and less will highlight it. Once you do a find on a file in less and "follow" the file, less will highlight in real time. I use this quite a bit when analyzing logs in real time while troubleshooting.

      Remember, less is more and more is less.

    141. 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
    142. Re:Show attached block devices by Anonymous Coward · · Score: 0

      The fingers you have used to type are too fat. To order a special typing wand, please mash the keyboard now.

    143. Re:Show attached block devices by MoogMan · · Score: 1

      It does indeed error, so you should:

      blockdev --report /dev/* 2>&1 | more

    144. 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.
    145. Re:Show attached block devices by Anonymous Coward · · Score: 0

      ctrl+r multiple times cycles through the matches in history

      Also the ctrl-a bringing you to the begining of the command line.

    146. Re:Show attached block devices by Anonymous Coward · · Score: 0

      You can add a lot of less commands as options on the command line. The above would be:

      less +F

      and it'll automatically start tailing the file. (ctrl-c to break out of the 'follow' mode and to scroll around)

      Personally, I use less +G instead of tail for this reason. G goes to the last line.

    147. 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...)

    148. 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.
    149. 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.

    150. Re:Show attached block devices by Anonymous Coward · · Score: 0

      sshfs has made my day and it's not even 10:00 yet. Thank you! (Posting anon to save the mods I've already given in this thread.)

    151. 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
    152. 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

    153. 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
    154. 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
    155. 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
    156. 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.)

    157. Re:Show attached block devices by Anonymous Coward · · Score: 0

      Blasphemy! There's no such thing as a bash-specific shell feature - zsh has it all and much more besides.

    158. 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.

    159. 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...

    160. Re:Show attached block devices by Short+Circuit · · Score: 1

      "ls|xargs foo" works in directories with thousands of files. "foo *" doesn't.

    161. Re:Show attached block devices by nevermore94 · · Score: 1

      My variation on the same:

      HISTFILE=$HISTFILE`tty | tr / .`

      --
      Nevermore.
    162. Re:Show attached block devices by Anonymous Coward · · Score: 0

      post the script

    163. Re:Show attached block devices by fransw · · Score: 1
      I second for less :-)

      less +F immediately starts the follow mode...

    164. 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.

    165. 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

    166. 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
    167. 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.
    168. Re:Show attached block devices by Quebec · · Score: 1

      omg, didn't know that one...

      Thx

    169. 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.

    170. Re:Show attached block devices by QuoteMstr · · Score: 1

      Like the ediff we've had in Emacs for 14 years? :-)

    171. Re:Show attached block devices by Anonymous Coward · · Score: 0

      in c and compatible shells from dir A: pushd B; pushd C

      now the command popd puts you back in directory B. another popd and you're back in directory A

    172. 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.

    173. 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?
    174. 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.
    175. Re:Show attached block devices by Anonymous Coward · · Score: 0

      I wish I hadn't already posted in this thread, I would mod this up.

    176. Re:Show attached block devices by ZeroNullVoid · · Score: 1

      cd
      used to install OS some of the time.

    177. 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
    178. 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;
    179. 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.

    180. 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/

    181. 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...
    182. Re:Show attached block devices by portscan · · Score: 1

      a lesson learned the hard way: don't drink and root

    183. 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.

    184. Re:Show attached block devices by Anonymous Coward · · Score: 0

      exec 2>/var/tmp/logfile

    185. Re:Show attached block devices by argo0s · · Score: 1

      You don't need to log out just use a .
      eg: . .profile

    186. 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!
    187. 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!
    188. 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
    189. 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.
    190. 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
    191. 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.

    192. Re:Show attached block devices by idfubar · · Score: 0

      How about:

      unset HISTSIZE
      unset HISTFILESIZE

      for removing the arbitrary limit on the command history?

      --

      Rishi Chopra
      www.rishichopra.org
    193. Re:Show attached block devices by rhs98 · · Score: 0

      I really like pressing esc then period - it gives you the last argument of the last command :)

    194. Re:Show attached block devices by Anonymous Coward · · Score: 0

      'script' is great for recording what you did. Useful for forwarding to know-nothing PHBs who say "can I get a log of what you did?"

    195. Re:Show attached block devices by J053 · · Score: 1

      blockdev --report /dev/* 2>/dev/null
      if you don't want to see the errors...

    196. Re:Show attached block devices by Anonymous Coward · · Score: 0

      pushd
      popd

      There is a directory stack in bash. Pushd goes to a new dir, and puts that dir on the stack. Popd then goes to the last visited directory before this pushd. This is actually the advanced version of 'cd -'.

      For details: http://www.gnu.org/software/bash/manual/bashref.html#The-Directory-Stack

    197. 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
  46. 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 Anonymous Coward · · Score: 0

      So what does that do ?
      I don't know bash enough to know, tried it and it slowed everything to a crawl, using all memory.

    9. Re:Bah, subtlety: by Gusfm · · Score: 1

      Damn, that was fast! I shouldn't have underestimated that thing! =D

    10. 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).

    11. 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.

    12. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      :(){ :|:& };:

      curious...what does this actually do?

    13. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      I hate you

    14. 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!'"
    15. 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!'"
    16. 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
    17. Re:Bah, subtlety: by Anonymous Coward · · Score: 1, Informative

      Damn you Google ! Damn you and your lousy "exact search" ! Exact search my a** !

    18. 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.
    19. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      bah, avoid in production servers :)

    20. 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.

    21. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      what does this make?

    22. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      Damn! :'(

    23. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      :(){ :|:& };:

      curiosly i copy&pasted this line my terminal. after that i had to reboot :) what does this command do?

    24. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      What does this command mean? specifically, How does it work?

      captcha:toasted.

    25. Re:Bah, subtlety: by infamous_blah · · Score: 1

      Mod parent fork-bomb!

    26. 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.
    27. 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.

    28. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      I'm not a newbie, but obviously not as bright as I thought I was. I recognize no-op, subprocess, group command, pipe, background characters, but still can't quite figure out what this does. Nothing good, I presume ;-)

    29. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      Wow. Absolutely cool, although it doesn't produce anything beyond "-bash: fork: Resource temporarily unavailable".

      Still... Could you gimme a hint of how it works? Please?

    30. 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.

    31. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      anyone know what that do? it seems to lock down by use all the memory and swap, but i have no idea how it works. some kind of infinite loop?

    32. 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.

    33. Re:Bah, subtlety: by t35t0r · · Score: 1
    34. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      That... was... cool! Now for your second trick, could you please expand on it and explain what it is doing?
      Or point to the FM so I can RT.

    35. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      :(){ :|:& };:

      Wtf that does? :)

    36. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      :(){ :|:& };:

      What that does? :)

    37. Re:Bah, subtlety: by Anonymous Coward · · Score: 0

      Apparently, that syntax doesn't work on Macs, phoie.

  47. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    This comment saddens unix gurus everywhere.

  48. SysAdmins tend to forget by Anonymous Coward · · Score: 0

    People keep forgetting to empty the bit bucket, even certified RedHat sysadmins.

  49. sudo rm -rf / by Anonymous Coward · · Score: 0

    sudo rm -fr /

    Especially if another admin is standing behind me as I type this command, it always surprises him/her.

    I also like these commands:

    touch me
    touch clothes
    rm clothes

    1. Re:sudo rm -rf / by doti · · Score: 1

      touch me
      touch clothes
      rm clothes

      me would end up alone

      --
      factor 966971: 966971
  50. 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.

  51. 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.
  52. 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 Anonymous Coward · · Score: 0

      LOL - modded funny :o)

      (TAB cycles through the tabbed completion list on Windows)

    13. 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!
    14. 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.

    15. 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.

    16. 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.

    17. 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.
  53. 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)"

  54. Best tool for wasting time by snspdaarf · · Score: 1

    Rogue. Definitely rogue.

    --
    Why, without your clothes, you're naked, Miss Dudley!
  55. 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.
  56. 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.

  57. 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

  58. 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?)

  59. 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 Anonymous Coward · · Score: 0

      For this one, you really should use "cd /export && tar -xf -"

      it bit me once

    2. 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

    3. Re:A few of mine... by Anonymous Coward · · Score: 0

      Ok, but if you already have ssh then you can scp instead. But this method can be useful if you run telnet or something else that doesn't support file transfer natively.

  60. 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
  61. -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 Anonymous Coward · · Score: 0

      Tool lazy to log in.

      'find' is one of my favorites. For example, at work, this is useful: "Show me the top ten largest files" (for when I need to clean up some disk space):

      find . -type f -size +1024k -ls | sort -n -b -r -k 7 | head

    6. 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.

    7. Re:-exec as a test by Anonymous Coward · · Score: 0

      Without conditions, an inline perl search/replace is handy:

      perl -pi -e 's/application\/xml/text\/xml/g' *.xml

      I remember this as easy as "pie" and think of starting out with:

      perl -pi -e 's///g'

      then inject patterns between the slashes as needed.

    8. 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)

    9. Re:-exec as a test by Anonymous Coward · · Score: 0

      Why use find for that! grep now has built in recursion!

      grep -R -l word .

    10. 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 {}"

    11. 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.

    12. Re:-exec as a test by Anonymous Coward · · Score: 0

      You could have done

      rename application text *.xml

  62. This is great... by Anonymous Coward · · Score: 0

    Ask Slashdot: Prove your geekiness. What better way to get a ton of comments on an inconsequential "story".

  63. 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
  64. subshells by Anonymous Coward · · Score: 0

    I think that's what they're called. You use them in conjunction with pipes.

    A simple example: tar cf - *| (cd /some/other/volume; tar xf -)

  65. 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 Anonymous Coward · · Score: 0

      Eh? Give everybody access to run /bin/laden? No way.
      I'd much rather shred -fu /bin/laden

    4. Re:Seen on a friend's T-Shirt by gmac63 · · Score: 1

      kill -9 /bin/laden

      --

      INSERT INTO comment VALUE('Doh!') WHERE user='you';
    5. Re:Seen on a friend's T-Shirt by Anonymous Coward · · Score: 0

      sudo chmod a+x /bin/laden

    6. Re:Seen on a friend's T-Shirt by Zaiff+Urgulbunger · · Score: 1

      I'm sure I don't need permission!

    7. Re:Seen on a friend's T-Shirt by Anonymous Coward · · Score: 0

      man find

    8. Re:Seen on a friend's T-Shirt by Anonymous Coward · · Score: 0

      chmod a+x /bin/laden

      Once you have executed /bin/laden another process will spawn. If you want to avoid that:

      $ find /Arabia -user usa -exec rm -f {} \;

    9. Re:Seen on a friend's T-Shirt by frisket · · Score: 1

      not to mention locate wmd

    10. Re:Seen on a friend's T-Shirt by Anonymous Coward · · Score: 0

      That is fantastic.. I can't believe I've not seen that one before.

    11. Re:Seen on a friend's T-Shirt by Anonymous Coward · · Score: 0

      Would have been even funnier if it were written as:

      chmod +x /bin/laden

      Which I guess works as anther general tip for the thread :)

    12. Re:Seen on a friend's T-Shirt by Anonymous Coward · · Score: 0

      Nah that just makes him executable,

      then you have to kill -9 /bin/laden

      or rm -rf /bin/laden

    13. Re:Seen on a friend's T-Shirt by Anonymous Coward · · Score: 0

      That just about sums up the last 8 years...

      "Allow /bin/laden to run"

    14. Re:Seen on a friend's T-Shirt by bobbozzo · · Score: 1

      find / -iname 'base*' -exec chgrp us '{}' \;

      --
      Nothing to see here; Move along.
    15. Re:Seen on a friend's T-Shirt by CoolGenie · · Score: 1

      $ where laden
      laden not found

  66. 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
    1. Re:expect by Anonymous Coward · · Score: 0

      or set up an ssh tunnel through the access device.

      you can set it up so that a local port will come out the other side of the access device with the access device as the source. So you can get around that and go direct.

      Check out the -L ( uppercase ) option to most ssh commands.

      In regards to your cgrep statement.

      from the gerp man page on my mac ( BSD ) Also seen in a stock RH install.

                    -A NUM, --after-context=NUM
                                  Print NUM lines of trailing context after matching lines.
                                  Places a line containing -- between contiguous groups of
                                  matches.

                    -B NUM, --before-context=NUM
                                  Print NUM lines of leading context before matching lines.
                                  Places a line containing -- between contiguous groups of
                                  matches.

                    -C NUM, --context=NUM
                                  Print NUM lines of output context. Places a line containing --
                                  between contiguous groups of matches. :-D

  67. 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
  68. strings and last by Anonymous Coward · · Score: 0

    strings and last are commands I did not know about until more recently

  69. backup/move away by Anonymous Coward · · Score: 0

    cp -iv filename{,.1}

    (and 2, 3, etc) - shell expands it into cp -iv filename filename.1.

    Similarly

    mv -iv filename{,.1}

    move away filename into filename.1.

    (poorman's VMS file versioning-like)

  70. 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

  71. 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).

  72. 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()?
  73. 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 Anonymous Coward · · Score: 0

      or just cat > filename, but sure, using /dev is always fun.

    2. 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

    3. 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.

    4. 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

    5. 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.

    6. Re:Paste your code to /dev/tty for upload by Anonymous Coward · · Score: 0

      You can leave off the /dev/tty.

      cat >file
      [paste here]
      ^D

    7. 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 :-)

  74. 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!
  75. alias="fc -e -" by nsupathy · · Score: 1

    alias='fc -e -'
    r v

    --
    #include std_disclaimer.h
  76. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    Though I really have no idea why:

    find /* >> biglist
    grep -i $SOMETHING biglist

    Why not just use locate instead?

  77. 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
  78. 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.

  79. 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.

  80. Null Windows by Anonymous Coward · · Score: 0

    # mv windows /dev/null

  81. Not having to run by Cornwallis · · Score: 1

    antivirus software.

  82. 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()?
  83. 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}'` ;-)

  84. 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 Anonymous Coward · · Score: 0

      Wow, I'm impressed. I've been using UNIX for almost 25 years, and most of these are new to me.

    11. 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.

    12. Re:short list of shell tips by Anonymous Coward · · Score: 0

      that %% probably doesnt do what you want

      foo=file.ext.ext
      ${foo%.ext}.newext -> file.ext.newext
      ${foo%%.ext}.newext -> file.newext

    13. Re:short list of shell tips by Anonymous Coward · · Score: 0

      find |wc -l would miscount files with newlines in the name)

      If your filenames have newlines in them, you're doing it wrong.

    14. 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.

    15. 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.

    16. 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 :)

    17. 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

  85. 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.

  86. Ohh, those people by jonaskoelker · · Score: 0, Offtopic

    I'm not sure if anyone in our society remembers them, but I think parent is talking about our kin with superhexadecichromatic vision. They were worshiping religious "icons" and the "hand of god". They could survive much greater monitor luminance than we.

    A strange breed, really. Lost in the mist of history.

    [increases the IV caffeine rate, grooms beard]

  87. Annoying by skipsandwichdx · · Score: 0

    yes | write

  88. 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!

  89. 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

  90. Argument Multiplexing by devinteske · · Score: 0

    I find these basic shell features to be invaluable (and amazes people).

    • Press Ctrl-A to go to the beginning of the line (works in any readline-based program, not just shells).
    • Press Ctrl-E to go to the end of the line
    • Press Ctrl-K to erase everything to the right of the cursor.

    Reminiscent of emacs, but very useful when the terminal doesn't like your HOME or END keys (which, if your terminal emulation isn't working properly, will dump control characters to your terminal rather than repositioning the cursor).

    And last, but definitely not least, the ability to act on multiple files that have similar names without retyping the name twice. For example:

    echo Arg{1,2,3}

    produces:

    Arg1 Arg2 Arg3

    So, let's say for example, you want to delete a file and it's backup (same name but has a '.bak' suffix). You could accomplish this with 3 normal ways:

    rm -f foo # remove the original rm -f foo.bak # remove the backup

    - or -

    rm -f foo foo.bak # remove both original and backup

    - or - (my favorite, which many people forget)

    rm -f foo{,.bak}

    The last command will expand "foo{,.bak}" into "foo foo.bak" before executing the entire command. Thus, you have deleted both the original and backup with minimal typing.

    This works GREAT for making backups prior to editing a source file. For example:

    cp file{,.orig}

    Also great for generating differentials:

    diff -u file{1,2}

    The above command will give you the differences between the files named "file1" and "file2".

  91. 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'

  92. 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

  93. grep for windows by Anonymous Coward · · Score: 0

    This is not really for unix, but.... I find it very usefull on windows boxes where grep is not readily available:

    dir | perl -e "print if /pattern/"
    perl -e "print if /pattern/" somefile.txt

    1. Re:grep for windows by Anonymous Coward · · Score: 0

      Yah, I forgot the -n flag :)

      dir | perl -ne "print if /pattern/"
      perl -ne "print if /pattern/" < somefile.txt

  94. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    True, although there's a corner case - it won't work if there are too many files in the folder.

  95. 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.

  96. 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 Anonymous Coward · · Score: 0

      xhost is an old X11 security hole. When you xhost +otherhost you give authorization to anybody (seemingly) coming from 'otherhost' to give orders to your X session, like duplicating the screen or reading keystrokes. I used that trick once to get the root password in clear off a sysadmin console.

      If you really have to give access to a distant computer, use 'xauth' (xauth list on the local display, xauth add COOKIE on the remote one). This is still insecure but not as much as xhost.

      If you care about security, re-direct your remote X apps automatically with ssh by logging in with 'ssh -X'.

    3. 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!

    4. 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.

    5. 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.
    6. Re:Share mouse and keyboard by Anonymous Coward · · Score: 0

      You can share a tty using the "screen" program.

      screen -x

      Came in handy back when I had my system admin job :)

    7. 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.

    8. 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.

    9. Re:Share mouse and keyboard by Anonymous Coward · · Score: 0

      once I worked in a place where some *nixes boxes lied around the walls of a room, me and a friend set all of them like this and were able to move the cursor around from each box to the next until we got to the first one, full circle... We even had a cursor race (whomever got the cursor a full circle around in the smallest time won!). Yeah, we had nothing better to do at that time.

    10. Re:Share mouse and keyboard by sseremeth · · Score: 1

      People are always dumbfounded (as they should be - great software) by Synergy2 along these lines.

    11. 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.

    12. Re:Share mouse and keyboard by SCHecklerX · · Score: 1

      oops. s/vnc/vmware/

    13. 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.

    14. Re:Share mouse and keyboard by Anonymous Coward · · Score: 0

      Best comment ever!
      Wow, that is really really really useful. Thanks a lot!

  97. 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.

  98. 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 Anonymous Coward · · Score: 0

      Thx ! I love you !

    4. Re:directory stack by Anonymous Coward · · Score: 0

      bash: cd: ~1: No such file or director

    5. 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
      $

  99. 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.

  100. 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
  101. 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.

    8. Re:Finding where your disk space went. by Anonymous Coward · · Score: 0

      ls -S also sorts by size...

  102. 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!
  103. 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?
  104. 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?

    3. Re:A real time saver! by Anonymous Coward · · Score: 0

      Maybe someone that executes commands without understanding them should be kept away from computers.

      Or give me their email address so I can check their bank details are correct...

    4. Re:A real time saver! by Anonymous Coward · · Score: 0

      Move parent up! It saved my marriage!

    5. Re:A real time saver! by Anonymous Coward · · Score: 0

      change all $old to $new in $file.
        perl -i -p -e "s/$old/$new/" $file

  105. Creating an empty file using redirection by Anonymous Coward · · Score: 0

    $>test

    Creates an empty file with name 'test'. Quite handy sometimes.

    1. Re:Creating an empty file using redirection by Skal+Tura · · Score: 1

      or just: touch

    2. 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"

  106. 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

  107. 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
  108. how about for loops? by Anonymous Coward · · Score: 0

    I use variations of this all the time:

    for i in `cat list`; do echo $i; ssh root@$i "/etc/init.d/apache restart"; done

  109. directory stacking by Anonymous Coward · · Score: 0

    how about pushd and popd? always useful when you need to navigate step-wise through an unknown directory structure and later on get back quickly to where you started from

  110. "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
  111. 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.

  112. I can't believe nobody has started the flamewar.. by fubar1971 · · Score: 1

    VI rulez!!!!

  113. 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

    2. Re:copying symlinks by Anonymous Coward · · Score: 0

      "Leard?" It's a shame RIT has such terrible liberal arts and humanities.
      -fellow RIT student.

  114. Mod mjcecil up, he corrects my error by qwertyatwork · · Score: 1

    Glad you caught that.

  115. 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.

  116. 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)
  117. 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
  118. 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.
  119. 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.

  120. BSD mail by Undead+NDR · · Score: 1

    I still use the old 'mail' command, especially to read local email from daemons.

  121. some nice aliases (bash syntax) by Anonymous Coward · · Score: 0

    alias lt="ls -lt|head"
    alias lsz="ls -l|sort -n -k 5"
    alias hg="history|grep"
    alias v="vim"

    i use these all the time

  122. 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?

  123. 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!
  124. 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.
  125. 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

  126. 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.
    2. Re:so many "tricks"... by Anonymous Coward · · Score: 0

      There's a rot13 command in the bsdgames package, you needn't resort to tr hackery.

  127. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    Wouldn't you use "locate" for something like that?

  128. 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.
  129. truncate file by Anonymous Coward · · Score: 0

    cat /dev/null >filename

  130. 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

  131. 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
  132. 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 Anonymous Coward · · Score: 0

      better: in you .bash_profile...

      alias grep="grep --color"

    4. Re:grep --color by Anonymous Coward · · Score: 0

      I was doing great until I got here. My brain just exploded.

    5. 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.

    6. Re:grep --color by Beezlebub33 · · Score: 1

      So does 'sdiff'

      --
      The more people I meet, the better I like my dog.
    7. Re:grep --color by Anonymous Coward · · Score: 0

      wow, thank you!

    8. Re:grep --color by Anonymous Coward · · Score: 0

      grep --color

      For some reason, many people are greatly surprised when they figure out that grep will highlight matches for them.

      Doesn't work with standard Solaris/HP UNIX. You need a GNU version of grep for this to work.

  133. 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).

  134. 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

  135. 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.
  136. 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?"

  137. banner!!! by Anonymous Coward · · Score: 0

    My favorite 'fun' shell command is banner.

  138. 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

  139. 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).

    3. Re:find, dc, sed, dd pipes by Anonymous Coward · · Score: 0

      1) You can just add it up in awk.
      E.g. echo "1\n2\n3\n4" | awk '{i+=$1; print i"\t"$0;}'

      2) du returns blocksizes by default. Use "du -h" to get human-readable K,M,G units. Or "du -b" to get it in bytes (apparent-size).

      3) "du -s" return the total for a particular file OR directory and its subdirectories.

      4) Use "du -Ss" to get the total for a particular file OR directory without its subdirectories.

  140. Re:How about a new GUI apt get trick? by Anonymous Coward · · Score: 0

    or, if you're a console weenie, "aptitude"

  141. 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

  142. 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" ?

  143. 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.
  144. 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 Anonymous Coward · · Score: 0

      also lsof will tell you what files or devices a process has open when used with the -p switch

      and also still, lsof can tell you which process is listening on a port --

      lsof -i :80

      for example will show which process is listening on port 80, the normal http web server port

      very handy, lsof!

    4. 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

    5. Re:lsof by Galilee · · Score: 0

      lsof -i:1234

      That command will tell you what process is listening on port 1234. This had saved me several times when I'm trying to find out what app grabbed the wrong port.

    6. Re:lsof by Anonymous Coward · · Score: 0

      In some cases you can sidestep the unmounting problem on linux by using umount -l to do a lazy unmount, which simply removes the mount point but keeps the filesystem available for whatever process was still using it. Then you can mount another filesystem at the mount point. Of course this won't help if you want to eject the disk or reformat the unmounted filesystem or something like that.

    7. 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
    8. Re:lsof by empaler · · Score: 1

      Also useful if you're deleting stuff, Ã lalsof | grep

  145. 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...

  146. 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

  147. 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).

  148. 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.

  149. 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 Anonymous Coward · · Score: 0

      How is that not really unix ?? you using a older version of OSX ?? or are you using a non intel mac ??

      as of the latest version , on intel , OSX is UNIX.

    2. Re:Not really unix ... by daveywest · · Score: 1

      I was implying that you won't find the "say" command in any other distro.

  150. tar copies by Anonymous Coward · · Score: 0

    Copying homedirs on old Sun boxes w/ command from the manpage tends to surprise people today (copy and preserve perms, ownership, symlinks etc. -- when done as root):


    cd /some/source/dir
    tar cf - . | (cd /some/dest/dir; tar xf -)

    Do it across the network:


    cd /some/source/dir
    tar cf - . | ssh user@host "cd /some/dest/dir; tar xf -"

    I realize cp with recursive and preserve options can work, but tar always just works great for this stuff.

  151. 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]
  152. 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.

  153. 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.

  154. directory stack! by Anonymous Coward · · Score: 0

    pushd, popd, and dirs

    great for jumping around the filesystem, then unwinding back to where you started

  155. 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

  156. 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).

  157. 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.

    2. Re:xargs by Anonymous Coward · · Score: 0

      when you're doing a oneliner that has "rm", be careful.

      The more correct way would be:

      find /tmp -type f -mtime +7 -print0 | xargs -0 -r rm

      which wouldn't choke on files with spaces or other weird characters.

  158. Tar, encrypt and make 4gb chunks of backup by Anonymous Coward · · Score: 0

    cdecrypt while tarring tar cf - /cygdrive/c/shared | ccrypt -k hello > test.cpt

    ccrypt while tarring for specific size:

    tar czf - /directory/to/backup | ccrypt -k hello | split -b4000m - /place/to/save/backupfile/to/filename.gz.cpt.

    To join:

    cat file.gz.cpt.*[a-z] | ccdecrypt -k hello | tar -xzf -

    The -k hello is the file containing the password to encrypt with.

  159. Help you I can, yes. by Anonymous Coward · · Score: 0

    I grew up on windows. Only found Linux Ubuntu last year. Found the command line shortly thereafter. I look at this thread and realize how little I've actually learned.

    Teach me the way of the force, Oh Jedi masters!

  160. 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.

  161. 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
  162. 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"
  163. 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

  164. 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 Anonymous Coward · · Score: 0

      kill (-9 optional) `ps -ef | grep <username> | awk {'print $2'}` is shorter ;-)

    2. Re:Kill all processes of a user by loftwyr · · Score: 1

      kill (-9 optional) `pgrep -u ` is shorter still.

    3. 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
  165. 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!
  166. 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 zoe23 · · Score: 0

      'sudo -s' or 'sudo -i' is actually the proper way to get a root shell using sudo. I bet you use Ubuntu?

    2. 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
    3. 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!
    4. 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.

  167. 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.

  168. 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 Anonymous Coward · · Score: 0

      kill -9 `echo $$`

    2. 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

    3. Re:Shell history tricks by Old+Wolf · · Score: 1

      For vi editing mode, simpler is: set -o vi

    4. Re:Shell history tricks by Anonymous Coward · · Score: 0

      But if you set up .inputrc you get vi mode in any application that uses the GNU readline library: gdb, etc.

    5. 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.

    6. Re:Shell history tricks by Anonymous Coward · · Score: 0

      I find interactive search much more usable, I bind it to ctrl-up and down. So I can quickly search for all commands that starts with what is at the left of the cursor.
      I can't stand using a command line without this.
      (it's the commands history-search-backward and history-search-forward in bash)

      Also I bind ctrl-g to type "|grep " and ctrl-l to type "|less".

    7. Re:Shell history tricks by mike3k · · Score: 1
      My favorite history trick:

      alias redo 'sudo \!-1'

    8. 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
    9. 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
    10. Re:Shell history tricks by Anonymous Coward · · Score: 0

      ls -1 > file

      exactly the same as:

      ls > file

      try it before replying.

    11. 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.

    12. Re:Shell history tricks by Anonymous Coward · · Score: 0

      You forgot [Ctrl-r] for quick search through history. Sort of like !?foo? but less committal and more interactive.

    13. Re:Shell history tricks by Anonymous Coward · · Score: 0

      ls > filename is exactly the same in every way, except shorter to type.

      Actually, it's not.

      Modern versions of ls notice that they are being redirected to a file, and automatically act like the -1 is being applied. But if you ever work with a sufficiently old/weird ls, you may find one that doesn't do this behavior by default. But that's nitpicking.

      More to the point, many people work with aliases. I have ls aliased as "ls -CF". Guess what happens if I leave off the "-1"? Indeed, I get columns in my redirected file. Now that I think about it, that "-C" is not needed; it's default behaviour anyway. I suppose can thank whoever wrote the .bashrc defaults for my Linux distro for that.

      "So," I hear you saying, "just change the stupid -C from your alias." In fact I just did so. Now I can leave off the -1 on my system, but if I type something on a colleague's system and I leave off the -1, I might not get the output I want.

      So, what have we learned?

      ls -1 when redirecting is not needed by default for a modern ls in the absence of aliases.

      You may notice that this is not precisely "the same in every way, except shorter to type".

      P.S. I choose to believe that when you said "is waste" you were just being short and to the point, rather than insulting. If you were being insulting whilst also being wrong, then -2 points to you. HTH, HAND.

    14. 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.

    15. 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.

  169. 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.
  170. Two of my favorites by Anonymous Coward · · Score: 0

    To go to the last directory I was in:
    cd -

    To search my history:
    ctrl + r

  171. 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()?
  172. Ctrl+R by Anonymous Coward · · Score: 0

    This is more a bash trick than just Unix, but I've found it really useful:

    Reverse search history (Ctrl+R):
    it searches backward starting at the current line and moving 'up' through the shell history as necessary.

    Perfect for "remembering" long commands quickly...

  173. 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.

  174. Sudo and the Wife by Anonymous Coward · · Score: 0

    To the wife:
    Make me a sandwich
    No!
    sudo make me a sandwich
    Ok

  175. watch - execute a program periodically by robmv · · Score: 1

    watch AnyProgram

    run AnyProgram every two seconds (default time) and show the output

  176. 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.

  177. Bashism - history completion by Anonymous Coward · · Score: 0

    "\e[1;3A": history-search-backward
    "\e[1;3B": history-search-forward

    These entries in inputrc (/etc or ~/) and a 'bind -f ~/inputrc' will give you Pg-Up/Pg-Dn command completion.

    Type the first few characters of a previously run command, and press 'Pg-Up'.

    This is a standard thing for SuSE, and hard to untrain your muscle memory to use. Add these lines - amaze your friends, fool your enemies!

  178. 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.
  179. Simple Source Control by Anonymous Coward · · Score: 0

    Simple source control (for local purposes or where real source control is overkill):

    $ ln foo.c foo.c.0
    $ cp foo.c.0 foo.c
    $ ln foo.c foo.c.1

    $ ls -l foo.c*
    5314 -rw-r--r-- 2 someone grp 332 Nov 5 12:01 foo.c
    4871 -rw-r--r-- 1 someone grp 324 Nov 5 00:50 foo.c.0
    5314 -rw-r--r-- 2 someone grp 332 Nov 5 12:01 foo.c.1

  180. top by dahl_ag · · Score: 1

    I was surprised by how how many unix people at my last job didn't know about 'top'...

  181. 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.

  182. xargs! by Anonymous Coward · · Score: 0

    > find . -exec grep -l keyword {} \;

    find . -print0 | xargs -0 grep -l keyword

    Much faster since it doesn't fork a new process for each file.

  183. 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.

  184. 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.

  185. blkid by Anonymous Coward · · Score: 0

    I use blkid to get UUID's of block devices to use in /etc/fstab

  186. CAT MY TOP! by Anonymous Coward · · Score: 0

    I had a manager who though he was UNIX savvy was surprised to learn what the 'cat' command was. He was also amazed at 'top'. He didn't last long here or he would have learned more than just those two. He's probably a UNIX Master now to the peers who dubbed him UNIX Savvy.

    One of the more useful tools I've ever used was 'strace'. So great for finding the unknown reason a binaries fails. Also 'lsof'.

    Many unix users have no clue you can use those to find out so much.

  187. tar to move stuff by Anonymous Coward · · Score: 0

    Here's an old command that was always in the man pages for tar on Solaris/SunOS boxes:

    cd && tar cf - . | ( cd / ; tar xfBp - )

    Maintains all ACL info etc.

  188. Just about everything by Anonymous Coward · · Score: 0
    • What sorts of things do you take for granted as a natural part of Unix that other people are surprised at?

    Given how clueless linux kids are and how important they think a transparency-enabled-gui-file-navigator is. . . just about everything you can do in a shell.

  189. 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

  190. 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'

  191. Impersonate by Anonymous Coward · · Score: 0

    With sudo access, you can impersonate:
    sudo su - someuser
    is invaluable to check what might be wrong with the user account "someuser" (eg, wrong ssh keys in .ssh/known_hosts). And you don't need the users password ;)

    Of course, BOFH is an invaluable source for inspiration. Gems like:

    "Um, I need to know how to rename a file" he says.
    Oh dear... Hang on, it's payday isn't it?! I'm in a good mood.
    "Sure. You just go 'rm' and the filename"

    really stayed with me all these years ;)

  192. 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 */
  193. 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!

  194. 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.
  195. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    xargs : how to deal with 300,000 files in one directory without totally losing your sanity.

  196. 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
  197. :> /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.)

  198. 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.

  199. bang dollar by Anonymous Coward · · Score: 0

    Why does no one know that !$ expands to the last argument of the last command in most shells (bash, sh, csh, zsh)?

    cd ~projects

    glug% cd ~projects
    cd: permission denied: /home/projects
    glug% ls -ld !$
    ls -ld ~projects
    drwxrw-r-x 30 projects projects 4096 2008-10-27 15:13 /home/projects
    glug% sudo chmod g+x !$
    sudo chmod g+x ~projects
    glug% cd !$
    cd ~projects
    glug%

    1. Re:bang dollar by seaturnip · · Score: 1

      I prefer to use alt-. instead (in bash).

  200. 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."
  201. 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

  202. !$ 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.

    3. Re:!$ in bash by jollyhockysticks · · Score: 0

      there is !^ available too which is the first argument of the last command, not often useful but sometimes.

  203. factor by grandadmiralmcb · · Score: 1

    typing factor and an integer will factor the integer into its prime factorization

  204. Alternate shells by Anonymous Coward · · Score: 0

    I'm frequently disappointed at how many people don't know that there are shells other than bash - and, for that matter, at how many people don't know that their shell is in fact a program called bash (or sh, or zsh, or csh, or ...)

  205. Generating EOF with ^D by Anonymous Coward · · Score: 0

    Exiting your shell using ^D: I keep seeing people typing in "exit", even "logout" manually every time.

  206. 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.

  207. 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!
  208. Re:How about a new GUI apt get trick? by Bandman · · Score: 1

    I've used "yum whatprovides" before. Is "provides" the same thing?

  209. cat, grep, sed, head, awk, tail and... by Anonymous Coward · · Score: 0

    anything bash can do by itself.

    They cast a combination of spells to guarantee maximum attack on big files that need parsing at breakneck speeds.

    all this mouse waving and smudging your touch screen stuff just slows you down when things need doing fast because the brown smelly stuff is planning a surprise visit to the fan LOL.

  210. 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.

  211. 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
  212. 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.

  213. 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

  214. 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.
  215. 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!

  216. 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...

  217. Re:How about a new GUI apt get trick? by Anonymous Coward · · Score: 0

    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".

    apt-cache search yourpackage

  218. 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

  219. 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.
  220. dont forget the unix sex commands by Anonymous Coward · · Score: 0

    gawk; grep; unzip; touch; strip; init,
    uncompress, gasp; finger; find,
    route, whereis, which, mount; fsck; nice,
    more; yes; gasp; umount; head, halt,
    renice, restore, touch, whereis, which,
    route, mount,
    more, yes, gasp, umount, expand, ping,
    make clean; sleep

  221. 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.

  222. most stupid shell script (and other stuff) by Anonymous Coward · · Score: 0

    put this in a script:
    #!/bin/ksh
    exec $0

    chmod it 755, run it, see your system getting nuked ;)

    (s)ed & (n)awk
    people seem to be literally afraid of those three most useful unix commands, here's some cool stuff i use them for everyday:

    get a certain field - most people would use this to get all uids from passwd:
    cat /etc/passwd | cut -d':' -f3

    with awk it's much kiss-er:
    awk -F":" '{ print $3}' /etc/passwd

    or get the total san storage configured for your veritas devices:
    df -k |nawk '/^\/dev\/vx/ {i=i+$2} END { printf("%s GB\n",i/1024/1024)}'
    # 908.018 GB

    use "$4" instead of "$2" and you get how much SAN space you have left in total, and so on. you get the idea how powerful awk is ;)

    sed is great for string substitutions:

    echo "the dog is blue" | sed s/dog/sky/
    # the sky is blue


    the problem with (SVR4) sed is, that you need to work with tmpfiles if you want to edit files with it. therefor i prefer "ed", especially when editing the same thing in a lot of files. say, the above "echo" would've been in 20 files, i'd do:

    for i in *files* ; do
    echo "s/dog/sky/.\nw\nq\n" |ed - $i
    done

    that's just the tip of the iceberg of what you can do with this three little tools.

    oh one last thing: if write/read isn't well known, who knows "talk"? try it on any >2.6 solaris box ;)

  223. copy a directory tree... by Anonymous Coward · · Score: 0

    tar cf - * | (cd /new_directory; tar xvf - )

  224. 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>

  225. Re:-1, lame attempt at humor by Anonymous Coward · · Score: 0

    I guess you'd know.

  226. 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.
  227. 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.

  228. More TAB awesomeness by badpazzword · · Score: 1

    On zsh you can even tab complete parameters.

    --
    When ideas fail, words become very handy.
  229. 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?

  230. 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.

  231. 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!
  232. Why does it have to be ./script ? by Anonymous Coward · · Score: 0

    Btw, why does shell require ./script syntax to run a script in current directory?
    Why isn't simply script enough?

    1. 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).

    2. Re:Why does it have to be ./script ? by Anonymous Coward · · Score: 0

      I see. I assumed . is always searched, like in DOS.

    3. 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)

  233. 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 ??

  234. 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

  235. 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.
  236. uhm, "mesg n" :) by Anonymous Coward · · Score: 0

    "mesg y" enables, that ppl can call you for chatting on a term
    "mesg n" disables it

    use "talk user@host" to open a chat application with bidirectional flow ... locally you can also select, on which terminal you want to call the user in case he is logged in with more than one terminal (its quite a fun to find me in my open terminals ^^)

    besides bc you can also do simple looping and calculation

    echo $((5+1))
    export data=11
    echo $((data * 11))

    there is quite a universe more on stuff, ye know? :p sometimes it helps reading manpages and manuals.....

  237. 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 :)

  238. process list by Sergo5020 · · Score: 1

    ps xawf|mail `whoami`

  239. 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.

  240. what is on your mind?? by Anonymous Coward · · Score: 0

    That looks a bit phallic.

  241. Re:This one always surprises people for some reaso by Galactic+Dominator · · Score: 1
    --
    brandelf -t FreeBSD /brain
  242. 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 :)

  243. 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 Anonymous Coward · · Score: 0

      Another backup trick:

      cd /some/dir; tar cf - . | ssh host '(cd /some/dir; tar xf -)'

      With a whole lot of other switches and/or piped commands possible.

    5. 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

    6. 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

    7. 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

    8. Re:Useful tricks. by Randle_Revar · · Score: 1

      >are they tucked in a .git folder under the checked in directory?

      yes

    9. 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
    10. 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
    11. 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!
    12. 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) ~ >

    13. 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.
    14. 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.)

    15. 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"

    16. 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
    17. 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}'.

    18. 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

    19. 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

    20. 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?

    21. 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.

    22. 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

    23. 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.

    24. 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

    25. Re:Useful tricks. by Anonymous Coward · · Score: 0

      Isn't git linux only though?

    26. Re:Useful tricks. by Anonymous Coward · · Score: 0

      Have you ever used git? it's sooooo much easier than svn. easier to setup, easier to administer, easier to share between systems, etc etc.

      it's pretty linux specific though.

    27. Re:Useful tricks. by Anonymous Coward · · Score: 0

      git push

    28. 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.

    29. 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
    30. Re:Useful tricks. by Anonymous Coward · · Score: 0

      "Ellie" is a shortening of "Elenor", not "Elizabeth". If you were really a woman you would know that.

      FWIW there's no shortage of shortenings of "Elizabeth". Like socialists, Elizabeths go around under so many pseudonyms it can be too easy to underestimate how many of them there are, walking among us, watching us.

  244. Re:Listing directory contents without the ls comma by msuarezalvarez · · Score: 1

    Your trick involves cutting and pasting, presumably using a mouse?!

  245. No one has mentioned for, foreach, etc? by Anonymous Coward · · Score: 0

    grep too. Piping makes you a god.

  246. 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

  247. 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

  248. FreeBSD's man pages by Anonymous Coward · · Score: 0

    Agreed. A quick look at even FreeBSD's man page quality would be a real eye-opener for most linux users. Which is not to say that I (necessarily) think FreeBSD is better in other regards.

  249. 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 */
  250. 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...
  251. 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/

  252. 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.

  253. 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 */
  254. writing a floppy image by Anonymous Coward · · Score: 0

    cat img.file > \dev\fd0

  255. 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.
  256. 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::

  257. 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.

  258. 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.

  259. 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.
  260. 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.)

  261. 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//'

  262. 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.
  263. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    Quick way to find a file on your system, including the path to the file.

    $ find /(directory) -name filename -print

    Example: $ find / -name *foo* -print

    will start at the root directory and look for any file which has the text "foo" in the name. This can be used with other commands for mass deletion of specific files.

    $ find / -name *foo* -print

    $ rm -rf `find / -name *foo* -print`

    -- stj

  264. 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]
  265. C-r by Anonymous Coward · · Score: 0

    C-r is wonderful

    It allows searching of your command history.

    I know anyone who isn't using this is going to freak out right about now.

  266. xargs by Anonymous Coward · · Score: 0

    xargs is really handy when you have a large data source and need to run a specific command over it.

    It takes a list of inputs on stdin and runs a command using your input as the arguments. It will run as many times as it needs to exhaust your list without overfilling the command line argument list.

    find /tmp -type f -mtime +7 | xargs -r rm

    Find all the regular files in /tmp more than 7 days old and remove them. It's more efficient than

    find /tmp -type f -mtime +7 -exec rm {} \;

    In case 2, rm is execed for each and every file found.

    In case 1, rm is run the minimum number of times, reducing forks, etc... and probably speeding things up, especially on a large file list.

  267. 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.

  268. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    • 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.

    There, fixed it for you. Otherwise you wouldn't catch partial matches.

  269. 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.

  270. 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.

  271. esc dot by Anonymous Coward · · Score: 0

    My favourite is "[Esc] ." (Esc key and dot)

  272. 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.

  273. Re:Hail to the chimp! by Omega996 · · Score: 1

    seriously.

  274. fgrep -nir by Anonymous Coward · · Score: 0

    fgrep -nir whaterver /etc
    (when you're wondering - where the fkuc was that whatever option)

  275. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    $ which echo
    /bin/echo

    Liar liar pants on fire

  276. 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).
  277. push and pop by Anonymous Coward · · Score: 0

    I use the pushd and popd commands in bash to quickly jump back and forth between directories

  278. 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.
  279. Re:rev (uniq too) by The+Bean · · Score: 1

    Instead of "sort | uniq" you could simply use "sort -u"

  280. 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.

  281. 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!
  282. UNIX guy gets laid by Anonymous Coward · · Score: 0

    cd /pub; gawk; sort; wine; talk; wine; talk; cd ~; more; wine; talk; strip; grep; yes; more; finger; yes; more; mount; fsck; eject; sleep; exec rm .bash_history;

  283. Directory stack by Anonymous Coward · · Score: 0

    The directory stack is like tabbed browsing in a command line.

    dirs -v ; #show the directory stack, and each dir number

    pushd /a/really/long/and/tedious/dirname ; #push a directory to the top of the stack

    pushd /another/long/one/noone/wants/to/type/twice ;

    dirs -v; #show stack again.
    pushd +2; #go to original dir
    eval cp foo `dirs +1` ; #cp foo to directory #1

    I alias dirs -v to 'd'. pushd to 'pu' and popd to 'po'. Try it!

  284. 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!)

  285. 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.

  286. bash trick by Anonymous Coward · · Score: 0

    C-r in bash and start typing a command you ran recently.

    Pretty cool bash trick :-)

  287. 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!
  288. 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.

  289. 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?

  290. Kill all of your processes by Anonymous Coward · · Score: 0

    kill -9 -1 as root ;)

  291. 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? "...!!"

    2. Re:Time warp by Anonymous Coward · · Score: 0

      That actually is correct. September 1752 was shortchanged.
      See:

      http://www.infoplease.com/spot/gregorian1.html

      http://www.webexhibits.org/calendars/year-text-British.html

      http://www.exit109.com/~ghealton/y2k/br1752a.html

  292. Perhaps already mentioned by tdashton · · Score: 1
  293. xargs examples by Bill+Dimm · · Score: 1

    Wikipedia gives some xargs examples.

  294. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    Except that that doesn't give echo an asterisk as a paramerer; to do that, you'd use:

    echo '*'

    And it would respond by echoing a literal asterisk.

    What you're doing is using echo to print the results of the shell's glob expansion of the command line...

  295. 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.

  296. 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

  297. 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.

  298. hu..?? by meuhlavache · · Score: 2, Funny

    What the hell all those geeks are talking about?

  299. 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
  300. 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.
  301. 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.

  302. 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.
  303. 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

  304. 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.

  305. 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
  306. 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.

  307. This is a great one... by mckillnm · · Score: 1

    ~$ yes > /dev/pts/0

    Just watch the other persons term...!

  308. 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.

  309. pipe through SSH to transfer files by Anonymous Coward · · Score: 0

    cat somefile | ssh bubba@192.168.1.1 cat > somefile

    1. 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?

  310. Don't try this at home by BratNZ · · Score: 1

    unlink /

    (Works instantly, unlike rm -rf /) :-)

  311. zgrep? by Anonymous Coward · · Score: 0

    I started using "zgrep" recently rather handy when you are looking through MANY .tar.gz log files that have been rotated and archived:

    zgrep textlookingfor ftp.log.*

    1. 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.

  312. 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.

  313. 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.
  314. Re: by MonoSynth · · Score: 1

    /Funny F3 F3 F3 F3... (That's not UNIX, that's what I'm doing right now in Firefox :) )

  315. 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 .

  316. 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!!

  317. Regular reader by Anonymous Coward · · Score: 0

    FTR this is one of the greatest threads

  318. 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.

  319. 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)

  320. Curiously absent from the many suggestions by ehintz · · Score: 1

    I would have thought apropos would be apropos in current context.

    --
    ehintz
  321. timecat by Lost+Engineer · · Score: 1

    time cat
    times how long it takes you to press ctrl+d.

  322. don't forget this old trick by Anonymous Coward · · Score: 0

    who | grep -i blond | date;
    cd ~; unzip; touch; strip;
    mount; finger; gasp; yes;
    uptime; umount; sleep

  323. You really need to know this one ... by schrom · · Score: 1

    :q!

  324. 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.
  325. bash trl-r by Anonymous Coward · · Score: 0

    Ctrl-r in bash does reverse search in bash history. So, just press Ctrl-r in bash and type away what you're looking for, very useful :)

  326. esc-. by Anonymous Coward · · Score: 1, Informative

    in bash, esc-. is a fantastic shortcut

  327. 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.)

  328. 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()?
  329. 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

  330. 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.
  331. 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 Anonymous Coward · · Score: 0

      -rwxr-sr-x 1 root tty 8192 2007-12-12 11:59 /usr/bin/bsd-write*

      Are you daft?

    3. 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
  332. 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.

  333. Bash history exec by Anonymous Coward · · Score: 0

    people often ask me:
    "What did the exclamation mark do?"

    Example:
    # apachectl restart
    Restarting Apache...
    # !apa
    Restarting Apache...

    and then I tell them, it goes through your bash history file and executes the first command which begins with whatever you type after the exclamation point. useful for repeating long commands or just being lazy.

  334. 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

  335. 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)

  336. 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
  337. 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 .

  338. 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

  339. 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.

  340. 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.

  341. 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."
  342. 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
  343. echo -n ":)" /dev/hda by Anonymous Coward · · Score: 0

    echo -n ":)" > /dev/hda ... or whatever harddisk he needs to boot from,

  344. everyday fun by Anonymous Coward · · Score: 0

    ps -aux | grep -i $PROCESSNAME

    What ports are open ?
    netstat -lane | less

    losf | grep -i tcp

  345. 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 Pvt_Ryan · · Score: 0, Redundant

      Think you got that wrong... it's: There are 10 kinds of UNIX admins... - those who can count - and those who can't (For those that fail to get the joke, 10 in Binary is 2)

    3. Re:10! by paulatz · · Score: 0, Redundant

      You've been found guilty of telling an old joke wrong and than explaining it pedantically. The jury is unanimous: the sentence is death.

      --
      this post contain no useful information, no need to mod it down
    4. Re:10! by iphayd · · Score: 0

      00 Those that don't know Binary
      01 Those that do
      10 Those that think they know binary, but don't know that 10 is the third numerator.

    5. 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
    6. Re:10! by Anonymous Coward · · Score: 0

      00 Those that don't know Binary
      01 Those that do
      10 Those that think they know binary, but don't know that 10 is the third numerator.

      Yeah, sort of like how the number 2 is the third numerator in the decimal system?

      Your point?

    7. Re:10! by Anonymous Coward · · Score: 0

      Actually, there are 10 kinds of UNIX admins...

      The ones who've yelled "oh shit!", the ones who will, the ones who waste time on Slashdot, the ones who aren't really Unix admins at all but pretend to be on Slashdot because they used a Ubuntu live-cd that one time, the ones who hate Linux for causing all those idiots to think they're Unix admins, the ones who wanted to be programmers but got railroaded into a different career, the ones who swear by vi, the ones who swear at vi, the ones who "ln emacs vi" on every machine they administer just to show those vi-lovers who's boss, and the ones who think that stupid binary joke is still funny.

    8. 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.
    9. Re:10! by Anonymous Coward · · Score: 0

      I think he just meant to show off that he doesn't know that there are 10 kinds of numbers (at least): the cardinals, which are used for measuring quantity, and the ordinals, which are use to measure relative position in an ordered structure.

    10. 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
  346. 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 ...

  347. Using /proc/[0-9]+/fd/[0-2] by Anonymous Coward · · Score: 0

    Some fun can be had (though rarely useful) redirecting to a process's std in/out/err. Background a process and forget you have to type "yes" to it?

    Find the pid
    echo yes >/proc/$PID/0

    Find your "friend"'s shell pid
    cat /dev/urandom >/proc/$PID/fd/1
    Basically write(1) without the nice warning message that you're typing to their tty.

    Course you have to have permission to write to the descriptors which means root or owning the process.

  348. 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)

  349. 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

  350. kill a bunch of processes at once... a time saver by Anonymous Coward · · Score: 0

    kill -9 `ps aux |grep foo| awk '{print $2}'`

  351. Re:Lego by decaying · · Score: 1

    grep somestring outputfile | cut -f 3 -d ' '

    --
    ----- One piece short of Legoland
  352. python by Anonymous Coward · · Score: 0

    python is another great command-line tool, of course!

  353. disown by starkadder · · Score: 0

    "disown" is a useful command when you have something running in a terminal and you have to shut down your client, especially if it is a process that is going to run for a long time. Just put the process into background and disown it. Now when the shell recieves a SIGHUP, the disowned process does not...

  354. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    I'll create an account later, anonymous coward for now...

    This saved my @ss when someone tromped on ls and redirected (>) over ls with the output of ls (I still don't know who did it). echo * saved the day!

  355. umm, so what? by Anonymous Coward · · Score: 0

    We've been doing remote X since the stone age, and doing it via SSH since SSH became available. I know I was using X over SSH in about 1995 between Linux and HP-UX workstations over PPP over a 14.4k modem, and I am sure I wasn't the first user to try that.

  356. 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.

  357. Semicolons and automating sequences by Anonymous Coward · · Score: 0

    I have certain tasks to bring down and up on random servers a few times per day. After having to manually log in, type the same command, wait 5 mins and type the up command, and then wait a while before i could close the window... I decided to chain the commands. Now I have this:

    tool down; date ; sleep 300; tool up; exit

    The command itself is low-moving and verbose, so date tells me how much of the 5 min. delay remains per window. The best part is how cool it is when you middle click each CLI window and minimize, knowing it will disappear in a few

    Also, my laptop used to demand an fsck everytime it ran out of battery. I dont care much for the results, but I had to come to it to type reboot manually.

    Now, I just do something like this this and return to my newly booted OS a few mins later:

    fsck -y /dev/sda6; reboot

  358. 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.

  359. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    heh, my first step after installing any linux distro such as redhat or fedora is "rpm -e slocate mlocate" just to be sure it is ripped out of the system!

  360. 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.

  361. 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
  362. true by Anonymous Coward · · Score: 0

    I love a command that does 'nothing successful

    emacs. Really, if you're a new to linux you have
    to type 'emacs' at a console.

    You cant get out without learning job control.

    And of course who could forget:
    export PS1=`clear`

  363. Always good for a laugh: by Anonymous Coward · · Score: 0

    for each in `head --lines 3000 /dev/urandom | strings | sed -e 's/[^a-Z1-9]//g'`; do touch $each;done

  364. sudo get a life by Anonymous Coward · · Score: 0

    get a life
    get a life
    get a life
    get a life

    oops! I could have written a shell script for this.

  365. tricks by Anonymous Coward · · Score: 1, Informative

    bash#set -o vi

    also

    $ls -tgo |less

    shows modified files first, useful for webmasters

  366. ls -1 |xargs -i do_something {} by Anonymous Coward · · Score: 0

    I love xargs. Replaces so many perl oneliners.

  367. 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.

    --
  368. N/A by Anonymous Coward · · Score: 0

    Is something useful supposed to be posted?
    I'm getting angry thinking that I could be more productive if I read the man-pages of programs I use everyday.

  369. lsof by Anonymous Coward · · Score: 0

    lsof -i [protocol]:[port] - Ex: lsof -i tcp:80

    for loops and key-based ssh authentication (with agent) are godsend when combined.

  370. 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.
  371. 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.

  372. 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.
  373. Ctrl-R mystifies people; applying a little magick by Anonymous Coward · · Score: 0

    In apps that use GNUReadline (or readline workalikes, or are otherwise emacs workalikes) ctrl-r does a reverse incremental history search. Bring up a bash shell, hit ctrl-r and type slowly. It amazes people every time.

    At a prior workplace we all had SUN machines as desktops (this was many moons ago). One afternoon while walking the office I was flagged down by fellow IT people sitting at a windows box frantically clicking in some windows photo app. They needed to resize several thousand employee photos for security badges and they were trying to enlist help because they wanted it done before the end of the week. I walked over to the workstation next to the PC and said "Um. Hold on.", opened up a terminal and typed "mkdir thumbs; for i in *.jpg ; do convert -scale 160x320 $i thumbs/$i ; echo $i ; done". I pressed enter and told them to go have a cup of coffee. It was magic, imagemagick, and it won over a couple of the holdouts into the Unix fan-club.

  374. Ctrl-D by Anonymous Coward · · Score: 0

    Control-D (the End of File character) to exit a shell. It's so second nature to me I don't even realize I'm doing it.

    This is a subset of the everything-is-a-file philosophy, even terminals, which is also very nifty.

  375. Send sexy pics to someone's X Window by Anonymous Coward · · Score: 0

    This trick was played on me in my first internship in a Unix admin group.

    While away from my PC, one of the guys executed

    xhost +

    on my terminal. Then when I came back and worked on my PC, they remotely opened pictures of busty babes in swimsuit on my PC, just as the boss went by:

    export DISPLAY=victim.host:0.0
    xv playboy.jpg

    I have since enjoyed the same fun with most of my own interns.

  376. 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.
  377. expect, rsync by Anonymous Coward · · Score: 0

    To transfer files, transparently compress blocks to save bandwidth, prompt for password only first time.

    Expect doesn't scale well with complexity, but _oh_ it's good at quick hacks that you use over-and-over.

  378. 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!
  379. 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!
  380. bash: Ctrl-r by Anonymous Coward · · Score: 0

    Search command history. Can use arrows or text for searching.

    Will add years to your life.

  381. 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 :)

  382. watch by Bombcar · · Score: 1

    watch ls -l

    will run ls -l every two seconds. Useful for watching a file transfer or similar.

  383. Mom's favorite by Doodman · · Score: 1

    I've always enjoyed using this on any Linux box:

    $ who mom likes

  384. 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.
  385. find -exec by Anonymous Coward · · Score: 0

    find ./ -name '*.foo' -exec sh -c "grep -Hw keyword \"{}\"" ';'

  386. 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

  387. 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
  388. 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

  389. 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.

  390. My favorite... by javajedi · · Score: 1

    $ kill -9 -1

  391. Hooks, hooks, hooks. by Anonymous Coward · · Score: 0

    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.

    Funny, just yesterday I made Growl (Mac only) notifications from my server's irssi instance (run in screen), which an archaic perl script sends over UDP, be tunneled over SSH to my MacBook Pro just by running a single command from it.

    It uses netcat to re-route UDP to server:9887 to an arbitrary port on the same machine, which a reverse SSH hook (-R yanno) tunnels to the MBP, and netcat again on the other end to re-UDPify it. From my .bashrc:


    function growlhook() {
            echo "Running local TCPâ'UDP hook";
            (nc -l 47695 | nc -u localhost 9887 &) 2>/dev/null # 2> to silence ZOMG U BG'D A PROC!! from bash
            localhookpid=$!

            echo "Running remote reverse SSH tunnel hook"
            ssh username@my.server.tld -R 47695:127.0.0.1:47695 \
                    'while sleep 0.5; do
                            echo "Starting remote UDPâ'TCP hook"
                            echo "Ready to forward notifications."

                            nc -l -u -p 9887 | nc localhost 47695

                            echo
                            echo "Remote UDPâ'TCP hook quit."
                    done'

            echo "Cleaning up"
            kill $localhookpid 2>/dev/null # Cleanup
            echo "Quitting"
    }

  392. 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.

  393. history-search by kokoko1 · · Score: 0

    It same me lot of time to have BSDs like command completion feature in Linux
    vi ~/.inputrc
    "\e[A":history-search-backward
    "\e[B":history-search-forward

    --
    http://askaralikhan.blogspot.com/
  394. 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

  395. 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.

  396. 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.

  397. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    find -iname '*~' -delete
    find -iname '*.sh' -exec chmod +x '{}' \;
    etc... find isn't just for finding things.

  398. viewing a config file by Anonymous Coward · · Score: 0

    egrep '^[^#]' /etc/httpd/conf/httpd.conf | less

  399. 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."
  400. 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

  401. 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.

  402. 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."
  403. rtfm... by swehack · · Score: 1

    man 1 write

  404. 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.

  405. 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.

  406. Machine locator in a large data centre by Anonymous Coward · · Score: 0

    snoop -a

  407. Which laden? by jokkebk · · Score: 1

    And to make sure you really encounter the right Laden along your path:

    which laden

    --
    http://codeandlife.com
  408. Aliases and... by Anonymous Coward · · Score: 0

    It seems that a lot of people either enjoy typing as much as they can or have forgetten about aliases.

    Lots of room to create useful shortcuts here. One of favourites is netstat piped to grep.

    alias ng='netstat -anop | grep'

    Usage: "ng EST" for established connections or "ng LIST" for listening ports.

    Anyone who has a bit of bash skill knows the special shell variables starting with "$" but not many people use the "!" variables. My favourite is "!$", which holds the last argument of the last command.

    Usage: cp foo bar; vi !$;

    1. Re:Aliases and... by Anonymous Coward · · Score: 0

      Aliases and bash functions are a good start. I have about 200 lines worth of both in my .bash_profile at work. But bash is an ugly, inconsistent language. I switched to Rush and never looked back.

  409. 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
  410. 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}

  411. don#t know what you're looking for? by Anonymous Coward · · Score: 0

    apropos - just in case you don't really know what you are looking for. But sometimes you need to run a catman -w or a makewhatis prior to the first use of apropos...

  412. 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 ?
    1. Re:Looking for the following trick by Anonymous Coward · · Score: 0

      Not a simple one.

      First you need to decide what exactly you want. Running on the same machine? Having a window on the same $DISPLAY? Running under the same user id?

      How you'd need to do it depends on which combination you prefer.

      Anyway, don't do it. A few programs do (Firefox being the most notable), and it is really annoying when a program just takes over an existing instance when it was explicitly told to open a new one.

      E.g. trying to open a new copy of Firefox to view a flash file that is likely to crash (flash player sucks), because I do not want to close the 20+ open tabs in the current one. Nope, stupid thing opens the flash file in the current one, and of course it crashes (Murphy).

  413. Hey. I know one! by Anonymous Coward · · Score: 0

    The best one I used so far.

    who | grep -i "brunette" | talk; cd ~; wine;
    talk; touch; unzip; touch; strip; gasp; finger;
    gasp; mount; fsck; more; yes; gasp;
    umount; make clean; sleep

  414. 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.

  415. Re:: /var/log/messages by AnteTempore · · Score: 1

    But you do not need the :

    > /var/log/messages

    will do.

  416. 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.

  417. to empty a file by v4vijayakumar · · Score: 1

    echo > file

  418. 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.

  419. 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

  420. 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 -"

  421. Re:Listing directory contents without the ls comma by Mjlner · · Score: 1

    $ delete /bin bash: delete: command not found

    --
    Lemon curry???
  422. ^L clears your screen.

  423. Unix wizardry comes with experience by Anonymous Coward · · Score: 0

    When everyone has their own unix boxes or sit in the same room at the office there isn't generally much need for write(1), have had to explain it's use also several times.

    Features of applications people use every day are often neglected, like you can "tail" with less also or open the less'd text in editor directly.. or, someone was once surprised at the ease of creating a socks proxy to a private network without any special tools..
      ssh -D8080 server
    (Setting up plain tunnel with -L is handy too)

    Most of all I see lack of knowledge in the simple utilities because there's so many of them, sort uniq nl tac watch etcetc.

    And of course the forté of unix, piping, is important.. tar-piping for example, eg. over ssh if there's busybox w/o scp on other end..
      tar zc files | ssh machine "tar zxf - -C dir"

    Of course sed, awk and a proper texteditor(tm) with some regex can easily be seen as magical to someone who's used to notepad and find-replace.

    tab-completion has been mentioned, but it can go much further than just commands, files or hostnames. Though too much of anything can be bad, at least in linuxmint it's sometimes annoying that with "tar zxf" tab only completes to *.tar.gz not *.tar.bz2 (and vice versa w/"tar jxf"), then you have to check directory listings to find the filename you've forgotten.

    Shells generally have amazing amount of usability features but if you don't have it setup the same way everywhere it's often easier to just use commands rather than trying to remember some key-combination.
    Basic line-editing though is crucial, alt-b/f or even ctrl-w (can you imagine) is something not everyone knows.

    RTFM is about the best advice anyone can give. :)

  424. 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.

  425. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    Even better:
    find / -iname $SOMETHING -exec rm -fv {}

  426. (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/
  427. 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 Anonymous Coward · · Score: 0

      arecord/aplay: Try "man sox", "man rec", "man play". A swiss-army knife of sound tools.

      tar: You can also use the "-f" flag. E.g. "-f-" for stdin/stdout.

    3. 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.
  428. nohup by Anonymous Coward · · Score: 0

    ssh remotebox
    nohup longrunningtask > log 2>&1 &
    exit

    Paul

  429. 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.

  430. Here's a classic... by SlashDev · · Score: 1

    nice top

    --

    TOP DSLR Cameras Reviews of the top DSLRs
  431. 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
  432. 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.
  433. I like that more by marcosdumay · · Score: 1

    To clean up some C compilation:
    rm * .o

  434. Some more .. by Anonymous Coward · · Score: 0

    This is all Solaris stuff, don't know if it's available on other *nixes.

    pagesize

    Tells you the size of your memory pages.

    listusers

    Give you a list of all the users having access to
    the machine, whether the're in files, NIS, NIS+, LDAP ..

    crle

    Configure run-time linking enviroment. Useful when debugging run-time library issues.

    cat /usr/pub/ascii
    cat /usr/pub greek

    Gives you a handy quick overview of ascii codes
    and the greek alfabet.

    There are many more commands of course ..

    check

  435. ctrlz by Anonymous Coward · · Score: 0

    Colored bash prompts:
    export PS1="\[\e[32;1;40m\h \w>\e[0m\]"

    (must have ANSI Color enabled terminal)

  436. pushd/popd in CSH by Anonymous Coward · · Score: 0

    pushd/popd in CSH (Most of my accounts use ksh right now).

  437. 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?!

  438. Bang character by Kleokat · · Score: 1

    $ mkdir /some/very/long/path
    $ cd !$

    or

    $ history
    401: ls
    402: mkdir /some/very/long/path
    $ !401

  439. ssh escape by Anonymous Coward · · Score: 0

    '~' escapes your ssh session and the next character will be interpreted by ssh, not the remote shell. If the next character is '.' then ssh terminates.

    Think carefully about which ssh catches the ~ if you run ssh from within ssh (it'll be the one closest to you, to send '~' to the ssh once removed go '~~' and so on).

    This originates from rsh/rlogin/cu/tip, very old unix commands.

  440. 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>

  441. 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"

  442. 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.

  443. 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

  444. RE: Useful Tricks (Regardless of Unix) by Anonymous Coward · · Score: 0

    One of the best tricks is to actually have a good command of the English language. You made some simple and regrettable grammar errors.

    First, do not begin a sentence with a conjunction. Yes, the word "So" is a conjunction.

    Second, a subject/verb agreement error in using "there's" with a plural object.

    Third, don't end sentences with prepositions like "of" or "at."

    Here is an edit of your post:

    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 and had to call me on the phone. He didn't even known you could do that. This got me thinking that there are probably lots of things like that, and likely things of which I've never heard. What sorts of things do you take for granted as a natural part of Unix that surprise other people?

    There, don't you feel better now?

  445. Some more tricks by Anonymous Coward · · Score: 0

    find a word in all man pages:
    zgrep -ri $1 /usr/share/man

    log everything that goes through your terminal:
    script $filename
    end by exiting the shell

    check that a remote port is open:
    hping2 -S -c 1 -p $port $remote_ip | grep SA
    (SA = Syn+Ack, R = Reset)

  446. 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.

  447. 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.

  448. 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...

    1. Re:tree by Anonymous Coward · · Score: 0

      It was in Tricks of the Unix Masters by Russ Sage, and I think maybe also in Unix Power Tools.

  449. #!/bin/rm by Anonymous Coward · · Score: 0

    This is my favorite: self-removing program mad in zero lines of code:

    #!/bin/rm

    Same thing for self-moving program:

    #!/bin/mv

  450. 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.

  451. 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!?
  452. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    Or using your short term memory (the one in your brain).

    Copying a four or five digit number does not require a mouse.

  453. 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.

  454. my mistake in clfs by Anonymous Coward · · Score: 0

    modify mipsel-unknown-linux-gnu to mipsel-suse-linux-gnu

  455. 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.

  456. undelete by Anonymous Coward · · Score: 0

    cat /dev/sda1 | grep
    search the raw data on the HDD for deleted, even data in a deleted patition. ;)

  457. pushd / popd by Anonymous Coward · · Score: 0

    http://www.softpanorama.org/Scripting/Shellorama/pushd_and_popd.shtml

  458. undelete by Anonymous Coward · · Score: 0

    cat /dev/sda1 | less
    view the raw data on you HDD. useful for undeleting ;)

  459. Sysadmin's alarm clock by Anonymous Coward · · Score: 0

    sleep 6h && yes ^G

  460. Sending mails by Anonymous Coward · · Score: 0

    easily interacting with the POP3 server and writing an email from console.

    People can't believe that it is possible !!!

    jag

  461. pipe through ssh, screen -x, less F by Anonymous Coward · · Score: 0

    pipe through ssh: tar czf - /whatever | ssh someone@somewhere /> backup.tgz
    press ~. to kill dead ssh sessions
    use screen -x to connect multiple screen clients to one desktop (ie share a console)
    use chown USER `tty`; su - USER; screen -x to hijack USER's screen without him/her noticing it
    use less and press F instead of tail -f to be able to scroll back (in log files)

  462. Clean up by Anonymous Coward · · Score: 0

    OSX is Unix now, so these apply to it too!

    I once had someone bring a Macbook in to the university bookstore I work at- she had gone into her filesystem, and for some reason (I don't know why), it was displaying the /etc, /var, /usr folders. She thought they were ugly and messy, so she moved them all into /Library. Then, when she rebooted, the system wouldn't come up! We spent a few minutes talking to her about what she did right beforehand, before we realized... single-user mode saved the day, she went home happy, and we went back to work amused.

    On a more serious note, go read http://en.wikipedia.org/wiki/Magic_SysRq_key if you don't already know about it. Immensely useful.

  463. 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
  464. 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.

  465. 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.

  466. 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.

  467. 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

  468. as an ex-windows user... by Anonymous Coward · · Score: 0

    i even find it amazing that in OSX (=unix) you can scroll up your command history.

    unpossible in windows :p

  469. 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.

  470. 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.

  471. 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"!

  472. That's stupid by herve_masson · · Score: 1

    cd /somewhere &

    1. Re:That's stupid by ion.simon.c · · Score: 1

      Bastard!

  473. 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 */
  474. 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."
  475. 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

  476. 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.

  477. make by Anonymous Coward · · Score: 0

    make love
    (yes, the directory should not have a file called 'love')

  478. Windows by Anonymous Coward · · Score: 0

    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.

    1. 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...
  479. !!,!#,!asdf,a^b^, pushd, popd by Anonymous Coward · · Score: 0

    a few of my favourites, though really obvious to me:

    !! (repeat last command; useful if last command was long and I meant to sudo it)

    !blah (repeat last command starting with blah)

    !# (repeat # command from history (type history))

    ^foo^bar (repeat previous command replacing first instance of foo with bar)

    and my favourites
    pushd
    popd

    push things ont a directory stack and remove them. rotate the stack with pushd. awesome if you need to look in /usr/scratch/long/path/and/stuff and another irritatingly long path.

  480. 4 things I could not live without by Anonymous Coward · · Score: 0

    1. find - most people don't use it. those who do, don't use it enough
    2. rename - the good one, that comes with perl
    3. perl -ne - awesomest use of the | evar
    4. rsync , especially with --rsh='ssh -l login'

    BONUS ROUND: ps waux --forest

  481. job control-ish by Anonymous Coward · · Score: 0

    batch: for commands that you want to run in the background, but whose results you'd like captured (and mailed to you)

    (rementioning) screen: terminal disassociation

    script: logging, logging, logging...

    a new favorite for when you don't have gnu find -print0 and gnu xargs -0:

    find /path -print | sh -c 'while read line ; do stuff with "$line" ; done'

    rsync

    du -sk * | sort -n

  482. lynx & others by Anonymous Coward · · Score: 0

    Ever need to download many files of one type off a website? Try this :

    $ wget `lynx -dump http://www.site.com/page.htm" | grep -o "http:.*ext" `

    That will download all files of type "ext" from http://www.site.com/page.htm. This trick doesn't always work, but on legitimate sites it generally does. There are probably ways to extend this functionality, but I don't know them. The expression on the face of right-click happy windows users is priceless. It is extremely useful for retrieving an entire batch of lesson files for, e.g. guitar (check out the Fender player's club) or retrieving a gallery of images from thumbnails.

    Also, I am a fan of
    $ pdfjoin --outfile out.pdf file1.pdf file2.pdf
    to concatenate multiple pdf files into one pdf file.

    The above works well in conjunction with :
    $ for f in *.epsc2; do epstopdf $f; done

    Finally, I work in simulation science, and I produce a lot of prototype model simulation results. I manipulate bash from the octave simulator functions to automatically pour parameters and results into HTML files, saving hours of tedious formating (LaTeX is great, but HTML produces more controllable output with less effort.)

  483. talk & ytalk by sdolgy · · Score: 1

    seriously, talk was very cool before icq and all the other im's out there. then ytalk. revolutionary!

  484. 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.
  485. Screen, Script, nc, etc.. by Anonymous Coward · · Score: 0

    screen -X and other shared screen tricks are awesome, and under used I think

    script, recording a console session, is incredibly handy for figuring out what an SA screwed up after the fact in production environs

    nc aka netcat is great, you can use it to move data around between servers, man nc

    tcpdump is of course awesome for troubleshooting network issues, along with ngrep

    cat /dev/urandom | write user is always a winner :D

  486. 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!
  487. 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.

  488. apropos by borowcm · · Score: 1

    Can't remember a command?
    apropos keyword
    From the man page: "apropos - search the whatis database for strings"

  489. 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")

  490. ls tricks by Anonymous Coward · · Score: 0

    ls -lt | head
    show most recently modified files.

    I use it much more than ls -l

    ls -l | sort -k5nr | head

    Sorts by descending file size.

  491. 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.
  492. sudo -i by zlamma · · Score: 1

    That's probably because they don't know about
    sudo -i

  493. 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

  494. 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

  495. Working between command line and Mac OS by Anonymous Coward · · Score: 0

    tr \\r \\n outfile

    Changes the Mac EOL character to the "standard" *nix-y \n. It's even useful ON the Mac since most CLI utilities/scripts/programs expect \n.

    1. Re:Working between command line and Mac OS by Anonymous Coward · · Score: 0

      Stupid me missed it in the preview, that command should redirect files for both input and output, but I'm too lazy to figure out how to make slash display it correctly...

  496. How about 'suspend' by Anonymous Coward · · Score: 0

    'suspend' is one that a couple of my team had never seen - as in:
    $ do stuff as user
    $ sudo
    # do stuff as root
    # suspend
    [1]+ Stopped sudo
    $ do more stuff as user
    $ fg
    sudo
    # do more stuff as root

  497. yes! by Anonymous Coward · · Score: 0

    yes

    this actually prints infinite many "y"s to stdout.
    Most versions accept arguments which to replace
    the standard "y" (as in "yes no")

    and also really cool (depends on OS):
        apply, jot, seq

    --
    rs

  498. Search through history by Anonymous Coward · · Score: 0

    Quick search through your bash history:

    Ctrl-r

    Also, I have a habit of marking some commands with commented identifiers so I can use a minimal number of keystrokes to retrieve and execute the command:

    $ vi `find ./ -type f | while read i; do grep -l SSL "$i"; done` # edit

    Then, I can easily get back to this guy by typing: [Ctrl-r]edit[return]

  499. ddate by pruneau · · Score: 1
    --
    [Pruneau /\o^O/\ warranty void if this .sig is removed]
  500. pushd popd by Anonymous Coward · · Score: 0

    pushd

    • pushes given directory to the top of the stack.

      popd changes directory back to whatever is on top

  501. 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
  502. 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."
  503. 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.

  504. 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

  505. fuck, i just ran that statement on my cygwin by Anonymous Coward · · Score: 0

    It didnt say "You live" either. Please tell me it didnt erase my whole hard drive

  506. --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.

  507. 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
  508. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    I used to think that, actually... *notice the anonymity*

  509. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    Ok, seriously.. I hate to say this... ..but does that code block look like a cock-and-balls to anyone else?

  510. Remote directory tree copy by Anonymous Coward · · Score: 0

    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 -)"

    1. 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.
  511. 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.

  512. 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$

  513. 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)

  514. 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;
  515. Convert That S**t! by Anonymous Coward · · Score: 0

    Whenever someone gives you a script that was created/edited in Windows it may result in a file that ends with alot of "^V" symbols thus the script can't run. So normally you would vi the file and go line by line to remove the extra dos characters.... NAH!!!

    dos2unix

  516. Roulette Breakdown by Anonymous Coward · · Score: 0

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

    Let me see if i can break this down for you...
    it helps to look at the parts as the "move" if you will.

    $[ $RANDOM % 6 ] will create a random number between 0-5 (6 in total, like most wheel guns)

    The reason $RANDOM alone seems to not work is you are attempting to run a random number as a command.

    Try this first
    `print $RANDOM`
    this will show you "unfiltered" return from the 'random' shell variable.

    Now try this
    `print $[ $RANDOM % 6 ]`
    this will return a random value as well but this time 0-5.

    lets say the return was 0

    Now on to the test statement, the shell will now interpret this as follows
    [ 0 == 0 ] where the first 0 is the return from `$[ $RANDOM % 6 ]` and the second 0 is the one you see in the raw code...this will clearly test true

    in this case the next part of this one-liner is
    `&& rm -rf /` now remember 0 does equal 0 so the && statement will work and execute the command `rm -rf /` ( remember && basicaly means if the stuff in front of me has a return code of 0 then do the stuff after me)

    Now for the last bit, lets say the `$[ $RANDOM % 6 ]` returned a 4 this time not a 0 now the test statement looks like this
    [ 4 == 0 ]this will evaluate as false a return code of 1. so the && will not be "triggered" however the || will now work because of the non zero return this part will act as a "failure to fire" in the 'wheel gun' completing the roulette statement. ( remember the || basicaly says if the stuff in front of me fails do the stuff after me )

    So to recap you will see one of 2 things happen
    if 0 the shell will do the following
    [ 0 == 0 ] && rm -rf/
    or otherwise (random doesnt equal 0)
    [ 4 == 0 ] || echo "You live"

    One last touch...here is a safe version to can run to see it in action
    `[ $[ $RANDOM % 6 ] == 0 ] && echo 'BANG!!!' || echo 'Click...You live'`

    (run it oh 6 times or so)

  517. 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!

  518. 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
  519. 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".

  520. 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.

  521. 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.)

  522. Are you sure your talking about UNIX ? by Anonymous Coward · · Score: 0

    I bet that most of you posting here that if you typed "uname -an" You will get a response Linuxxxxx...

    The post related to UNIX. try running your commands on a UNIX shell you will notice there is a difference.

    I work on SCO UNIX and it really humbled me when I realised my 5 years experience on a Linux machine meant almost nothing.

    1. 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.
  523. 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

  524. Sweet ... by NoSalt · · Score: 0

    Sweet ... very nice. I bow to the scripting masters. I had to change it to:

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

    just to see what would happen.

  525. for loops by Anonymous Coward · · Score: 0

    for loops are great in many situations. one common one i run into is a directory with thousands of files.. you execute a rm -f * only to receive an error of 'Argument list too long'. the solution to something like this would be: for ls in *; do; rm -f $ls; done

  526. Re:This one always surprises people for some reaso by Anonymous Coward · · Score: 0

    I think he is making a point that using that command multiple times is a time waster whereas sending the output to a file and then just grep-ing it as many times as you want is faster.

    I would say, then, that there is `locate` for that reason, although locate is not as powerful (i.e. no -exec).

  527. tail, find, vim by Anonymous Coward · · Score: 0

    did anybody mention "tail -f"?

    I have to install cygwin on all my servers just to have 'tail', 'find', and 'vim'.

  528. Comment removed by account_deleted · · Score: 2, Funny

    Comment removed based on user account deletion

  529. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  530. Regex for math expr? by Anonymous Coward · · Score: 0

    How a bout just writing a recursive descent parser, much clearer and less glitchy than regepxs.

  531. 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.
  532. perms by Anonymous Coward · · Score: 0

    chmod 000 /bin/chmod

    1. 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.
  533. 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.

  534. pushd/popd by Anonymous Coward · · Score: 0

    two very useful commands that many *nix users don't know
    besides, "lsof" is a stranger to many users too

  535. evil by Anonymous Coward · · Score: 0

    'unset HISTFILE' for all your BOFH needs

  536. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    This is why "ren *.foo *.bar" works in MS operating systems but "mv *.foo *.bar" does not work in unix-like operating systems.

  537. 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 ...

  538. 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 ...

  539. 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.

  540. 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.

  541. Re:How about a new GUI apt get trick? by Anonymous Coward · · Score: 0

    oh noes!
    apt has different commands for different purposes!
    it must be teh badness!

    as for Yum:
    1. WHY is -C not default?
    2. It is actually _much_ slower than apt. I have never had apt take _hours_ updating the list of available software, but the moment you add something like the DAG repositories to yum, the update does take hours.
    And the DAG repositories still don't give you even the barest fraction of the available software in Debian or Ubuntu.

    Yum's existence makes no sense at all - apt-rpm seemed to work ok, what exactly does Yum give you?

  542. the best trick by Anonymous Coward · · Score: 0

    rm -f * *

  543. Re:: /var/log/messages by Domini · · Score: 1

    > bash
    $> :> testing
    $> > testing
    $> csh
    ~> :> testing
    ~> > testing
    Invalid null command.

  544. CSH tricks by Anonymous Coward · · Score: 0

    IN CSH:

    Check out the CSH ":" options:

    % set foo = "/foo/bar/a.b.c.d.e"

    % echo $foo
    ==> /foo/bar/a.b.c.d.e

    % echo $foo:r
    ==> /foo/bar/a.b.c.d

    % echo $foo:r:r
    ==> /foo/bar/a.b.c

    % echo $foo:t
    ==> a.b.c.d.e

    % echo $foo:t:r:r:r
    ==> a.b

    % echo $foo:h
    ==> /foo/bar

    % echo $foo:e
    ==> e

    Try ":q" (Quoted wordlist) to keep spaces in names...

    Try "!foo:p" -- it prints out the command without executing.
    (Putting it into your history.)

    Or: (Use \! in CSH aliases.)
    alias tgcc 'g++ \!:* -o \!:1:r -Wall ; if ( $status == 0 ) ./\!:1:r'

  545. 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).

  546. Re 40lines of comments Re:There is this part ... by Anonymous Coward · · Score: 0

    That sounds like a good thing for a boss to request, Probably shorter ways to document a regex, but if it's a business critical part that needs to be revisited, and revised quickly by less experienced people, your boss seems pretty good.

    Maintainability is awesome

  547. modern music by Anonymous Coward · · Score: 0

    This has always been my favorite:
    cat /dev/mem > /dev/dsp

    (my require sudo access, but I assure you it's safe to run, as long as your speakers aren't too loud ;) )

  548. Remote CDs .... by Anonymous Coward · · Score: 0

    A friend (in the UK) gave me (in the US) shell access to one of his machines. Popping open the door of a CD tray from 6,000 miles away, or randomly playing whatever happened to be in the drive, was somehow existentially amusing....

  549. Email by Anonymous Coward · · Score: 0

    For a list of email addresses:

    rev <addresses | sort | rev

    ... sorts the addresses by TLD, domain, and subdomain or host. Which can be useful, particularly if you're kicking out large numbers of emails (technical email lists, not spam, course), and want to cache your MX lookups.

  550. Re:Listing directory contents without the ls comma by Anonymous Coward · · Score: 0

    Surely thats just an excuse to post an ASCII art penis.

  551. Show the path of the last directory you were in by Anonymous Coward · · Score: 0

    without going there.

    useful when you are speed terminalling (new verb, i know) and you are in "/mnt/backupDrive/new/old/longdates/20081104/hardToRememberPath/" and you are looking at some file, and then you do "cd /etc/" and ls in about 2 seconds out of habit:

    so then you can just do:

    cd - | cat

    and it shows the path of the previous directory without traversing there.

    oh well i guess it is a very specific thing to do.

    but i just taught it to myself now and it was very useful.

    i love linux.

  552. Re:find in sources by Anonymous Coward · · Score: 0

    grep -iIRn 'content' . | grep -v svn

    It is poor man's show references.

  553. 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