Saturday, April 16, 2011

Effectively using history command

    1) To display timestamp with commands  
    # set HISTTIMEFORMAT='%F %T '# history
    2) To search the command line history, press Ctrl + R and start typing the command. The closest match from the history will be displayed. When the expected command appears press enter to execute. Press the right arrow to select the command and start editing. 
    3) To execute a particular command from history, find out the command number. Command number can be found from the left most column when the history command is executed. Then type !<command number>. For e.g. !5 to execute the command with number 5.
    4) To execute a previous command from history that starts with a particular word, type !<starting few letters of the command>. Then the immediate previous command that start with those words will be executed.
    5) By default the history file is stored in ~/.bash_history
    6)  To avoid duplicates in the command history
    export HISTCONTROL=ignoredups



            Sunday, March 27, 2011

            Grub2 tips & tricks

            How to remove old kernels?

                Use the following command to search for installed kernels
                   sudo aptitude search linux-image | grep -E "^i"
                Above command will provide the list of installed kernels. Unwanted/old kernels can be removed with the following command. 
                   sudo aptitude purge <kernel name from the above list>
                Finally the boot menu can be updated with the following command
                   sudo update-grub

              Tuesday, February 8, 2011

              Using sed

              For searching and replacing text in a file

              sed 's/<text to be searched>/<replacing text>/' <input file>
              For example sed 's/foo/bar/' test, replaces the word foo with bar in the file test

              Monday, February 7, 2011

              SVN Quick Reference


              1. SVN Properties
              • SVN Externals (svn:externals)
              Setting this property works like a soft link in the unix file system. Assume we have an application that uses some common utilities which are located in a different path in the repository. Using this properly we can create a soft link to the common utilities from our current application. So anyone who checks out the application will also get the common utilities automatically through  this link. It looks as though the common utilities are present as part of the application.

              To set the property
              svn propset svn:externals <local dir> <repository>

              To get the property. Go the directory containing externals
              svn propget svn:externals 

              To update the property. Make sure the SVN_EDITOR environment variable is set to a valid editor ( for e.g export SVN_EDITOR=vi). Go the directory containing externals and type the following.

              svn propedit svn:externals .

              The editor will open where you can modify the external symbols. 
              Use svn update to get the updated version and then svn commit to commit the changes.