Bash – netstat ( network statistics related )

commandline session

$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 – netstat ( network statistics related ) – Video Tutorial Related

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


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 <==
Nov 10 20:11:08 debian sshd[2541]: Server listening on 0.0.0.0 port 22.
Nov 10 20:11:08 debian sshd[2541]: Server listening on :: port 22.
Nov 10 20:11:15 debian sshd[2541]: Received signal 15; terminating.

==> 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


Handling File Name With Space

commandline session

$ > test file
Usage: file [-bchikLlNnprsvz0] [--apple] [--mime-encoding] [--mime-type]
            [-e testname] [-F separator] [-f namefile] [-m magicfiles] file ...
       file -C [-m magicfiles]
       file [--help]
$ls
test
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
$> "test file"
$ls
test  test file
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test file
$> test
test       test file
$> test  newfile
bash: newfile: command not found
$> test newfile
$ls
test  test   test file  test newfile
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test file
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test newfile
$> test  newfile
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test file
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test newfile
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:01 test  newfile
$

the following video tutorial content may not be fully accurate


watch – execute a program periodically

commandline session

following commandline session may not be accurate.

$vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  0      0 2246368  32720 497284    0    0   217    10  236  436  3  1 92  3
$watch vmstat
$watch -n 0.5 vmstat
$watch -n 0.5 iostat
$watch -n 0.5 iostat
$iostat
Linux 3.12.0 (debian) 	Friday 08 November 2013 	_x86_64_	(2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           6.64    0.01    2.31    1.80    0.00   89.24

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               8.82       272.09        51.03     696015     130532

$

the following video tutorial content may not be accurate


GNU/Linux command : Changing Passwords

commandline session

$sudo -
[sudo] password for jeffrin:
sudo: -: command not found
$
$su -
Password:
root>passwd -e jeffrin
passwd: password expiry information changed.
root>exit
logout
$login jeffrin
login: Cannot possibly work without effective root
$sudo login jeffrin
[sudo] password for jeffrin:
sudo: Account or password is expired, reset your password and try again
Changing password for jeffrin.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
Password:
Last login: Sat Nov  2 22:01:20 IST 2013 on pts/0
Linux debian 3.11-1-amd64 #1 SMP Debian 3.11.5-1 (2013-10-17) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
No mail.
$exit
logout
$sudo -s
[sudo] password for jeffrin:
Sorry, try again.
[sudo] password for jeffrin:
sudo: 1 incorrect password attempt
$su -
Password:
root>passwd jeffrin
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root>

following video tutorial content may not be accurate

GNU/Linux Commands for Beginners : alias

this tutorial content may not be accurate




Copyright © 2009,  2010,  2011,  2012,  2013, 2014     BeautifulWork Project    e-mail:  ahiliation@yahoo.co.in
BeautifulWork Project comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.