Feeds:
Posts
Comments

Testing Articles

Living Life as Tester

Ugly Baby Syndrome

Screen command

Screen, this command might not be well known to many people but but its one of those programs that you just can’t stop using once you’ve started. Previously I used VNC to connect the remote servers, but now i have stopped using VNC. Now I am using SCREEN on a regular daily basis and it’s really easy to use.

Screen program provides the following functionality:

  • Remote terminal session management (detaching or sharing terminal sessions)
  • Unlimited windows (unlike the hardcoded number of Linux virtual consoles)
  • Scrollback buffer (not limited to video memory like Linux virtual consoles)
  • Copy/paste between windows
  • Split terminal (horizontally) into multiple regions
  • Locking other users out of terminal
  • Screen is an easy way to allow processes to continue running after the session is terminated, if you lose connection screen will save your spot

Following is the content of my ~/.screenrc file
************************************************************
startup_message off
vbell off
caption always “%{= bb}%{+b w}%n %h %=%t %c”
hardstatus alwayslastline “%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<”
activity “Activity in %t(%n)”
shell -/bin/bash
************************************************************
Screen Commands

screen Start screen

screen -x Connect to an existing screen session

screen -d detaching a screen session

screen -r reattaching the screen session

Ctrl+a c New window

Ctrl+a n Next Window

Ctrl+a p Previous Window

Ctrl+a ” Select window from list

Ctrl+a Ctrl+a Previous window viewed

Ctrl+a <0-9> Select the numbered window

Ctrl+a A Set window title

Ctrl+a K Kill window

Ctrl+a d Detach screen from terminal

Ctrl+a x Lock Session

Ctrl+a : Goto screen command prompt

Ctrl+a ? Show key binding/command names

Ctrl+s Pause the output on screen

Ctrl+q Resume the output on screen

First Indian football team won Nehru Cup, then Indian Hockey Team won the Asia cup and then it was the turn of Indian cricket team, They won the 20-20 World cup and then Vishwanathan Anand became the World Chess champion. All these 4 big events happened in just in a span of almost one month. Isn’t it the CHAK DE INDIA effect?

August 29, 2007 – Football Nehru Cup, India never reached finals of Nehru cup before, and this time they won this title be defeating Syria by 1-0.

September 9, 2007 – Hockey Asia Cup, India started this tournament with a win of 1-0 on China. Later, India played at its best while thrashing Sri Lanka with 20-0, Thailand with 16-0. In final, they performed superbly and won the title by defeating Korea with 7-2. India ended the tournament with 57 goals and just 5 goals against them without a single defeat. Isn’t it unbelievable?

September 24, 2007 – Cricket 20-20 World Cup, I am a big fan of cricket but due to poor performance of India since last year, i lost interest in cricket and when India was out from ODI world cup 2007 in the first round, i just stopped the watching Indian cricket matches, i thought its very hard for Indian cricket team to come back. But the Indian cricket team proved me (and of course others also) wrong very soon. In 20-20 world cup, they were playing like champions, Sometimes luck also favored them and they WON the 20-20 world cup. They won this title by defeating Pakistan, South Africa, England and our world champion Australia.

September 30, 2007 – Vishwanathan Anand became the World Chess champion, after winning the global tournament in Mexico.

All this happened just after CHAK DE INDIA was released, I think that all the teams must have followed what SRK told in the movie.
“Play for India first, then for the team, if anything is still left then play for yourself”

I hope India will continue this Chak De India effect.

CHAK DE INDIA!………

chak_de_india1.png

Linux Cut command

Cut Command
————

Divide a file into several parts (columns)

syntax:
cut [-b] [-c] [-f] list [-n] [-d delim] [-s] [file]

Examples:
——–

1. Let say you have a file test.txt which has colon(:) seperated data

406378:Sales:Itorre:Jan
031762:Marketing:Nasium:Jim
636496:Research:Ancholie:Mel
396082:Sales:Jucacion:Ed

If you want to print first set of data from each row, you can use cut command as follow:

cut -d”:” -f1 test.txt

If you want to print just columns 1 to 6 of each line (the employee serial numbers), use the -c1-6 flag, as in this command

cut -c1-6 test.txt

Linux Tips

Display the top most process utilizing most CPU (top -b 1)
Show the working directory of a process ? (pwdx pid )
Display the parent/child tree of a process ? (ptree pid )
Display the no.of active established connections to localhost ? (netstat -a | grep EST)
How to create null file ? (cat /dev/null > filename1)
Display top ten largest files/directories ? (du -sk * | sort -nr | head)
Display disk usage (du -h)
How to save man pages to a file ? (man | col -b > filename )
Display the files in the directory by file size ? (ls -ltr | sort -nr -k 5)
Display the processes, which are running under yourusername ( ps -aef | grep username)
Display the all files recursively with path under current directory ? ( find . -depth -print)
Display the Disk Usage of file sizes under each directory in currentDirectory ? (du -k . | sort -nr)
List the files in current directory sorted by size ? (ls -l | grep ^- | sort -nr)

Today i came across a problem in solaris. The problem was that while starting my application server, it was throwing an error “Address already in use”.

My app server is a java process and there are many other java process which are running on my zone. But the issue is, how may i know that which java process is using that particular port?

I followed following steps:
1. List all the java process running on my zone ( ps -eaf |grep vagrawal| grep java )
2. Go through each java process and check if it using that particular port ( pfiles $pid|grep 1182 )
(here $pid is the process id of the java process and 1182 is the port number of which i am looking for)

Above method works fine but it is bit a long process, as i have to run step 2 for all java processes, so i ran a folowing command on my console:

for pid in `ps -eaf|grep vagrawal|grep java|grep -v grep|awk -F” ” ‘{print $2}’`; do echo ================= $pid >>myfile; pfiles $pid|grep 1182 >>myfile; done

above loop goes through all the java process and write there process IDs in the file ‘myfile’, and i am also checking usage of my port for that particular process (using pfiles) and prints its output in same file.

Finally there would be a single process which would be using that particular port. Now I can find easily that process in ‘myfile’

Now i have process ID of the process which is occupying my port, and i can kill that by kill -9 pid

Puzzle links

http://puzzles-tricks.blogspot.com/

http://www.brainvista.com/bv/index.php

http://www.allinterview.com/Interview-Questions/Puzzles.html

http://www.techinterview.org/index.html

Follow

Get every new post delivered to your Inbox.