Posts

Linux Admin Q&A

Interview Questions And Answers Q: - How are devices represented in UNIX? All devices are represented by files called special files that are located in /dev directory. Q: - What is 'inode'? All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. Q: - What are the process states in Unix? As a process executes it changes state according to its circumstances. Unix processes have the following states: Running : The process is either running or it is ready to run . Waiting : The process is waiting for an event or for a resource. Stopped : The process has been stopped, usually by receiving a signal. Zombie : The process is dead but have not been removed from the process table. Q: - What command should you use to check the number of files and ...

Apache Interview QA

Interview Questions And Answers Q: - What is location of log files for Apache server ? /var/log/httpd Q: - What are the types of virtual hosts ? name-based and IP-based. Name-based virtual host means that multiple names are running on each IP address. IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address. Q: - How to restart Apache web server ? service httpd restart Q: - How to check the version of Apache server ? rpm -qa |grep httpd Q: - What is meaning of "Listen" in httpd.conf file ? Port number on which to listen for nonsecure (http) transfers. Q: - What is DocumentRoot ? it is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory. Q: - On which port Apache server works ? http - port 80 https - port 443 Q: - Tell me...

Redirect thread dump to another file?

On Jboss or Tomcat application server, we usually use kill -3 PID to get thread dump to default STDOUT which is catalina.out under $Tomcat_Home/logs folder. It might be nature to use command kill -3 PID > some.file 2>&1 to try to redirect the thread dump info to some.file than default one. However, it will not work. The reason is kill is just a command to send a signal to a process. You are redirecting the output of the kill command itself rather than the process (what the process does upon receipt of a signal is separate), so the redirect (supposed to kill command itself) has no effect on which file the process (PID) will write to. Given that, if we need redirect thread dump for that process to some other file, we need add redirects to that process when it starts. Another popular way is to use jstack -F PID to get the whole thread dump forcefully. "jstack" : A JVM troubleshooting tool that prints stack traces of all running threads of a given JVM proce...

Taking Thread Dump in Linux

Generating a Thread Dump on Linux, including Solaris and other Unixes 1.) Identify the java process that JIRA is running in: This can be achieved by running a command similar to: [root@server2~]#ps -ef | grep java root      8876  8854 12 10:54 pts/5    00:08:37 /usr/jdk1.6.0_16/bin/java -Dprogram.name=run.sh -server -Xms256m -Xmx1024m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/data2/jboss/lib/endorsed -classpath /data2/jboss/bin/run.jar:/usr/jdk1.6.0_16/lib/tools.jar org.jboss.Main -c all -b 192.168.2.102 -Djboss.messaging.ServerPeerID=1 root     10154  9577  0 12:02 pts/3    00:00:00 grep java   2.) Find the process ID of the JVM and use the ps command to get list of all processes:  kill -3 The thread dump will be printed to Confluence's stan...

Java Thread Dump

Understanding a Java thread dump 1. Introduction In my opinion, one of the greatest things about Java is the ability to get meaningful thread dumps on a running production environment without having to enable DEBUG mode. The thread dump is a snapshot of exactly what's executing at a moment in time. While the thread dump format and content may vary between the different Java vendors, at the bare minimum it provides you a list of the stack traces for all Java threads in the Java Virtual Machine. Using this information, you can either analyze the problem yourself, or work with those who wrote the running code to analyze the problem. 2. What is a stack trace? I mentioned earlier that the thread dump is just a list of all threads and the full stack trace of code running on each thread. If you are a J2EE Application Server administrator and you've never done development before, the concept of a stack trace may be foreign to you. A stack trace is a dump of the curre...

How to log output of remote ssh session ?

There are many instances when you are going to ssh to remote server for troubleshooting and data gathering purposes and you want to save those data in your computer. There is a less frequently but useful "tee" command which could be used to log all output in a remote ssh session. What it will actually do is that it will generate one file which will capture all the commands as well as their output. ssh user@remote.server.com | tee /path/of/log/file This command is very useful for troubleshooting purposes. !Enjoy Kuldeep Sharma

