Very nice collection. A tech at the datacenter that hosts one my servers showed me trick #3 and I remember being thrilled sitting there watching him do stuff on my server and sharing the keyboard to type messages back and forth in vi.
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.
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.
great list! I especially liked the tip about sharing a screen session, been wanting a solution like that many times!
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)
See the thing is that if you're knee deep in an unfamiliar system trying to fix it you type "ls" about a dozen times a minute. Adding two unnecessary keystrokes (doubling the length!) not only adds up it makes typos more common.
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.
There's a tribal aspect, too; not to mention jargon as a barrier to entry. And what professional wants to forgo hard-won knowledge?
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.
If that really bothers you, just alias those commands.
alias 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.
If unix were being designed from the ground up, today, user friendly commands, with aliases to power user abbreviations might make sense. It was, however, created some 30+ years ago.
yeah, if you don't like it, change it (you could even put them on a USB stick or a server somewhere so you could install them on a new machine quickly). That one could change it honestly didn't occur to me til you said it.
If you want user friendly, use the GUI. The commands are meant to be quick to write for frequent users, especially in the days when shells didn't do command completion.
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.
I'm aware of GRUB and LILO. But as bootloaders, I didn't realize they were able to modify the Linux root password so easily. The question still stands: is it possible in any flavour of Linux to change the root password by modifying the kernel parameters at boot-time?
On any flavor of linux that uses GRUB or LILO it's possible to modify the kernel parameters at boot time to enter single-user mode. Once you're in single-user mode you have full root privileges and environment and can change any passwords or files you like.
My general attitude to passwords is "Never choose something you'd be ashamed to recite to your mother over the phone", since you never know when you'll be in a position where you may have to do exactly that.
As an information assurance guy, I'd encourage users to use the most embarassing possible passwords, since you should never share them. If you need to make resources available to more entities, do it by sharing access, not authentication.
Is it just me or are downvoted posts completely unreadable? It would be nice if there were an "unhide" button or something; it's extremely annoying to have to squint to read it.
That's intentional. Downvoted posts fade both to save people from reading them (presumably most are mistaken or nasty) and to damp the submitter's karma loss (the fainter they are, the harder you have to work to be offended by them).
Are you're kidding me? If I must really share. . .most sys admins encourage their users to come up with passwords that read like 'pornographic catch phrases' written in 1337 speak as means of ensuring system security while the end-user is less likely to forget their password since it's something offensive yet expressive.
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.