Subscribe:

Ads 468x60px

Friday, August 31, 2012

Useful Linux Commands

Here I am documenting few useful linux terminal command:


  1. Command to report system disk space usage:
    [osao@slc01nga ~]df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/xvda2           195592588 177362320   8294652  96% /
    tmpfs                  3931448       368   3931080   1% /dev/shm
    /dev/xvda1             1007896    124588    832108  14% /boot
    slcnas411:/export/home1/osao
                         16106127360 8378327360 7727800000  53% /home/osao
    10.246.4.40:/vol/ade_infra/prod/LINUX.X64
                         100663296   5784768  94878528   6% /usr/dev_infra/platform
    10.246.4.37:/vol/ade_infra/prod/GENERIC
                         100663296   5784768  94878528   6% /usr/dev_infra/generic
    slc1001nap:/vol/local/x86_64/redhat/60_prod/packages
                         1132462080 1087278784  45183296  97% /usr/local/remote/packages
    slc1001nap:/vol/local/linux/redhat/packages
                         1132462080 1087278784  45183296  97% /usr/local/redhat/packages
    Command to see these in summarised short form
    [osao@slc01nga ~]df -lhk
  2. Command for knowing all services running on a machine
    [osao@slc01nga ~] nmap localhost     (in place of localhost you can give other live machine also in your intranet)

  3. Command for knowing a port number for service running and Process ID (pid)
    [osao@slc01nga ~]netstat -anp | grep 9000  (it will search a service running on port no. 9000)
    The following two command will also do the same:
    [osao@slc01nga ~] lsof -w -n -i tcp:8080
    [osao@slc01nga ~]  fuser -n tcp 8080
  4. Command for knowing Directory/File size
    [osao@slc01nga ~]du -hs
  5. Command for searching particular string in particular files in regular expression form
    For ex. here we are searching in all files whose name end contains .jspx or .jsff and file contains text "encoding"
    [osao@slc01nga ~]grep -H -r -n -i --color "encoding" . --include='*.[j][s][fp][xf]'
  6. Perl Command to replace all occurences of string to other string
    the format is
    [osao@slc01nga ~]/usr/bin/perl -p -i -e "s/string1/string2/g"  
    For Ex. for converting all occurences of "ReSult" to "" We will invoke the command
      [osao@slc01nga ~] /usr/bin/perl -p -i -e "s/ReSuLt/$Result_Count<\\/font>/g"






Thursday, August 30, 2012

All about File System and Pendrive formatting


For long time, I have been delaying the proper understanding about all types of filesystems we see while formatting disk-drives/pendrives. But today I decided to drill down, investigate and better document it one place taking some 1/2 an hour. So, here it is.

How to format disk-drive/pen-drive in windows/linux

It's almost same in both OS, right click on the drive -> Format->Start->Ok
But in between we come across 4 options for Filetypes . In Windows-XP/windows7 (FAT, FAT32, NTFS and exFAT) and in Linux(FAT, ext2, ext4 and encrypted FAT). We will not see FAT and FAT32 if our drive memory is > 32 GB. So what is the difference between these file systems and which one should we choose? Let’s look at the advantages of each.

Various Filetypes

Advantages of NTFS  over FAT & FAT32:

  • read/write files > 4 GB and up to maximum partition size. (So, if your jump drive stores oftenly HD movies or big setup file > 4GB. NTFS is best suited.)
  • In NTFS partition memory created are > 32GB.
  • Better file compression filesystem used, hence better space management.
  • better space management = less fragmentation.
  • allows more clusters on larger drives = less wasted space.
  • add user permissions to individual files and folders (Windows Professional).
  • on-the-fly file encryption using EFS (Encrypting File System in Windows XP and 7).

Advantages of FAT & FAT32 over NTFS:

  • compatible with virtually all operating systems.
  • takes up less space on USB drive.
  • less disk writing operations = faster and less memory usage.

exFAT Compared To FAT & FAT32:

  • read/write files larger than 4 GB.
  • create drive partitions larger than 32 GB.
  • better space management = less fragmentation.

Wednesday, August 8, 2012

List of Comments in all Programming/Scripting language

I always find it difficult to remember the syntax of different programming/scripting languages I learnt/know. And most common syntax is Comments in various programming/scripting language. So, here I am documenting them all.
Comments are used to embed/put programmer/human-readable comments/tips/suggestion/annotations in the source code of a computer program. Those comments are generally significant to programmers but typically ignorable to compilers and interpreters.

  1. Java
    1. One liner:  // comments
    2. Multi liner: /*  first line
                           second line
                           third line
                      */

  2. Ada
    1. One liner:  -- comments
    2. Multi liner: -- first line
                       -- second line

  3. C#
    1. One liner:  // comments
    2. Multi liner: /*  first line
                           second line
                           third line
                      */

  4. C++
    1. One liner: // comments
    2. Multi liner: /* first line
                           second line
                           third line
                       */

Monday, August 6, 2012

How to find IP Address and Geographical Location of Website

Yes, it's very much possible.
There are 2 methods for finding IP Address of website.

Method 1:
Go to Command Terminal. Invoke command "ping "
for ex. I passed command "ping www.google.com"

 
Whenever we ping the domain name of any website, the ping packet goes to the website and returns the acknowledgement packet with the IP Address of the website. Many famous/giant Web sites do not return replies(acknowledgement) to ping commands because lot's of ppl keep trying for this(like I tried in example "ping www.google.com"). So to avoid unnecessary traffic, they write a bot, not to reply back to pings,  but the site IP address can usually still be obtained. This "ping" technique will fail if the website is not-hosted/blocked/temporarily down/unavailable or if the server/computer used to perform the ping is not connected to the Internet.
You can also try typing only the IP Address in URL address bar of browser, it will work ! because it makes interface with DNS in between.

Saturday, August 4, 2012

How to take complete webpage screenshot in Chrome and Firefox


How to take complete webpage screenshot in Chrome, Firefox and Explorer


Conventional Methods

  • Pressing Fn+Prnt Scrn  keys together will give you complete screenshot of what is visible in monitor (and not the complete website )
  • Pressing Alt+Prnt Scrn keys together will give you screenshot of Current window and not the taskbar, battery status, time, volume like things in up/down of the control window

For Complete webpage screenshot