Tuesday, November 27, 2012

Check the dir size

To check the Dir size.
=====================

[root@TESTBED ~]# du -h --max-depth=1 /opt/ | sort -n -r

[root@TESTBED ]# du -h --max-depth=1 | sort -n -r


File size
=====

[root@TESTBED ]# du -h -s /opt/abc.txt

[root@TESTBED ]# du -h -s /opt/*

Clear the memory cache.

Clear the memory cache.
======================

# sync; echo 3 > /proc/sys/vm/drop_caches

Hardware clock set

# hwclock --show
$ date

Set clock

To set the system clock directly:

# date MMDDhhmmYYYY



Hardware Clock Set
====================
To set the hardware clock directly (the argument must be in local time, even if you keep your hardware clock in UTC.):

# hwclock --set --date="YYYY-MM-DD hh:mm:ss"

# hwclock --set --date=hh:mm:ss"


or

Synch time to hardware to OS / OS to hardware

The hardware clock can be set from the system clock and vice versa:

# hwclock --systohc
# hwclock --hctosys

Create a local compressed tarball from remote system directory

Create a local compressed tarball from remote host directory


# ssh user@host "tar -cf - /path/to/dir" | gzip > dir.tar.gz

Public Key issue while installing rpm through yum


Public Key issue while installing rpm through yum.

============================================

1. Check keys.
  
    find / -name "*GPG*"

  - Will get answers like below

    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-former
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-rhx
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-auxiliary
    /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta


2. Go to the /etc/pki/rpm-gpg/
    # cd /etc/pki/rpm-gpg/

3. type the below command.
   # rpm --import *GPG*

 The above command wont be give any kind of output.

Adding SWAP by dd command

Create and add swap space in linux.
===========================

#dd if=/dev/zero of=/swap1 bs=1024 count=1048576

#dd if=/dev/zero of=/dev/swap1 bs=1G count=4

#mkswap /swap1

#swapon /swap1

#free -m


bs=1024 ( 1MB )
count=1048576 ( 1GB )

Adding proxy in Linux

Adding proxy in Linux
===================

Run the below commands  in terminal to get proxy details for temporary.

export http_proxy=http://proxy-ip:port/
export https_proxy=https://proxy-ip:port/

export http_proxy=http://proxy-url:port/
export https_proxy=https://proxy-url:port/


Add the proxy details in /etc/profile to permanent changes and access to all users (global set),
or else add in user .bach_profile file to get effect on selected user.


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

For FTP

$export ftp_proxy=http://<proxy-server-ip>:<port>

with auth
$export ftp_proxy=http://<user>:<password>@<proxy-server-ip>:<port>

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

For svn

#vi /etc/subversion/servers


[global]
#http-proxy-host=my.proxy
#http-proxy-port=80
#http-proxy-username=[username]
#http-proxy-password=[password]

Friday, October 12, 2012

Remote ssh login issue

If you have reinstalled Linux or UNIX with OpenSSH, you will get the bellow

error. (or else changes in hostname and ip address)
=======
Error
=======

[root@TESTBED ]# ssh root@192.168.x.x
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
8c:32:d8:2c:94:18:4f:7f:7f:2a:15:60:4d:6f:50:79.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:3
RSA host key for 192.168.x.x has changed and you have requested strict

checking.
Host key verification failed.
lost connection
[root@TESTBED ]#

=====================================

Solution :
Add the remote machine as known host as below.
to known host


[root@TESTBED ]# ssh-keygen -R 192.168.x.x
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
[root@TESTBED ]#


Saturday, February 11, 2012

SVN from Windows and more on SVN

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjVhNjA0MjhjZTY4OTY1OQ

SVN and more on SVN

#which svn

If this returns a valid path as output, then it means that svn is installed on your linux box. If not, you need to install it. Installing subversion is very easy (for most distributions) and ample documentation is available on the web. You can start with http://subversion.apache.org/.

Four steps to complete svn repository creation on linux

1. log onto server as root
2. I prefer to have all svn repositories in one directory for better organization and easy maintenance. So next step for me would be to change to my svn directory.

cd /svnRepos

If you do not already have a directory for svn repositories, I would recommend creating one.

mkdir svnRepos

3. Create repository using following command

