nmap . -O: Enable OS detection

commandline session

$nmap 127.0.0.1

Starting Nmap 6.00 ( http://nmap.org ) at 2013-11-24 17:56 IST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00019s latency).
Not shown: 997 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
25/tcp  open  smtp
111/tcp open  rpcbind

Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
$nmap -O 127.0.0.1
TCP/IP fingerprinting (for OS scan) requires root privileges.
QUITTING!
$sudo nmap -O 127.0.0.1
[sudo] password for jeffrin:

Starting Nmap 6.00 ( http://nmap.org ) at 2013-11-24 17:56 IST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000057s latency).
Not shown: 997 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
25/tcp  open  smtp
111/tcp open  rpcbind
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=6.00%E=4%D=11/24%OT=22%CT=1%CU=32670%PV=N%DS=0%DC=L%G=Y%TM=5291F0
OS:7A%P=x86_64-unknown-linux-gnu)SEQ(SP=FF%GCD=1%ISR=111%TI=Z%CI=Z%II=I%TS=
OS:8)OPS(O1=M400CST11NW6%O2=M400CST11NW6%O3=M400CNNT11NW6%O4=M400CST11NW6%O
OS:5=M400CST11NW6%O6=M400CST11)WIN(W1=8000%W2=8000%W3=8000%W4=8000%W5=8000%
OS:W6=8000)ECN(R=Y%DF=Y%T=41%W=8018%O=M400CNNSNW6%CC=Y%Q=)T1(R=Y%DF=Y%T=41%
OS:S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=41%W=0%S=A%A=Z%F=R%O=%
OS:RD=0%Q=)T5(R=Y%DF=Y%T=41%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=41%W
OS:=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=41%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)
OS:U1(R=Y%DF=N%T=41%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%D
OS:FI=N%T=41%CD=S)

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 12.17 seconds
$
$sudo nmap -O 192.168.0.1

Starting Nmap 6.00 ( http://nmap.org ) at 2013-11-24 17:59 IST
Nmap scan report for 192.168.0.1
Host is up (0.00047s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE
53/tcp open  domain
80/tcp open  http
MAC Address: 5C:D9:98:5C:01:1A (D-Link)
Device type: general purpose
Running: Linux 2.6.X
OS CPE: cpe:/o:linux:kernel:2.6
OS details: Linux 2.6.29 - 2.6.31
Network Distance: 1 hop

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 2.10 seconds
$

nmap . -O: Enable OS detection – Video Tutorial Related

[source : http://www.youtube.com/user/metalx1000 ]

[youtube https://www.youtube.com/watch?v=XaCzpqIU5-A?rel=0&w=560&h=315]

What does the command “netstat ” do ?

ABOUT netstat

In computing, netstat (network statistics) is a command-line network utility tool that displays network connections for the Transmission Control Protocol (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics. It is available on Unix-like operating systems including macOS, Linux, Solaris, and BSD, and is available on Windows NT-based operating systems including Windows XP, Windows Vista, Windows 7, Windows 8 and Windows 10.

It is used for finding problems in the network and to determine the amount of traffic on the network as a performance measurement.[1] On Linux this program is mostly obsolete, although still included in many distributions.

On Linux, netstat (part of "net-tools") is superseded by ss (part of iproute2). Replacement for netstat -r is ip route. Replacement for netstat -i is ip -s link, replacement for netstat -g is ip maddr, all of which are recommended instead

RELATED SHELL SESSION EXPOSURE
[bash light=”true”]
$netstat –tcp
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 debian.local:39585 74.125.169.8:http ESTABLISHED
tcp 0 0 debian.local:39586 74.125.169.8:http ESTABLISHED
tcp 0 0 debian.local:47951 maa03s17-in-f6.1e:https ESTABLISHED
tcp 0 0 debian.local:47203 maa03s17-in-f0.1e1:http ESTABLISHED
$
$netstat –tcp –numeric
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 1 0 192.168.0.101:54541 46.22.210.18:80 CLOSE_WAIT
tcp 0 0 192.168.0.101:54542 46.22.210.18:80 ESTABLISHED
tcp 0 0 192.168.0.101:39585 74.125.169.8:80 ESTABLISHED
tcp 0 0 192.168.0.101:39586 74.125.169.8:80 TIME_WAIT
tcp 0 0 192.168.0.101:47951 74.125.236.198:443 ESTABLISHED
tcp 0 0 192.168.0.101:47203 74.125.236.192:80 ESTABLISHED
$netstat –tcp –numeric
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.0.101:54542 46.22.210.18:80 TIME_WAIT
tcp 0 0 192.168.0.101:39585 74.125.169.8:80 ESTABLISHED
tcp 0 0 192.168.0.101:39586 74.125.169.8:80 TIME_WAIT
tcp 0 0 192.168.0.101:47951 74.125.236.198:443 ESTABLISHED
tcp 0 0 192.168.0.101:47203 74.125.236.192:80 ESTABLISHED
$netstat –tcp –listen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:35436 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
tcp6 0 0 [::]:501100 [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
$netstat –tcp –listen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:35436 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
tcp6 0 0 [::]:501100 [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
$netstat –tcp –program
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 debian.local:39600 74.125.169.8:http ESTABLISHED 3846/chrome
tcp 0 0 debian.local:47951 maa03s17-in-f6.1e:https ESTABLISHED 3846/chrome
tcp 0 0 debian.local:47203 maa03s17-in-f0.1e1:http ESTABLISHED 3846/chrome
$
$netstat –tcp –route
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
$netstat –tcp –statistics
IcmpMsg:
OutType3: 1
Tcp:
522 active connections openings
0 passive connection openings
14 failed connection attempts
16 connection resets received
2 connections established
60302 segments received
41524 segments send out
22 segments retransmited
21 bad segments received.
140 resets sent
UdpLite:
TcpExt:
190 TCP sockets finished time wait in fast timer
495 delayed acks sent
1 delayed acks further delayed because of locked socket
Quick ack mode was activated 32 times
47899 packet headers predicted
1353 acknowledgments not containing data payload received
406 predicted acknowledgments
7 congestion windows recovered without slow start after partial ack
22 other TCP timeouts
32 DSACKs sent for old packets
3 DSACKs sent for out of order packets
5 DSACKs received
25 connections reset due to unexpected data
16 connections reset due to early user close
TCPSackShiftFallback: 2
TCPChallengeACK: 21
TCPSYNChallenge: 21
IpExt:
InMcastPkts: 929
OutMcastPkts: 42
InBcastPkts: 16
OutBcastPkts: 14
InOctets: 83827635
OutOctets: 2776707
InMcastOctets: 332300
OutMcastOctets: 5264
InBcastOctets: 1808
OutBcastOctets: 1006
$

[/bash]
LINKS
https://en.wikipedia.org/wiki/Netstat
https://stackoverflow.com/tags/netstat/info

Bash – netstat ( network statistics related ) – Video Tutorial Related

[ source : http://www.youtube.com/user/metalx1000 ]

[youtube https://www.youtube.com/watch?v=wcrQgKNUD10?rel=0&w=560&h=315]

GNU/Linux BASH builtin commands

commandline session

$pwd
/home/jeffrin/playground
$which pwd
/bin/pwd
$
$/bin/pwd
/home/jeffrin/playground
$/bin/pwd -P
/home/jeffrin/playground
$pwd -P
/home/jeffrin/playground
$help pwd
pwd: pwd [-LP]
    Print the name of the current working directory.

    Options:
      -L	print the value of $PWD if it names the current working
    	directory
      -P	print the physical directory, without any symbolic links

    By default, `pwd' behaves as if `-L' were specified.

    Exit Status:
    Returns 0 unless an invalid option is given or the current directory
    cannot be read.
$mkdir  direct
$ln -s  direct/  directlink
$pwd
/home/jeffrin/playground
$cd direct
$pwd
/home/jeffrin/playground/direct
$pwd -P
/home/jeffrin/playground/direct
$/bin/pwd
/home/jeffrin/playground/direct
$/bin/pwd -P
/home/jeffrin/playground/direct
$cd ..
$cd directlink
$pwd
/home/jeffrin/playground/directlink
$pwd -P
/home/jeffrin/playground/direct
$/bin/pwd
/home/jeffrin/playground/direct
$/bin/pwd -P
/home/jeffrin/playground/direct
$/bin/pwd --help
Usage: /bin/pwd [OPTION]...
Print the full filename of the current working directory.

  -L, --logical   use PWD from environment, even if it contains symlinks
  -P, --physical  avoid all symlinks
      --help     display this help and exit
      --version  output version information and exit

NOTE: your shell may have its own version of pwd, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

Report pwd bugs to bug-coreutils@gnu.org
GNU coreutils home page: 
General help using GNU software: 
For complete documentation, run: info coreutils 'pwd invocation'
$pwd --help
bash: pwd: --: invalid option
pwd: usage: pwd [-LP]
$

GNU/Linux BASH builtin commands – Video Tutorial Related

[ source : http://www.youtube.com/user/theurbanpenguin ]

[youtube https://www.youtube.com/watch?v=Kv42Beohmyo?rel=0&w=560&h=315]

uptime w whoami id hostname apropos whatis

commandline session

$uptime
 20:57:47 up  1:41,  3 users,  load average: 0.64, 0.71, 0.70
$
$w
 20:57:49 up  1:41,  3 users,  load average: 0.64, 0.71, 0.70
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
jeffrin  tty7     :0               19:16    1:41m  3:50   0.04s gdm-session-worker [pam/gdm3-autologin]
jeffrin  pts/0    :0               20:52    1:25   0.08s  0.08s bash
jeffrin  pts/1    :0               20:57    5.00s  0.05s  0.00s w
$
$whoami
jeffrin
$
$id
uid=1000(jeffrin) gid=1000(jeffrin) groups=1000(jeffrin),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),104(scanner),107(bluetooth),109(netdev)
$
$hostname
debian
$
$
$apropos apt-get
apt-get (8)          - APT package handling utility - - command-line interface
$
$whatis apt-get
apt-get (8)          - APT package handling utility - - command-line interface
$

apt-get (8) – APT package handling utility – – command-line interface

commandline session

NO WARRANTY

$sudo apt-get remove cowsay
[sudo] password for jeffrin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cpp-4.7 libdrm-nouveau1a libmpc2 linux-headers-3.11-1-common linux-kbuild-3.11
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  cowsay
0 upgraded, 0 newly installed, 1 to remove and 1061 not upgraded.
After this operation, 91.1 kB disk space will be freed.
Do you want to continue [Y/n]?
(Reading database ... 163573 files and directories currently installed.)
Removing cowsay ...
Processing triggers for man-db ...
$sudo apt-get remove --purge cowsay
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'cowsay' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  cpp-4.7 libdrm-nouveau1a libmpc2 linux-headers-3.11-1-common linux-kbuild-3.11
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1061 not upgraded.
$sudo apt-get  --purge cowsay
E: Invalid operation cowsay
$sudo apt-get install cowsay
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cpp-4.7 libdrm-nouveau1a libmpc2 linux-headers-3.11-1-common linux-kbuild-3.11
Use 'apt-get autoremove' to remove them.
Suggested packages:
  filters
The following NEW packages will be installed:
  cowsay
0 upgraded, 1 newly installed, 0 to remove and 1061 not upgraded.
Need to get 0 B/21.9 kB of archives.
After this operation, 91.1 kB of additional disk space will be used.
Selecting previously unselected package cowsay.
(Reading database ... 163508 files and directories currently installed.)
Unpacking cowsay (from .../cowsay_3.03+dfsg1-4_all.deb) ...

Processing triggers for man-db ...
Setting up cowsay (3.03+dfsg1-4) ...
$sudo apt-get remove --purge cowsay
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cpp-4.7 libdrm-nouveau1a libmpc2 linux-headers-3.11-1-common linux-kbuild-3.11
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  cowsay*
0 upgraded, 0 newly installed, 1 to remove and 1061 not upgraded.
After this operation, 91.1 kB disk space will be freed.
Do you want to continue [Y/n]?
(Reading database ... 163573 files and directories currently installed.)
Removing cowsay ...
Processing triggers for man-db ...
$

Video Tutorial (NO WARRANTY)

[youtube https://www.youtube.com/watch?v=bveLudaVAqQ?rel=0&w=560&h=315]

Standard Input,Output and Error Related

commandline session

NO WARRANTY
$echo content > file
$cat file
content
$echo content 1> file
$cat file
content
$echo content 2> file
content
$cat file
$
$echo content 0> file
content
$cat file
$echo content 3> file
content
$cat file
$ls /root/
ls: cannot open directory /root/: Permission denied
$ls /root/ 2> file
$cat file
ls: cannot open directory /root/: Permission denied
$ls /root/ 2>> file
$cat file
ls: cannot open directory /root/: Permission denied
ls: cannot open directory /root/: Permission denied


Video Tutorial Related (NO WARRANTY)

[youtube https://www.youtube.com/watch?v=shFMEJJ_fpU?rel=0&w=560&h=315]

-mtime n File’s data was last modified n*24 hours ago

commandline session

$find . -mtime +1000000
$find . -mtime +100000
$find . -mtime +10000
$find . -mtime +1000
./wallphotos-old
./wallphotos-old/8002_1600x1200-wallpaper-cb1267712759.jpg
./wallphotos-old/18738_1600x1200-wallpaper-cb1271712460.jpg
./wallphotos-old/3767_1600x1200-wallpaper-cb1267712187 (1).jpg
./wallphotos-old/8020_1600x1200-wallpaper-cb1267712767.jpg
./wallphotos-old/3664_1600x1200-wallpaper-cb1267712118.jpg
./wallphotos-old/17801_1600x1200-wallpaper-cb1273013536.jpg
$

head and tail Command Related

commandline session

following session display may not be accurate

$sudo head dmesg
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.46-1+deb7u1
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.2.0-4-amd64 root=UUID=3219e911-81fb-4d52-ba7c-117a58d09312 ro quiet
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009e800 (usable)
[    0.000000]  BIOS-e820: 000000000009e800 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 000000009e5e7000 (usable)
[    0.000000]  BIOS-e820: 000000009e5e7000 - 000000009e619000 (reserved)
$sudo head ls
head: cannot open `ls' for reading: No such file or directory
$sudo head -6 dmesg
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.46-1+deb7u1
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.2.0-4-amd64 root=UUID=3219e911-81fb-4d52-ba7c-117a58d09312 ro quiet
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009e800 (usable)
$sudo head -3 auth.log daemon.log
==> auth.log  daemon.log <==
Nov 10 20:11:07 debian acpid: starting up with netlink and the input layer
Nov 10 20:11:07 debian acpid: 1 rule loaded
Nov 10 20:11:07 debian acpid: waiting for events: event logging is off
$tail -f iostat
tail: cannot open `iostat' for reading: No such file or directory
$tail -f dmesg
tail: cannot open `dmesg' for reading: Permission denied
$sudo tail -f dmesg
[   14.815581] NET: Registered protocol family 31
[   14.815587] Bluetooth: HCI device and connection manager initialized
[   14.815593] Bluetooth: HCI socket layer initialized
[   14.815603] Bluetooth: L2CAP socket layer initialized
[   14.815824] Bluetooth: SCO socket layer initialized
[   14.847521] Bluetooth: RFCOMM TTY layer initialized
[   14.847531] Bluetooth: RFCOMM socket layer initialized
[   14.847535] Bluetooth: RFCOMM ver 1.11
[   14.924529] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   14.924536] Bluetooth: BNEP filters: protocol multicast
^C$

a typical video tutorial related

NO WARRANTY

[youtube https://www.youtube.com/watch?v=QPT64WvDN-Q?rel=0&w=560&h=315]

Debian GNU/Linux Easter Eggs and Game Related

commandline session

the following session may not have an accurate display.

$apt-get help
$apt-get help | tail
  -f  Attempt to correct a system with broken dependencies in place
  -m  Attempt to continue if archives are unlocatable
  -u  Show a list of upgraded packages as well
  -b  Build the source package after fetching it
  -V  Show verbose version numbers
  -c=? Read this configuration file
  -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
See the apt-get(8), sources.list(5) and apt.conf(5) manual
pages for more information and options.
                       This APT has Super Cow Powers.
$apt-get moo
         (__)
         (oo)
   /------/
  / |    ||
 *  /---/
    ~~   ~~
...."Have you mooed today?"...
$aptitude -v moo
There really are no Easter Eggs in this program.
$aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program?
$aptitude -vvv moo
Stop it!
$aptitude -vvvv moo
Okay, okay, if I give you an Easter Egg, will you go away?
$aptitude -vvvvv moo
All right, you win.

                               /----
                       -------/      
                      /               
                     /                |
   -----------------/                  --------
   ----------------------------------------------
$aptitude -vvvvvv moo
What is it?  It's an elephant being eaten by a snake, of course.
$aptitude -vvvvvvv moo
What is it?  It's an elephant being eaten by a snake, of course.
$aptitude -vvvvvvvv moo
What is it?  It's an elephant being eaten by a snake, of course.
$/usr/games/cowsay hello Jeffrin
 _______________

 ---------------
           ^__^
           (oo)_______
            (__)       )/
                ||----w |
                ||     ||
$/usr/games/cowsay -e +
^C
$/usr/games/cowsay -e + hello
 _______

 -------
           ^__^
           (+)_______
            (__)       )/
                ||----w |
                ||     ||
$

a video tutorial related

[youtube https://www.youtube.com/watch?v=HVqGVVdUFag?rel=0&w=560&h=315]

DEBUG Method Development . LOG.0.2

method to downgrade debian from a unstable tree to stable tree

step 1
put the following content in /etc/apt/preferences.d/default
Package: *
Pin: release a=stable
Pin-Priority: 1001

step 2
make your sources.list to stable pointers.
step 3
apt-get update
apt-get upgrade
next do sensibly


To Fix Things, work on a stable system and chroot to the broken system
The command “ar” can be used to extract files from debian binary package
export PYTHONPATH=/usr/lib/python2.7 for debian related for showing python module path related.

the above content may not be accurate.