Tuesday, September 24, 2013

Useful Unix File Finding Commands

Useful Unix File Finding Commands

Following are some bunch of commands that might be useful if you want to find files in unix/linux.

Large Files

Find files larger than 10MB in the current directory downwards…
find . -size +10000000c -ls
Find files larger than 100MB…
find . -size +100000000c -ls

Old Files

Find files last modified over 30days ago…
find . -type f -mtime 30 -ls
Find files last modified over 365days ago…
find . -type f -mtime 365 -ls
Find files last accessed over 30days ago…
find . -type f -atime 30 -ls
Find files last accessed over 365days ago…
find . -type f -atime 365 -ls

Find Recently Updated Files

There have been instances where a runaway process is seemingly using up any and all space left on a partition. Finding the culprit file is always useful.
If the file is being updated at the current time then we can use find to find files modified in the last day…
find  . -type f -mtime -1 -ls
Better still, if we know a file is being written to now, we can touch a file and ask the find command to list any files updated after the timestamp of that file, which will logically then list the rogue file in question.
touch testfile
find .  -type f -newer testfile -ls

Finding tar Files

A clean up of redundant tar (backup) files, after completing a piece of work say, is sometimes forgotten. Conversely, if tar files are needed, they can be identified and duly compressed (using compress or gzip) if not already done so, to help save space. Either way, the following lists all tar files for review.
find . -type f -name "*.tar" -ls
find . -type f -name "*.tar.Z" -ls

Large Directories

List, in order, the largest sub-directories (units are in Kb)…
du -sk * | sort -n
Sometimes it is useful to then cd into that suspect directory and re-run the du command until the large files are found.

Removing Files using Find

The above find commands can be edited to remove the files found rather than list them. The “-ls” switch can be changed for “-exec rm {}\;”=.
e.g.
find . -type f -mtime 365 -exec rm {} \;
Running the command with the “-ls” switch first, is always prudent to see what will be removed.
The “-ls” switch prints out summary information about the file (like owner and permissions). If just the filename is required then swap “-ls” switch for “-print”.

Wednesday, August 14, 2013

Difference between War, Jar & Ear

Difference between War, Jar & Ear


1.JAR : JAVA Archives and it allows aggregating many files into One.It usually hold java classes in lib.
JAR files (Java ARchive) allows aggregating many files into one, it is usually used to hold Java classes in a library. i.e. Math.jar 
(file with a .jar extension)

2.War(web archive)   This is Web Application archive which contains basic web application like servlet, jsp, html. This can be run on simple tomcat server
WAR files are similar to JAR files, except that they are specifically for web applications made from Servlets, JSPs, and supporting classes(file with a .war extension)


3.Ear (: Enterprise Archives)
An EAR file is an enterprise application deployed to an application server like WebLogic, WebSphere, JBOSS, etc. It might contain WARs, JARs, etc. 

EAR = WAR(Web module) + JAR(can be EJB module or application client module)
files with a .ear extension

Saturday, January 26, 2013

Too many files opened issue

How to solve too many files issue?

This issue occur in two areas
1. If Web server, App server and Data base servers residing in One machine, then you m ayget this error
2. If socket timed out not mentioned then this issue may this issue.

Using ulimit -a command, we will find how many sockets had that machine. In any machine 1024 is the maximum sockets.

Bottleneck identification:

Using netstat -a|grep WAIT|wc -l command we will find how many sockets opened by the application. If 1024 connection are utilized then we will get too many open files.

If you want know which server opened more socket, just use lsof -p <Process ID> for finding the sockets opened by that process.

Internal Process  of a socket: All HTTP requests internally used TCP connection. One TCP connection is one Socket in computer science language. So if you send n number of requests to the server , the server opens the socket to handle your requests but we need to close the sockets once your request got over other wise socket won't close, for this we need to mention the socket timed out.

Solutions:


For issue 1: Just increase the sockets using ulimit -Hn <Parameter> (Ex ulimit -Hn 2048)command, but it is not recommended , you have to discuss with your architect on this.

For issue 2: Just provide the socket time out in your server configuration file. In web server change the value in  uri_worker.property file

Wednesday, August 8, 2012

Websphere application server Admin ND 7.0, Online training


 Websphere application serve 8.5.5 Administration on linux, Online /classroom training
