Following in the spirit of Hidden Features of PowerShell and various others on Stack Overflow, what Linux commands or combinations of commands do you find essential in your work?
Also See:
Hidden Features of MySQL
Hidden Features of PowerShell
Hidden features of Oracle Database
Hidden Features of Windows 2008
Hidden Features of Solaris/OpenSolaris
Hidden Features of SQL Server
Hidden Features of IIS (6.0 / 7.0)
To get the ball going, I find screen to be essential:
Maybe I don't use these every day, but I use them frequently:
lsof often gets ignored, its a very useful tool. lsof lets you view a list of every open file on the system, who / what is using it, etc.
For instance:
Now I see that I'm logged into a shell in another terminal, and /mnt/hardy is my current working directory. So I can either kill that shell, or go to the other terminal and get out of that directory so it can be unmounted.
That's really a trivial example, its very handy for cleaning up the occasional 'bot' infestation too. The options are extensive, see man lsof for more.
I was surprised to find that you can run remote GUI applications over SSH, using the "-X" parameter. For example:
The gedit window appears on my local machine, editing the "my.cnf" file on the server.
I'm assuming this only works if your client machine has an X environment -- in other words, not on Windows. But it works great on my Mac!
To change to the last directory you were in:
Network stack can be left running after a system halt. I don't know if this is current with the 2.6.x series of kernels, but on older versions, you could configure the firewall/routing, then halt the system without a shutdown, leaving just the network stack running. This would allow you to make a cheap (although static) firewall that "can't be hacked" - because there's nothing to hack, as there are no programs or services, just the network stack portion of the kernel passing packets back and forth...
I like "locate" - a much easier way to find files than the gnarly "find . -name xxxx -print". Note that you have to use the updatedb command with it to a your file index up to date; see the man pages for details.
I find "ngrep" really useful for debugging network code on remote servers without having to punt tcpdump files around:
for example, will show you live HTTP requests and responses.
One other thing I've found useful frequently is the "-e" switch to strace:
will show all open() syscalls for a given pid, and
will exclude all calls to rt_sigprocmask() from the output (useful for debugging RoR code, which seems to make an awful lot of those calls when built to use pthreads).
Thankfully I've only needed a couple of times, but the Magic SysRq key still remains one of my all time favorite hidden features.
Alt+SysRq+RSEIUB