Unix commands

Unix commands Interview questions

unix commands :-


1.Search a file from root directory.(filename = sample.txt)
  find / -name sample.txt

2.Display the numbers in sorted order
   sort -nu

3.Display the updated lines in file
  tail -f filename

4.How to zip a Directory
  gzip -r /hom/bea/app

5.How to kill a prosess.
   kill -9 pid

6.Display all java process in unix.
    ps -ef |grep java

7.How to delete 10 lines in vi editor.
    10dd

8.How to search a string and replace tin  vi editor.
     :"%s/old string /new string/ gi"

9.How to search a string in vi editor from bottom to top.
     ?string name

10.How to insert a line above the current line in vi editor .
      esc+o

11.How to rename a file .
     mv file1 file2

12. copy the content one directory to another directory.
        cp -r dir1/file1 dir2/file2

13. How can delete blank lines in directory.
      grep -v "^$" sample > temp
      mv temp sample

14.How can replace astring in unix.
     sed "s/oldstring/newstring/g" filename

15.Syntax for zip and unzip afile.
     gzip filename
     guzip filename.gz

16.How can display top 10 disk usage files.
  du -sh *|sort -nr|head -10

17.How to retrive a field in a file.
   cut -f 1,2 stud.

18.what is command search a string in a file.
     grep

19).How to goto the end of the line in Vieditor?
     G

20).Copy 10 line in vi editor?
      10yy

21).How to go to insert mode in vi editor?
      Esc+i

22).How to search a string in a file(filename=sample,string=weblogic)?
     grep weblogic sample

23).How to copyfile from one unix to other unix system and syntax (file=sample.txt,target host=192.168.11.128,target file path=/home/bea)?
     scp -rp sample.txt username@192.168.11.128:/home/bea

24).Copy file from path to other tree structure is given below?

25).How to find out CPU utiligation?
      top

26).How to execute ascript using nohup(script name=startweblogic.sh)?
      nohup ./startWeblogic.sh &

27).Which command is used to search and replace a string?
       sed

28).wich command is used to search astring in multiple files?
      fgrep

Weblogic Server Basic Components

Below are the basic components of weblogic server


Domain:

Domain is a group of weblogic server resources like admin server, managed server, jms, connection pool, data sources etc or whatever the resource you know of weblogic server since domain is the basic unit you have to create after installation and everything created and configured under a domain. 

It can be possible to create multiple domains from a single installation and each domain has it's own resources but this is recommended only on development environment where you may want to test different applications or different customer applications on different domain. All domains are independent of each other. 


Admin Server & Admin Console

Admin server is a central unit which is used to configure and monitor a domain resources. it provides a browser or GUI based console called admin console for configuration and monitoring of the domain resources. 

Admin server is also a server instance which have all the capabilities just like we have on managed servers ( see next post for managed server ) but since it's a central repository for the domain configuration so it's not recommended to used it as a managed server but you can use it as a managed server on non production environments for testing purpose.


Managed Server

A managed server is an instance of weblogic server which is used to host ( deploy in terms of weblogic ) your applications and associate other domain resources with that. For example you create and deploy jar, ear, ear etc files and deploy on managed servers and after that create connnection pools, data source and associated with your managed server to let your application connect and get connection from database.

When you start a managed server it connects to admin server to get configuration and other deployment settings.

A domain can have multiple managed servers ( no upper limit of managed servers, you can create as many as you want only considering your hardware configuration ). They all can be independent servers or can be grouped into cluster to get scalability, availability, maintainability etc ( see below for cluster ).


Machine


A machine is a logical representation of the physical machine (computer) that hosts one or more WebLogic Server instances. or in a simple word you can say Machine is a host on which your weblogic server is running. When you create and configure a machine you need to configure node manager and for that you need to define the host on which your node manager is running ( actual host or called machine ) as well as node manager port ( see below for node manager )


Node Manager

Node Manager is a Java utility or service which runs as a separate process from WebLogic Server and allows you to perform common operations tasks related with Managed Servers  
regardless of its location with respect to its Administration Server. 

Use of Node Manager is optional but it provides valuable benefits if your WebLogic Server environment hosts applications with high 

Node manager is used to start or stop remote managed servers, remote managed servers means the servers distributed or configured on different machines or host, like In case of production where we ran multiple managed servers across different hosts in a single domain to get high availability, in that case all servers are distributed across multiple hosts however control via single admin console. make sure you have node manager running on each host and a machine configured via admin console for each host and respective managed server(s) associated with respective machine.