This course provides the student with the necessary skill set to handle all sorts of administrative tasks on WebSphere Application server 8.5.5 ND.However with an instructor we can tremendously speed up the learning process. The following are the topics covered.

Contace details :
Suvash  :9008500244
Mohan  : 9739172531
gsgudi@gmail.com
Course type : Classroom/ online training
Duration: 5 weeks

8.5.5.0 New Features
Architecture 
Websphere application server ND 8.5.5 Architecture 
Need for application servers
WAS management features
WAS flavors
WAS Topologies
Installation
Virtual Box installation
Preparation and prerequisites
Graphical installation
Installation verification/problems during installation
Profiles 
profile types 
Different ways to create a profile
profile Directory structure
Profile Backup /restore
Profile Delete
Node federation
Workload Management (WLM) & High Availability
 
Clustering (vertical & Horizontal)
Virtual Host
start to end of request processing in clustered env
Edge Components
Load Balancer
HA Manager
 
System Management & Application 
Log files
Cell, Dmgr, Node, Profile, Server terminology
Start/Stop Environment
Admin console overview
Deployment of JEE Applications (.war & .ear)
Synchronization of Config file & settings

Deploying your Applications
Application file types
Deploying an application
Starting and stopping your applications
Data access applications
Data sources
Preparing our sample database
JDBC providers
Creating a JDBC provider
Creating a J2C alias
Creating a data source
Deploying a data access application
Selecting installation options
Mapping modules to servers
Providing JSP reloading options for web modules
Mapping shared libraries
Mapping resource references to resources
Mapping virtual hosts for web modules
Mapping context roots for web modules
Reviewing the deployment steps
Using the application
IBM HTTP Server & Plug-in 
Installing IHS and WebSphere Plug-in
Creating Web server definition
Plug-in generation and propagation
Administrative Scripting
The wsadmin tool
Interactive commands
Individual commands
Profile scripts
Command script files
Listing installed applications with Jython
Installing an application using Jython
Querying application status
Security 
Global security
Global security registry types
Turning on global security
Standalone custom registry
Local operating system
Configuring an LDAP registry in WebSphere(LDAP config material)
Administrative roles
Mapping users and groups to administrative roles
Monitoring & Tuning 
Enable Appl Server Performance monitoring
Dynamic Cache
Tivoli Performance Viewer (TPV)
TPV advisor
Request Metrics
JVM tuning
JVM core and heap dumps
Requesting a Java core dump using Jython
Requesting a heap dump using Jython
Requesting a Java core dump using the kill command
JVM-triggered heap dump
Analysing a Java core (thread) dump
Problem Determination & troubleshooting 
where to start
symptoms of a problems
Importance of Log files, trace & analyzer
Heap dump & Thread dump
Hung Thread detection
Memory leaks diagnostics
 
How to send error to IBM
WebSphere Configuration
File structure
XML configuration files
Important properties files
Logs
JVM settings
Classloaders
SSL
SSL Concepts
Configure SSL between IHS and WAS
The ikeyman tool
Product Maintenance
Locating and downloading updates
Update installers
Applying updates
 Verification of updates
 Silent updates
 Feature packs
 Backing up your system
 Installer logs
Interview Stuff 
Sample WAS Resumes
Providing WAS FAQ’s
Certification Dump 
Redbooks
Introducing you to IBM various WAS Resources.....






Thursday, July 28, 2011

To verify if TRACE is enabled/disabled for Apache Webserver

After TRACE has been disabled according to the instructions mentioned in my thread, a TRACE request will be responded to with HTTP status code 403 (FORBIDDEN).

Using telnet to verify the configuration for a non-SSL web server port
The telnet command provided with most operating systems can be used to verify that the configuration changes to disable TRACE have been made. Note that telnet can only be used to test non-SSL ports, since it does not have the capability to perform the SSL handshake or to encrypt the data.

$ telnet 127.0.0.1 8080
Trying...
Connected to 127.0.0.1.
Escape character is '^]'.
TRACE / HTTP/1.0
A: b
C: d
Host: foo

HTTP/1.1 403 Forbidden
Date: Mon, 04 Oct 2004 14:23:31 GMT
Server: IBM_HTTP_SERVER
Connection: close
Content-Type: text/html; charset=iso-8859-1

