The writings of Peter Stuifzand

Weblog: linux

Let's say you run nmap on your local box and you see an open port, but don't know which program is listening on that port. Wouldn't it be great to be able to find out? The program you need to find this information is lsof, or list open files. This program can show you a lot of information about open files, ports and directories.

Let's go back to the original question. Run the following command.

sudo lsof -i4:80

With this command we get a list of programs which listen or connect to port 80. Its output should look like this:

COMMAND     PID     USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
apache2    3080     root    4u  IPv4   13546      0t0  TCP *:www (LISTEN)
apache2    3123 www-data    4u  IPv4   13546      0t0  TCP *:www (LISTEN)
apache2    3124 www-data    4u  IPv4   13546      0t0  TCP *:www (LISTEN)
apache2    3125 www-data    4u  IPv4   13546      0t0  TCP *:www (LISTEN)
apache2    3126 www-data    4u  IPv4   13546      0t0  TCP *:www (LISTEN)
apache2    3127 www-data    4u  IPv4   13546      0t0  TCP *:www (LISTEN)
apache2   18335 www-data    4u  IPv4   13546      0t0  TCP *:www (LISTEN)
apache2   18337 www-data    4u  IPv4   13546      0t0  TCP *:www (LISTEN)

This shows you all local running processes that LISTEN on the www port. This could also show open connections to other web servers.

Today I created this simple script that will find your local IP address or you Linux machine.

#!/bin/sh
# Shows ip address of eth0
/sbin/ifconfig | awk '/^eth0/,/^$/' | awk '/inet addr/ { print $2 }' | cut -d: -f2

It uses the output of ifconfig. First it finds the part that contains the information for eth0. Then it find the line with the inet addr, which contains your IP address. At the end it cuts the line in two parts and only prints the second part.

If you want to print the IP address of another interface, then you need to change the name eth0 to that interface name.

In 2005 I wrote a small post about the programs that I use on a regular basis. I will try and find out what has changed and what stayed the same.

I still use:

Programs that I don't use anymore:

Programs that I use now:

This isn't a complete list of all the programs that I use. There are more programs, that I use but those are more on the backend of things. These are all user programs. I could also add Apache to this list or Perl, but are not really useful here.

Dwm is the 'dynamic window manager' and is written in only 2000 lines of C code. This is quite nice. The size and the quality of the code is really good, so its really easy for me to make some modifications.

The first modifications that I made, where for keys to start programs. F2 now starts the terminal and F4 starts a webbrowser. F3 starts gmrun, but I'm not sure if I need, or that I like it. Some people use it, some people like it, but most of the time I just use a terminal. Its already open, so. The thing is: in Ion3, F3 opens a query window just like gmrum and lets me start a program.

The next modification that I made was for the switching between tags. In Ion3 I could move to the next or previous workspace by pressing Meta-K N, or Meta-K P. Now I can do the same thing in dwm.

I also tried a few other things but these didn't stuck, which means I couldn't get them to work the way I liked.

It seems I'm always on the lookout for new windowmanagers. Last year started using Ion3, which I really like. Yesterday I saw a windowmanager called dwm and it is written in about 2000 lines of C code. This is not useful in itself, but it makes it easier to understand the code and make some small modifications without actually understanding all of it. And 2000 lines isn't that much either.

Configuration of dwm is done through editing the source code of the program. Which is actually quite a simple way to make changes.

My Alt key stopped working in rxvt-unicode. Still works in Firefox. I don't have any idea about how it stopped working. After some searching and trying, I found out that I had to add a line to my .Xdefaults file.

URxvt.modifier: meta

After reloading the file with xrdb -merge ~/.Xdefaults, the Alt key started working again as it did before.

A short list of the applications/programs that I use.

Today I fixed my computer. It now will rip cd's, without being really slow. Actually I only had to install a new kernel. I now use 2.6.8 instead of 2.6.7.

Ripping cd's with sound-juicer is really simple.

Yesterday I installed a new Debian setup. I used Redhat before, but I began to show signs of old age.

Now I have Gnome 2.6 and some more nice stuff. There are some many packages, that I'm not yet sure what to install.

View archived entries