It provides the capability to auto health checking of managed servers and restart it automatically in case any server goes down.

Note :- Node manager is a independent java based utility which has not any dependency on weblogic or vice versa, so in case your node manager goes down there is no impact on your weblogic server running instances.


Cluster

Cluster is a group of manager servers work together to achieve high availability, scalability and for lots of other benefits. It appears to client as a single instance. All clustered servers can be on same or distributed across difference machines ( but in same cluster and domain ).   


Use of cluster provides the benefits of scalability, maintainability, high availability, load balancing, failover capabilities etc.

Thread Dump

Thread Dump:

  1. What is Thread dump?
  2. When we will take Thread dump? (Scenarios)
  3. How  Many  ways take Thread Dumps
  4. Thread Dump Generating Procedure
  5. What can I Analysis with Thread Dump?
  6. How can I analysis thread dump?
  7. Actions taken for Issue resolving
  8. References

 Coming to step by step learning:
--------------------------------

What is Thread dump?

Thread Dump is a textual dump of all active threads and monitors of Java apps running in a Virtual Machine.

When we will take Thread dump? (Scenarios)

1.  Scenario 1: when server is hang Position, i.e. that time server will not respond to coming requests.

2.  Scenario 2: While sever is taking more time to restart

3.  Scenario 3: When we are Getting exception like “java.lang.OutOfMemoryException”

4.  Scenario 4: Process running out of File descriptors. Server cannot accept further requests because sockets cannot be created

5.  Scenario 5: Infinite Looping in the code


How many ways take Thread Dumps?

Many types we have to take a Thread dumps. As per your flexibility you can choose one Procedure. For analyzing take dumps some Intervals (like every 10mins, 10mins etc.).



Generating Dump Talking Procedures

1. Take Thread dump from Console by Using of below command
    $kill -3 PID
   (For Getting PID, Use this Command ps –ef | grep “java”)
Here The Output of the Thread Dump will be generated in the Server STDOUT.
(Note: If a process is not responding to kill -3 then it’s a JVM bug.)


2. Generation Thread Dump via Admin Console

a.  login to Admin Console(with Admin Username/Password)
b.  Click on Server, after choose your server
c.  Goto Monitoring TAB
d.  Goto Threads TAB, after click on “Dump Thread Stack” Button
e.  Now you can view the all the Threads in Same page
f.  Copy and paste in a txt file.

3.  We can Collect Thread Dump Using “WebLogic.Admin” which is deprecated, but still available or may be available in near future as well As i think because it is one of the best debugging utility for Admins.

  java WebLogic.Admin -url t3://hostname: port -username Weblogic -password Weblogic THREAD_DUMP


This Thread Dumps will be generated in Servers STDOUT file


4. Getting Thread Dumps by using Jstack Utility

    a.jstack –m (to connect to a live java process)

    b. jstack –m [server_id@]
                (to connect to a remote debug server)
    (-m Means print both java and native frames (mixed mode)) 

5. By Using WLST Script, can contain extension of (.py)

connect(‘weblogic’,'weblogic’,'t3://hostname:port′) cd (”Servers’) ls()cd (‘AdminServer’) ls() threadDump()

 Execute this Script in console. 

What can I Analysis with Thread Dumps?
We need to analyze the thread dumps for analyzing running threads and their states to identifying.

How can I analysis thread dumps?

For analyze thread dumps we have lots of tools to understand easily thread states

1.  samurai tool :

    In this tool you can identify all the Thread states by     identifying colors. We need to take care about Deadlocks and waiting state threads.

   More Details:

    $ java -jar samurai.jar

     After running we will get a Screen like below

      Goto Thread dump tab
    When Samurai detects a thread dump in your log, a tab named "Thread Dump" will appear.

 You can just click "Thread dumps" tab to see the analysis result. Samurai colors idle threads in gray, blocked threds in red and running threds in green. There are three result views and Samurai shows "Table view" by default. In many case you are just interested in the table view and the sequence view. Use the table view to decide which thread needs be inspected, the sequence view to understand the thread's behavior. You should takecare especially threds always in red.


2.  TDA Tool :


Actions taken for Issue resolving

1.  Classic Dead Locks : Look for the threads waiting for monitor entry

For Example :

"ExecuteThread: '95' for queue: 'default'" daemon prio=5 tid=0x411cf8 nid=0x6c waiting for monitor entry [0xd0f80000..0xd0f819d8]
    at weblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java:766)
    at weblogic.jdbc.common.internal.ConnectionEnv.destroy(ConnectionEnv.java:590)
