Sunday, 5 July 2015

Steps for postgres db backup and restore through command line

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

Steps for postgres db backup and restore through command line
-------------------------------------------------------------

To take pg backup
~~~~~~~~~~~~~~~

# su - postgres
$ /opt/PostgreSQL/9.4/bin/pg_dump cawc > /opt/PostgreSQL/9.4/data/cawc_bck.sql


To restore pg backup
~~~~~~~~~~~~~~~~~
**For remote system
**Copy the created backup file ( cawc_bck.sql ) in /opt/PostgreSQL/9.4/data/ directory ( to avoid db user permission )

#su - postgres
$ /opt/PostgreSQL/9.4/bin/psql -d cawc -f /opt/PostgreSQL/9.4/data/cawc_bck.sql

7 Examples to Manage Linux Password Expiration and Aging Using chage

7 Examples to Manage Linux Password Expiration and Aging Using chage

  

# apt-get install chage

Note: It is very easy to make a typo on this command. Instead of chage you may end up typing it as change. Please remember chage stands for “change age”. i.e chage command abbreviation is similar to chmod, chown etc.,

1. List the password and its related details for an user

As shown below, any user can execute the chage command for himself to identify when his password is about to expire.
Syntax: chage –-list username (or) chage -l username

$ chage --list dhinesh
Last password change                                    : Apr 01, 2009
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

If user dhinesh tries to execute the same command for user ramesh, he’ll get the following permission denied message.
$ chage --list ramesh
chage: permission denied

Note: However, a root user can execute chage command for any user account.

When user dhinesh changes his password on Apr 23rd 2009, it will update the “Last password change” value as shown below.

Please refer to our earlier article: Best Practices and Ultimate Guide For Creating Super Strong Password, which will help you to follow the best practices while changing password for your account.
$ date
Thu Apr 23 00:15:20 PDT 2009

$ passwd dhinesh
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

$ chage --list dhinesh
Last password change                                    : Apr 23, 2009
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

2. Set Password Expiry Date for an user using chage option -M

Root user (system administrators) can set the password expiry date for any user. In the following example, user dhinesh password is set to expire 10 days from the last password change.

Please note that option -M will update both “Password expires” and “Maximum number of days between password change” entries as shown below.
Syntax: # chage -M number-of-days username

# chage -M 10 dhinesh

# chage --list dhinesh
Last password change                                    : Apr 23, 2009
Password expires                                        : May 03, 2009
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 10
Number of days of warning before password expires       : 7

3. Password Expiry Warning message during login

By default the number of days of warning before password expires is set to 7. So, in the above example, when the user dhinesh tries to login on Apr 30, 2009 — he’ll get the following message.
$ ssh dhinesh@testingserver
dhinesh@testingserver's password:
Warning: your password will expire in 3 days

4. User Forced to Change Password after Expiry Date

If the password expiry date reaches and user doesn’t change their password, the system will force the user to change the password before the login as shown below.
$ ssh dhinesh@testingserver
dhinesh@testingserver's password:

You are required to change your password immediately (password aged)
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for dhinesh
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:

5. Set the Account Expiry Date for an User

You can also use chage command to set the account expiry date as shown below using option -E. The date given below is in “YYYY-MM-DD” format. This will update the “Account expires” value as shown below.
# chage -E "2009-05-31" dhinesh

# chage -l dhinesh
Last password change                                    : Apr 23, 2009
Password expires                                        : May 03, 2009
Password inactive                                       : never
Account expires                                         : May 31, 2009
Minimum number of days between password change          : 0
Maximum number of days between password change          : 10
Number of days of warning before password expires       : 7

6. Force the user account to be locked after X number of inactivity days

Typically if the password is expired, users are forced to change it during their next login. You can also set an additional condition, where after the password is expired, if the user never tried to login for 10 days, you can automatically lock their account using option -I as shown below. In this example, the “Password inactive” date is set to 10 days from the “Password expires” value.

Once an account is locked, only system administrators will be able to unlock it.
# chage -I 10 dhinesh

# chage -l dhinesh
Last password change                                    : Apr 23, 2009
Password expires                                        : May 03, 2009
Password inactive                                       : May 13, 2009
Account expires                                         : May 31, 2009
Minimum number of days between password change          : 0
Maximum number of days between password change          : 10
Number of days of warning before password expires       : 7

