Tuesday, March 31, 2009

Linux scan for open ports

A nice command to scan open ports for a host/ip is:

nmap -sS -O

You will get an answer like this:

22/tcp open ssh
25/tcp open smtp
80/tcp open http
110/tcp open pop3
111/tcp open rpcbind
119/tcp open nntp
135/tcp filtered msrpc
137/tcp filtered netbios-ns
138/tcp filtered netbios-dgm
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds
1720/tcp filtered H.323/Q.931
3306/tcp open mysql
8080/tcp open http-proxy
8081/tcp open blackice-icecap
8443/tcp open https-alt
Device type: general purpose

If you need to see the open ports from inside (your server) use netstat:

netstat -a

You will get something like:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:cvspserver *:* LISTEN
tcp 0 0 *:mysql *:* LISTEN
tcp 0 0 *:netbios-ssn *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:http-alt *:* LISTEN
tcp 0 0 *:microsoft-ds *:* LISTEN
tcp 0 0 *:www-http *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:https *:* LISTEN
udp 0 0 *:netbios-ns *:*
udp 0 0 *:netbios-dgm *:*
udp 0 0 *:tftp *:*

Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 5170 @/tmp/hald-local/dbus-B cG6NtYfGm
unix 2 [ ACC ] STREAM LISTENING 7389 /var/lib/mysql/mysql.so ck
unix 2 [ ] DGRAM 8071089 /var/lib/dhcp/dev/log
unix 2 [ ] DGRAM 8071091 /var/lib/named/dev/log
unix 2 [ ] DGRAM 2177 @/org/kernel/udev/udevd
unix 2 [ ] DGRAM 5171 @/org/freedesktop/hal/u dev_event

Thursday, March 26, 2009

Linux: sort your folder by size

In case you need to sort your folders by size, in Linux, you can use the following command:

du --max-depth=1 /home/ | sort -n -r

of course replace '/home/' with your desired folder.

Why automate your business?

Why do you need to automate your business?

The answer is very simple: reduce human time which is VERY expensive.
Someone said that silicate (Si) is cheaper than carbon (C) and that is true.

I started this journey - to automate my business - as I had a lot of problem with employees and I'm searching for a solution.

A friend of mine said that if an employee has a personal problem that problem will become yours.

I started by developing a time tracking software for our company needs and it turned out that it worth - a lot. Now I know exactly where time was spent and more important I can detect very easily who is lagging behind with schedules.

I do not start praising our application - I think any time tracking application can be very helpful.

The main idea is that if you have many automated control mechanisms in place you can sleep better - not as a baby but better than without them.

I hope I will be able to add more and more scripts & software to Scriptoid so that anyone that need to automate his business to find a good solution.

Also we will create a repository for developers to reuse codes, snippets, recipes and programs we are using every day and find it useful.