Sunday, 1 January 2012

Welcome 2012

Lets welcome the new year 2012 with joy .Let us hope it might be another year of fun and inspirations. The Linux started its historical journey in 1991. It is been 20 years now. The growth was really dramatic , It will continue its journey in that way. Once again Happy new year for all who loves Linux and opensource.

Wednesday, 14 December 2011

Searching strings with grep command

Let me discuss a situation- I have saved all of my contacts information as separate files and put it in a folder called contacts. I have to find the file which contain the name Mr. John. I get started with opening each files in my text editor and ctr+f to find john..it was too difficult since I have about 300 files to search. But working a little smart I found john in 2 minutes..How ? The grep command .
 Grep is a command-line text-search utility originally written for Unix. The name comes from the ed command g/re/p (global / regular expression / print). The grep command searches the given file for lines containing a match to the given strings or words. grep displays the matching lines by default.
How to use grep command :
1.Searching for a string in a file

                $ grep train vehicles.txt

    the above usage will print all the lines containing the text train from vehicles.txt
2 .Searching in multiple files of same type :

                $ grep train *.txt

    the above command will print all the lines with text 'train' from all the text files in that folder
3. Searching by ignoring case sensitivity (with parameter -i)

                $ grep -i train vehicles.txt

     the above command will search all the 'train' sequences wihtout matching the cases.
4 . Word search

                $ grep -w train vehicles.txt
 
     Selecting all lines containing train as a word, i.e. surrounded' by white space (speedtrain
     and train  do not not match) may be accomplished with the -w option flag
5. Count lines when words are matched
             
                $ grep -c 'word' /directory


      grep can count the number of times that the pattern has been matched for each file using -c (count)    option.
6.Search recursively in an entire directory

               $ grep -r 'word' /directory  

   You can search recursively i.e. read all files under each directory for a string .







Monday, 5 December 2011

Installing an rpm file in Debian systems


In Linux the two important variants of Operating Systems are Debian And Red hat. For off line installation of softwares Debian variant uses files of type .deb and Red hat uses .rpm files. Most of us uses Debian variant OS and our famous Ubuntu is a Debian variant OS.
>>What you will do to install an rpm file in a Debian variant system , if you can't find out the Debian version of that item ?
There is a way to install an .rpm file in Debian variant systems. You can use alien package converter to do so. Alien is a program that converts between the rpm, dpkg, stampede slp, and slackware tgz file formats. If you want to use a package from another distribution than the one you have installed on your system, you can use alien to convert it to your preferred package format and install it.
Note:Alien should not be used to replace important system packages, like sysvinit, shared libraries, or other things that are essential for the functioning of your system. Many of these packages are set up differently by Debian and Red Hat, and packages from the different distributions cannot be used interchangeably. In general, if you can’t un-install the package without breaking your system, don’t try to replace it with an alien version.
Install alien converter :
The software is available at Ubuntu Universe repository.So add that repository in software sources (Option is available there) ,open up the terminal and type
the following commands :
             $ sudo apt-get update
             $ sudo apt-get install alien

Installing the .rpm file

First convert the .rpm file to .deb by the following command(assumed that your files are in the home directory ) :
             $sudo alien -k name-of-rpm-file.rpm
this will produce a .deb file with the same name.now use dpkg to install the .deb file .
             $sudo dpkg -i name-of-deb-file.deb



Done :)

Monday, 28 November 2011

Split Your Large Files into small files very easily in Your Ubuntu machine



What will we do if we got a situation that we have to transfer a file of 5 GB and the available resource is just two 4 GB Pen drives. I used to stuck in such situations many times especially when you have to copy a Blue-ray film of 5-7 GB s. Most of the times we have to depend on the software s like zip manager . But the thing is that Without any softwares we can simply split up our files using the Linux command terminal,more simpler than the software method.
Go and open up the Terminal and use the following command :

      $ split –b600m yourfile yoursplitfiles.

To join the smaller files to get the big files back:

        $ cat yoursplitfiles.* >yourfile
Here 'yourfile' stands for the name of your big file and 'yoursplitfiles' stands for the splited files. Like the  same way you think.


Note : Dont forget to put a dot(.) after the name 'yoursplitfiles' otherwise it will be diffficult to rejoin




Friday, 25 November 2011

Have Fun with Command Line Browser In Linux


I would like to mention about command line again. These days I was trying something different in my terminal .something smells good and useful .what was that ?Simply access the web pages in command line. A Google searched gave me solution .It is somewhat a special experience ,especially for a Geek. Imagine a situation like this.. if your GUI get crashes and you have only the command line access and u need to check one of your important mails ,no other ways .....Don't Worry, A software called links2 comes to help you .
  Links2 is a web browser which is based on 'links' and can be run in two modes. It will display web pages only in text when run in console mode and renders images in a variety of graphics formats when run in graphics mode from within a X window system. Without going to more technical let me explain what to do :

* Install Links2 to in your system
steps are simple . Connect to Internet and type following command to the terminal
         $ sudo apt-get install links2
The browser is designed to run in console mode. But it can be run in graphics mode too..the important feature is the speed. It render the Web-pages very fast .

* How to start and browse with links2 ?
Open terminal and type following command:
         $ links2 www.google.com
replace www.google.com with your site..

* Start links2 in graphics mode
Open terminal and type following command:
         $ links2 -g www.google.com

* Shortcuts used in links2 :
  • '\' - toggle between viewing the web page and its source code.
  • '/' - used to search for a word or term in the website that is displayed.
  • [Esc]key - Shows a menu at the top of the browser from which you can also make choices.
  • '=' - Provides further information about the web page such as its size, the web server serving the web page and its url.
  • '|' - Pipe displays the header information.
  • '<-' - left arrow will take you to the previous view. '->' - right arrow will take you forward to the latest view.
  • [Page up]and[Page down]- these keys can be used to navigate through the web page one page at a time. But you can also use[Space bar]and 'b' key combination for the same.
  • 'g' - will pop-up a dialog box where you can enter the url of the website you want to view. To open this dialog box with the url of the current page already entered, press 'G'.
  • Move the mouse pointer over an image and press 'i' to see only the image.

Geeks please note :
You can find a hidden folder .links2/ in your home folder with configuration files .A file named links2.cfg contains all configurations.

Screen shots :
Google in Linux terminal

In Graphics mode