Reason: The above thread is waiting to acquire lock on Resource Allocator object. The next step is to identify the thread that is holding the Resource Allocator object
"ExecuteThread: '0' for queue: '__weblogic_admin_rmi_queue'" daemon prio=5 tid=0x41b978 nid=0x77 waiting for monitor entry [0xd0480000..0xd04819d8]
    at weblogic.jdbc.common.internal.ConnectionEnv.getPrepStmtCacheHits(ConnectionEnv.java:174)
    at weblogic.common.internal.ResourceAllocator.getPrepStmtCacheHitCount   (ResourceAllocator.java:1525)
Reason: This thread is holding lock on source Allocator object, but is waiting for Connection Env object. This is a classic deadlock.

     

2.  Threads in wait() state:
   A sample dump:

"ExecuteThread: '10' for queue: 'SERV_EJB_QUEUE'" daemon prio=5 tid=0x005607f0 nid=0x30 in Object.wait() [83300000..83301998]
  at java.lang.Object.wait(Native Method)
  - waiting on (a weblogic.ejb20.pool.StatelessSessionPool)
at weblogic.ejb20.pool.StatelessSessionPool.waitForBean(StatelessSessionPool.java:222)

Reason: The above thread would come out of wait() under two conditions
 (Depending on application logic)
1) One of the thread available in the execute queue pool would call notify() on this object when an instance is available. (If the wait() is indefinite).
  This can cause the thread to hang for ever if server never does a notify() to this object.
2) If the timeout exceeds, the thread would throw an exception and back to execute queue thread pool.

WebLogic Topics

  1. Introduction to WebLogic:
-------------------------------
  • WebLogic Server Domains
  • Directory Structures
  • Install WebLogic Server
  • The Configuration Wizard
  • The Configuration Wizard: Creating A New Domain
  • Starting The Administrative Server
  • The Administration Console
  • Administrative Tasks
  • Setting the Domain Environment
  • Automatically Starting Admin Servers
  • Managed Servers
  • Password boot.properties.
  • Examining Server Status.
  • Shutting Down Servers.
  • Start Scripts.
  • config.xml.


  1. WLST:
-------
  • The WLST
  • MBeans And JMX Administration
  • MBeans And WLST
  • Starting WLST
  • Simple WLST Commands
  • WLST Is Hierarchical
  • Navigating WLST
  • MBean Operations
  • Other WLST Commands
  • Scripting With WLST
  • Recording WLST Scripts
  • Sample Recorded Script


  1. WebLogic Logging:
----------------------
  • Introduction
  • WebLogic Logging Services
  • Java Logging API
  • Log4j
  • Specifying the Logging Implementation
  • Message Severity
  • WebLogic Server Logs
  • HTTP Access Log
  • JMS Log
  • Domain Log
  • Viewing Logs





  1. Application Structure:
--------------------------
  • Java Web Application Architecture
  • J2EE Architecture
  • Web Application Programming Model MVC
  • An MVC Example
  • What is Application Assembly?
  • Web Module
  • EJB Modules
  • Enterprise Application Modules
  • Accessing Web Applications


  1. Deployment:
---------------
  • The Process
  • Deployment Overview
  • Archive Vs Expanded Directory
  • Default Deployment Names
  • Deployment Methods
  • Starting/testing/Monitoring/Updating/stopping/Deleting an Application
  • Editing Deployment Descriptors

  1. Deployment Modes:
-----------------------
  • Using Command Line Deployment
  • T3 Protocol Overview
  • wldeploy Ant Task
  • WebLogic Scripting Tool (WLST)
  • Deployment Plans

  1. JDBC:
-------
  • Types of JDBC Drivers
  • Working with a Database via JDBC (Client side)
  • The Need for Connection Pooling
  • Connection Pooling and Data Sources
  • Connecting with Data Source
  • Steps in using Connection Pooling
  • Admin Tasks for Connection Pools and Data Sources
  • JDBC Driver Support in WebLogic Server
  • Database Access Using WebLogic
  • Working with Data Sources
  • Creating a Data Source
  • Editing Data Source Properties
  • Monitoring Data Source and Connection Pools.







  1. JMS:
