>chage :-
chage (1) - change user password expiry information
amaresh@eOdissa-desktop:~$ chage -l amaresh
Last password change : Jul 08, 2009
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
>seq:-
seq (1) - print a sequence of numbers
amaresh@eOdissa-desktop:~$ seq 1 4
1
2
3
4
amaresh@eOdissa-desktop:~$ seq 1 2 6
1
3
5
amaresh@eOdissa-desktop:~$ seq 6
1
2
3
4
5
6
amaresh@eOdissa-desktop:~$ seq 1 3 9
1
4
7
>vmstat :-
vmstat (8) - Report virtual memory statistics
usage: vmstat [-V] [-n] [delay [count]]
-V prints version.
-n causes the headers not to be reprinted regularly.
-a print inactive/active page stats.
-d prints disk statistics
-D prints disk table
-p prints disk partition statistics
-s prints vm table
-m prints slabinfo
-S unit size
delay is the delay between updates in seconds.
unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)
count is the number of updates.
Q:What command do you use to get the information about disk statistics?
Ans:- vmstat -d
amaresh@eOdissa-desktop:~$ vmstat -d
disk- ------------reads------------ ------------writes----------- -----IO------
total merged sectors ms total merged sectors ms cur sec
ram0 0 0 0 0 0 0 0 0 0 0
ram1 0 0 0 0 0 0 0 0 0 0
ram2 0 0 0 0 0 0 0 0 0 0
ram3 0 0 0 0 0 0 0 0 0 0
ram4 0 0 0 0 0 0 0 0 0 0
ram5 0 0 0 0 0 0 0 0 0 0
ram6 0 0 0 0 0 0 0 0 0 0
ram7 0 0 0 0 0 0 0 0 0 0
ram8 0 0 0 0 0 0 0 0 0 0
ram9 0 0 0 0 0 0 0 0 0 0
ram10 0 0 0 0 0 0 0 0 0 0
ram11 0 0 0 0 0 0 0 0 0 0
ram12 0 0 0 0 0 0 0 0 0 0
ram13 0 0 0 0 0 0 0 0 0 0
ram14 0 0 0 0 0 0 0 0 0 0
ram15 0 0 0 0 0 0 0 0 0 0
sr0 0 0 0 0 0 0 0 0 0 0
sda 129824 12599 1675591 430108 108073 14333 979288 2993424 0 36
Q:What command do you use to get the information about disk table?
Ans:-vmstat -D
amaresh@eOdissa-desktop:~$ vmstat -D
18 disks
5 partitions
129824 total reads
12599 merged reads
1675591 read sectors
430108 milli reading
107383 writes
13450 merged writes
966704 written sectors
2990880 milli writing
0 inprogress IO
366 milli spent IO
Q:What command do you use to get the information about no of forking ?
Ans:- vmstat -f
amaresh@eOdissa-desktop:~$ vmstat -f
11008 forks
>What command do you use to create swap space?
It's All about Professional work ... Some tips and tricks.. Feel free to Share !!!
Tuesday, 18 August 2009
Thursday, 13 August 2009
Unix Interview questions (sed)
> remove first column of a space delimited txt
how to remove the first column of a space delimited txt file? there are 12+ columns... what is the cleanest way?
>delete 7th column in unix,
>how to remove spaces in a string using sed.
>replace space or spaces in a line of a file with a single :
>sed : remove whitespace
>To remove all whitespace (including tabs) from left to first word, enter:
* s/ : Substitute command ~ replacement for pattern (^[ \t]*) on each addressed line
* ^[ \t]* : Search pattern ( ^ - start of the line; [ \t]* match one or more blank spaces including tab)
* // : Replace (delete) all matched pattern
how to remove the first column of a space delimited txt file? there are 12+ columns... what is the cleanest way?
cut -d\ -f4-
OR
cat | cut -d\ -f4-
OR
sed -e 's/^[ \t]*//' filename
OR
cat
OR
sed -e 's/^[ \t]*//' filename
>delete 7th column in unix,
cut -f1-6,8- filename
>how to remove spaces in a string using sed.
`echo "$infilename" | sed 's/^ *//;s/ *$//`
>replace space or spaces in a line of a file with a single :
sed -e 's/\s/:/g'
>sed : remove whitespace
sed 's/ $//' file1.txt > file2.txt # Remove the last space at eol
sed 's/ *$//' file1.txt > file2.txt # Remove all spaces at eol
sed 's/ *$//' file1.txt > file2.txt # Remove all spaces at eol
>To remove all whitespace (including tabs) from left to first word, enter:
cat | sed -e 's/^[ \t]*//'
Where,* s/ : Substitute command ~ replacement for pattern (^[ \t]*) on each addressed line
* ^[ \t]* : Search pattern ( ^ - start of the line; [ \t]* match one or more blank spaces including tab)
* // : Replace (delete) all matched pattern
Monday, 10 August 2009
Some Network Linux Commands...
How will you get only TCP protocol status in a network?
Ans:- # netstat -t
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 eOdissa-desktop.l:59156 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:59175 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:57170 px-in-f83.google.co:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:45271 pv-in-f100.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41356 a96-17-8-64.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:52631 a96-17-8-48.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41932 ord-qs2-n24.panther:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54438 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54442 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56950 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56949 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56948 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56947 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:53859 221x247x49x219.ap:34580 ESTABLISHED
How will you get only UDP protocol status in a network ?
Ans:- # netstat -u
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -u
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
How will you find only listening socket information?
Ans:- #netstat -l
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.152.128 * 255.255.255.128 U 0 0 0 tap0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
192.168.0.0 192.168.152.129 255.255.0.0 UG 0 0 0 tap0
172.16.0.0 192.168.152.129 255.240.0.0 UG 0 0 0 tap0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
How will you get the class of any IP ?
Ans:- ipcals ( install apt-get install ipcalc in debian linux)
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# ipcalc 192.168.1.143
Address: 192.168.1.143 11000000.10101000.00000001. 10001111
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000
HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001
HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110
Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111
Hosts/Net: 254 Class C, Private Internet
root@eOdissa-desktop:/home/amaresh/Documents/Testing#ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
Address: 192.168.0.1 11000000.10101000.0 0000000.00000001
Netmask: 255.255.128.0 = 17 11111111.11111111.1 0000000.00000000
Wildcard: 0.0.127.255 00000000.00000000.0 1111111.11111111
=>
Network: 192.168.0.0/17 11000000.10101000.0 0000000.00000000
HostMin: 192.168.0.1 11000000.10101000.0 0000000.00000001
HostMax: 192.168.127.254 11000000.10101000.0 1111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.0 1111111.11111111
Hosts/Net: 32766 Class C, Private Internet
Subnets after transition from /17 to /18
Netmask: 255.255.192.0 = 18 11111111.11111111.11 000000.00000000
Wildcard: 0.0.63.255 00000000.00000000.00 111111.11111111
1.
Network: 192.168.0.0/18 11000000.10101000.00 000000.00000000
HostMin: 192.168.0.1 11000000.10101000.00 000000.00000001
HostMax: 192.168.63.254 11000000.10101000.00 111111.11111110
Broadcast: 192.168.63.255 11000000.10101000.00 111111.11111111
Hosts/Net: 16382 Class C, Private Internet
2.
Network: 192.168.64.0/18 11000000.10101000.01 000000.00000000
HostMin: 192.168.64.1 11000000.10101000.01 000000.00000001
HostMax: 192.168.127.254 11000000.10101000.01 111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.01 111111.11111111
Hosts/Net: 16382 Class C, Private Internet
Subnets: 2
Hosts: 32764
How will you monitor your LAN IP?
Ans:- iptraf (use apt-get install iptraf in debian linux)

