A blog for Linux Lovers.

Posted by sibu on February 17, 2011

Jboss and its versions


JBoss Application Server (or JBoss AS) is a free software/open-source Java EE-based application server. Because it is Java-based, the JBoss application server operates cross-platform: usable on any operating system that Java supports. JBoss AS was developed by JBoss, now a division of Red Hat.


JBoss AS 4.0, a Java EE 1.4 application server, features an embedded Apache Tomcat 5.5 servlet container. It supports any Java Virtual Machine between versions 1.4 and 1.6.

JBoss AS 4.2 also functions as a Java EE 1.4 application server, but deploys Enterprise JavaBeans 3.0 by default. It requires the Java Development Kit version 5. Tomcat 5.5 comes bundled with it.

JBoss AS 5.1, released as of 2009, operates as a Java EE 5 application server. It is a minor update of the major release JBoss AS 5.0

Boss AS 6.0,[3] the current stable release and an unofficial implementation of Java EE 6, was released on December 28, 2010.

Posted by sibu on January 11, 2010

Stderr and Stdout Redirection.

1.) stdout to a file

The output of a command will redirect to another file.

Eg:          ls -l > list.txt

2.) stderr to a  file

The following command will redirect the  stderr ouput of a program to a new file.

Eg:       grep sibu * 2> grep-errors.txt

Here, a file called ‘grep-errors.txt’ will be created and it will contain what you would see the stderr portion of the output of the ‘grep sibu *’ command.

3.) Stdout to Stderr

This will cause the stderr ouput of a program to be written to the same filedescriptor than stdout.

Eg:          grep sibu * 1>&2

Here, the stdout portion of the command is sent to stderr..

4.): stderr to stdout

This will cause the stderr ouput of a program to be written to the same filedescriptor than stdout.

Eg:       grep * 2>&1

Here, the stderr portion of the command is sent to stdout.

5.) stderr and stdout 2 file

This will place every output of a program to a file. This is suitable sometimes for cron entries, if you want a command to pass in absolute silence.

Eg:       rm -f $(find / -name core) &> /dev/null

Posted by sibu on October 17, 2009

Options Directive

Using this Options directive controls  we can set server features  for a particular directory.

Options  can be set to None, in which case none of the extra features are enabled.

All :

All options except for MultiViews. (Default Settings).

ExecCGI :

Execution of CGI scripts using mod_cgi is permitted.

FollowSymLinks :

The server will follow symbolic links in this directory.

Includes :

Server-side includes provided by mod_include are permitted.

Indexes :

If the directory does not contain any  DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory.

MultiViews :

Content negotiated “MultiViews” are allowed using mod_negotiation.

You have to be very care full while using + and - symbols with Options

For example, without any + and - symbols:

<Directory /home/sibu>
Options Indexes FollowSymLinks

<Directory /home/sibu/test>
Options Includes

then only Includes will be set for the /home/sibu/test directory.

If the second Options directive uses the + and - symbols:

<Directory /home/sibu>
Options Indexes FollowSymLinks

<Directory /home/sibu/test>
Options +Includes -Indexes

then the options FollowSymLinks and Includes are set for the /home/sibu/test directory.

Posted by sibu on October 17, 2009

Enable Server Side Include(SSI)

SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served.  Its use to add dynamically generated content to an existing HTML page.

SSI configurations

We must have mod_include module installed and enabled on apache. Also need to  have the following directive either in your httpd.conf file, or in a .htaccess file:

Options +Includes

This tells Apache that you want to permit files to be parsed for SSI directives.

It always better to tell Apache that which files should be parsed. There are two ways to do this. We can configure to parse any file with a particular file extension, such as .shtml, with the following directives:

        AddType text/html .shtml
        AddHandler server-parsed .shtml

One disadvantage to this approach is that if you wanted to add SSI directives to an existing page, you would have to change the name of that page in order to give it a .shtml extension.

The other method is to use the XBitHack directive:

        XBitHack on

XBitHack tells Apache to parse files for SSI directives if they have the execute bit set. So, to add SSI directives to an existing page, rather than having to change the file name, you would just need to make the file executable using chmod.

chmod +x pagename.html

Posted by sibu on October 10, 2009

MySQL information_schema error when using mysqldump utility

While executing the mysqldump command  you may have experienced following errors.

mysqldump: Got error: 1044: Access denied for user ‘root’@'localhost’ to database ‘information_schema’ when using LOCK TABLES

To quickly fix this problem use the following switch when running mysqldump for MySQL database backups.

mysqldump -u root -p -all-databases -single-transaction > all.sql

Posted by sibu on September 20, 2009

VPS creation commands.

VPS Creation

# vzctl create VEID –ostemplate osname
# vzctl set VEID –ipadd a.b.c.d –save
# vzctl start VEID

Here VEID is the numeric ID for the VPS;
osname is the name of the OS template for the VE,
and a.b.c.d is the IP address to be assigned to the VE.


# vzctl create 101 –ostemplate fedora-core-5-minimal
# vzctl set 101 –ipadd –save
# vzctl start 101

VE should be up and running now; you can see its processes

# vzctl exec VEID ps ax

To provide VEID password

# vzctl exec VEID passwd ‘username’

To enter VE give the following command:

# vzctl enter VEID
entered into VPS VEID

Adding ip address to a VPS and creating networking

