Tuesday, March 24, 2009

Apache restart with Sudo Permission - Issue

Unfortunately, this issue ate my 5 days to fix this issue.
and the resolution was very very small compare to time take by it.

Issue :
While restarting apache with sudo access it was throwing some exception, while same with root was working fine.

Exception :
$ sudo /etc/init.d/apache restart
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable LD_LIBRARY_PATH was undefined
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable JAVA_BINDIR was undefined
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable JAVA_HOME was undefined
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable JAVA_ROOT was undefined
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable JDK_HOME was undefined
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable JRE_HOME was undefined
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable JRUBY_HOME was undefined
[Tue Mar 17 17:01:45 2009] [warn] PassEnv variable ORACLE_HOME was undefined
Syntax OK
Shutting down httpd2 (waiting for all children to terminate) done
Starting httpd2 (prefork) [Tue Mar 17 17:01:47 2009] [warn] PassEnv variable LD_LIBRARY_PATH was undefined
[Tue Mar 17 17:01:47 2009] [warn] PassEnv variable JAVA_BINDIR was undefined
[Tue Mar 17 17:01:47 2009] [warn] PassEnv variable JAVA_HOME was undefined
[Tue Mar 17 17:01:47 2009] [warn] PassEnv variable JAVA_ROOT was undefined
[Tue Mar 17 17:01:47 2009] [warn] PassEnv variable JDK_HOME was undefined
[Tue Mar 17 17:01:47 2009] [warn] PassEnv variable JRE_HOME was undefined
[Tue Mar 17 17:01:47 2009] [warn] PassEnv variable JRUBY_HOME was undefined
[Tue Mar 17 17:01:47 2009] [warn] PassEnv variable ORACLE_HOME was undefined
done

Resolution :

Since apache is not able to find above environment variable of user shell, its throwing the exception, so to restart the apache use option -i ( to preserver exception)

The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of the user that the command is being run as. The comâmand name argument given to the shell begins with a - to tell the shell to run as a login shell. sudo attempts to change to that user's home directory before running the shell. It also initializes the environment, leaving TERM unchanged, setting HOME, SHELL, USER, LOGNAME, and PATH, and unsetting all other environment variables. Note that because the shell to use is determined before the sudoers file is parsed, a runas_default setting in sudoers will specify the user to run the shell as but will not affect which shell is actually run.

Make sure you have to execute the below command, if you are facing issue while executing this add " (root) NOPASSWD: /bin/bash /etc/init.d/apache2 *" in /etc/sudoers file

$ sudo -i /etc/init.d/apache restart

Syntax OK
Shutting down httpd2 (waiting for all children to terminate) done
Starting httpd2 (prefork) done

WOW !!

Wednesday, March 11, 2009

Change user password expiry in linux

chage - change user password expiry information

SYNOPSIS
chage [-D binddn] [-P path] [-m mindays]
[-M maxdays] [-d lastday] [-I inactive] [-E expiredate] [-W warndays] user

chage -l [user]

DESCRIPTION
chage is used to list and change the password expiry information of a user. It allows the system administrator to change the number of days
between allowed and required password changes and the date of the last password change. It allows also to define when an account will expire. The
chage command is restricted to the system administrator, except for the -l option, which may be used by an user to determine when his password or
account is due to expire.

If no option is given, chage operates in an interactive mode, prompting the user with the current values for all of the fields. Enter the new
value to change the field, or leave the line blank to use the current value. If the users exists in the local passwd file, but not in the local
shadow file, chage will create a new entry in the shadow file.

Tuesday, March 10, 2009

Find installation date for Windows Server

This seems to be challenging to find installation date for installation date for Windows server.


On Windows Server (works on Windows XP too)

On command prompt, execute : systeminfo | find /i "install date"