Tuesday, March 3, 2009

Basic Interview Questions

  1. How many arguments shell script can take
    Ans: execute "getconf ARG_MAX" the output will tell you how many argument shellscript can take.

  2. How do you capture variable in shell script
    Ans: Using $1,$2 etc.

  3. What is difference between tomcat and jboss
    Ans: Tomcat is a pure servlet engine, with no EJB. JBoss supports EJB and JMS related stuff. JBoss is a full J2EE application server.. it supports the bulk of the J2EE spec. It is more common to refer to J2EE as a more complete reference of what an application server can and should include, of which Tomcat only implements a part, while the complete download of JBoss (including Tomcat) conforms to the full J2EE specification, and hence is amore "complete" application server.

  4. What is difference between sh file-name and ./file-name
    Ans: ./ can be executed only if the file has execute permission

  5. What is the command to check the free ports
    Ans: use “nmap”

  6. How do you reset password in mysql
    Ans: Start mysql with “mysql-safe –skip-grant-tables”

  7. What is the Default flag for "Kill"
    Ans: Default flag for kill is "TERM/-15" 

  8. I create a user, the user logs in but can't create files in his dir. Why? The dir permissions are ok.
    Ans: check quota, check if disk is full

  9. df and du show different values, why ?
    Ans: http://sysunconfig.net/aixtips/df_du_diff_out.txt

  10. How to implement round-robin load-balancing in bind (dns) ?
    Ans: Add two A records for the same hosts with different IP and set TTL as zero for them.

  11. Write a shell script to generate a HTML.

  12. What is the difference between hard link and soft links ? Atleast 2 differences.
    Ans:
    1. About inode: In a hard link, inode nos will be same for both files, but will have different names. Soft link is a file which links to the original file (equivalent to shortcut in Windoze)

    2. About filesystem location: Hard links cannot reside on different partitions/filesystems (why? bcos same inode), soft links can point to files in any location.

  13. What are the types of files in Linux ? How do u know a file type ?
    Ans:
    d = directory
    l = symbolic link
    s = socket
    p = named pipe
    - = regular file
    c= character (unbuffered) device file special
    b=block (buffered) device file special

  14. How to Replicate different databases to different slaves?
    Ans: either one of the following (Ref: http://www.databasejournal.com/features/mysql/article.php/10897_3355201_2)
    1. Do the following settings in master (my.cnf)
        binlog-ignore-db=test
        binlog-ignore-db=scratch
        binlog-do-db=catalog
        binlog-do-db=users
        binlog-do-db=sessions
    2. Do the following settings in slave (my.cnf)
        replicate-do-db=catalog
        replicate-ignore-db=test
        replicate-ignore-db=scratch
        replicate-do-db=test
        replicate-do-db=sessions

  15. What is SOA in DNS
    Ans: Statement Of Authority

  16. What is Exit code for Ctrl + C
    Ans: 130

  17. What to do if i am getting error "passwd: Authentication token manipulation error" while updating the root password
    Ans: chattr -i /etc/shadow

  18. What Could happen if /sys directory is not there?
    Ans: Your system might say "Couldnt open //dev/tty3" n/w wont be start. And system also gives error like "comp init: Id "c2" respawning too fast: disabled for 5 minutes"

  19. What to do if dh -h gives "df: cannot read table of mounted file systems: Is a directory"
    Ans: /etc/mtab is the file. check if there if something wrong with it. This error mostly come when /etc/mtab is the directory not the file. Delete the /etc/mtab and do "mount -a" this will resolve your issue.

  20. What is the difference between "/etc/bashrc" and "/etc/profile"
    Ans: The global /etc/profile and your own local  ~/.bash_profile are read when the shell is invoked as an interactive login shell, for example when you open a remote terminal session to someone else's machine, or when you log into your own machine without X Windows running, or when you hit ctrl-alt-F1 from X Windows to start a virtual terminal session.

    The global /etc/bashrc (if it exists) and your own local  ~/.bashrc is read when the shell is invoked as an interactive non-login shell, for example when you open up a terminal window in Gnome or KDE.

  21. How do I print the line in between 25 to 50 from abc.txt which is of 100 lines in it.
    Ans: tail -n +25 abc.txt | head -n 25

2 comments:

  1. How you can Run the cronjob which run on 1st and 3rd Saturday OR how to write the cronjob which will run on every alternate saturday.

    Ans: put the below line in your crontab
    0 1 1-7,15-21 6 /path/to/myscript

    Here we are considering 1st saturday falling between 1 to 7 and 3rd saturday will fall between 15-21.

    ReplyDelete
  2. Cronjob which will run every 15 Seconds.

    Ans: You can't go below one minute granularity with cron. What you can do is, every minute, run a script that runs your job, waits 15 seconds and repeats.

    ReplyDelete