Usually when you are working on building the platform for any application, you might be given UNIX (Solaris/Linux/HP-UX/AIX) boxes and new generation with Virtual boxes. which contains nothing you need to do many installations and configurations. To make your administrative task easy and simple we need to setup a fine tuned profile file. This profile file will be holding the multiple environment variables those are reusable when you log-on to UNIX Kernel Here you can define shell functions or you can define simple single lined aliases that makes lengthy commands set to simple trimmed single letter or meaningful words.
What is user SHELL and its profile association?
In your UNIX Kernel when a new user login will check the /etc/passwd file which shell is assigned by the super-user. It will look for the system profile and assign the environment values, then on top of it user profile can be loaded. Hence the variable is defined in system profile can be overridden by user profile. Example PATH environment variable that can be over written by user defined profiles most usual thing it is. So careful while defining such variables. It could behave differently for Solaris same line cannot work on Linux or on AIX box.
Why do we need this to be customize User profile?
Any Middleware admin may involve install and configuring the Apache or Oracle WebCenter Sites or spaces or SOA, Hadoop or Build and deployment platform may requires ANT or Gradle, Jenkins or Hudson setups. Every component that interacts with Middleware runs on the same UNIX Kernel need customized variables that can be referred from any directory or path, so we need them as global variables, this you can acquire by defining them as environment variables in SHELL profile. UNIX Operating system provides all shells associated with a specific default system provided and a user profile script and that is in the hidden file which prefixed with dot(.) so it looks like .profile in your home directory. You can view them by ls -la command.
Where can I find this profile script?
Usually when you login to UNIX Kernel, you will be landing to a directory that is designated to your user HOME directory. Suppose you already working on some other path, you can simply use cd or cd ~ and press enter the OS will takes to home directory. Alternatively you can use system defined environment variable by giving cd $HOME.
How do I know I am in which SHELL?
First you need to know about your user login SHELL(default). Every user can have different choice of having a shell. Once you have assigned user or role for WebLogic environment setup then how do you know what SHELL it is? use the following:
How many SHELL do my env have?
To know this you could do little experiment on your prompt with the following commands
$ type bash
Then you can look in that directory all shell names ends with 'sh', list them with small regular expression trick on your ls command. The main trick here is using 'anchor' symbols, the $ symbol indicates ending of the word pattern, and you can use for avoiding the .sh files in that directory character classes can be negated with the [^] syntax.
[WLA@server~]$ cat /etc/shells /bin/sh /bin/bash /sbin/nologin /bin/tcsh /bin/csh /bin/ksh ...
[WLA@server~]$ ls /usr/bin | grep [^.]sh$
[WLA@server~]$ ls /usr/bin |grep [^.]sh$ |wc -l
How to set bash as login SHELL?
I feel the Bourne Again Shell (bash) is best suitable login shell for WebLogic environment setup. Now your immediate question might be 'How do you know which shell is assigned to your user profile?' Here is the Trick for you!!
$ echo $SHELL
The login shell will be assigned as per the common profile set by Solaris/Linux Administrator. That can be changed by passwd -e or passwd -r if you must have root access then only you can do editing the passwd file and update your desired shell there. Some times it is rejects you and shouts 'permission denied'. Just smile on it you can proceed with the following trick!! Using exec command, that will replaces the existing shell with new shell that you want.
exec $SHELL -l
|Shell replacement ksh to bash with exec|
What is a process?process is an entity in execution. The process can be created by fork, exec system calls. the exec system call replaces current process. In the above also happens same for login shell. Example If your default login shell is given as KSH(/bin/ksh), but in your .profile given exec command to replaces the shell with BASH(/bin/bash).
So, now I am ready with sample .bash_profile for WebLogic 11g for Solaris 10
Implementing the best practices all together, to make this most generic profile.
#============================================== # Sample .bash_profile or .bashrc or .profile for ksh # Middleware Admin on Solaris 10 operating environment # Updated : October 8, 2010 #============================================== clear USERNAME=$LOGNAME HOSTNAME=`hostname` #---------- echo Welcome message --------------------- echo echo Welcome $USERNAME. You are on Server: $HOSTNAME !!! export JAVA_HOME=$HOME/Oracle/Middleware/jdk160_18 #---------------WebLogic Specific --------------------------------------- export MW_HOME=$HOME/Oracle/Middleware/ export WL_HOME=$MW_HOME/wlserver_10.3 export ORACLE_HOME=/opt/oracle/product/9.2.0 export LD_LIBRARY_PATH=$WL_HOME/server/native/solaris/sparc:$WL_HOME/server/lib/solaris/oci920_8:$ORACLE_HOME/lib32:$LD_LIBRARY_PATH export THREADS_FLAG=native export PATH=$PATH:.:$JAVA_HOME/bin:/usr/bin:/usr/ucb:/etc:$WL_HOME/bin:$ORACLE_HOME/bin:/usr/ccs/bin:/usr/share/lib:/sbin:/usr/sbin:/usr/local/bin:$WL_HOME/server/bin export CLASSPATH=$WL_HOME/server/lib/weblogic.jar:$JAVA_HOME/jre/lib/rt.jar #---------------- End of WebLogic specific --------------------------------- export MANPATH=$MANPATH:/usr/share/man export EDITOR=vi export PS1="[\u@\h \w]\$ " alias cls="clear" alias sl=ls alias cd..="cd .." alias cd...="cd ../.." alias gi="grep -i" alias l="ls -al|grep '^d'" alias lm="ls -al | more" alias h=history alias hm="history | more" alias nu="who|wc -l" # nu - number of users alias np="ps -ef|wc -l" # np - number of processes running alias p="ps -ef" alias help=man alias path="echo $PATH" ##### End of the sample .bash_profile for smart WLA ################# #===== Published on http://wlatricksntips.blogspot.com =============#
Importance of DOT(.) in PATH
I just started using the above .bash_profile but, something missing in it... when I wish to start my WebLogic server from domain home I need to give dot and forward slash (./). This looks somewhat unusual, when I add a DOT( .) in PATH variable made everything normal and I can start my WebLogic instances with my customized script from the prompt.
Power of PATH
More power to your user shell with adding /usr/sbin most of the network, system relavent commands available to you at command prompt.
The changes I made for the PATH line adding JAVA_HOME/bin your latest Java binaries will be useful at command prompt such as jps, jstat, jmap very useful when you deal with heap dumps and memory issues, $WL_HOME/server/bin consists of most of the WebLogic related configuration and maintenance commands available to you, it is little trick you need adding this in Solaris and Linux because it uses L-R precedence on Solaris for Linux R-L use appropriately.
Java want CLASSPATH
When there is a need of running ANT or build scripts you need runtime that is rt.jar and tools.jar in CLASSPATH this very often.
If you are using JRockit instead of SunJava then you don't need the rt.jar or tools.jar files in CLASSPATH. Other than this we have WebLogic specific utility commands that can be run from any where if you add weblogic.jar into the CLASSPATH. You can run the following command line utilities:
- java weblogic.WLST
- java weblogic.Admin
- java weblogic.Deployer
Overcome Human Errors with Alias
Mistakes can be made by humans it is obvious thing. Mostly while working on UNIX environments while typing the command there could be mistype happens. Example very effective WebLogic troubleshooter in the pressure situations might mistype 'sl -l' instead of 'ls -l'. sometimes 'l s-lrt' these mistakes can be over come with proper identifying our typing styles :) define them as alias with correct command.
That looks pretty and easy to use. If you need any assistance write a comment or reach me on G+ or FB please don't shy!! : )
Usage of umask
When your WebLogic server generating logs need common access to the other users who are just monitoring the system or auditing the system. Such users are not WebLogic admin user, even though they need to access your logs. For this privileges every WebLogic server logs folder you need to update using chmod command repeatedly. To resolve this best option is using umask.
Don't forget to write back your comments and queries.
Ubuntu profile setup in VMNow a days Ubuntu became almost alternative for Windows OS with great UI features in a Linux flavors. In Ubuntu the default user shell is 'bash'. The order it will execute according to the system profile. The system contains bashrc. So you can place your environment variables int the .bashrc or else alternatively you can call the . ~/.bash_profile in the .bashrc
export JAVA_HOME=/usr/lib/jvm/java-7-oracle export PATH=$PATH:$JAVA_HOME/bin export WL_HOME=/home/pavanwla/Oracle/Middleware/Oracle_Home/wlserver export CLASSPATH=$WL_HOME/server/lib/weblogic.jar:.Please share your experiance with profile and without knowing about the profile. Lets have best profile for your WebLogic environments that you build. References
5. The umask command usage