Pages

Monday, November 10, 2014

Install VNC viewer on Centos 5.X machines

yum groupinstall "GNOME Desktop Environment"

yum install vnc*

Add this line at the end of /etc/sysconfig/vncservers

VNCSERVERS="5:root" VNCSERVERARGS[2]="-geometry 800x600 "


Login as user and set vnc password :

vncpasswd command :


---------------------------------------------------------


create file xstartup under .vnc of home directory and give 777 permission

Add the below lines in xstartup file

#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
        eval `dbus-launch --sh-syntax –exit-with-session`
        echo "D-BUS per-session daemon address is: \
        $DBUS_SESSION_BUS_ADDRESS"
fi
exec gnome-session

Monday, June 30, 2014

how to delete a speacial character from last line

Please use the below command to delete special character from the last line of grep output

rev | cut -c 2- | rev

Thursday, June 5, 2014

Adding SWAP space

First method : on hard disk

create a new filesystem

# mkswap /dev/sdc1
swapon /dev/sdc1
# vim /etc/fstab
/dev/sdc1               swap                    swap    defaults        0 0
# swapon -s
Filename                        Type            Size    Used    Priority
/dev/sda2                       partition       4192956 0       -1
/dev/sdc1                       partition       1048568 0       -2

# free -k
             total       used       free     shared    buffers     cached
Mem:       3082356    3022364      59992          0      52056    2646472
-/+ buffers/cache:     323836    2758520
Swap:      5241524          0    5241524
The SWAP sizer formula : if RAM is < 8 GB , SWAP should be equal to 8GB
If RAM is > 8 GB, the SWAP is half of the RAM size

How to check which process is using more memory in linux server

1. ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5

2. use top command

then SHIFT + f button in the keyboard

Press the Letter corresponding to %MEM

Then press ENTER

3. ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 10

4. ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS


Monday, May 5, 2014

How to update heap size in tomcat 7

Step 1: Open up the catalina.sh file with any text editor.

Step 2: Search for "JAVA_OPTS=" in the file and in particular locate the following lines of code:


if [ -z "$LOGGING_MANAGER" ]; then
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
else 
JAVA_OPTS="$JAVA_OPTS $LOGGING_MANAGER"
fi


Step 3: At the end of the JAVA_OPTS definitions add "-Xms256m -Xmx512m".


if [ -z "$LOGGING_MANAGER" ]; then
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms256m -Xmx512m"
else 
JAVA_OPTS="$JAVA_OPTS $LOGGING_MANAGER -Xms256m -Xmx512m"
fi


Step 4: Save the file and restart Tomcat.

Friday, April 25, 2014

Skype APK : custom notification sound

Hi,

I noticed that the latest skype on android devices lacks some features. As set custom notification sound for incoming IM's. You can use the given link to download the modified skype apk in which we can set custom notification tones.

http://www7.zippyshare.com/d/57399210/155042/Skype_4.7.0.43514_v22.apk



Bash script to save user history

Hi

Please find the below script which can save each users history to a common place for security purpose. So that later admin can review the commands performed by each user on the machine. (like who has stopped some service, who reboot the machine etc)

#!/bin/bash
echo "date > date.txt" >> .bash_profile
touch .logout.sh
read -r -d '' FILECONTENT <<'ENDFILECONTENT'
#!/bin/bash
user=`whoami`
var=`cat date.txt`
echo "The user $user logged to this machine at $var"
echo "The user $user executed the below commands"
history
echo "The session completed at `date`"
history -c
history -w
ENDFILECONTENT
echo "$FILECONTENT" > .logout.sh
chmod 700 .logout.sh
echo "source .logout.sh >> /tmp/historylog" >> .bash_logout


save this content as some file.sh like history.sh
give 700 permission
chmod 700 history.sh
./history.sh

Note : it will clear the session's history each time.


Wednesday, January 8, 2014

PHP recompile to get JPEG support

How to enable JPEG support in PHP

1. Run the below command to test whether JPEG support is there or not

#php -r 'print_r(gd_info());'

Output :

Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] =>
    [T1Lib Support] =>
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] =>
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
)

2. rpm -qa | grep -e libjpeg

if you get output like below

libjpeg-turbo-1.2.1-3.el6_5

then go forward, otherwise install the library

3. check where the library is

find / -name libjpeg*

it may be inside /usr/lib64. Make symbollic link to /usr/lib

ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/lib64/libjpeg.so.62.0.0 /usr/lib/libjpeg.so.62.0.0
ln -s /usr/lib64/libjpeg.so.62 /usr/lib/libjpeg.so.62

4. then recompile PHP

goto the php downloaded folder and do "make clean"

then

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-zlib --enable-mbstring  --with-gd  --with-pdo-mysql --with-jpeg --with-jpeg-dir=/usr/lib

make

make install

5. Verify JPEG support as below


#php -r 'print_r(gd_info());'

Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] =>
    [T1Lib Support] =>
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
)