svnadmin create /path/to/repo/RepoName

where : RepoName is the name of repository to be created. As an example, I want to create a repository for my testproject. I would write

svnadmin create testproject

4. Change group ownership of repository for the intended group. In this case, consider I have a user group created as “all” and I want this group to have ownership to this repository.


chown -R :all /path/to/repo/RepoName
5. Grant Read/Write/Execute permissions to “all” on this repository

chmod -R 770 /path/to/repo/RepoName

6. Go to the /path/to/repo/RepoName/conf dir
and edit teh files. authz passwd svnserve.conf

authz
=====
[groups]
# harry_and_sally = harry,sally
admin = admin

# [/foo/bar]
# harry = rw
# * =
admin = rw


# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
admin = rw
==============================
==============================
passwd
======
[users]
# harry = harryssecret
# sally = sallyssecret
admin = admin123
==============================
==============================
svnserve.conf
==========
[general]
anon-access = none [edit these 4 linies without giving any space]
auth-access = write
password-db = /svnrepo/repo/conf/passwd
realm = repo [repo is my repository name]

===========-------------==============


Kill the process.

[If old repo is thare - killall svnserve]
[ to remove all - rm -rf find .-type d - name svnrepo/]


start the server
==========
svnserve -d --listen-port 2122 -r /svnrepo/repo

svnserve -d --listen-host 172.2x.x.12 -r /svnrepo/repo

svn import /svnrepo/repo/main svn://172.2x.x.12/svnrepo/repo/ -m "Import"

svn checkout svn://172.2x.x.12/svnrepo/repo/

---------------===================----------------===========

try from windows it will work

===================================================

Add folder's in svn

Go to repo dir

mkdir project
svn add project
svn commit project


svn import DATA svn://172.2x.x.33/svnrepo/repo -F DATA/file1

svn import svn://172.2x.x.33/svnrepo/repo -F DATA/file1

====================================================

SVN repository creation on linux in four steps

  1. log onto server as root
  2. I prefer to have all svn repositories in one directory for better organization and easy maintenance. So next step for me would be to change to my svn directory.

cd /svnRepos

If you do not already have a directory for svn repositories, I would recommend creating one.

mkdir svnRepos

  1. Create repository using following command

svnadmin create /path/to/repo/RepoName

where : RepoName is the name of repository to be created. As an example, I want to create a repository for my testproject. I would write

svnadmin create testproject

  1. Change group ownership of repository for the intended group. In this case, consider I have a user group created as “all” and I want this group to have ownership to this repository.

chown -R :all /path/to/repo/RepoName

  1. Grant Read/Write/Execute permissions to “all” on this repository

chmod -R 770 /path/to/repo/RepoName

6. svnserve -d --listen-port 2122 -r /home/demo/repository

Adding user to the sudoers

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjUyYWZmNTE1MmU3MGI2MTc

Adding Additional Hard Drives in Linux

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjQxYWZhNTNkODMxZjUzZTk

Restrict the user his home dir at ssh login

1. make a copy of bash with the name of rbash
#cp /bin/bash /bin/rbash

2. Add the user with rbash
[#useradd -s /bin/rbash ]
#useradd -s /bin/rbash admin

Restrict the user his home dir at ftp login

Go to /etc/vsftpd/vsftpd.conf file

# vi /etc/vsftpd/vsftpd.conf

add the below line at the end of file

chroot_local_user=YES

save the file and restart the vsftpd serverice.

ex :
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

chroot_local_user=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

Mount .iso file

# mount -o loop /ISO/rhel-server-5.1-i386-dvd.iso /mnt

mounting the .iso image to the /mnt directory.

For unmount

# umount /mnt

Fix MBR in dual boot system

Issue:

How can I fix a dual-booting system if I had to reinstall Windows and now I can no longer boot to Red Hat Enterprise Linux?

Resolution:

When Windows is reinstalled, it overwrites the GRUB bootloader in the Master Boot Record (MBR). The next time the system is booted, the usual GRUB menu will no longer be available and the system boots straight to Windows. This can be easily fixed.

Boot from Red Hat Enterprise Linux installation CD #1. At the installation boot prompt, type linux rescue then hit Enter. Follow the instructions as you would in a normal installation process. (There is no need to enable networking.) It will then inquire if you want to search for a Red Hat Enterprise Linux installation. Select Continue and the installer will now attempt to search for the operating system in your drives. If the search is successful, the rescue environment will mount it in /mnt/sysimage. You will be given a minimal shell.

At the shell prompt, do the following:

# chroot  /mnt/sysimage
# cd /boot/grub
# head grub.conf

The last command will show something similar to the following:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,1)
#          kernel /boot/vmlinuz-version ro root=/dev/hda2
#          initrd /boot/initrd-version.img
#boot=/dev/hda
default=0

