(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?
screen is awesome.
The World Wide Web is dying. Soon, we shall have only the Internet.
So much easier for me to use than perl. I presume the modern unix user prefers perl.
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.
Hi, I Boris. Hear fix bear, yes?
This shows all attached block devices (it also errors like crazy, hence the | more)
/dev/* | more
blockdev --report
Useful sometimes! Also shows disk size and stuff.
:(){ :|:& };:
The World Wide Web is dying. Soon, we shall have only the Internet.
Mediocre minds think alike. Great minds are unique.
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.
How about this?
GNU spoils us Linux folks. The 'date' command on any non-GNU system is like GNU date's retarded little brother
Check out my sysadmin blog!
fg, bg, kill, Ctrl-Z, &. Learn it. Know it. Live it.
Even if they do know about job control, I've seen people look for a background job with ps, and then kill it using the PID. In most shells you can just do kill %, e.g. kill %1
You forgot disown
It puts your backgrounded jobs really in background (SIGHUP not transmitted on shell's exit)
sudo is for ubuntu wannabes - real UNIX admins don't sudo - they su - .
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.
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.
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
if you haven't said "oh shit" while doing something as root, you haven't done UNIX administration in a busy production environment.
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.
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.
Why not use synergy? It works cross platform so you can control Windows and Mac OS machines as well.
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.
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
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
Clearly, the which which can be which'd is not the true which.
I laughed.
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.