Tuesday, May 31, 2005

Finding out what a process is doing with strace

strace is a very powerfull and useful command, especially if you are trying to figure out what a certain process is doing ... (in other words, where the heck does it spend all its time). In essence what it does is tell you all the system calls and signals the process is making, which helps understand what it is doing.

You can run it in a couple of ways, either run the process within an "strace shell", or attach to an existing process.
The command prints A LOT of output, but it's usually pretty easy to understand what is going on

To run within an "strace shell":
strace -f -v COMMAND
strace -f -v -o output.txt COMMAND
(output.txt will have the strace output as oppsed to stdout)

To attach to a live process:
strace -f -v -p PID

strace is very powerful, and very detailed, but usually gives invaluable results!

(Thanks to my friend Eran for helping with syntax and such)

Recent update ..
Redhat just put out a nice little guide here : http://www.redhat.com/magazine/010aug05/features/strace/

Thursday, May 26, 2005

The power of mutt

Mutt is an e-mail client that for some reason many people don't know!

It's very powerful, especially when trying to send e-mail from command line with attachements, or similar requirements.
Here's a couple of useful commands I often use.

To send an e-mail with attachment (and no message body) use:
mutt -a attachment_filename -s "Subject goes here" user@domain.com < /dev/null

The above command will send the e-mail with the attachement and subject to user@domain.com. The redirect from /dev/null makes sure there is no message body.

If you want to send an HTML e-mail you can use:
mutt -e "my_hdr Content-Type: text/html" -s "Subject" user@domain.com < msg.html

The above command sends an HTML e-mail to user@domain.com, using msg.html as the input file. The -e parameter allows you to change the content type. You can also put this in your .muttrc if you use it often.

For more details see mutt.org

Saturday, May 21, 2005

mplayer is a better movie player !

Ok, so I tried Kaffeine (based on Xine) for a while .. I even upgraded to the latest xine engine and the latest Kaffeine version. And yet, some movies (mostly WMV) get distorted all the time. It kind'a looks like the refresh on the image does not work properly.
So, I gave up, and installed mplayer. I have to report, it's much better !
I think it loads faster, it plays inside the browser (unlike Kaffeine) and most important support movies better.

Installation is very quick using urpmi. As simple as: urpmi mplayer
This will install mplayer, and you still need the mplayer plugin for your browser. The latter can be installed using: urmpi mplayerplugin

Assuming you are like me .. you have Mozilla and FireFox installed, so the mplayerplugin gets installed in the wrong directory ...
To fix that, you just need to copy the file to the right places:
cp /usr/lib/mozilla/plugins/mplayerplug-in.so /usr/lib/firefox/plugins
cp /usr/lib/mozilla/components/mplayerplug-in.xpt /usr/lib/firefox/components

And that's that!

happy movie watching..

Wednesday, May 18, 2005

Changing the host name

I am sorry.. but changing the host name on a linux box is a pain in the ...
Come on .. why can't we come up with a single place (or at least a single command) that takes care of everything (and works on multiple distros).

The steps to change your host name are:
1. Change the current machine name : hostname 'New Name'
2. Change the boot settings at : /etc/sysconfig/network (change the HOSTNAME entry)
3. Change /etc/hosts. Make sure that in /etc/hosts you put both entries for your short and long host name. Usually you want to put the long and then the short.
e.g. : benyolin.mydomain.com benyolin

To check it use :
hostname (should display the short one)
hostname -s (should display the short one)
hostname -f (should display the long one)


Another way to look at PS

Sometimes, you want to know more about processes ..
PS can take all sorts of parameters.
I often use:
ps -ewwo pid,ppid,pmem,rss,vsize,tid,rtprio,ni,pri,psr,pcpu,etime,stat,args

and you can pipe grep " D " .. to see which processes in IO wait.