The command syntax below to add networking to the existing VPS

# vzctl set VEID –ipadd ipaddr  –nameserver nameserverIP  –hostname hostname –save

The –ipadd parameter assigns the IP address to the first venet interface in the guest OS, the –hostname assigns the VPS its hostname, and the –nameserver parameter provides the first nameserver.

How to Assign fixed amount of RAM for the created VPS?

Here is an example of setting the VPS with a guaranteed 256 MB RAM and a maximum of 1GB RAM.

vzctl set vpsid –vmguarpages 65536 –save
vzctl set vpsid –privvmpages 262144 –save

vmguarpages ->The memory that is ‘guaranteed’ to the VPS
privvmpages -> The ‘maximum’ amount of memory that will be granted to the VPS

Replace vpsid with with the VPS_ID.


vzctl set 105 –vmguarpages 65536 –save
vzctl set 105 –privvmpages 262144 –save

Start your VPS with the command

vzctl start vpsid

Example : vzctl start 105

Posted by sibu on September 20, 2009

Commands to monitor the process.

Find Out The Top 10 Memory Consuming Process

# ps -auxf | sort -nr -k 4 | head -10

Find Out top 10 CPU Consuming Process

# ps -auxf | sort -nr -k 3 | head -10

Max cpu resource usage

# ps -eo pcpu,pid,user,args | sort -r -k1 | more

To get the long list of a process, if we have pid

# ps -efm –columns 2048 | grep <pid>


The command iostat report Central Processing Unit (CPU) statistics and input/output statistics for devices, partitions and network filesystems (NFS).


Posted by sibu on June 28, 2009

How to Reset a Linux Box root password.

If the linux box protected with root password only.

Do a hard reboot on the machine and click on ‘e’ button to edit the boot like when you get the grub menu. Scrol down to the line which starts with kernel and hit ‘e’ again to edit and add ‘single’ (with out quotes) at the end and hit Enter. Now use ‘b’ to boot then you will get single user mode from where you can change the server root password.

If the linux box protected with a password for single user mode.

Few system require root password to boot into ‘single mode’ in that case try to edit the gurb boot line and add ‘init=/bin/bash’ at the end of kernel line. You will be redirected to a bash shell instead of init.

Now you may want to mount the root paritition with read/write permission.

mount –no remount,rw /

Then reset the password.

If the Grub is protected with a root password, then try booting from a LiveCD and open a root shell.  Execute fdisk –l to show the available disk partition. Mount the root paritition to /mnt

mount -o,rw /dev/hda1 /mnt

Make sure that you mount a root partition. Next change this partition as your root directory using following command

chroot /mnt

Now try to change the root password using passwd command.

Posted by sibu on June 20, 2009

History with Time and Date.

History with Time and Date

The command history will give you the list of command which you executed earlier. By default you won’t get the the command execution time and date.

If you wish to have a history details with time and date please do the following.

Open /etc/bashrc file and add the following line.

Export HISTTIMEFORMAT=”%h%d - %H:%M:%S”

After adding this line, relogin to the shell and execute the history command.

Posted by sibu on June 20, 2009

Iptables to log messages to a different log file

According to man page:

Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Several different tables may be defined. Each table contains a number of built-in chains and may also contain user defined chains.

By default, Iptables log message to a /var/log/messages file. However you can change this location. I will show you how to create a new logfile called /var/log/iptables.log. Changing or using a new file allows you to create better statistics and/or allows you to analyze the attacks.
Iptables default log file

For example, if you type the following command, it will display current iptables log from /var/log/messages file:
tail -f /var/log/messages



Oct  4 00:44:28 debian gconfd (anish-4435): Resolved address “xml:readonly:/etc/gconf/gconf.xml.defaults” to a read-only configuration source at position 2
Oct  4 01:14:19 debian kernel: IN=ra0 OUT= MAC=00:17:9a:0a:f6:44:00:08:5c:00:00:01:08:00 SRC= DST= LEN=60 TOS=0×00 PREC=0×00 TTL=51 ID=18374 DF PROTO=TCP SPT=46040 DPT=22 WINDOW=5840 RES=0×00 SYN URGP=0


Procedure to log the iptables messages to a different log file

Open your /etc/syslog.conf file:

vi /etc/syslog.conf

Append following line

kern.warning /var/log/iptables.log

Save and close the file.

Restart the syslogd (Debian / Ubuntu Linux): /etc/init.d/sysklogd restart On the other hand, use following command to restart syslogd under Red Hat/Cent OS/Fedora Core Linux: /etc/init.d/syslog restart

Now make sure you pass the log-level 4 option with log-prefix to iptables. For example:
DROP everything and Log it
iptables -A INPUT -j LOG –log-level 4
iptables -A INPUT -j DROP

For example, drop and log all connections from IP address to your /var/log/iptables.log file:

iptables -A INPUT -s -m limit –limit 5/m –limit-burst 7 -j LOG –log-prefix ‘** HACKERS **’ –log-level 4
iptables -A INPUT -s -j DROP


* –log-level 4: Level of logging. The level # 4 is for warning.
* –log-prefix ‘*** TEXT ***’: Prefix log messages with the specified prefix (TEXT); up to 29 letters long, and useful for distinguishing messages in the logs.

You can now see all iptables message logged to /var/log/iptables.log file:
tail -f /var/log/iptables.log