Monday, December 26, 2011

Session2 strace and ltrace Dec 21st, 2011 3.00 PM

     Second session was presided over by Mr.Vijay Guru and the complete session was video taped by Mr.Kamesh Jayachandran for future reference. The session covered the following topics:
  • strace
  • ltrace
Initially let us have a look into the UNIX system architecture.

Kernel
               It is an operating system software which is used to control the entire hardware.

System Calls
               It is like a bridge or interface between the kernel and the user.The build-in functions used for this purpose is called system calls.

Library Routines
               These are also build-in functions which are stored separately and accessed when ever necessary.

Shell
               Shell is a type of special application which is used to provide an interface for other applications to run.

strace
               It is a debugging utility used to trace all the system calls during a process. It can be used to find the actual working of a process.
               We can use many different options along with strace. Some of them are:
-c     it is used to tabulate all the errors and system call made by a process
        check, strace -c sort filename





-o     is used to save the output of strace to a file specified






-p     this option is used to strace based on the process-id

  1. open a new terminal B
  2. find the process id of the terminal by echo $$
  3. say 12345
  4. in terminal A type strace -p 12345
  5. now terminal A will  wait for input in terminal B
  6. once you enter some data in terminal B strace will show the system calls in process 12345
-f     this is used to trace child process

-ff    this option is used along with -o  option, it will create a file named filename.pid each time where .pid is the process id

-r     this is used to print the relative time-stamp for each process occurring concurrently

-t     prints the time-stamp for each and every process

-tt    prints the time-stamp for each and every process along with microseconds

-T    prints the time taken to complete each system call

-e trace=systemcall   is used to trace a specific system call

-s string-length is used to specify the size of the output string


ltrace:

     All the option in strace work pretty much same in ltrace. Some other options include:

-n indent-length    this option is used to indent all the sub calls by spaces of the given size(indent-length)
 


-S    used to display both system calls and library calls


Also while using LINUX commands the options can be combined together as follows:

      sort -nr filename instead of sort -n -r filename

     where -n indicates numeric field and -r indicates reverse order sort(descending order)

Thats it and we'll meet after some other session.... bye....

Monday, December 19, 2011

Day1 Training in My Company - Dec 19th, 2011 Monday 4.00 PM

     Day1 training in my company began at 4 in the evening on 19th of December 2011. Mr. Kamesh Jayachandran took over the session on the topic of  SMTP( Simple Mail Transfer Protocol ). I had the training along with my newly joined friends (freshers). Some experienced guys in the company also joined the training session. We discussed about the various topics:

  • SMTP protocol
  • DNS
  • UNIX commands
  • Concept of relaying and more...
     Then we had a small demonstration about anonymous mailing and how to be cautious about hackers. Now let us have a small demonstration about it.

  • Use nslookup command
  • Then set q=mx 
  • Now type gmail.com (you can use any mail server)
  • Select any one option from mail exchanger let's take alt4.gmail-smtp-in.l.google.com



  • Give exit now
  • Type telnet alt4.gmail-smtp-in.l.google.com 25 (25 is SMTP port for email routing)
  • You will get a message as 'Connected to alt4.gmail-smtp-in.l.google.com' 


  • Say helo xyz.com
  • You will get a message as '250 mx.google.com at your service'
  • Type mail from: <rajnikanth@gmail.com> (don't leave out angled brackets <, >)
  • You will get '250 2.1.0 OK' message
  • Now type rcpt to: <any valid email address>
  • You will again get '250 OK' message
  • Type data
  • '354 Go ahead' message will be displayed
  • Now type as follows
    • From: rajnikanth@gmail.com
    • To: the-same-valid-email-as-above
    • Subject: Hi
  • Now leave an empty line and press enter
  • Start typing your message now
  • To end typing the message place a '.' (dot) in a new line
  • You will get '250 OK'  message
  • Now quit




  • Now if the recipient opens the mail box, the false mail would have been dispatched (gmail may store it as a Spam mail for security reasons)






  • You can find out whether the mail is a genuine one or a fake by checking the full header of the mail, in gmail click show original option



     Lots of clarifications and lots of queries were raised. It was a very good discussion. As, this was my first sit-together since the time I was appointed in a firm (Dec 15th 2011), all sorts of vague questions rose in my mind. But the session took me to surprise and was so friendly. This continued for an hour and then it was time for tea.

     ( I got my IBM Think pad.. during this break.. I was eagerly awaiting for it.. Thanks a lot.. guys..)


     The the session continued for the freshers as the experienced guys left. We had large and small discussions about:
  • Quick Sort algorithm based on the book "Beautiful Code Leading Programmers Explain How They Think"
  • Clarifications for the queries that peeped out during the first half of the session
  • Great author "Donald Knuth" and his books http://en.wikipedia.org/wiki/Donald_Knuth
     Then we finally winded up at 6.40 in the evening....

That was a great session to participate...