Forbidden

You don't have permission to access /
on this server.

Connection closed.

The information sent by the client is no longer echoed, and the request fails with HTTP status code 403.

If the response to the TRACE request continues to result in a response with status code 200, verify that the required directives were added to all containers and the main scope of the configuration file, and also verify that the web server has been restarted to activate the updated configuration.

Sticky Bit (-rwsr-xr-x Unix file permission)

Everybody handling a Unix operating system would very well know what chmod 777 means. That the owner, group and the user of the file is given all permissions (Read, Write and Execute on a particular file). This could otherwise be written as “chmod ugo+rwx “. Meaning that you are giving User, Group and Owner of the file, the rights to Read, Write and Execute the file.

Here comes the rws scenario. Best example that is available for this rws is /usr/bin/passwd command (just issue a “ls -l /usr/bin/passwd”) .

Normally, any user is allowed change HIS password. Meaning he can make an entry or change HIS entry in the /etc/passwd file. But he can never be given ‘WRITE’ permissions on the file because he might end up disturbing other person’s password too. Only a ROOT user is allowed permissions on the /etc/passwd file.

This is where the “rws” comes to picture. When we give “rws” permission to the /usr/bin/passwd command, Unix would assume that the command is executed by the ROOT user. (the user doesnt have permissions on the /etc/passwd file but the root user has). Root user (RWS) permissions could be given on a file as chmod 4700 .

arun@arun-desktop:~/Desktop$ chmod 4700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rws—— 1 arun arun 0 2007-01-17 06:48 hi.txt

If you need to act as a group user of a file and not a normal user when executing a particular command (as against the root user) then user “chmod 2700 ”

arun@arun-desktop:~/Desktop$ chmod 2700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx–S— 1 arun arun 0 2007-01-17 06:48 hi.txt

The 4 and 2 in the front of the chmod commands are called as SUID and SGID bits.

What if we put a 1 instead of 4 and 2 (chmod 1700 ).

arun@arun-desktop:~/Desktop$ chmod 1700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx—–T 1 arun arun 0 2007-01-17 06:48 hi.txt

It shows a “T” in the place of “x” for a normal user. This “T” bit is called as the Sticky bit.

“When the sticky bit is turned on for a directory users can have read and/or write permissions for that directory, but they can only remove or rename files that they own. The sticky bit on a file tells the operating system that the file will be executed frequently. Files like this are kept in swap space even when they aren’t being executed. Although this takes up swap space it greatly reduces the time it takes to execute the program. Some programs such as vi have the sticky bit turned on by default on some Unixes.”

Apache Installation on Linux ( Compile)

Download and Install Apache 2.2

Download apache from the Apache 2.2 http://httpd.apache.org/download.cgi#apache22

Look for the section with the phrase "best available version" like "Apache HTTP Server (httpd) 2.2.x is the best available version". At the time of writing this tutorial Apache 2.2.16 is the official best available version.

Click on the link for "httpd-2.2.16.tar.gz" and download the installer.


Once the file is copied on the Linux server (example: /usr/local/install).

1. Use the following command to extract the tar file.

cd /usr/local/install

tar -xzf httpd-2.2.16.tar.gz


A directory will be created "httpd-2.2.16"

2. Now, Let`s execute the configuration script:

cd /usr/local/install/httpd-2.2.16

./configure --prefix=/usr/local/install/apache --enable-mods-shared=all --enable-proxy --enable-expires --enable-vhost-alias

or

./configure --prefix=/usr/local/install/apache --enable-so --with-mpm=worker --enable-proxy=share --enable-ssl --enable-proxy --enable-rewrite --enable-headers --enable-deflate --enable-proxy-http --enable-proxy-balancer --enable-proxy-ajp --enable-expires --enable-usertrack


3. The following steps will compile Apache based upon the configuration defined:

make


4. The following step will install the Apache build:

make install



5. Use the following commands to control the Apache Web Server.

/usr/local/install/apache/bin/apachectl -k stop

/usr/local/install/apache/bin/apachectl -k start


6. Go to the internet browser and try the url http://host:80/.

You should see, It Works!

This means, the Apache webserver installation went successful.