Monday, December 3, 2012

Install and Configure Subversion in Linux


Before Installing Subversion check whether berkely db is installed. For Berkely db installation check Berkely db installation

Download and Install subversion-1.4.6
 
wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz 

tar -zxvf subversion-1.4.6.tar.gz
 
cd subversion-1.4.6
[root@test]./autogen.sh
You can run ./configure now.

Running autogen.sh implies you are a maintainer.  You may prefer
to run configure in one of the following ways:

./configure --enable-maintainer-mode
./configure --disable-shared
./configure --enable-maintainer-mode --disable-shared

Note:  If you wish to run a Subversion HTTP server, you will need
Apache 2.0.  See the INSTALL file for details.
 
run the below commands to complete the installion 
 
 ./configure --with-berkelay-db=/usr/local/bkdb
 make
 make install 

Here bkdb is the folder where i installed bkdb

Before running svn commands check the modules are correctly installed or not for the subversion

check this line are there in /etc/httpd/conf/httpd.conf file

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
 
or install it using the below command and enter the above lines in the http conf file.
 
yum install mod_dav_svn
 
check the modules are entered in apache config file 
 
[root@GAI-1397 subversion-1.4.6]# /etc/init.d/httpd start
Starting httpd: [Sun Nov 25 11:36:53 2012] [warn] module dav_svn_module is already loaded, skipping
[Sun Nov 25 11:36:53 2012] [warn] module authz_svn_module is already loaded, skipping
                                                           [  OK  ]

Now create one repository with svnadmin command.Run this command inside your subversion folder.

[root@test subversion-1.4.6]# cd
[root@test ~]# mkdir /test/
[root@test ~]# svnadmin create /test/repos
[root@test ~]# cd /test/repos
[root@test repos]# ls
conf  dav  db  format  hooks  locks  README.txt

This full path you have to specify in SVNPath.
[root@test repos]# pwd
/test/repos

Then at the end of the httpd.conf file you have to add 
 
#for svn path
<Location /test/repos>
DAV svn
SVNPath /usr/local/src/subversion-1.4.6/repos
</Location>
restart apache
 
Now import a sample file using the below command 
 
[root@test ~]# svn import -m  "2initial import." file:///usr/local/src/subversion-1.4.6/repos 
 
Check the logs using below command
 
 [root@test repos]# svn log file:///usr/local/src/subversion-1.4.6/repos
------------------------------------------------------------------------
r1 | root | 2012-11-25 12:25:22 +0530 (Sun, 25 Nov 2012) | 1 line

2initial import.
------------------------------------------------------------------------
http://localhost(you have to give your domain name)/test/repos

Now you are ready to checkout the files with any svn client.  


 
For security purpose to give authentication to the user we have to create authentication file with the command, 
  
[root@test ~]# htpasswd -cm /etc/svn-auth-file test
New password:
Re-type new password:
Adding password for user test

[root@test ~]# cat /etc/svn-auth-file
test:$apr1$yal.A/..$vXSzgm19LKem9i6RIOUon/
 
And to specify which access you want to give the user, create svn-access-file inside /etc.

Inside this file add code as,

[/]
* = rw

add these lines in the http configuration location folder

SVNPath /usr/local/src/subversion-1.4.6/repos
AuthzSVNAccessFile /etc/svn-access-file
AuthType Basic
AuthName “test”
AuthUserFile /etc/svn-auth-file
Require user user_name

[root@test ~]# chkconfig svnserve on
[root@test ~]# /etc/init.d/svnserve start

[root@test ~]# egrep --iw 'User|Group' -color=auto /etc/httpd/conf/httpd.conf
User apache
Group apache

[root@test ~]# chown -R apache:apache /usr/local/src/subversion-1.4.6/repos/

You can also specify the setting for https in  vi /etc/httpd/conf.d/subversion.conf
 
You can create multiple repos and specify with the above syntax in subversion or apache configuration file.
 
We can now co from other servers using smart svn and also we can download it through http using the below url
 
http://localhost/test/repos 
 
 
 

Install Berkely db in Linux

Download the Berkely db

[root@test]tar -zxvf db-5.3.21.tar.gz
[root@test]cd db-5.3.21

./configure --prefix=/usr/local/bkdb --enable-compat185 --enable-dbm --disable-static --enable-cxx
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking if building in the top-level or dist directories... yes
configure: error: Berkeley DB should not be built in the "dist" directory. Change directory to the build_unix directory and run ../dist/configure from there.

[root@test] cd build_unix && ../dist/configure --prefix=/usr/local/bkdb --enable-compat185 --enable-dbm --disable-static --enable-cxx

[root@test]make docdir=/usr/local/bkdb install
Installing documentation: /usr/local/bkdb
 
 
Berkely db is installed perfectly now. 

Install GCC from scratch

Install GCC from scratch with GMP, MPFR, MPC, ELF, without shared libraries


GMP

GMP is the GNU Multiple Precision Arithmetic Library.

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
bunzip2 gmp-4.3.2.tar.bz2
tar xvf gmp-4.3.2.tar
cd gmp-4.3.2
./configure --disable-shared --enable-static --prefix=/tmp/gcc
make && make check && make install

PFR is the GNU Multiple-precision floating-point rounding library. It depends on GMP.

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
bunzip2 mpfr-2.4.2.tar.bz2
tar xvf mpfr-2.4.2.tar
cd mpfr-2.4.2
./configure --disable-shared --enable-static --prefix=/tmp/gcc --with-gmp=/tmp/gcc
make && make check && make install

MPC

MPC is the GNU Multiple-precision C library. It depends on GMP and MPFR.

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar zxvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --disable-shared --enable-static --prefix=/tmp/gcc --with-gmp=/tmp/gcc --with-mpfr=/tmp/gcc
make && make check && make install

ELF stands for Executable and Linkable Format. This library takes provides architecture-independent size and endian support.

wget http://www.mr511.de/software/libelf-0.8.13.tar.gz
tar zxvf libelf-0.8.13.tar.gz
cd libelf-0.8.13
./configure --disable-shared --enable-static --prefix=/tmp/gcc
make && make check && make install

GCC is the GNU Compiler Collection. It depends on GMP, MPFR, MPC, and ELF.

wget http://www.netgull.com/gcc/releases/gcc-4.6.2/gcc-4.6.2.tar.gz
tar zxvf gcc-4.6.2.tar.gz

We must build gcc in a scratch directory, so we create it on the same mount point (within /tmp would trigger cross compile host issues)

mkdir -p /opt/downloads/gcc-4.6.2
cd /opt/downloads/gcc-4.6.2