How will you get your bandwidth usages of your interface by host ?
Ans:- iftop
Ans:- # netstat -t
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 eOdissa-desktop.l:59156 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:59175 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:57170 px-in-f83.google.co:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:45271 pv-in-f100.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41356 a96-17-8-64.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:52631 a96-17-8-48.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41932 ord-qs2-n24.panther:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54438 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54442 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56950 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56949 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56948 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56947 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:53859 221x247x49x219.ap:34580 ESTABLISHED
How will you get only UDP protocol status in a network ?
Ans:- # netstat -u
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -u
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
How will you find only listening socket information?
Ans:- #netstat -l
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.152.128 * 255.255.255.128 U 0 0 0 tap0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
192.168.0.0 192.168.152.129 255.255.0.0 UG 0 0 0 tap0
172.16.0.0 192.168.152.129 255.240.0.0 UG 0 0 0 tap0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
How will you get the class of any IP ?
Ans:- ipcals ( install apt-get install ipcalc in debian linux)
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# ipcalc 192.168.1.143
Address: 192.168.1.143 11000000.10101000.00000001. 10001111
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000
HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001
HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110
Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111
Hosts/Net: 254 Class C, Private Internet
root@eOdissa-desktop:/home/amaresh/Documents/Testing#ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
Address: 192.168.0.1 11000000.10101000.0 0000000.00000001
Netmask: 255.255.128.0 = 17 11111111.11111111.1 0000000.00000000
Wildcard: 0.0.127.255 00000000.00000000.0 1111111.11111111
=>
Network: 192.168.0.0/17 11000000.10101000.0 0000000.00000000
HostMin: 192.168.0.1 11000000.10101000.0 0000000.00000001
HostMax: 192.168.127.254 11000000.10101000.0 1111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.0 1111111.11111111
Hosts/Net: 32766 Class C, Private Internet
Subnets after transition from /17 to /18
Netmask: 255.255.192.0 = 18 11111111.11111111.11 000000.00000000
Wildcard: 0.0.63.255 00000000.00000000.00 111111.11111111
1.
Network: 192.168.0.0/18 11000000.10101000.00 000000.00000000
HostMin: 192.168.0.1 11000000.10101000.00 000000.00000001
HostMax: 192.168.63.254 11000000.10101000.00 111111.11111110
Broadcast: 192.168.63.255 11000000.10101000.00 111111.11111111
Hosts/Net: 16382 Class C, Private Internet
2.
Network: 192.168.64.0/18 11000000.10101000.01 000000.00000000
HostMin: 192.168.64.1 11000000.10101000.01 000000.00000001
HostMax: 192.168.127.254 11000000.10101000.01 111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.01 111111.11111111
Hosts/Net: 16382 Class C, Private Internet
Subnets: 2
Hosts: 32764
How will you monitor your LAN IP?
Ans:- iptraf (use apt-get install iptraf in debian linux)

How will you get your bandwidth usages of your interface by host ?
Ans:- iftop

Monday, 3 August 2009
JOb for .Net as well as C/C++
Hi,
We have 8 positions for .Net in our team (2 – 6 yrs experience).
Kindly refer your friends who have worked on .net desktop applications.
WPF, WCF, Silverlight, XBAP will be added advantage.
Also we have 5 openings for linux, c, c++ with network programming skills ( 2- 6 yrs). Kindly refer for this as well.
Please forward this to your friends.
CV’s can be sent to kmjeetendra@tycoint.com
Thanks & Regards
Jeet
We have 8 positions for .Net in our team (2 – 6 yrs experience).
Kindly refer your friends who have worked on .net desktop applications.
WPF, WCF, Silverlight, XBAP will be added advantage.
Also we have 5 openings for linux, c, c++ with network programming skills ( 2- 6 yrs). Kindly refer for this as well.
Please forward this to your friends.
CV’s can be sent to kmjeetendra@tycoint.com
Thanks & Regards
Jeet