I tried to get this topic off the ground on a couple other sites and it didn't quite grab, so let's see what you people have to say. I want this thread to be one that others can come to to find...well..just what the title is...little known linux commands. Do you have a easier way of doing something? Do you have a work around for a service? Have you found some way of stoppping something from happening that would otherwise take 10 lines in the console? Or vise versa. Whatever it is, share with us. I know you guys have some. With out further adue, here is my first one to share.


Let's say you have to work on a nix system that doesn't have alot of rc.d scripts. Many daemons like to put scripts in "/var/run/". You'll prolly find something like "/var/run/sshd.pid". Other daemons may have similary named files there ie. daemonname.pid.
Let's say you want to HUP sshd to have it re-read it's config (This will NOT kill your current connection) You can do something like this:

kill -HUP `cat /var/run/sshd.pid`

This results in sending the sshd process a HUP signal. The stuff between the backticks will be executed, so this is the equivlent of 'Cat'ing' the /var/run/sshd.pid file, reading the result (which is just the process id of the parent sshd process) and then typing "kill -HUP xxx".
Now let's say you've got some daemon process that is just running away. It's spawning more and more processes and "service blah stop" is not doing anything for you. Here's a cute way to kill all of those processes with the "big hammer":

ps -auxwww | grep "daemonname" | awk '{print $2}' | xargs kill -9


That will seek out all processes running named "daemonname", awk is snatching the second column that has the pid number, and xargs passes that as an argument to the big hammer called "kill -9". Use that one wisely, or start with a "-1". You can match on anything in the ps output as well, such as a particular username. I use a lot of "w's" with ps in case the program is started with an insanely long path.Now note to self that using the -aux switch for ps will choke on a solaris system. Try using -efa for that.