/opt/downloads/gcc-4.6.2/configure  --disable-shared --disable-bootstrap  --disable-libstdcxx-pch  --enable-languages=all  --enable-libgomp  --enable-lto  --enable-threads=posix  --enable-tls  --with-gmp=/tmp/gcc  --with-mpfr=/tmp/gcc  --with-mpc=/tmp/gcc  --with-libelf=/tmp/gcc  --with-fpmath=sse
make && make install

Saturday, November 10, 2012

LVM Snapshot

LVM Snapshot is one of the good methods  data backup and restore. You can take a lvm snapshot for huge data. Here i took lvm snapshot for 60G with 300M but you should actually calculate the size according to the data you take the backup.

-s, --snapshot OriginalLogicalVolume{Name|Path}

              Create  a  snapshot  logical volume (or snapshot) for an existing, so called original logical volume (or origin).  Snapshots provide a ’frozen image’ of  the  contents  of the  origin while the origin can still be updated. They enable consistent backups and online recovery of removed/overwritten data/files.  Thin snapshot is created when the origin  is  a  thin  volume  and the size is not specified. Thin snapshot shares same blocks within the thin pool volume.  The snapshot with the specified  size  does  not need  the  same amount of storage the origin has. In a typical scenario, 15-20% might be enough.  In case the snapshot runs out of storage, use  lvextend(8)  to  grow  it. Shrinking  a  snapshot  is  supported by lvreduce(8) as well. Run lvdisplay(8) on the snapshot in order to check how much data is allocated  to  it.   Note  that  a  small
amount  of  the  space you allocate to the snapshot is used to track the locations of the chunks of data, so you should allocate slightly more space than you actually need and  monitor  the rate at which the snapshot data is growing so you can avoid running  out of space.

So, for a 100 GB LV, We can start with 20 GB for the snapshot volume.


A snapshot volume ONLY contains the files that have been changed since it was created. i.e. If you only changed 2kb of files since the snapshot... the snapshot consumes 2kb of disk space. It is a good idea to plan on allowing the snapshot sufficient space to do what you need before the snapshot is removed... i.e. if you are going to make 100gb of changes after the snaphot is taken... you need to allocate 100gb to the snapshot.. so it can consume 100gb if needed.

Actually, the space that is in actual use by the snapshot can be easily seen after activating the volumes (e.g., with vgchange -a y) -- in percents of the total space allocated for the snapshot:

it is shown in the Allocated to snapshot row of the output of lvdisplay, or by the snap_percent option of lvs.

(I simply was examining the volumes without activating them -- that's why I couldn't see this info straight on.)

If, for example, it's 5%, then you can simply use lvreduce -l 5%LV (or a bit more) to recalim all the unused space from the snapshot volume.

We can take a backup of this using copy command or the dd command.

There is also auto extend option for copy on write in lvm snapshot, we need to specify the percent in /etc/lvm.conf file  auto extend  line.

Example:

[root@ tester~]# lvcreate -L300M -s -n test /dev/VG1/public
  Rounding up size to full physical extent 320.00 MB
  Logical volume "test" created
Here test is the name of the snapshot and its size will be 300M This is a snapshot for logical
volume public.

[root@ tester~]# mkdir /mnt/test
[root@ tester~]# lvdisplay

 --- Logical volume ---
  LV Name                /dev/VG1/test
  VG Name                VG1
  LV UUID                SetE4Z-x9oD-72dH-tKc3-PltJ-vbPk-HXGZmv
  LV Write Access        read/write
  LV snapshot status     active destination for /dev/VG1/public
  LV Status              available
  # open                 0
  LV Size                60.00 GB
  Current LE             1920
  COW-table size         320.00 MB
  COW-table LE           10
  Allocated to snapshot  0.00%
  Snapshot chunk size    4.00 KB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

[root@ tester ~]# mount -t ext3 /dev/VG1/test /mnt/test

cd /mnt/test

[root@ test]# ls

It now has the same data like the logical group public.
cd

You can now remove a file or data from the original one and test it.
Then copy the same file from the snapshot. It works..

[root@ tester~]# tar -cf /dev/VG1/test /mnt/test
To take backup of the lvm snapshot.

[root@tester ~]# umount /dev/VG1/test /mnt/test
umount: /dev/VG1/test: not mounted
umount: /mnt/test: not mounted

[root@ tester~]# lvremove /dev/VG1/test
Do you really want to remove active logical volume test? [y/n]: y
  Logical volume "test" successfully removed

Monday, November 5, 2012

Reset the system default permissions using --setperms and --setugids.

Restore default system permissions in Linux using --setperms and --setugids.

1) To permissions on files and directories

for a in $(rpm -qa); do rpm --setperms $a; done

2) To reset uids and gids on files and directories :

for b in $(rpm -qa); do rpm --setugids $b; done












Password Protect a Directory Using htpasswd.

Password protect a directory in apache using .htaccess, so that only users with user name and password can access the website.

In order to set the password protected directory, you need to create a .htaccess with the  below lines

AuthType Basic
AuthName "Restricted Access"
AuthUserFile
Require user 


 And your httpd conf file must contain these lines to make the .htaccess work

Directory
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny

For example if you need to protect a directory test, first check the user,group of the apache and change the permissions.

[root@tester ~]# egrep -iw 'User|Group' --color=auto /etc/httpd/conf/httpd.conf
# If you wish httpd to run as a different user or group, you must run
# User/Group: The name (or #number) of the user/group to run httpd as.
#  . On SCO (ODT 3) use "User nouser" and "Group nogroup".
#    suggested workaround is to create a user www and use that user.
#  NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
#  when the value of (unsigned)Group is above 60000;
#  don't use Group #-1 on these systems!
User apache
Group apache
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
# The path to the end user account 'public_html' directory must be
    # To enable requests to /~user/ to serve the user's public_html
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{User-agent}i" agent
#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
# file in a language the user can understand.

[root@tester ~]# chown apache:apache test
[root@tester ~]# chmod 0660 test


Now you can generate the password using the htpassword for the user. here the user is tester

[root@tester ~]# htpasswd -c /home/tester/password tester
New password:
Re-type new password:
Adding password for user tester

[root@tester ~]# cat /home/tester/password
tester:V8Lg1v0SHqo72

Now you can keep the password file in the same location or different location and make a entry in the .htaccess file. Keep the password file in different location so that it cannot be accessible by the user when viewing the website.

.htaccess
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/httpd/conf/password
Require user tester

Here i placed the password file in different location and entered the required user as tester for accessing.

It works!!

You also have the option of deleting the htpasswd user using the below syntax

[root@tester ~]# htpasswd -D /home/tester/password tester
Deleting password for user tester




Wednesday, October 10, 2012

Extundelete tool to recover Deleted files.

