Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

(Useful) Stupid Unix Tricks?

timothy posted more than 5 years ago | from the sed-is-underrated dept.

Unix 2362

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?

cancel ×
This is a preview of your comment

No Comment Title Entered

Anonymous Coward 1 minute ago

No Comment Entered


rm -rf / (5, Funny)

Anonymous Coward | more than 5 years ago | (#25648981)

rm -rf /

Re:rm -rf / (2, Informative)

Anonymous Coward | more than 5 years ago | (#25649087)

more like
sudo rm -rf /

Show attached block devices (2, Insightful)

duguk (589689) | more than 5 years ago | (#25649297)

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.

Re:rm -rf / (0)

Anonymous Coward | more than 5 years ago | (#25649329)

rm -rf /

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

this one really stupid (-1, Redundant)

Anonymous Coward | more than 5 years ago | (#25648985)

sudo rm -rf /

Well (5, Funny)

Anonymous Coward | more than 5 years ago | (#25648993)


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

Re:Well (5, Interesting)

FooAtWFU (699187) | more than 5 years ago | (#25649233)

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.

session-sharing with screen -x (5, Insightful)

FooAtWFU (699187) | more than 5 years ago | (#25648995)

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

screen is awesome.

Re:session-sharing with screen -x (0)

Anonymous Coward | more than 5 years ago | (#25649199)

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

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

Re:session-sharing with screen -x (2, Funny)

CppDeveloper (829095) | more than 5 years ago | (#25649305)

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.

There is this part ... (5, Funny)

140Mandak262Jamuna (970587) | more than 5 years ago | (#25648997)

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

Hail to the chimp! (-1)

Anonymous Coward | more than 5 years ago | (#25648999)

Congratulations on your purchase of a brand new nigger! If handled properly, your apeman will give years of valuable, if reluctant, service.

You should install your nigger differently according to whether you have purchased the field or house model. Field niggers work best in a serial configuration, i.e. chained together. Chain your nigger to another nigger immediately after unpacking it, and don't even think about taking that chain off, ever. Many niggers start singing as soon as you put a chain on them. This habit can usually be thrashed out of them if nipped in the bud. House niggers work best as standalone units, but should be hobbled or hamstrung to prevent attempts at escape. At this stage, your nigger can also be given a name. Most owners use the same names over and over, since niggers become confused by too much data. Rufus, Rastus, Remus, Toby, Carslisle, Carlton, Hey-You!-Yes-you!, Yeller, Blackstar, and Sambo are all effective names for your new buck nigger. If your nigger is a ho, it should be called Latrelle, L'Tanya, or Jemima. Some owners call their nigger hoes Latrine for a joke. Pearl, Blossom, and Ivory are also righteous names for nigger hoes. These names go straight over your nigger's head, by the way.

Owing to a design error, your nigger comes equipped with a tongue and vocal chords. Most niggers can master only a few basic human phrases with this apparatus - "muh dick" being the most popular. However, others make barking, yelping, yapping noises and appear to be in some pain, so you should probably call a vet and have him remove your nigger's tongue. Once de-tongued your nigger will be a lot happier - at least, you won't hear it complaining anywhere near as much. Niggers have nothing interesting to say, anyway. Many owners also castrate their niggers for health reasons (yours, mine, and that of women, not the nigger's). This is strongly recommended, and frankly, it's a mystery why this is not done on the boat

Your nigger can be accommodated in cages with stout iron bars. Make sure, however, that the bars are wide enough to push pieces of nigger food through. The rule of thumb is, four niggers per square yard of cage. So a fifteen foot by thirty foot nigger cage can accommodate two hundred niggers. You can site a nigger cage anywhere, even on soft ground. Don't worry about your nigger fashioning makeshift shovels out of odd pieces of wood and digging an escape tunnel under the bars of the cage. Niggers never invented the shovel before and they're not about to now. In any case, your nigger is certainly too lazy to attempt escape. As long as the free food holds out, your nigger is living better than it did in Africa, so it will stay put. Buck niggers and hoe niggers can be safely accommodated in the same cage, as bucks never attempt sex with black hoes.

Your Nigger likes fried chicken, corn bread, and watermelon. You should therefore give it none of these things because its lazy ass almost certainly doesn't deserve it. Instead, feed it on porridge with salt, and creek water. Your nigger will supplement its diet with whatever it finds in the fields, other niggers, etc. Experienced nigger owners sometimes push watermelon slices through the bars of the nigger cage at the end of the day as a treat, but only if all niggers have worked well and nothing has been stolen that day. Mike of the Old Ranch Plantation reports that this last one is a killer, since all niggers steal something almost every single day of their lives. He reports he doesn't have to spend much on free watermelon for his niggers as a result. You should never allow your nigger meal breaks while at work, since if it stops work for more than ten minutes it will need to be retrained. You would be surprised how long it takes to teach a nigger to pick cotton. You really would. Coffee beans? Don't ask. You have no idea.

Niggers are very, very averse to work of any kind. The nigger's most prominent anatomical feature, after all, its oversized buttocks, which have evolved to make it more comfortable for your nigger to sit around all day doing nothing for its entire life. Niggers are often good runners, too, to enable them to sprint quickly in the opposite direction if they see work heading their way. The solution to this is to *dupe* your nigger into working. After installation, encourage it towards the cotton field with blows of a wooden club, fence post, baseball bat, etc., and then tell it that all that cotton belongs to a white man, who won't be back until tomorrow. Your nigger will then frantically compete with the other field niggers to steal as much of that cotton as it can before the white man returns. At the end of the day, return your nigger to its cage and laugh at its stupidity, then repeat the same trick every day indefinitely. Your nigger comes equipped with the standard nigger IQ of 75 and a memory to match, so it will forget this trick overnight. Niggers can start work at around 5am. You should then return to bed and come back at around 10am. Your niggers can then work through until around 10pm or whenever the light fades.

Your nigger enjoys play, like most animals, so you should play with it regularly. A happy smiling nigger works best. Games niggers enjoy include: 1) A good thrashing: every few days, take your nigger's pants down, hang it up by its heels, and have some of your other niggers thrash it with a club or whip. Your nigger will signal its intense enjoyment by shrieking and sobbing. 2) Lynch the nigger: niggers are cheap and there are millions more where yours came from. So every now and then, push the boat out a bit and lynch a nigger.

Lynchings are best done with a rope over the branch of a tree, and niggers just love to be lynched. It makes them feel special. Make your other niggers watch. They'll be so grateful, they'll work harder for a day or two (and then you can lynch another one). 3) Nigger dragging: Tie your nigger by one wrist to the tow bar on the back of suitable vehicle, then drive away at approximately 50mph. Your nigger's shrieks of enjoyment will be heard for miles. It will shriek until it falls apart. To prolong the fun for the nigger, do *NOT* drag him by his feet, as his head comes off too soon. This is painless for the nigger, but spoils the fun. Always wear a seatbelt and never exceed the speed limit. 4) Playing on the PNL: a variation on (2), except you can lynch your nigger out in the fields, thus saving work time. Niggers enjoy this game best if the PNL is operated by a man in a tall white hood. 5) Hunt the nigger: a variation of Hunt the Slipper, but played outdoors, with Dobermans. WARNING: do not let your Dobermans bite a nigger, as they are highly toxic.

Niggers die on average at around 40, which some might say is 40 years too late, but there you go. Most people prefer their niggers dead, in fact. When yours dies, report the license number of the car that did the drive-by shooting of your nigger. The police will collect the nigger and dispose of it for you.

Have it put down, for god's sake. Who needs an uppity nigger? What are we, short of niggers or something?

They all do this. Shorten your nigger's chain so it can't reach any white women, and arm heavily any white women who might go near it.

Not unless it outnumbers you 20 to 1, and even then, it's not likely. If niggers successfully overthrew their owners, they'd have to sort out their own food. This is probably why nigger uprisings were nonexistent (until some fool gave them rights).

Yeah, well, it would. Tell it to shut the fuck up.

A nigger's skin is actually more or less transparent. That brown color you can see is the shit your nigger is full of. This is why some models of nigger are sold as "The Shitskin".

What you have there is a "wigger". Rough crowd. WOW!

They're as common as dog shit and about as valuable. In fact, one of them was President between 1992 and 2000. Put your wigger in a cage with a few hundred genuine niggers and you'll soon find it stops acting like a nigger. However, leave it in the cage and let the niggers dispose of it. The best thing for any wigger is a dose of TNB.

And you were expecting what?

When you came in here, did you see a sign that said "Dead nigger storage"? .That's because there ain't no goddamn sign.

Configuration script (2, Funny)

davidwr (791652) | more than 5 years ago | (#25649193)

$ configure . --ignoretroll
Configuration aborted. Installation files deleted. Uploader banned.

Re:Hail to the chimp! (1)

VeNoM0619 (1058216) | more than 5 years ago | (#25649335)

And to think, if only you picked a better product to sell, you could be making millions in marketing...

Yes YOU! Just transfer all your money to my Nigerian bank and you too could be making millions...

I call that... the reverse troll.

Uhhmmm... (2, Funny)

Crazy Brian (657840) | more than 5 years ago | (#25649009)

It doesn't crash?

Re:Uhhmmm... (0)

Vancorps (746090) | more than 5 years ago | (#25649177)

Could have fooled me, I minimized a screen in firefox which for some reason resulted in x crashing and at least nicely closing all the apps I had open. Doesn't crash my ass.

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

Stupid Unix Trick... (-1, Redundant)

Anonymous Coward | more than 5 years ago | (#25649023)

rm -r /*

Stupid Tricks (2, Interesting)

Anonymous Coward | more than 5 years ago | (#25649025)

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.

Re:Stupid Tricks (1)

mihalis (28146) | more than 5 years ago | (#25649285)

10 biggest files or subdirs in current working dir:

$ du -sk * | sort -nr | head -10

ftp from a command line (0, Interesting)

Anonymous Coward | more than 5 years ago | (#25649027)

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

Wohoooo, the first one! (-1, Offtopic)

Anonymous Coward | more than 5 years ago | (#25649029)

Shit, I have to type something, someone can comment before me!!!

Re:Wohoooo, the first one! (0)

Anonymous Coward | more than 5 years ago | (#25649247)

But to be on topic...

First, you didn't specify for whom you ask...

Now, command line itself and it's power is what surprises most people... including the "administrators"...

Then, there is a talk which I haven't used for a long time...

All the little command line tools like cut, uniqe, tail, tr, head, tail... not so small tools like sed, awk... many people simply do not know for them...

A yes, '#!' "trick" to make any file executable...

And while we are at that, many people coming from Windows think that executable has to have .exe extension...

Find / Grep (2, Informative)

BigJClark (1226554) | more than 5 years ago | (#25649033)

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]

Re:Find / Grep (1, Informative)

Anonymous Coward | more than 5 years ago | (#25649175)

find . -exec grep -l {} \;

Re:Find / Grep (1)

cavtroop (859432) | more than 5 years ago | (#25649187)

and they call themselves 'linux admins'?

Geez, low barrier to entry you have over there... :)

Re:Find / Grep (0)

Anonymous Coward | more than 5 years ago | (#25649367)

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

Re:Find / Grep (0)

Anonymous Coward | more than 5 years ago | (#25649397)

the proper term is PIPE

| is the pipe operator.

grep -R (1)

cain (14472) | more than 5 years ago | (#25649047)

To find a string in a file I used to do "find . | xargs grep foo". A cow orker saw me doing that and told me about grep -R, recursive grep. So the same statement would be "grep -R foo ."

Re:grep -R (1)

e9th (652576) | more than 5 years ago | (#25649207)

That just means you're getting old. The -R option is a newcomer. Certainly SVR4 grep didn't have it.

On to the pranks! (4, Funny)

Anonymous Coward | more than 5 years ago | (#25649049)

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

Tab (5, Informative)

computersnstuff (799942) | more than 5 years ago | (#25649053)

I'm sure everyone at some point is surprised of tabbed completion.

Re:Tab (5, Funny)

Anonymous Coward | more than 5 years ago | (#25649179)

I'm sure everyone at some point is surprised of tabbed completion.

Woah! Got any more?

(yes, I'm being sarcastic)

Re:Tab (1)

jd (1658) | more than 5 years ago | (#25649283)

I think more are surprised that the tab completion enhancements package for BASH haven't been updated in years.

Re:Tab (0)

Anonymous Coward | more than 5 years ago | (#25649331)

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

Surprised that it does it correctly. (1, Interesting)

khasim (1285) | more than 5 years ago | (#25649337)

On Windows, tabbed completion grabs the FIRST entry that matches.

On Linux, tabbed completion lists ALL the entries that match.

Re:Tab (5, Informative)

Craig Davison (37723) | more than 5 years ago | (#25649363)

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.

How about a new GUI apt get trick? (0)

Anonymous Coward | more than 5 years ago | (#25649055)

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

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

Does it exist? If not, it should.

Re:How about a new GUI apt get trick? (2, Informative)

Blublu (647618) | more than 5 years ago | (#25649241)

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

I never knew that command (5, Insightful)

PingXao (153057) | more than 5 years ago | (#25649059)

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.

Re:I never knew that command (5, Insightful)

PhilipPeake (711883) | more than 5 years ago | (#25649423)

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.

rev (1)

LeninZhiv (464864) | more than 5 years ago | (#25649065)

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.

Re:rev (4, Funny)

genner (694963) | more than 5 years ago | (#25649185)

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.

Listing directory contents without the ls command (4, Informative)

thepacketmaster (574632) | more than 5 years ago | (#25649067)

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

Re:Listing directory contents without the ls comma (4, Informative)

marcansoft (727665) | more than 5 years ago | (#25649257)

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.

Re:Listing directory contents without the ls comma (0)

Anonymous Coward | more than 5 years ago | (#25649271)

echo just echoes the names, shell does the expansion and passes the argument list to echo.

Re:Listing directory contents without the ls comma (0)

Anonymous Coward | more than 5 years ago | (#25649317)

This comment saddens unix gurus everywhere.

A simple search (2, Informative)

AKAImBatman (238306) | more than 5 years ago | (#25649069)

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

Re:A simple search (2, Informative)

UnderScan (470605) | more than 5 years ago | (#25649261)


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

is fine for non-GNU UNIX grep.

If you have GNU grep, then

grep -lR keyword .

Re:A simple search (1)

cain (14472) | more than 5 years ago | (#25649315)

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

In fewer keystrokes:

grep -R keyword .

Re:A simple search (0)

Anonymous Coward | more than 5 years ago | (#25649395)

instead of all this rubbish: find . -exec grep -l keyword {} \;

you can do:

grep -lir keyword .

to do a recursive case-insensitive search for keyword in all files and spit out the filenames.


Screen (4, Funny)

hardburn (141468) | more than 5 years ago | (#25649077)

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.

Re:Screen (0)

CronoCloud (590650) | more than 5 years ago | (#25649323)

I don't use screen, that's what mrxvt is for. (Yes, I know you can detach screen sessions locally and resume remotely, plus all sorts of other neat tricks but I never need to do that.)

X-forwarding (5, Informative)

mikeb (6025) | more than 5 years ago | (#25649079)

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.

Re:X-forwarding (2, Funny)

Anonymous Coward | more than 5 years ago | (#25649281)

other side of the world and run X programs over forwarding.

The real amazing thing is that they stayed their waiting so long!

Anonymous Coward (0)

Anonymous Coward | more than 5 years ago | (#25649081)

People keep forgetting to empty the bit-bucket, even redhat certified sysadmins.

Talk / DD / Mount (5, Informative)

p14-lda (517504) | more than 5 years ago | (#25649105)

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.

rm -rf /* (2, Funny)

davidwr (791652) | more than 5 years ago | (#25649139)

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.

Re:rm -rf /* (0)

Anonymous Coward | more than 5 years ago | (#25649407)

Your a sick, sick human being.

If he liked write (1)

jandrese (485) | more than 5 years ago | (#25649143)

You should show him wall(1). There's always the ever useless finger(1) command as well.

If you really want to blow someone's mind, show them some of the more advanced vi tricks. I still contend to this day that it's impossible for any mere mortal to know all of the possible commands in vi.

Crushing a finger users terminal (2, Funny)

Bardwick (696376) | more than 5 years ago | (#25649327)

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

Re:If he liked write (1)

cain (14472) | more than 5 years ago | (#25649401)

finger is good for seeing who is logged into a machine. A plain "finger" shows everyone who is logged in. Useful on multiuser machines.

I like the fun little Bash stuff (2, Interesting)

hexadevil (1351505) | more than 5 years ago | (#25649147)

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.

search and replace in files (3, Interesting)

cain (14472) | more than 5 years ago | (#25649153)

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)

cd - (5, Informative)

JustinOpinion (1246824) | more than 5 years ago | (#25649157)

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!

This one always surprises people for some reason (2, Interesting)

yttrstein (891553) | more than 5 years ago | (#25649171)

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.

Re:This one always surprises people for some reaso (4, Informative)

interiot (50685) | more than 5 years ago | (#25649411)

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

previous directory, reversing lines, and xargs (1)

Bill Dimm (463823) | more than 5 years ago | (#25649213)

Nothing too spectacular, but:

Go back to the previous directory:
cd -

Reverse lines from a file:

And, of course, xargs, which is almost infinitely useful.

Re:previous directory, reversing lines, and xargs (1)

jd (1658) | more than 5 years ago | (#25649379)

For directories, don't forget that many shells support some form of directory stacking - eg: push, pop in BASH.

talk (2, Informative)

Anonymous Coward | more than 5 years ago | (#25649219)

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.

Job control. (5, Informative)

Craig Davison (37723) | more than 5 years ago | (#25649221)

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

Some good ones... (1)

xgr3gx (1068984) | more than 5 years ago | (#25649225)

The wall command is good one.
Sends a message to everyone's console.
Talk is cool too.
I think you do talk username and it will send a message like wall to just that user.
Came in handy when public IM was down at work.

Sounds.. (1)

Piranhaa (672441) | more than 5 years ago | (#25649227)

.. a little more annoying than the Jim Carrey screeching noise from Dumb and Dumber..

cat /dev/urandom > /dev/audio

Few things... (1)

cfulmer (3166) | more than 5 years ago | (#25649239)

lp *
(Sure, you can select a bunch of things in Windows and print, but it tends to tie up your desktop. lp doesn't.)

in csh:
foreach f ( * )
mv $f $f.backup

(Please don't start a "don't program in csh" flamewar. It's just an easy 3 liner.)

Get off my lawn! (1)

phayes (202222) | more than 5 years ago | (#25649243)

Over ten years, over ten years...

I was using write over a 1/4 century ago on AT&T 3B5's. On the really old PDP's we inherited they didn't even have write. I had to use a script that grepped & cut their tty from who & then used cat to redirect my keyboard to their screen...

Job Control in Shells (0)

Anonymous Coward | more than 5 years ago | (#25649255)

A lot of people don't know job control (^Z, fg, bg) and don't know how to switch in a single shell between an editor and some other command (like a compiler) without quitting the editor. For convenience, I like to use the alias z=suspend, which probably also a lot of people don't understand why this is useful. Likewise, people don't know any longer how to suspend a remote shell (using ~^Z).

SysAdmins tend to forget (0)

Anonymous Coward | more than 5 years ago | (#25649319)

People keep forgetting to empty the bit bucket, even certified RedHat sysadmins.

sudo rm -rf / (0)

Anonymous Coward | more than 5 years ago | (#25649321)

sudo rm -fr /

Especially if another admin is standing behind me as I type this command, it always surprises him/her.

I also like these commands:

touch me
touch clothes
rm clothes

Dupe your TTY output to someone else using script (1)

dbrossard (911407) | more than 5 years ago | (#25649349)

This is useful when you want to show someone else what you are seeing in your TTY without actually letting the interact with the session.
"script | tee -a /dev/pts/(#of other tty)"

multitasking in a terminal (2, Informative)

shvytejimas (1083291) | more than 5 years ago | (#25649415)

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.

Imbedding output with ' (1)

qwertyatwork (668720) | more than 5 years ago | (#25649417)

You can use '' to imbed output to a command. Example

ls -l 'locate gcc' // Output would give you a long listing of wherever gcc is located

Another one is using -exec "{}" ";" with find, example.

find ~/tvshows -name doctor\*who\* -exec mplayer -fs "{}" ";"

The "{}" is the filename, not sure about ";" but its needed.

htop, dd, wmctrl stuff (1, Interesting)

Anonymous Coward | more than 5 years ago | (#25649419)

Various apps have nice little things that are useful at one time or another, so to name a few:

htop (better top) - has a nice feature that does a strace on a live process by pressing s when the process is selected

dd (everyone knows this one) - while doing a large transfer, you can send it the USR1 signal and it will display the transfers' progress (bonus points for doing something like watch -n 5 killall -USR1 dd)

wmctrl (interactions with WMs) - useful in all kinds of scripts, like looping every few seconds and searching for a specific window title then running some commands based on that (did someone IM you while you're AFK?, make keyboard's NUMLOCK blink if the screen's sleeping)

etc. etc.

A few of mine... (1)

digitalhermit (113459) | more than 5 years ago | (#25649421)

Clear a file:

Use the watch utility to keep checking the status of an output. E.g.:

      watch ls -l foo

Within vim and vi you can read input from the shell. This allows you to do things across the network and read it directly into the current buffer. For example, launch vim then do: :r! ssh maggot@darkstar cat /etc/ldap.conf

This is a shortcut method of copying the file locally, editing, then saving.

On machines where rsync is not available, I often use tar/ssh to move directories:

      tar cf - /home/maggot/source | ssh maggot@darkstart "cd /export; tar xf - "

Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Sign up for Slashdot Newsletters
Create a Slashdot Account