7. How to disable password aging for an user account

To turn off the password expiration for an user account, set the following:
  • -m 0 will set the minimum number of days between password change to 0
  • -M 99999 will set the maximum number of days between password change to 99999
  • -I -1 (number minus one) will set the “Password inactive” to never
  • -E -1 (number minus one) will set “Account expires” to never.
# chage -m 0 -M 99999 -I -1 -E -1 dhinesh

# chage --list dhinesh
Last password change                                    : Apr 23, 2009
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

 

How to Set JAVA_HOME / PATH variables Under Linux Bash Profile

How to Set JAVA_HOME / PATH variables Under Linux Bash Profile

I just need a help to show me how to setup java path on Linux. How can I set JAVA_HOME and PATH variables for every user under my Linux system?

~/.bash_profile is a startup script which generally runs once. This particular file is used for commands which run when the normal user logs in. Common uses for .bash_profile are to set environment variables such as PATH, JAVA_HOME, to create aliases for shell commands, and to set the default permissions for newly created files.

Set JAVA_HOME / PATH for a single user

Login to your account and open .bash_profile file

$ vi ~/.bash_profile

Set JAVA_HOME as follows using syntax export JAVA_HOME=<path-to-java>. If your path is set to /usr/java/jdk1.7.0_07/bin/java, set it as follows:

export JAVA_HOME=/usr/java/jdk1.7.0_07/bin/java

Set PATH as follows:

export PATH=$PATH:/usr/java/jdk1.7.0_07/bin

Feel free to replace /usr/java/jdk1.7.0_07 as per your setup.
Save and close the file. Just logout and login back to see new changes. Alternatively, type the following command to activate the new path settings immediately:
 
$ source ~/.bash_profile

OR
 
$ . ~/.bash_profile

Verify new settings:
 
$ echo $JAVA_HOME
 

$ echo $PATH

Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:
 
$ which java

Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.

Set JAVA_HOME / PATH for all user

You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:
 
# vi /etc/profile

Next setup PATH / JAVA_PATH variables as follows:
 
export PATH=$PATH:/usr/java/jdk1.7.0_07/bin
 

export PATH=$PATH:/usr/java/jdk1.7.0_07/bin

Save and close the file. Once again you need to type the following command to activate the path settings immediately:
 
# source /etc/profile

OR
 
# . /etc/profile

Friday, 3 July 2015

HOW TO INSTALL GIMP 2.8 ON CENTOS 6 / RHEL6

HOW TO INSTALL GIMP 2.8 ON CENTOS 6 / RHEL6


first install required packages:
yum install -y aalib aalib-devel libexif-devel libjpeg-devel libpng-devel
yum install -y libtiff-devel libmng-devel libXpm-devel librsvg-devel libwmf-devel
yum install -y libffi-devel webkitgtk-devel python-devel zlib-devel pygtk2-devel
Download Following Packages:
gimp-2.8.6
ftp://ftp.gimp.org/pub/gimp/v2.8/gimp-2.8.6.tar.bz2
babl-0.1.10
ftp://ftp.gimp.org/pub/babl/0.1/babl-0.1.10.tar.bz2
gegl-0.2.0
ftp://ftp.gimp.org/pub/gegl/0.2/gegl-0.2.0.tar.bz2


download and extract above 9 packages and copy to /opt