Extundelete is a utility that can recover deleted files from an ext3 or ext4 partition. The ext3 file system is the most common file system when using Linux, and ext4 is its successor. extundelete uses the information stored in the partition's journal to attempt to recover a file that has been deleted from the partition. There is no guarantee that any particular file will be able to be undeleted, so always try to have a good backup system in place, or at least put one in place after recovering your files! 

Login as root

Extract the downloaded file and enter in to the directory using cd command,

Installation is very simple, Type

./configure
make && make install.

[root@tester ~]# cd  /usr/local/src/

Download the latest version of extun delete from the below URL
http://extundelete.sourceforge.net/

To compile and install this program, you must first install the binary and development packages for e2fsprogs and e2fslibs. You must also have installed a C++ compiler and a make utility to be able to compile extundelete.  You will get a error like below if your system doesn't have C compiler installed.


[root@tester ~]# ./configure
Configuring extundelete 0.2.0
configure: error: C++ compiler cannot create executables
See `config.log' for more details.

Just Install the C Compiler to fix this issue,

[root@tester ~]# Yum install gcc

and Now

[root@tester ~]#  ./configure
Configuring extundelete 0.2.0
Writing generated files to disk

[root@tester ~]# make
make -s all-recursive
Making all in src

[root@tester ~]# make install
Making install in src
/usr/bin/install -c 'extundelete' '/usr/local/bin/extundelete'

Installed Successfully.


Extundelete will restore any files it finds to a subdirectory of the current directory named “RECOVERED_FILES”. To run the program, type “extundelete --help” to see various options available to you.

[root@tester ~]# cd  /data

[root@tester data]# rm -rf test1


Here /dev/mapper/VolGroup02-data  is mounted in /data
To recover the deleted file, We need to unmount the /data parition

 [root@tester ~]# umount /data
 [root@tester ~]#/usr/local/bin/extundelete /dev/mapper/VolGroup02-data --restore-all
WARNING: Extended attributes are not restored.
Loading filesystem metadata ... 1485 groups loaded.
Loading journal descriptors ... 102 descriptors loaded.
Writing output to directory RECOVERED_FILES/
Searching for recoverable inodes in directory / ...
1 recoverable inodes found.
Looking through the directory structure for deleted files ...
Failed to restore inode 98305 to file RECOVERED_FILES/test1:Unable to set proper file size.
0 recoverable inodes still lost.

 [root@tester ~]# cd RECOVERED_FILES

It will create the RECOVERED_FILES Directory and restore the files in it,

 [root@tester ~]# ls
test1

File restored successfully.

Now you can remount the partition /dev/mapper/VolGroup02-data to /data

 [root@tester ~]# mount /dev/mapper/VolGroup02-data /data


You can follow the same steps for a restoring a single directory or single file using the following syntax.

extundelete /dev/sdb1 —-restore-directory
extundelete / —-restore-files

To Recover files in the / partition,

In my system /dev/sda2 is mounted on /
cd /
rm -rf test2
mount -o remount,ro /
# cd /secondarydrive (/dev/sda3) or (should have read/write access)
# extundelete / —-restore-files /test2

/usr/local/bin/extundelete / --restore-files /test2

Received error like below


/usr/local/bin/extundelete: "/" is a directory. You need to use the raw filesystem


used /dev/sda2 and the files are recovered successfully.

# cd RECOVERED_FILES
# ls
#test2

I have tried and recovered files up to 2 GB in the /partition. I never tried after reboot because the inode numbers may be replaced or overwritten by other files newly created and it is not possible to recover the files deleted before reboot.

You can download and get more information on this, from the below URL.

http://extundelete.sourceforge.net/






Thursday, October 4, 2012

389-Console Directory Server Installation

  The 389 Directory Server (previously Fedora Directory Server) is an LDAP (Lightweight Directory Access Protocol) server developed by Red Hat. The name 389 is derived from the port number for LDAP                                                                  
I followed the below steps for installing the Directory server.                                                                                                                       
   cd /etc/yum.repos.d
    yum clean all
   yum install xorg-x11-deprecated-libs
   yum install java-1.6.0-openjdk
   yum install 389-ds*
   yum install yum-plugin-protectbase.noarch
   yum -y localinstall epel-release-5-4.noarch.rpm
   yum -y update
   yum install mod_authz_ldap
   yum install openldap-clients

[root@tester tmp] wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
 --2012-09-21 12:36:44--  http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
 Resolving download.fedoraproject.org... 152.19.134.146, 140.211.169.197, 209.132.181.16, ...
 Connecting to download.fedoraproject.org|152.19.134.146|:80... connected.
 HTTP request sent, awaiting response... 302 FOUND
 Location: http://mirrors.einstein.yu.edu/epel/5/x86_64/epel-release-5-4.noarch.rpm [following]
 --2012-07-19 11:36:08--  http://mirrors.einstein.yu.edu/epel/5/x86_64/epel-release-5-4.noarch.rpm
 Resolving mirrors.einstein.yu.edu... 129.98.1.19, 129.98.1.27
 Connecting to mirrors.einstein.yu.edu|129.98.1.19|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 12232 (12K) [application/x-rpm]
 Saving to: `epel-release-5-4.noarch.rpm'
2012-09-21 12:36:44 (437 KB/s) - `epel-release-5-4.noarch.rpm' saved [12232/12232]

[root@tester tmp] ls -l epel-release-5-4.noarch.rpm
 -rw-rw---- 1 root root 12232 Sep 21  2012 epel-release-5-4.noarch.rpm

Okay, that’s better.  Let’s try yum install again:

[root@tester tmp] yum -y localinstall epel-release-5-4.noarch.rpm

… failed

the key problem again

 [root@tester tmp] rpm --checksig /tmp/epel-release-5-4.noarch.rpm
 /tmp/epel-release-5-4.noarch.rpm: (SHA1) DSA sha1 md5 (GPG) NOT OK (MISSING KEYS: GPG#217521f6)

Okay, let’s get that one:

[root@tester tmp] wget http://fedoraproject.org/static/217521F6.txt
 --2012-09-21 12:40:50--  http://fedoraproject.org/static/217521F6.txt
 Resolving fedoraproject.org... 152.19.134.146, 140.211.169.197, 209.132.181.16, ...
 Connecting to fedoraproject.org|152.19.134.146|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 1820 (1.8K) [text/plain]
 Saving to: `217521F6.txt'

100%[===============================================================================================>] 1,820       --.-K/s   in 0s

