Lazy Linux: essential tricks for admins
ibm.com
ibm.com
office$ ssh -R 9999:localhost:22 user@home ## do this in a screen for good measure
and another lesser known ssh feature:
home$ ssh -D 8888 -p 9999 user@localhost
and now you have a SOCKS proxy on home:8888 that will access everything visible to the computer named "office".
For extra credit add PingTunnel and a hotspot that happens to allow ICMP and enjoy free internet wherever you go.
fuser -fuck /dev/whatever
http://moka.ccr.jussieu.fr/doc_link/C/a_doc_lib/cmds/aixcmds...Oh, admin humor.
My company uses trick #5 as a primary feature for accessing the remote Linux machines that our product is built upon. We have it set up so that every single machine automatically creates a reverse SSH tunnel to the server on boot, so that the tunnel is always accessible in case we need it. Very cool stuff.
stty sane ^j
(That's Ctrl-j there.)
You might be flying blind, but just do it and you might get your screen back.
You probably know this, but to rescue a hosed system with Knoppix or similar live-cd:
- Boot from CD.
- Open root console.
- Mount your usual root partition: mount -t somefs /dev/hda1 /mnt/oldsys
- chroot /mnt/odlsys /bin/bash
Showed that to another admin who'd lost a production box, and his chin kind of hit the floor :) I gifted him the Knoppix disk... You can also use that to reset passwords (as per the article), by editing /etc/shadow or /etc/passwd in the /mnt/oldssys directory.
How Knoppix saved the day
another great tip is how to list all subdomains on registered (not all dns servers allow this, many times you need to be on the same network, or it isn's allowed at all, but for solving you own dns issues it's a boon)
dig mydomain.com. axfr
fuser, strace, ltrace, nc come to mind offhand.
They sound like fairly sensible abbreviations to me.
"Global Regular Expression Print" is a terrible name on its own, too.
There are some nice conventions though, once you know grep there's egrep, ngrep, etc. Then there's the -stat family, prstat, iostat, vmstat, mpstat, etc.
Grep is its own special case, I'm not going to argue that it's a good name a priori but it does have the benefit of being completely unique not to mention far too entrenched to change now. Not to mention that it's "burp" in Yiddish.
Unix is difficult to pick up but once your brain operates in that special warped way things do make sense by extension.
Nonetheless, I entirely agree with you about ls, and about sticking to the conventions that have developed around unix.
That said, I kind of like the weird names, esp grep. (Wasn't that in Stranger in a Strange Land or something?)
But I do object to inconsistent options. One example is: mkdir -p a/b/c This will make all three nested directories, if needed; but there is no equivalent: mv -p x a/b/c/y There also isn't: cp -p a/b/c [1]. You have to create the nested destination directories (a/b/c) first.
[1] cp has a -p option, but with a different meaning...
BTW: It would be nice if HackerNews had the `` markdown of Reddit for inline code. There's been a bit of code sharing recently, and I like that in a "hacker" site.
like thisalias listopenfiles=ls
alias netfind=ngrep
...and so forth. I've done that to add the DOS "cls" command to clear my terminal screen. Also, I'm a Cisco admin, so I have aliased "en" to "su", and the reverse on Cisco switches and routers. Yes, Cisco also has the alias command in IOS.
There's the favourite DOS->unix:
alias cd..="cd .."When ls utility was created standard RAM was 10KB and power computers looked like this http://images.appleinsider.com/leopard-preview-server-1.jpg
I guess if your IO interface is a real dead-tree paper then each character counts.
Man "mebibits" sounds terrible.
Hee, things I didn't think I'd ever see on ibm.com, #12234 in a series.
People with company songbooks and nice ties must be spinning in their graves
Single User Mode isn't unique to CentOS/Redhat, or even Linux. In fact, the concept behind it isn't even unique to Unix: One of Microsoft's 10 security rules is "if the bad guy has unrestricted physical access to your box, it isn't your box anymore."
edit for clarity, due to reply
GRUB doesn't change the Unix root password. GRUB--like any other bootloader--lets you boot to single user mode, which doesn't require a password. Single user mode lets you change the Unix root password.
Is the same true for BSDs, Solaris, et al?
FreeBSD: http://www.cyberciti.biz/tips/howto-freebsd-reset-recover-ro...
OpenBSD: http://www.openbsd101.com/tipstricks.html#tt1
Solaris: http://www.cyberciti.biz/tips/solaris-boot-system-into-singl...
p4ss1ng g4s 1n h3r 4ss w/ my sp34r
d4n4 d03s d1ld0s @t d4 d1ld0 st0re
d1ck r4p3d j4n3 w/ h1s d1ng d4ng