Some Interview Stuff

Image
1) Define a deamon? Ans: In Unix or Other Multitasking Operating Systems a Daemon is a computer program that runs in Background, rather than under the control of a user. These are usually Intiated as Background processes.Typically Daemons have names that ends with "d" e.g. mysqld,syslogd,pptpd,sshd etc. 2.) Can we use crontab to run a script per second? if yes how? if no why? Ans: I think we can't. In crontab (the one the user can edit) the smallest timeperiod is 1 minute. The crontab deamon, which checks the crontab file, runs every 30 seconds.          But we can make use of some scripting to run script after some seconds but not every second. 3)I have a file each line contains “/var/www/html”, replace this entry in all lines with “/home/xyz/red”  with single command or an editor. Ans: For this make the use of sed(Stream Editor) command by using some other separator than "/".    AS :   #sed -i 's#/var/www/html#...

Squid Transparent Proxy Server

Image
  A proxy server is a server (a computer system or an application) that acts as an intermediary for requests from clients seeking resources from other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource, available from a different server. The proxy server evaluates the request according to its filtering rules. For example, it may filter traffic by IP address or protocol. If the request is validated by the filter, the proxy provides the resource by connecting to the relevant server and requesting the service on behalf of the client.                        Fig. Schematic representation of a proxy server, where the computer in the middle acts as the proxy server between the other two. Transparent proxies An intercepting proxy (also forced proxy or transparent proxy ) combines a proxy server w...

Top 5 Memory Consuming Processes in Linux

Hi,        Some times we need to know the most memory consuming process. In Linux you can do this with the help of following command. [root@server2~]#ps axo %mem,command,pid | sort -nr | head -n 5  24.2 /usr/java/jdk1.6.0_24/bin/j 2223  9.4 /usr/sbin/mysqld --basedir= 2855  1.9 /usr/java/jdk1.6.0_24/bin/j 2065  0.8 /usr/libexec/gdmgreeter 3847  0.2 /usr/libexec/gdm-rh-securit 3798 Here option "axo"  allow us to see Every Process in User-Defined format. !!Enjoy Linux Kuldeep

Setting Java Heap Size

Two JVM options are often used to tune JVM heap size: -Xmx for maximum heap size, and -Xms for initial heap size. Here are some common mistakes I have seen when using them: Missing m, M, g or G at the end (they are case insensitive). For example, java -Xmx128 BigApp java.lang.OutOfMemoryError: Java heap space The correct command should be: java -Xmx128m BigApp . To be precise, -Xmx128 is a valid setting for very small apps, like HelloWorld. But in real life, I guess you really mean -Xmx128m Extra space in JVM options, or incorrectly use =. For example, java -Xmx 128m BigApp Invalid maximum heap size: -Xmx Could not create the Java virtual machine. java -Xmx=512m HelloWorld Invalid maximum heap size: -Xmx=512m Could not create the Java virtual machine. The correct command should be java -Xmx128m BigApp , with no whitespace nor =. -X options are different than -Dkey=value system properties, where = is used. Only setting -Xms JVM option and its value is greater t...

389 Directory Server | Fedora Directory Server On CentOS

389 Directory Server The 389 Directory Server (previously Fedora Directory Server ) is an LDAP (Lightweight Directory Access Protocol) server developed by Red Hat, as part of Red Hat's community-supported Fedora Project. 389 Directory Server is identical to the Red Hat Directory Server, just rebranded. The name 389 is derived from the port number for LDAP. Features 1.) 389 Directory Server has multi-master capability. 2.) 389 Directory Server also has the ability to export parts of the directory to read-only servers. This is similar to the Read Only Domain Controller in Microsoft's Active Directory Domain Services. 3.) 389 Directory Server has a Java-based GUI front end for administration, but the underlying LDAP database can be managed by other LDAP compliant tools. First you need to download & install epel rpm package, that is repository rpm packages.Then you can install packages with your usual method, and the EPEL repository is included. [root@server2/etc/dirsr...