2012-09-21 12:40:50 (59.9 MB/s) - `217521F6.txt' saved [1820/1820]

[root@tester tmp] rpm --import 217521F6.txt


 Verify the signature now

[root@tester tmp]  rpm --checksig /tmp/epel-release-5-4.noarch.rpm
 /tmp/epel-release-5-4.noarch.rpm: (sha1) dsa sha1 md5 gpg OK

 see  we can install it.

[root@tester tmp] yum -y localinstall epel-release-5-4.noarch.rpm
 Loaded plugins: downloadonly, fastestmirror, security
 Setting up Local Package Process
 Examining epel-release-5-4.noarch.rpm: epel-release-5-4.noarch
 Marking epel-release-5-4.noarch.rpm to be installed
 Loading mirror speeds from cached hostfile
 * base: mirror.metrocast.net
 * extras: centos.mirror.nac.net
 * updates: mirror.7x24web.net
 Resolving Dependencies
 --> Running transaction check
 ---> Package epel-release.noarch 0:5-4 set to be updated
 --> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================
 Package                          Arch                       Version                  Repository                                    Size
 =========================================================================================================================================
 Installing:
 epel-release                     noarch                     5-4                      /epel-release-5-4.noarch                      0.0

Transaction Summary
 =========================================================================================================================================
 Install       1 Package(s)
 Upgrade       0 Package(s)

Downloading Packages:
 Running rpm_check_debug
 Running Transaction Test
 Finished Transaction Test
 Transaction Test Succeeded
 Running Transaction
 Installing     : epel-release                                                                                                      1/1

Installed:
 epel-release.noarch 0:5-4

Complete!

[root@tester tmp] yum -y update

Hmm.  The update of R-devel failed, which makes me unhappy.  I’m going to disable this repo by default. (Edit the file /etc/yum.repos.d/epel.repo and set enabled=0 where it says enabled=1).

Now, let’s get back to the task at hand.  Can we now install mod_auth_cas?

[root@tester tmp] yum -y install --enablerepo=epel mod_auth_cas

...

Installed:
 mod_auth_cas.x86_64 0:1.0.8.1-2.el5

Complete!

[root@tester tmp]  yum install 389-ds
..
Dependencies Resolved

=======================================================================================================================
 Package                          Arch              Version                                   Repository          Size
=======================================================================================================================
Installing:
 389-ds                           noarch            1.2.2-1.el6                               epel               9.9 k
Installing for dependencies:
 389-admin                        x86_64            1.1.29-1.el6                              epel               344 k
 389-admin-console                noarch            1.1.8-1.el6                               epel               202 k
 389-admin-console-doc            noarch            1.1.8-1.el6                               epel                43 k
 389-adminutil                    x86_64            1.1.15-1.el6                              epel                64 k
 389-console                      noarch            1.1.7-1.el6                               epel                72 k
 389-ds-base                      x86_64            1.2.9.14-1.el6_2.2                        updates            1.4 M
 389-ds-base-libs                 x86_64            1.2.9.14-1.el6_2.2                        updates            363 k
 389-ds-console                   noarch            1.2.6-1.el6                               epel               1.4 M
 389-ds-console-doc               noarch            1.2.6-1.el6                               epel                55 k
 389-dsgw                         x86_64            1.1.9-1.el6                               epel               468 k
 cyrus-sasl-gssapi                x86_64            2.1.23-13.el6                             base                33 k
 idm-console-framework            noarch            1.1.7-2.el6                               epel               1.1 M
 java-1.5.0-gcj                   x86_64            1.5.0.0-29.1.el6                          base               139 k
 java-1.6.0-openjdk               x86_64            1:1.6.0.0-1.43.1.10.6.el6_2               updates             25 M
 java_cup                         x86_64            1:0.10k-5.el6                             base               197 k
 jline                            noarch            0.9.94-0.8.el6                            base                86 k
 jpackage-utils                   noarch            1.7.5-3.12.el6                            base                59 k
 jss                              x86_64            4.2.6-20.el6                              base               746 k
 ldapjdk                          x86_64            4.18-6.el6                                base               847 k
 libgcj                           x86_64            4.4.6-3.el6                               base                19 M
 mod_nss                          x86_64            1.0.8-14.el6_2                            updates             82 k
 nss-tools                        x86_64            3.13.1-7.el6_2                            updates            725 k
 perl-CGI                         x86_64            3.51-119.el6_1.1                          base               206 k
 perl-Mozilla-LDAP                x86_64            1.5.3-4.el6                               base               160 k
 rhino                            noarch            1.7-0.7.r2.2.el6                          base               778 k
 sinjdoc                          x86_64            0.5-9.1.el6                               base               705 k
 svrcore                          x86_64            4.0.4-5.1.el6                             base                15 k
 tzdata-java                      noarch            2012b-3.el6                               updates            154 k
 zip                              x86_64            3.0-1.el6                                 base               260 k

Transaction Summary
=======================================================================================================================
Install      30 Package(s)

Total download size: 54 M
Installed size: 169 M
Is this ok [y/N]:

Configuration
setup-ds-admin.pl


[root@tester ~]# setup-ds-admin.pl

==============================================================================
This program will set up the 389 Directory and Administration Servers.

It is recommended that you have "root" privilege to set up the software.
Tips for using this program:
  - Press "Enter" to choose the default and go to the next screen
  - Type "Control-B" then "Enter" to go back to the previous screen
  - Type "Control-C" to cancel the setup program

Would you like to continue with set up? [yes]:

==============================================================================
Your system has been scanned for potential problems, missing patches,
etc.  The following output is a report of the items found that need to
be addressed before running this software in a production
environment.

389 Directory Server system tuning analysis version 10-AUGUST-2007.

NOTICE : System is x86_64-unknown-linux2.6.32-220.13.1.el6.x86_64 (2 processors).

NOTICE : The net.ipv4.tcp_keepalive_time is set to 7200000 milliseconds
(120 minutes).  This may cause temporary server congestion from lost
client connections.

WARNING: There are only 1024 file descriptors (hard limit) available, which
limit the number of simultaneous connections. 

WARNING: There are only 1024 file descriptors (soft limit) available, which
limit the number of simultaneous connections. 

WARNING  : The warning messages above should be reviewed before proceeding.

Would you like to continue? [no]: yes

==============================================================================
Choose a setup type:

   1. Express
       Allows you to quickly set up the servers using the most
       common options and pre-defined defaults. Useful for quick
       evaluation of the products.

   2. Typical
       Allows you to specify common defaults and options.

   3. Custom
       Allows you to specify more advanced options. This is
       recommended for experienced server administrators only.

To accept the default shown in brackets, press the Enter key.

Choose a setup type [2]:


==============================================================================
Enter the fully qualified domain name of the computer
on which you\'re setting up server software. Using the form
<hostname>.<domainname>
Example: eros.example.com.

To accept the default shown in brackets, press the Enter key.

Warning: This step may take a few minutes if your DNS servers
can not be reached or if DNS is not configured correctly.  If
you would rather not wait, hit Ctrl-C and run this program again
with the following command line option to specify the hostname:

    General.FullMachineName=your.hostname.domain.name

Computer name [centos.linuxproblems.org]:

==============================================================================
The servers must run as a specific user in a specific group.
It is strongly recommended that this user should have no privileges
on the computer (i.e. a non-root user).  The setup procedure
will give this user/group some permissions in specific paths/files
to perform server-specific operations.

If you have not yet created a user and group for the servers,
create this user and group using your native operating
system utilities.

System User [nobody]: ldap
System Group [nobody]: ldap

==============================================================================
Server information is stored in the configuration directory server.
This information is used by the console and administration server to
configure and manage your servers.  If you have already set up a
configuration directory server, you should register any servers you
set up or create with the configuration server.  To do so, the
following information about the configuration server is required: the
fully qualified host name of the form
<hostname>.<domainname>(e.g. hostname.example.com), the port number
(default 389), the suffix, the DN and password of a user having
permission to write the configuration information, usually the
configuration directory administrator, and if you are using security
(TLS/SSL).  If you are using TLS/SSL, specify the TLS/SSL (LDAPS) port
number (default 636) instead of the regular LDAP port number, and
provide the CA certificate (in PEM/ASCII format).

If you do not yet have a configuration directory server, enter 'No' to
be prompted to set up one.

Do you want to register this software with an existing
configuration directory server? [no]:

==============================================================================
Please enter the administrator ID for the configuration directory
server.  This is the ID typically used to log in to the console.  You
will also be prompted for the password.

Configuration directory server
administrator ID [admin]:
Password:
Password (confirm):

==============================================================================
The information stored in the configuration directory server can be
separated into different Administration Domains.  If you are managing
multiple software releases at the same time, or managing information
about multiple domains, you may use the Administration Domain to keep
them separate.

If you are not using administrative domains, press Enter to select the
default.  Otherwise, enter some descriptive, unique name for the
administration domain, such as the name of the organization
responsible for managing the domain.

Administration Domain [linuxproblems.org]:

==============================================================================
The standard directory server network port number is 389.  However, if
you are not logged as the superuser, or port 389 is in use, the
default value will be a random unused port number greater than 1024.
If you want to use port 389, make sure that you are logged in as the
superuser, that port 389 is not in use.

Directory server network port [389]:

==============================================================================
Each instance of a directory server requires a unique identifier.
This identifier is used to name the various
instance specific files and directories in the file system,
as well as for other uses as a server instance identifier.

Directory server identifier [centos]: centos-ds

==============================================================================
The suffix is the root of your directory tree.  The suffix must be a valid DN.
It is recommended that you use the dc=domaincomponent suffix convention.
For example, if your domain is example.com,
you should use dc=example,dc=com for your suffix.
Setup will create this initial suffix for you,
but you may have more than one suffix.
Use the directory server utilities to create additional suffixes.

Suffix [dc=linuxproblems, dc=org]:

==============================================================================
Certain directory server operations require an administrative user.
This user is referred to as the Directory Manager and typically has a
bind Distinguished Name (DN) of cn=Directory Manager.
You will also be prompted for the password for this user.  The password must
be at least 8 characters long, and contain no spaces.
Press Control-B or type the word "back", then Enter to back up and start over.

Directory Manager DN [cn=Directory Manager]:

==============================================================================
Certain directory server operations require an administrative user.
This user is referred to as the Directory Manager and typically has a
bind Distinguished Name (DN) of cn=Directory Manager.
You will also be prompted for the password for this user.  The password must
be at least 8 characters long, and contain no spaces.
Press Control-B or type the word "back", then Enter to back up and start over.

Directory Manager DN [cn=Directory Manager]:
Password:
Password (confirm):

==============================================================================
The Administration Server is separate from any of your web or application
servers since it listens to a different port and access to it is
restricted.

Pick a port number between 1024 and 65535 to run your Administration
Server on. You should NOT use a port number which you plan to
run a web or application server on, rather, select a number which you
will remember and which will not be used for anything else.

Administration port [9830]:

==============================================================================
The interactive phase is complete.  The script will now set up your
servers.  Enter No or go Back if you want to change something.

Are you ready to set up your servers? [yes]:

Creating directory server . . .
Your new DS instance 'centos-ds' was successfully created.
Creating the configuration directory server . . .
Beginning Admin Server creation . . .
Creating Admin Server files and directories . . .
Updating adm.conf . . .
Updating admpw . . .
Registering admin server with the configuration directory server . . .
Updating adm.conf with information from configuration directory server . . .
Updating the configuration for the httpd engine . . .
Starting admin server . . .
output: Starting dirsrv-admin:
output:                                                    [  OK  ]
The admin server was successfully started.
Admin server was successfully created, configured, and started.
Exiting . . .
Log file is '/tmp/setupk3F6CN.log'

[root@tester ~]# ps -ef | grep ldap
ldap     17547     1  0 12:13 ?        00:00:00 ./ns-slapd -D /etc/dirsrv/slapd-centos-ds -i /var/run/dirsrv/slapd-centos-ds.pid -w /var/run/dirsrv/slapd-centos-ds.startpid
ldap     17671 17667  0 12:13 ?        00:00:00 /usr/sbin/httpd.worker -k start -f /etc/dirsrv/admin-serv/httpd.conf

Verify the installation

[root@tester ~]# /usr/bin/ldapsearch -x -h centos -s base -b "dc=linuxproblems, dc=org" "objectclass=*"
# extended LDIF
#
# LDAPv3
# base <dc=linuxproblems, dc=org> with scope baseObject
# filter: objectclass=*
# requesting: ALL
#

# linuxproblems.org
dn: dc=linuxproblems,dc=org
objectClass: top
objectClass: domain
dc: linuxproblems

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

Running the Console

Now you should be able to run the console either locally, or remotely for example from my laptop:

[root@tester ~]# ssh -X centos /usr/bin/389-console -a http://centos:9830

Admin Server Console

From the 389-console, users can choose the admin server console:

    389admin.png
    389adminconsole.png

Directory Server Console

Or the directory server console:

    389directory.png
    389directoryconsole.png

You can read more about the console on the redhat documentation site and see more screenshots here.
Stopping and Starting

Stop and Start a directory server instance

[root@tester ~]# stop-dirsrv centos-ds
[root@tester ~]# ps -ef | grep slapd
root    22855 22147  0 13:26 pts/0    00:00:00 grep slapd
[root@tester ~]# start-dirsrv centos-ds
[root@tester ~]# ps -ef | grep slapd
ldap     22862     1  1 13:27 ?        00:00:00 ./ns-slapd -D /etc/dirsrv/slapd-centos-ds -i /var/run/dirsrv/slapd-centos-ds.pid -w /var/run/dirsrv/slapd-centos-ds.startpid

Stop and Start the directory server admin instance

[root@tester ~]# stop-ds-admin
[root@tester ~]]# ps -ef | grep admin-serv
root    22730 22147  0 13:25 pts/0    00:00:00 grep admin-serv
[root@tester ~]# start-ds-admin
#root@tester ~]# ps -ef | grep admin-serv
root     22737     1  0 13:26 ?        00:00:00 /usr/sbin/httpd.worker -k start -f /etc/dirsrv/admin-serv/httpd.conf
root     22740 22737  0 13:26 ?        00:00:00 /usr/sbin/httpd.worker -k start -f /etc/dirsrv/admin-serv/httpd.conf
ldap     22741 22737  0 13:26 ?        00:00:00 /usr/sbin/httpd.worker -k start -f /etc/dirsrv/admin-serv/httpd.conf

Directory Server Gateway, Phonebook and Org Chart

[root@tester ~]# /usr/sbin/setup-ds-dsgw
######################################################################
This shell script will configure the Directory Server
Gateway, Phonebook and Org Chart web applications to
work with the Administration Server.

Reading parameters from Administration Server config . . .
Using Administration Server URL http://centos.linuxproblems.org:9830 . . .
Reading parameters from Directory Server /etc/dirsrv/slapd-centos-ds . . .
Using Directory Server URL ldap://centos.linuxproblems.org:389/dc=linuxproblems,dc=org . . .
Generating config file /etc/dirsrv/dsgw/dsgw.conf . . .
Generating config file /etc/dirsrv/dsgw/pb.conf . . .
Generating config file /etc/dirsrv/dsgw/orgchart.conf . . .
Generating config file /etc/dirsrv/dsgw/default.conf . . .
Generating the credential database directory . . .
Adding configuration to httpd config file /etc/dirsrv/admin-serv/httpd.conf . . .
Enabling links to web apps from Administration Server home page . . .

The Directory Server Gateway web applications have been successfully configured.
You will need to restart your Administration Server.
######################################################################

[root@tester ~]# stop-ds-admin
[root@tester ~]# start-ds-admin

Now browse to the admin server at http://<adminserver>:9830/dist/download

  













Thursday, September 27, 2012

Create a Swap File in Linux

Add Additional Swap space for System performance.

Check the size of the disk and create a swap space accordingly.

[root@vmtest02 ~]# free -m
                     total       used       free     shared    buffers     cached
Mem:          2003        437       1565          0         24        307
-/+ buffers/cache:        105       1897
Swap:         4102          0           4102

[root@vmtest02 ~]# df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3     12G  4.1G  6.8G  38% /
/dev/sda6     ext3     20G  3.7G   15G  20% /u01
/dev/sda5     ext3    3.9G  775M  3.0G  21% /tmp
/dev/sda1     ext3     99M   11M   83M  12% /boot
tmpfs        tmpfs   1002M     0 1002M   0% /dev/shm

Create Storage file for 1GB using the below command.

[root@vmtest02 ~]# dd if=/dev/zero of=/u01/swapfile1 bs=1024M count=1
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 68.8808 seconds, 15.6 MB/s

To set the swap area, type

 [root@vmtest02 ~]# mkswap /u01/swapfile1
Setting up swapspace version 1, size = 1073737 kB

 By default the permissions will be

[root@vmtest02 ~]# ls -l /u01/swapfile1
-rw-r--r-- 1 root root 1073741824 Sep 27 13:26 /u01/swapfile1

change it root and set the permissions to 0600 for security reasons

Check the partition size reduced by 1GB

[root@vmtest02 ~]# df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3     12G  4.1G  6.8G  38% /
/dev/sda6     ext3     20G  4.7G   14G  25% /u01
/dev/sda5     ext3    3.9G  775M  3.0G  21% /tmp
/dev/sda1     ext3     99M   11M   83M  12% /boot
tmpfs        tmpfs   1002M     0 1002M   0% /dev/shm

Activate the swap file and cross check the swap size.

[root@vmtest02 ~]# swapon /u01/swapfile1

Verify the swap space.

[root@vmtest02 ~]# free -m
                   total       used       free     shared    buffers     cached
Mem:          2003       1477        525          0         26       1331
-/+ buffers/cache:        120       1883
Swap:         5126          0          5126

Check the details of swap files using the below command.

swapon -s


You can also make the swap  on and off using the below commands.

swapoff -a &&  swapon -a
To make it permanent after reboot , make a entry in /etc/fstab like

 u01/swapfile1 swap swap defaults 0 0





R installation in Linux

        cd  /usr/local/src/
        wget http://linux.softpedia.com/dyn-postdownload.php?p=1182&t=0&i=1

    --> tar -zxvf  R-2.15.tar.gz
   ---> cd R-2.15
   --> ./configure --prefix=/usr/local/R-2.15 --enable-R-shlib
    --> make
    --> make install
    --> Add R path in the bash profile.


  --> open this file /etc/ld.so.conf.d/R-i386.conf and put the following entry /usr/local/R-2.15/lib/R/lib then save and exit.
  --> run the ldconfig command.

It should work fine.

Install for 64 bit architechture.

Download from source, untar
./configure

 Neither an F77 compiler nor f2c found error

If you receive the above error follow the below steps

Yum install gcc*  will fix the issue.


R is now configured for x86_64-unknown-linux-gnu

  Source directory:          .
  Installation directory:    /usr/local/R-2.15

  C compiler:                gcc -std=gnu99  -g -O2
  Fortran 77 compiler:       gfortran  -g -O2

  C++ compiler:              g++  -g -O2
  Fortran 90/95 compiler:    gfortran -g -O2
  Obj-C compiler:            gcc -g -O2

  Interfaces supported:      X11, tcltk
  External libraries:        readline
  Additional capabilities:   PNG, JPEG, iconv, MBCS, NLS
  Options enabled:           shared R library, shared BLAS, R profiling

  Recommended packages:      yes

configure: WARNING: you cannot build DVI versions of the R manuals
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals


make ; make install

configure: error: --with-x=yes (default) and X11 headers/libs are not available

If you receive the above error , follow the below steps

./configure --prefix=/usr/local/R-2.15 --enable-R-shlib  --with-x=no

export PATH=$PATH:/usr/local/R-2.15/bin

ln /usr/local/R-2.15/lib64/R/lib /usr/local/lib64

export  R path in bash profile

Thursday, September 20, 2012

BOOST Installation in Linux

cd /usr/local/src/
wget  boost_1_51_0.tar.gz
tar -zxvf  boost_1_51_0.tar.gz
cd  boost_1_51_0

 ./bootstrap.sh --with-libraries=signals,python --prefix=/usr/local/ --includedir=/usr/local/include/ --libdir=/usr/local/lib

./b2

################################################

mod_wsgi Installation

The aim of mod_wsgi is to implement a simple to use Apache module which can host any Python application which supports the Python WSGI interface. The module would be suitable for use in hosting high performance production web sites, as well as your average self managed personal sites running on web hosting services.

cd /usr/local/src/

wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
tar -zxvf mod_wsgi-3.4.tar.gz
cd mod_wsgi-3.4

 locate apxs
./configure --with-apxs=/usr/local/apache/bin/apxs  --with-python=/usr/local/bin/python
make
make install

Edit httpd.conf file
LoadModule wsgi_module modules/mod_wsgi.so

For apache 1.3 version
AddModule mod_wsgi.c

/etc/init.d/httpd/ restart

Install python 2.7 using tar file

    cd /usr/local/src/
    wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
    tar -zxvf Python-2.7.2.tgz
    cd Python-2.7.2
    ./configure --prefix=/opt/python2.7 --with-threads --enable-shared
    make
    make install


Once the python is installed separately export LD_LIBRARY_PATH=/usr/local/lib
path of the current python library.

If it doesn't work try locating the libpython and place it in the right path to make it work.

   --> ./configure --prefix=/usr/local/python2.7  --enable-shared
   --> make ; make install
   --> updatedb
   --> locate libpython2.7.so.1.0
   --> cp -r /usr/local/python2.7/lib/libpython2.7.so.1.0 /usr/lib
  -->  Add /usr/lib in /etc/ld.so.conf file
  -->   Type ldconfig command
   --> Add python path in the bash profile.

It works now !!

PHP Installation in Linux

 
cd /usr/local/src
wget http://es.php.net/distributions/php-5.4.1.tar.gz
tar -zxvf  php-.5.4.1.tar.gz
cd php-5.4.1

Run the command updatedb

Find the exact path of the Apache extension tool (apxs) using
 locate apxs 


./configure --with-apxs2=/usr/sbin/apxs --with-mysql=/usr/bin/mysql --with-libdir=lib64 --enable-mbstring --with-mcrypt

you can also use --prefix= (to the location you need the php to be installed)

Error
checking libxml2 install dir… /opt/xml2/
checking for xml2-config path…
configure: error: xml2-config not found. Please check your libxml2 installation.

Solution
yum -y install libxml2-devel
Error
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

Solution
yum install libmcrypt
yum install libmcrypt-devel

Error:
configure: error: Cannot find MySQL header files under /usr/bin/mysql.
Note that the MySQL client library is not bundled anymore!


./configure --with-apxs2=/usr/sbin/apxs --with-mysqli=/usr/bin/mysql_config --enable-mbstring --with-mcrypt


make
make install

generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
config.status: executing default commands


PHP installed successfully now.

You can check the installed php using:

rpm -qa  | grep -i php

For more details you can check 

./configure --help


######################################################################################

Wednesday, September 19, 2012

Apache 2 installation

cd /usr/local/src

 Download the latest version of http and run the below commands

wget http://apache.techartifact.com/mirror//httpd/httpd-2.4.3.tar.gz

tar -zxvf httpd-2.4.3.tar.gz

cd httpd-2.4.3

./configure --prefix=/usr/local/apache2 --with-php=/usr/bin/php --with-mysql=/usr/bin/mysql  --
enable-mods-shared=all --with-included-apr

 You may get the below errors,  you can fix it by following the below steps

configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.


cd  /usr/local/src/
wget http://apache.techartifact.com/mirror//apr/apr-1.4.6.tar.gz
tar -zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure
make
make install

cp -r /usr/local/src/apr-1.4.6 /usr/local/src/httpd-2.4.3/srclib/

cd ../httpd-2.4.3/

./configure --prefix=/usr/local/apache2 --with-php=/usr/bin/php --with-mysql=/usr/bin/mysql --enable-mods-shared=all --with-apr=/usr/local/src/httpd-2.4.3/srclib/apr-1.4.6 --with-apr-util=/usr/local/src/apr-util-1.5.1

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/


cd ..

wget pcre

./configure
make
make install

 cd ../httpd-2.4.3/

./configure
configure: error: Did not find pcre-config script at /usr/local/src/pcre-8.31/

yum install pcre-devel

apr-util not found.configure: error: APR-util version 1.3.0 or later is required

wget apr-util1.5.0

./configure --with-apr=/usr/local/src/apr-1.4.6

make
make install

cd httpd

./configure --prefix=/usr/local/apache2 --with-php=/usr/bin/php --with-mysql=/usr/bin/mysql --enable-mods-shared=all --with-apr=/usr/local/src/httpd-2.4.3/srclib/apr-1.4.6 --with-apr-util=/usr/local/src/apr-util-1.5.1

make
make install

 ps -ef | grep httpd

killall -9 httpd

 cd /usr/local/apache2/bin/

./apachectl start

It should work...

Enable User Home directory http://xxx.ip.xxx/~username

All you have to do is editing these example lines in your httpd.conf

#
# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is received.
#
<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>

#
# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
</LimitExcept>
</Directory>



Note that the files and all the directories  have to  read permission for the user under which apache runs. That normally means they have to be world readable. Apache does not use the permissions of the refering user.

If it doesn't work, make sure you have mod_userdir installed.


Restricting what users are permitted to use this feature

Using the syntax shown in the UserDir documentation, you can restrict what users are permitted to use this functionality:

UserDir disabled root krish raj

The configuration above will enable the feature for all users except for those listed in the disabled statement. You can, likewise, disable the feature for all but a few users by using a configuration like the following:

UserDir disabled
UserDir enabled sai tester


Enabling a cgi directory for each user

In order to give each user their own cgi-bin directory, you can use a <Directory> directive to make a particular subdirectory of a user's home directory cgi-enabled.


<Directory /home/*/public_html/cgi-bin/>
Options ExecCGI
SetHandler cgi-script
</Directory>

Then, presuming that UserDir is set to public_html, a cgi program example.cgi could be loaded from that directory as:

http://example.com/~tester/cgi-bin/example.cgi

           
Save the file using :wq or x

Restart apache /etc/init.d/httpd restart

It will work

If you find any internal server error there must a permission issues for the files and directories.

Ensure that the directories have 755 permission and files have 644 permission.

you can also run the below command.

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;

Try running the above command inside the directory so that other files in the server doesn't get affected.

Restart the apache . It will work.

By default when adding the user, the public_html directory will not be available. I tried by creating the public_html direcotry in /etc/skel .

After this when ever i create a user the public_html directory is created by default to the users home directory.

Wednesday, September 12, 2012

Check the Process id and Process states

 [root@crs2 ~]# ps -aux | less


USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2040   632 ?        Ss   09:30   0:00 init [5]     
                    
root         2  0.0  0.0      0     0 ?        S    09:30   0:00 [migration/0]
root         3  0.0  0.0      0     0 ?        SN   09:30   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    09:30   0:00 [watchdog/0]
root         5  0.0  0.0      0     0 ?        S<   09:30   0:00 [events/0]
root         6  0.0  0.0      0     0 ?        S<   09:30   0:00 [khelper]
root         7  0.0  0.0      0     0 ?        S<   09:30   0:00 [kthread]
root        10  0.0  0.0      0     0 ?        S<   09:30   0:00 [kblockd/0]
root        11  0.0  0.0      0     0 ?        S<   09:30   0:00 [kacpid]
root       180  0.0  0.0      0     0 ?        S<   09:30   0:00 [cqueue/0]
root       183  0.0  0.0      0     0 ?        S<   09:30   0:00 [khubd]
root       185  0.0  0.0      0     0 ?        S<   09:30   0:00 [kseriod]
root       249  0.0  0.0      0     0 ?        S    09:30   0:00 [pdflush]
root       250  0.0  0.0      0     0 ?        S    09:30   0:00 [pdflush]
:



You can check the process id and states of process using the below command and syntax.

[root@crs2 ~]# ps -C init -o pid=,cmd,stat
      CMD                         STAT
    1 init [5]                    Ss

[root@crs2 ~]# ps -C firefox -o pid=,cmd,stat
      CMD                         STAT
 6666 /bin/sh /usr/lib/firefox-1. S

 Processes states that ps indicate are:

D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.

< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group

Wednesday, August 8, 2012

Disable su for users not in wheel group

You can disable the su option for users not in wheel group.

vim /etc/pam.d/su

#auth           required        pam_wheel.so use_uid


Uncomment this line , Save and exit.  There after the users cannot use su option, will display incorrect password.

Monday, August 6, 2012

Set the shell prompt with your messages using PROMPT_COMMAND

You can use the PROMPT_COMMAND to make your current shell displaying a message of your own ideas.

Here ''Have a wonderful day" is my message.


[root@tester ~]# PROMPT_COMMAND="echo Have a wonderful day"
Have a wonderful day

[root@tester ~]# date
Mon Aug  6 21:35:43 IST 2012
Have a wonderful day

[root@tester ~]# cat /etc/issue

Red Hat Enterprise Linux Server release 5.1 (Tikanga)
Kernel \r on an \m

Have a wonderful day

[root@tester ~]# unset
Have a wonderful day

[root@tester ~]# date
Mon Aug  6 21:36:35 IST 2012
Have a wonderful day


[root@tester ~]# PROMPT_COMMAND=" "
[root@tester ~]# date
Mon Aug  6 21:37:16 IST 2012

All the countries time can be checked in linux with the single command "tzselect"

[root@tester ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 2
Please select a country.
 1) Anguilla              18) Ecuador               35) Paraguay
 2) Antigua & Barbuda     19) El Salvador           36) Peru
 3) Argentina             20) French Guiana         37) Puerto Rico
 4) Aruba                 21) Greenland             38) St Kitts & Nevis
 5) Bahamas               22) Grenada               39) St Lucia
 6) Barbados              23) Guadeloupe            40) St Pierre & Miquelon
 7) Belize                24) Guatemala             41) St Vincent
 8) Bolivia               25) Guyana                42) Suriname
 9) Brazil                26) Haiti                 43) Trinidad & Tobago
10) Canada                27) Honduras              44) Turks & Caicos Is
11) Cayman Islands        28) Jamaica               45) United States
12) Chile                 29) Martinique            46) Uruguay
13) Colombia              30) Mexico                47) Venezuela
14) Costa Rica            31) Montserrat            48) Virgin Islands (UK)
15) Cuba                  32) Netherlands Antilles  49) Virgin Islands (US)
16) Dominica              33) Nicaragua
17) Dominican Republic    34) Panama
#? 10
Please select one of the following time zone regions.
 1) Newfoundland Time, including SE Labrador
 2) Atlantic Time - Nova Scotia (most places), PEI
 3) Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971
 4) Atlantic Time - New Brunswick
 5) Atlantic Time - Labrador - most locations
 6) Atlantic Standard Time - Quebec - Lower North Shore
 7) Eastern Time - Quebec - most locations
 8) Eastern Time - Ontario - most locations
 9) Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
10) Eastern Time - Thunder Bay, Ontario
11) Eastern Time - east Nunavut - most locations
12) Eastern Time - Pangnirtung, Nunavut
13) Eastern Time - Resolute, Nunavut
14) Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
15) Central Time - central Nunavut
16) Central Time - Manitoba & west Ontario
17) Central Time - Rainy River & Fort Frances, Ontario
18) Central Time - west Nunavut
19) Central Standard Time - Saskatchewan - most locations
20) Central Standard Time - Saskatchewan - midwest
21) Mountain Time - Alberta, east British Columbia & west Saskatchewan
22) Mountain Time - central Northwest Territories
23) Mountain Time - west Northwest Territories
24) Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
25) Pacific Time - west British Columbia
26) Pacific Time - south Yukon
27) Pacific Time - north Yukon
#? 21

The following information has been given:

        Canada
        Mountain Time - Alberta, east British Columbia & west Saskatchewan

Therefore TZ='America/Edmonton' will be used.
Local time is now:      Mon Aug  6 09:49:49 MDT 2012.
Universal Time is now:  Mon Aug  6 15:49:49 UTC 2012.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
        TZ='America/Edmonton'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
America/Edmonton

Tuesday, July 31, 2012

Enable and disable shell built in commands.

Enable command allows you to enable and disable your shell built in commands.

View the shell built in commands using

[root@tester ~]# enable
enable .
enable :
enable [
enable alias
enable bg
enable bind
enable break
enable builtin
enable caller
enable cd
enable command
enable compgen
enable complete
enable continue
enable declare
enable dirs
enable disown
enable echo
enable enable
enable eval
enable exec
enable exit
enable export
enable false
enable fc
enable fg
enable getopts
enable hash
enable help
enable history
enable jobs
enable kill
enable let
enable local
enable logout
enable popd
enable printf
enable pushd
enable pwd
enable read
enable readonly
enable return
enable set
enable shift
enable shopt
enable source
enable suspend
enable test
enable times
enable trap
enable true
enable type
enable typeset
enable ulimit
enable umask
enable unalias
enable unset
enable wait

Disable the commands using -n option

[root@tester ~]# enable -n history
[root@tester ~]# history
bash: history: command not found.

[root@tester ~]# history

Enable the commands using -a option.

145  enable -a history
  146  history
  147  enable
  148  man command
  149  enable -n history
  150  history
  151  enable -a history
  152  history | less
 153   history


You can also view using the set command . For more options you can check with man page.

[root@tester ~]# set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off