Monday, August 9, 2010

Do you have alias in your profile??

Making mistake is human nature but, overcoming that mistake turning to desired outcome is very wise thing. You want to learn about that wise trick?


If yes follow me!!

In Unix platform there is a file called .profile (some Linux enviroments it is .bash_profile). Which executed automatically when you logon to your user, which inturn have the enviroment variables which are required to run your application on WebLogic. For WLA required to setup a standard .profile for his production enviroment that is for JAVA_HOME, WL_HOME are major some of the enviroments requires ORA_HOME in this file.

Defining JAVA_HOME, WL_HOME, etc is common thing for any WLA. But your my Smart WLA then you might applying a intersting UNIX command 'alias'. Most of the time we use 'ls' command for listing the files/folders. By mistake you might mistype as 'sl' instead of 'ls'. sometimes feeling hungry!! or thursty!! and typing command that may go wrong like 'cd..' or 'cd...'. Collect all these common mistypos and make use of 'alias' command then see!!

Though, You make mistake in typing it will give you desired command output. I like this command, since when I found it. This command makes magic, it is very interesting feature in UNIX. Just append to your .profile the following lines:
######WLA Smart idea for using alias #############################
alias cls=clear
alias sl=ls 
alias cd..="cd .."
alias cd...="cd ../.."
alias gi="grep -i"
alias l="ls -al"
alias lm="ls -al | more"
alias h=history
alias hm="history | more"

This is value added to your work, obviously it will reduce your time spending on working machine. Performance will be improved if you find more common mistakes in your enviroment and sortout with 'alias' the magical command, it will give you fruties results!!

3 comments:

  1. Great idea!!! This can reduce our time by not typing long same commands 100 times a day.

    Shahbaz

    ReplyDelete
  2. alias u="uname -a"
    alias i="ip -o a s |grep inet |awk '{print \$2,\$4}' |grep -v ^lo |sed 's/\// \//g'"
    alias p="ps fauxwww"
    alias pp="ps fauxwww |less"
    alias pg="ps fauxwww |grep"

    ReplyDelete
    Replies
    1. Etc, idea is to have letters close to each other,
      also another hint [deploying my own bashrc on server temp.]:

      [root@base ~]# cat .bashrc
      # .bashrc
      # User specific aliases and functions
      sss() {
      ## Removing http[s] and :port and /url from address
      host=$( echo ${*:1} | \
      sed "s/\(http\|https\|ftp\)\:\/\///g" | \
      sed "s/\(\/\|\:\).*//g" )

      ## if .domain is missing, try .homecredit.net
      if [[ ! "${host}" =~ .*\..*\. ]];
      then
      host="$host.homecredit.net"
      fi

      ssh -o StrictHostKeyChecking=no ${host} "cat > /tmp/.bashrc_temp" < ~/.bashrc_remote
      ssh -t ${host} "bash --rcfile /tmp/.bashrc_temp ; rm /tmp/.bashrc_temp"
      }

      # ex. $ s server.somewhere.com
      alias s="sss"

      # Source global definitions
      if [ -f /etc/bashrc ]; then
      . /etc/bashrc
      fi

      ### local aliases etc.
      # .... do your own ;-)

      ---- it will deploy this


      [root@base ~]# cat .bashrc_remote
      # .bashrc
      # this file can be safely removed
      #
      # Source global definitions
      if [ -f /etc/bashrc ]; then
      . /etc/bashrc
      fi


      ### Colors
      RS="\[\033[0m\]" # reset
      FBLK="\[\033[30m\]" # foreground black
      FRED="\[\033[31m\]" # foreground red
      FGRN="\[\033[32m\]" # foreground green
      FYEL="\[\033[33m\]" # foreground yellow
      FBLE="\[\033[34m\]" # foreground blue
      FMAG="\[\033[35m\]" # foreground magenta
      FCYN="\[\033[36m\]" # foreground cyan
      FWHT="\[\033[37m\]" # foreground white


      ## Variables
      tec_user_host="$FYEL\u@\h$RS"
      tec_serv_type=$(uname -n |cut -d'.' -f2)
      tec_serv_path="$FGRN\W$RS"


      ## Customization
      case ${tec_serv_type} in
      'prod') tec_serv_type="[$FRED${tec_serv_type}$RS]" ;;
      'dev') tec_serv_type="[$FGRN${tec_serv_type}$RS]" ;;
      *) tec_serv_type="[--]" ;;
      esac

      #\[\033[0m\]
      ## Important things
      # - date because of different timezones in different countries
      export PS1="[$tec_user_host $tec_serv_type $FWHT$(date +%d/%m/%k:%M)$RS $tec_serv_path]\$ "

      # one touch show
      alias u="uname -a"
      alias i="ip -o a s |grep inet |awk '{print \$2,\$4}' |grep -v ^lo |sed 's/\// \//g'"
      alias p="ps fauxwww"
      alias pp="ps fauxwww |less"
      alias pg="ps fauxwww |grep"

      Delete

Blurb about this blog

Blurb about this blog

Essential Middleware Administration takes in-depth look at the fundamental relationship between Middleware and Operating Environment such as Solaris or Linux, HP-UX. Scope of this blog is associated with beginner or an experienced Middleware Team members, Middleware developer, Middleware Architects, you will be able to apply any of these automation scripts which are takeaways, because they are generalized it is like ready to use. Most of the experimented scripts are implemented in production environments.
You have any ideas for Contributing to a Middleware Admin? mail to me wlatechtrainer@gmail.com
QK7QN6U9ZST6