Friday, December 18, 2009

Unix a Real O/S


Unix is a real Operating System. A real operating system has minimum two qualification more than one person access the computer at the same time, and while doing so each person can run multiple Application.

Unix is a multi-user OS. Each user uses a different terminal at the minimum consisting of keyboard & monitor and its connected to the main computer (Host). Resources namely HD, processor, memory etc..
A smart programmer uses the unix environment and its tool to turn out programs faster and batter.
Think big and u will have think Unix.

Some Unix Network Tracking Commands:

Getting the hostname
$ hostname
Root

Output from ipconfig on Solaris
$ ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
pcn0: flags=201004843
mtu 1500 index 2
inet 192.168.1.25 netmask fffffc00 broadcast 192.168.3.255
lo0: flags=2002000849 mtu 8252 index 1
inet6 ::1/128
pcn0: flags=202004841 mtu 1500 index 2
inet6 fe80::20c:29ff:fe7f:dc5/10

netstat command
$ netstat -r
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ---------- ---------
default voyager.example.pri UG 1 139 pcn0
192.168.0.0 solaris2.example.pri U 1 447 pcn0
solaris2 solaris2 UH 1 35 lo0
Routing Table: IPv6
Destination/Mask Gateway Flags Ref Use If
--------------------------- --------------------------- ----- --- ------- -----
fe80::/10 fe80::20c:29ff:fe7f:dc5 U 1 0 pcn0
solaris2 solaris2 UH 1 0 lo0

Extracting a list of connected machines
$ netstat -a|egrep 'tcp|udp'|grep ESTABLISHED|awk '{ print $5; }'|cut -d: -f1|sort|uniq
localhost
narcissus.mcslp.p
nautilus.wireless
polarbear.wireles
solaris2.vmbear.mcs
sulaco.mcslp.pri

Pinging machine on your own network
$ ping bear
PING bear.mcslp.pri (192.168.0.2): 56 data bytes
64 bytes from 192.168.0.2: icmp_seq=0 ttl=64
time=0.154 ms
64 bytes from 192.168.0.2: icmp_seq=1 ttl=64
time=0.162 ms
64 bytes from 192.168.0.2: icmp_seq=2 ttl=64
time=0.149 ms
64 bytes from 192.168.0.2: icmp_seq=3 ttl=64
time=0.161 ms
64 bytes from 192.168.0.2: icmp_seq=4 ttl=64
time=0.162 ms
64 bytes from 192.168.0.2: icmp_seq=5 ttl=64
time=0.161 ms

Running nmap to scan range of IP addresses
$ nmap -sP 192.168.1.25/22
Starting Nmap 4.76 ( http://nmap.org ) at 2009-03-24 15:59 GMT
Host 192.168.0.1 appears to be up.
Host bear.mcslp.pri (192.168.0.2) appears to be up.
Host narcissus.mcslp.pri (192.168.0.3) appears to be up.
Host 192.168.0.10 appears to be up.
Host 192.168.0.27 appears to be up.
Host sulaco.mcslp.pri (192.168.0.101) appears to be up.
Host nautilus.wireless.mcslp.pri (192.168.0.109) appears to be up.
Host 192.168.1.1 appears to be up.
Host 192.168.1.25 appears to be up.
Host gentoo1.vmbear.mcslp.pri (192.168.1.52) appears to be up.
Host gentoo2.vmbear.mcslp.pri (192.168.1.53) appears to be up.
Nmap done: 1024 IP addresses (11 hosts up) scanned in 5.78 seconds

nmap operating system scan
# nmap -sT -O bear
Starting Nmap 4.76 ( http://nmap.org ) at 2009-03-24 16:20 GMT
Interesting ports on localhost (127.0.0.1):
Not shown: 985 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
53/tcp open domain
111/tcp open rpcbind
143/tcp open imap
443/tcp open https
783/tcp open spamassassin
902/tcp open iss-realsecure
993/tcp open imaps
2000/tcp open callbook
2049/tcp open nfs
3128/tcp open squid-http
3306/tcp open mysql
10024/tcp open unknown
10025/tcp open unknown
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.17 - 2.6.25
Network Distance: 0 hops
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 1.71 seconds

Using traceroute
$ traceroute solaris2
traceroute to solaris2 (192.168.1.25), 30 hops max, 40 byte packets
1 solaris2.mcslp.pri (192.168.1.25) 0.651 ms 0.892 ms 0.969 ms