Notice the commented line #boot=/dev/hda. This shows where the GRUB bootloader was previously installed. In this case it is in the MBR of the first IDE drive. To restore the bootloader, execute:

# grub-install /dev/hda

Reboot the system exiting the shell (twice) by executing:

# exit
# exit

The original GRUB bootloader should now be restored.

Create .iso file from cdrom

# dd if=/dev/cdrom of=/ISO/rhel5.iso

if=/dev/cdrom is the location of cdrom drive

/ISO is the direcrory where the iso file going to store.

rhel.iso is the file iso image dile name.

===============================

mkisofs also use to create iso image fine.

================================

Cisco VPN anyconnect Client Configuration

https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxsaW51eHdlYndvcmxkfGd4OjlmNGE5YWZjYzVlOWQ4

Burn .iso file in cd/dvd

# cdrecord -v /dev/cdwriter /ISO/myisofile.iso

Sea Linux version

To sea the Linux version

#uname -a

#cat /etc/sysconfig/redhat-release

Friday, February 10, 2012

SUSE Linux VNC configuration.

1. Start the vnc server

# vncserver :20

It will create the .vnc/ dir in user home dir.

2. Open .vnc/xstartup file
Enter as below

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
xterm -geometry 1280x1024 -depth 32
twm &
startkde

[Have to add startkde to open the KDE desktop]

3. Restart the vnc serverice.

# vncserver -kill :20
# vncserver :20

Telnet in RHEL5

Install this rpm telnet-server-0.17-31.EL4.3.i386.rpm
service xinetd reload

if rrot login is blocked

do this

To overcome this “problem”, simply open /etc/pam.d/remote and remark this following line, where the PAM module pam_securetty.so disallows root user login remotely via telnet and the alike (except SSH).

Original /etc/pam.d/remote with this line:

auth required pam_securetty.so

Tweaked /etc/pam.d/remote that remark (comment out) pam_securetty.so:

# auth required pam_securetty.so

Create and add swap space in linux.

#dd if=/dev/zero of=/swap1 bs=1024 count=1048576

#mkswap /swap1

#swapon /swap1

#free -m


bs=1024 ( 1MB )
count=1048576 ( 1GB )

You can edit /etc/fstab to enable your swap file automatically at boot time.
By adding an entry like this:

/opt/swapfile swap swap defaults 0 0

Installing Ruby and Rubygems on Linux

ruby-1.8.7-p174.tar
rubygems-1.3.7.tar

Copy this files into the linux machine.
exc : /opt
---------------------------------------
Before installation, Check zlib package availablity.

zlib-1.2.3-3.i386.rpm
zlib-devel-1.2.3-3.i386.rpm

Its better installed both once agailn. Its available in RHEL5 cd.

#rpm -ivh zlib* --force

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

Install Ruby.

- Copy ruby-1.8.7-p174.tar into opt/
-Provide permission
#cmhod 777 ruby-1.8.7-p174.tar

-Install
#tar -xvsf ruby-1.8.7-p174.tar

-Provide permission to the ruby-1.8.7-p174 folder
#chmod -R 777 ruby-1.8.7-p174

#cd ruby-1.8.7-p174

#./configure

#make

#make install

-Come out and check installation.
#ruby -v
----------------------------------------------------
Install Rubygems.


Copy rubygems-1.3.7.tar into opt/
-Provide permission
#cmhod 777 rubygems-1.3.7.tar

-Install
#tar -xvsf rubygems-1.3.7.tar

-Provide permission to the ruby-1.8.7-p174 folder
#chmod -R 777 rubygems-1.3.7

---> Connetct to the Direct network and install
the remaining support apps( gems) for rubygems.