-----

  • The Trouble with RMI/IIOP
  • Messaging to the Rescue
  • Messaging Features
  • Publish/Subscribe
  • Point-to-Point
  • Java Messaging Service
  • Terminology
  • Durable Subscription
  • Deployment Descriptor Entry
  • Binding the Queue or Topic
  • Transactions & Guaranteed Delivery
  • WebLogic JMS Server
  • Creating a JMS Server
  • Creating a Connection Factory
  • Creating a Topic
  • Threshold and Quota
  • Configuring Threshold and Quota
  • Creating a Distributed Topic/Queue
  • Creating a Distributed Topic
  • Monitoring JMS in WebLogic
  • Messaging Bridge


  1. NodeManager:
------------
  • Node Manager Overview
  • Node Manager Functionality & Configuration
  • Starting/Restarting/shutting an Administration Server from Node Manager
  • Starting/Restarting/shutting a Managed Server from Node Manager
  • Creating a Machine
  • Adding Server Instances To a Machine
  • Starting The Node Manager.
  • Monitoring Managed Servers
  • Node Manager Logs and Configuration Files.


  1. Security:
---------
  • WebLogic Server Security
  • Authentication / Authorization
  • Resources That Can Be Secured
  • Authentication Mechanisms
  • Overview: Security Tasks For Securing Resources
  • WebLogic Security Realms
  • Configuring A User Registry
  • The Embedded LDAP Server
  • Managing Users/Groups
  • User Lockout
  • Managing Roles
  • Securing A Resource
  • WebLogic Server Policies
  • Specifying A Policy Condition
  • Policies And Roles
  • Creating A Scoped Role
  • Declarative Security
  • Example: Securing A Web Resource
  • Example: Securing A Web Resource Specifying Roles
  • Example: Securing A Web Resource Specifying Constraints
  • Example: Securing A Web Resource Specifying Constraints
  • Example: Securing A Web Resource Auth Method
  • Example: Securing A Web Resource Auth Method
  • Example: Securing A Web Resource Map Roles
  • Encryption
  • SSL
  • Public Key / Private Key Encryption
  • Secure Communication Over The Web - SSL
  • SSL And WebLogic Server
  • Creating A Digital Certificate
  • Dealing With A CA
  • Configuring WebLogic Server SSL: Keystores
  • Configure WebLogic SSL Settings


  1. Clustering:
-----------
  • What Is Clustering?
  • What Components Can Be Clustered?
  • Basic Cluster Diagrams
  • The Load Balancer
  • Web Container Load Balancing
  • Horizontal Vs. Vertical Clustering
  • Clustering WebLogic Server
  • WebLogic Cluster Requirements
  • Create A Cluster
  • Multicasting vs. Unicasting
  • Configure Application Resources
  • Deploy Applications To The Cluster
  • Configure A Load Balancer
  • Load Balancer Options
  • Hardware Load Balancers
  • Proxy Plug In Load Balancers
  • HttpClusterServlet Load Balancer
  • Session State
  • Clustered Session State
  • Session State Strategies
  • In-Memory Replication
  • Configuring Session State Replication
  • JDBC Session Persistence
  • JDBC Multi Data Sources
  • Creating A Multi Data Source


  1. Performance Tuning:
-------------------
  • Response Time
  • The significance of throughput
  • Response Time Curve
  • Think time
  • Saturation
  • Response time at system saturation
  • Basic Tuning Methodology
  • Areas To Tune
  • Tuning Hardware
  • Tune The Operating System
  • Tune The JVM
  • JVM Choices
  • Memory Performance Concerns
  • Client or Server VM
  • The Heap
  • Configure The Heap Size
  • Allocation Failure
  • Garbage Collection
  • Analyzing Verbose GC - Sun
  • Verbose GC - JRockit
  • Thread Local Heap (TLH)
  • Memory Tuning Goals
  • Effect of Initial Heap Size on GC
  • Controlling the GC Timings
  • Optimizing GC
  • Self Optimizing Throughput Collector
  • JRockit Management Console
  • JRA Recording
  • Tuning WebLogic Server
  • Thread Settings
  • Monitoring Threads
  • Connection BackLog
  • Tuning The Back End