go to terminal with root and copy Following Code :-
############################################################
mkdir /opt/gimp2.8
cd /opt/babl-0.1.10
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/glib-2.34.0
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/gegl-0.2.0
export PKG_CONFIG_PATH=/opt/gimp2.8/lib/pkgconfig
export LD_LIBRARY_PATH=/opt/gimp2.8/lib
mkdir /opt/gegl
mkdir /opt/gegl/buffer
mkdir /opt/gegl/buffer/babl
cp -p /opt/gimp2.8/include/babl-0.1/babl/*.h /opt/gegl/buffer/babl/
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/atk-2.2.0
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/cairo-1.12.16
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/pango-1.29.4
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/gdk-pixbuf-2.24.1
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/gtk+-2.24.10
export LD_LIBRARY_PATH=/opt/gimp2.8/lib
export PKG_CONFIG_PATH=/opt/gimp2.8/lib/pkgconfig
./configure –prefix=/opt/gimp2.8
make
make install
cd /opt/gimp-2.8.6
export LD_LIBRARY_PATH=/opt/gimp2.8/lib
export PKG_CONFIG_PATH=/opt/gimp2.8/lib/pkgconfig
./configure –prefix=/opt/gimp2.8
make
make install
/opt/gimp2.8/bin/gimp-2.8
############################################################

It Will Take approximate (30-40 Minutes to compile)
After Compile
go to terminal and enter
/opt/gimp2.8/bin/gimp-2.8

Thursday, 25 June 2015

cannot change directory in ftp


FTP PROBLEM
#500:oops: cannot change directory.

FTP SOLUTION
#getenforce

...check selinux status

#getsebool -a | grep ftp

check for ftp_home_dir----off

#setsebool -P ftp_home_dir 1 (or ON)

Saturday, 9 May 2015

Torque Installation on master node and compute node


Torque Installation on master node and compute node

master:######mastername.org
computenode:compute node name
MasterNode:
#ssh-keygen -t rsa /*password less access*/
#ssh-copy-id aetpl2
#yum install libtool openssl-devel libxml2-devel boost-devel gcc gcc-c++
#wget http://wpfilebase.s3.amazonaws.com/torque/torque-5.1.0-1_4048f77c.tar.gz
#tar -zxvf torque-5.1.0-1_4048f77c.tar.gz
#mv torque-5.1.0-1_4048f77c torque-5.1
#cd torque-5.1
# ./configure
# make
#make install
# cp contrib/init.d/trqauthd /etc/init.d
#chkconfig --add trqauthd
#echo /usr/local/lib > /etc/ld.so.conf.d/torque.conf
#ldconfig
#echo aetpl3.org > /var/spool/torque/server_name
#export PATH=/usr/local/bin/:/usr/local/sbin/:$PATH
#./torque.setup root
Currently no servers active. Default server will be listed as active server. Error 15133
Active server name: aetpl3.org pbs_server port is: 15001
trqauthd daemonized - port /tmp/trqauthd-unix
trqauthd successfully started
initializing TORQUE (admin: root@aetpl3.org)

You have selected to start pbs_server in create mode.
If the server database exists it will be overwritten.
do you wish to continue y/(n)?y
root 5064 1 0 15:12 ? 00:00:00 pbs_server -t create
Max open servers: 9
set server operators += root@aetpl3.org
Max open servers: 9


#vim /var/spool/torque/server_priv/nodes
aetpl2.org /*add compute node name*/
# make packages
# cp contrib/init.d/pbs_server /etc/init.d
# chkconfig --add pbs_server
#service pbs_server restart
#cp contrib/init.d/pbs_mom /etc/init.d
# chkconfig --add pbs_mom
# service pbs_mom start


#cp contrib/init.d/pbs_sched /etc/init.d
#chkconfig --add pbs_sched

#service pbs_sched start
#Starting TORQUE Scheduler: [ OK ]
#scp torque-package-clients-linux-x86_64.sh torque-package-mom-linux-x86_64.sh root@aetpl2:/root
#useradd user
#passwd user
#su – user
#ssh-key-gen -t rsa /* password less user*/
#ssh-copy-id aetpl2@user
#su – user
#mkdir job
#vim test.sh
#!/bin/bash
#PBS -l walltime=00:1:00
#PBS -l nice=19
#PBS -q test
date
sleep 10
date
#qsub test.sh /*job submission*/
#qstat -a /* job status*/
#pbsnodes /*list all nodes*/
Compute nodes:
#cd
# ./torque-package-clients-linux-x86_64.sh --install

Installing TORQUE archive...

Done.
./torque-package-mom-linux-x86_64.sh --install

Installing TORQUE archive...
# service pbs_mom start
Starting TORQUE Mom: [ OK ]
# chkconfig pbs_mom on

# scp contrib/init.d/pbs_mom root@aetpl2:/etc/init.d/

# chkconfig --add pbs_mom

# service pbs_mom start
Starting TORQUE Mom: [ OK ]
#chkconfig pbs_mom on
#useradd user
#passwd user
#su – user
#ssh-keygen -t rsa /* password less user*/
#ssh-copy-id aetpl2@user
#su – user
#

Wednesday, 6 May 2015

Install And Configure PXE Server And Client On CentOS 6.5

http://www.unixmen.com/setup-pxe-boot-environment-using-cobbler-centos-6-5/