-Run setup file from rubygems.
#ruby /opt/rubygems-1.3.7/setup.rb

-Install other apps from outer network.
#gem install getopt –version 1.4.0

#gem install rdiscount --version 1.6.5

#gem install rdoc --version 2.3.0

and check,
#gem list

=======================================

Error : WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

If you have reinstalled Linux or UNIX with OpenSSH, you will get the bellow error. (or else changes in hostname and ip address)
=======
Error
=======

[root@TESTBEDMRPDB opt]# ssh root@172.21.17.43
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
8c:32:d8:2c:94:18:4f:7f:7f:2a:15:60:4d:6f:50:79.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:3
RSA host key for 172.21.17.43 has changed and you have requested strict checking.
Host key verification failed.
lost connection
[root@TESTBEDMRPDB opt]#

=====================================

Solution :
In destination machine add as below.
to known host


[root@TESTBEDMRPDB opt]# ssh-keygen -R 172.21.17.43
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
[root@TESTBEDMRPDB opt]#


and / or

may be check below

#TESTBEDQCMRPGDB.PABNG.COM,172.21.17.43 ssh-rsa

How to set multiple IP addresses using Linux command line

Go to /etc/sysconfig/network-scripts

Make multiple copies of ifcfg-eth0 and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.

Open each of them and at least change the IPADDR to your chosen IP address and the NETMASK to the subnet mask for that IP

address.

A sample entry would look like this:

DEVICE=eth0:0
BOOTPROTO=static
IPADDR=34.123.111.21
NETMASK=255.255.255.0
ONBOOT=yes


Restart the network:
/sbin/service network restart

killing application/process when close the putty

killing application/process when close the putty, even process given in background to run.

======================================

Create the nohup.out file in user home directori.

and restart the command

it will updat the file.

================================================

(This is one not tryed)
Nohup allows a client process to not be killed if a the parent process is killed, for argument when you logout.
Even better still use: nohup /bin/sh -c "echo \$\$ > $pidfile; exec $FOO_BIN $FOO_CONFIG " > /dev/null

Nohup makes the process you start immune to termination which your SSH session and its child processes are kill upon you logging out. The command i gave provides you with a way you can store the pid of the application in a pid file so that you can correcly kill it later and allows the process to run after you have logged out.


==================================================

can also use screen command for same. Brock pointed out disown shell internal command for same purpose. Here is how you can try it out:

$ pullftp.sh &
$ disown -h
$ exit

Java heap size test

java -Xms256m -Xmx6128m -XX:MaxPermSize=256m test

Install Apche

./configure --prefix=/opt/apache2.0/
make
makeinstall

===========================
Configure APR if required.

./configure --prefix=/usr/local/apr-httpd/
make
make install

# Build and install apr-util 1.2
cd ../apr-util
./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/
make
make install

=========================
add Libary Path in environment vaeiables.

export LD_LIBRARY_PATH=/op/httpd../lib/
like
export LD_LIBRARY_PATH=/opt/EPIC/apache2.0/lib/

and check the below

#httpd -v

==========================================
Apache installation with mod_proxy enable

./configure --prefix=/opt/apache2.0/ --enable-module=proxy --enable-

shared=proxy
make
makeinstall

To delete File older than 7 days

# find /root/older -mtime +7 -exec rm -f {} \;


touch to change time stamp

# touch -t 200205121759.30 install.log

2002-05-12 time 17:59:30

Cleare cache

#sync; echo 3 > /proc/sys/vm/drop_caches

Check dir sizes

[root@TESTBEDSFCSB ~]# du -h --max-depth=1 /opt/ | sort -n -r

[root@TESTBEDREEDQAB bin]# du -h --max-depth=1 | sort -n -r


File size
=====

[root@TESTBEDREEDQAB bin]# du -h -s /opt/abc.txt

[root@TESTBEDREEDQAB bin]# du -h -s /opt/*

CPU info of linux machine

# cat /proc/cpuinfo
----------------------

Step by step check

# less /proc/cpuinfo

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

# grep processor /proc/cpuinfo

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

Count Cores in CPU

# grep cores /proc/cpuinfo

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

To Verify that you have dual core cpu

# grep -i core /proc/cpuinfo