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?

272 of 2,362 comments (clear)

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

    rm -rf /

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

      more like
      sudo rm -rf /

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

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

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

      Mediocre minds think alike. Great minds are unique.

    4. 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.
    5. Re:rm -rf / by macshome · · Score: 4, Funny

      Pshaw! All 1337 sysadmins just live as root!

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

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

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

      cat /dev/urandom > /dev/dsp

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

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

      That's my alarm clock.

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

    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.

      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.

    12. Re:rm -rf / by EthanV2 · · Score: 2, Informative

      I believe you mean NO CARRIER

    13. 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.
    14. 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
    15. Re:rm -rf / by fr4nk · · Score: 2, Informative

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

      should clear out the MBR.

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

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

    17. Re:rm -rf / by carrier+lost · · Score: 4, Funny
      CARRIER LOST

      Hello?

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

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

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

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

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

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

      For recent versions:

      sudo -i

      shorter

      --
      Mir tut es leid, Menschen daß Einfältigfehlersuchenbaumfolgendenaffen sind.
    28. 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!
    29. 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.

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

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

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

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

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

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

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

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

    41. Re:rm -rf / by dna_(c)(tm)(r) · · Score: 4, Funny

      42 ?

    42. Re:rm -rf / by pato101 · · Score: 2, Informative

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

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

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

      No, that is the answer for the opposite!

      --
      Am I eval()? - http://www.monst3r.com.br
    45. 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
    46. 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!

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

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

      I laughed.

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

    51. 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.
    52. Re:rm -rf / by 4D6963 · · Score: 5, Funny

      Mediocre minds think alike. Great minds are unique.

      My thoughts exactly.

      --
      You just got troll'd!
    53. 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.

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

    55. 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.
    56. 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.
    57. 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.

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

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

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

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

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

    screen is awesome.

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

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

    2. Re:session-sharing with screen -x by 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
    3. 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
    4. 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"

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

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

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

      eject cdrom is great for locating poorly labeled machines too!

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

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

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

    8. 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 */
    9. 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.
  5. Uhhmmm... by Crazy+Brian · · Score: 2, Funny

    It doesn't crash?

    --
    "Do what you can, with what you have, where you are."
    1. Re:Uhhmmm... by Isaac1357 · · Score: 2

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

  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.

  7. grep and awk by yakmans_dad · · Score: 4, Insightful

    So much easier for me to use than perl. I presume the modern unix user prefers perl.

  8. Find / Grep by BigJClark · · Score: 2, Informative


    I find a combination of find/grep to be pretty useful. Not sure about how unknown it is, but I do know that several UI-based linux admins around our office don't know about "stacking" commands. (I know, I know, one would think they would be mutually-exclusive ;) )

    find . | grep [string]

    --

    Hi, I Boris. Hear fix bear, yes?
    1. Re:Find / Grep by Anonymous Coward · · Score: 5, Funny

      I have a theory that find + xargs + grep is Turing-complete. Can't prove it, but it feels right.

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

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

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

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

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

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

      How about this?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  14. Screen by hardburn · · Score: 4, Funny

    A sys admin was recently surprised that I didn't use screen. My explaination was that all that C-x stuff reminded me too much of using Emacs.

    Moderators are free to mod this Flamebait or Insightful, depending on personal bias.

    --
    Not a typewriter
    1. Re:Screen by Randle_Revar · · Score: 2, Informative

      you don't have to use Ctrl-a. You can bind screen's escape to any key.

  15. 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 Shikaku · · Score: 3, Informative

      http://www.math.umn.edu/systems_guide/putty_xwin32.html

      First result of X-Forwarding on Google.

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

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

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

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

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

  19. 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?
  20. 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 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?"
  21. One word: by MMC+Monster · · Score: 4, Funny

    Showers

    --
    Help! I'm a slashdot refugee.
  22. 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.

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

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

  26. 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 XXeR · · Score: 2, Informative

      that's a lot of work to do what 'disown' does

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

  29. 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 MrMunkey · · Score: 4, Informative

      cd -

      Change to your previous directory. It's great for going from dev to test environments from time to time.

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

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

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

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

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

    9. Re:Show attached block devices by c0p0n · · Score: 2, Informative

      cd

      takes you to your home directory.

      --

      Your head a splode
    10. 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.

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

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

    13. 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
    14. Re:Show attached block devices by the_B0fh · · Score: 5, Funny

      Oh my ghod. This is considered informative? Who let all the PFYs in?

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

    17. 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?
    18. 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."
    19. 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.
    20. Re:Show attached block devices by fracai · · Score: 3, Funny

      .py or it didn't happen.

      --
      -- i am jack's amusing sig file
    21. 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.
    22. 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.

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

    24. 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?
    25. 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."
    26. 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.
    27. 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.

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

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

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

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

    32. 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!
    33. Re:Show attached block devices by eosp · · Score: 2, Informative

      It uses different, non-Python syntax, but I find Fish useful.

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

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

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

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

    38. 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
    39. 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
  30. 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 jkiol · · Score: 5, Funny

      @$**& well we know it works in cygwin too.

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

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

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

  34. 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()?
  35. -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 {} \;

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

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

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

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

  43. 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 knothead99 · · Score: 2, Insightful

      Why not use synergy? It works cross platform so you can control Windows and Mac OS machines as well.

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

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

  45. sudo !! by n.e.watson · · Score: 3, Informative

    !! in bash uses the last command you entered. $ make_me_a_sandwich What? No. $ sudo !! okay. $

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

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

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

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

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

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

    BTW: How does one ork a cow?

    Very, VERY, carefully.

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

  55. 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}$/
  56. 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

  57. My personal fave by 44BSD · · Score: 4, Funny

    echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc

  58. 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 starfishsystems · · Score: 3, Informative

      diff -y Compares files side by side.

      --
      Parity: What to do when the weekend comes.
  59. 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.

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

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

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

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

  64. 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!
  65. Shell history tricks by steveha · · Score: 5, Informative

    There are a whole bunch of "history" tricks, to recall old commands without using the mouse.

    When I started college, I studied the shell's man page until I knew them all. Some are so obscure I have forgotten them.

    Generally, these involve an '!' character in some way.

    Here are a few I use:

    !! # run again the last command that was run
    !9 # run again the command with history number 9
    !v # run again the last command that started with a 'v'
    !vi # run the last command that started with "vi"
    !?foo? # run the last command that had the string "foo" anywhere in it

    diff oldfile newfile
    mv !$ !^ # same as "mv newfile oldfile"
    # !$ is last arg of previous command, !^ is first arg

    ls foo bar baz
    rm -f !!* # same as "rm -f foo bar baz"
    # !!* repeats all arguments from previous command

    There are actually some baroque tricks that recall a previous command and perform a search-and-replace on it, but for anything that complicated I just recall the line and edit it. The baroque tricks would have been pretty darn cool back in the paper teletype days, though.

    By the way, the Bash shell can be configured to edit command lines using vi or Emacs commands. I described how to do it in an article I wrote for Linux Journal magazine. It's the last section, "vi or Emacs Mode in the Shell".

    http://www.linuxjournal.com/article/8361

    Oh, not exactly a history trick, but here's something I use all the time:
    ls -1 > /tmp/files
    vi /tmp/files # edit list to include just the files I want
    rm `cat /tmp/files`
    # `cmd` inserts the standard output from cmd into the command line as if you typed it

    ls -1 > /tmp/files
    vi /tmp/files
    # edit list to include just the files I want
    # now run this command: :%s+.*+mv & /some/directory/path/&+
    # save file and quit vi
    source /tmp/files

    This moves the chosen files to "/some/directory/path". The breakdown of the vi command is as so:
    : # invoke "ex mode" for search and replace command
    % # run the following command on every line of the file
    s # do a search and replace
    + # use a '+' for the command delimiter, so I won't have to backslash escape '/' chars in the path

    .* # all characters on the line
    + # end the match pattern, begin replace pattern
    # & refers to the match pattern, thus all chars on the line
    mv & /some/directory/path/& # replace "foo" with "mv foo /some/directory/path/foo"

    Takes less time to do it than to explain it!

    The above is perhaps overkill if all the files are going to the same place. It's great if you want to send some files one place, some to another, because you can just edit the destinations until it looks right.

    steveha

    --
    lf(1): it's like ls(1) but sorts filenames by extension, tersely
    1. Re:Shell history tricks by bobstreo · · Score: 2, Informative

      How about setting FCEDIT to your favorite editor, and running fc on the command line, very very VERY handy when messing with long paths. (stupid java)

      the script command is also your friend when creating pointless documentation people will never read.

      another thing people never think of is the
      nohup command.

      sshfs is kinda spiffy if you want to mount things over an ssh connection.

      I do HATE with a passion when the same commands on different OS versions (I'm looking at you here SUN) ouput different results.

      Oh and don't forget stupid little things like aliases in your shell startup file. I just like typing l to do an ls -aF.

      You can also write some nice functions for your startup files. and don't forget the logout files, you can have some fun there.

      Also if you're old school command line and really bored:

      http://nadvsh.sourceforge.net/nadvsh.6.html

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

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

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

  69. 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
  70. 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?
  71. 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
  72. 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 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.

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

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

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

  76. 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"
  77. 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)
  78. 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? "...!!"

  79. hu..?? by meuhlavache · · Score: 2, Funny

    What the hell all those geeks are talking about?

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

  81. 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
  82. 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."
  83. 10! by Anonymous Coward · · Score: 3, Funny

    > There's two kinds of real UNIX Admins.

    Actually, there are 10 kinds of UNIX admins...

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

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

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

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

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

  90. (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/
  91. 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.
  92. 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!

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

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

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

  97. Comment removed by account_deleted · · Score: 2, Funny

    Comment removed based on user account deletion