Pages

Wednesday 8 February 2012

Handling Folders and Files with Linux command Line[part1]


As we know Linux command Line is the powerful tool for a user. First of all let us discuss about 3 basic commands which helps you to manage files and folders.
      1. pwd
      2. ls
      3. cd
pwd :
This command prints the present working directory. That is if you want to know actual location where you are standing in your terminal section ,just type pwd . It makes your navigation better.
ls  :
The ls command is used to list the files and folders in the current directory .It is similar to the 'dir' command in Windows. It is important to mention about some parameters those are used along with ls to make this mapping efficient .

    1. ls  -a
    The above command will list all the files and folders including the hidden
    files.
    2. ls  -r
    This command will list the contents in reverse order.
    3. ls  *.txt
    This will list all the files of type .txt .You can change the extension say .jpeg
    for picture type files.


cd :
The simple command which is used to navigate to another directory expanded as change directory. The syntax is cd   <directory>
eg: cd /usr/bin will move the current directory to /usr/bin.
Note : You can navigate to the previous directory by the command 'cd ..'






Monday 16 January 2012

Know the amount of available Disk Space in Linux


We are already know that the Linux shell is the powerful tool which is capable of doing any jobs related with Linux OS .Read more about Linux terminalclick here .Here in this post I am going to tell about a simple command which is used to know the free space available in the hard disk partitions with in no time.
To get started open up the  terminal and  :
  • Type df you can see the list of partitions with available free space listed.
  • Type df -a to get a detailed listing of free space. this Include in the listing file-systems that have a size of 0 blocks, which are omitted by default.
  • Type df -h to get a listing more optimized .Here size is listed in MBs .-h stands for human readable form .
To get the detailed syntax information use the command man df. This will list all the possibilities of the command.


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 :)