Pages

Friday, October 1, 2010

Network related Commands

Display Connection Configuration: ipconfig /all

Display DNS Cache Info: ipconfig /displaydns

Clear DNS Cache: ipconfig /flushdns

Release All IP Address Connections: ipconfig /release

Renew All IP Address Connections: ipconfig /renew

Re-Register the DNS connections: ipconfig /registerdns

Change/Modify DHCP Class ID: ipconfig /setclassid

Network Connections: control netconnections

Network Setup Wizard: netsetup.cpl

Test Connectivity: ping whatismyip.com

Trace Route: tracert

Displays the TCP/IP protocol sessions: netstat

Display Local Route: route

Display Resolved MAC Addresses: arp

Display Name of Computer Currently on: hostname

Display DHCP Class Information: ipconfig /showclassid

NameServer Lookup: nslookup whatismyip.com

Wednesday, June 9, 2010

Oracle 10g Quick Installation

Oracle Prerequisites and Install Requirements

Login to Solaris 10 server as root and open a terminal window
# /usr/sbin/prtconf | grep Memory - Check RAM (Recommended 1GB)
# /usr/sbin/swap –s - Check Swap (Free Space on swap)
# df -h /tmp - Check /tmp (Recommended 750MB)
# uname –r - Check Solaris Version
# hostname - Check host name

Check for Required installed Solaris Packages
# pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibm SUNWlibms SUNWsprot SUNWtoo SUNWi1of
SUNWi1cs SUNWi15cs SUNWxwfnt

If any package is missing (not installed), install them using Solaris 10 CD pack as below example
#pkgadd -d . SUNWi1cs

Create User Groups, Oracle Users & .profile
To create user groups related to oracle, edit group file using vi editor and add 2 user groups
(oracle, oinstall) as per below
# vi /etc/group
dba::101:
oinstall::100:oracle

To create oracle user refer the below sequence
# mkdir /export/home/oracle
# vi /etc/passwd
oracle:x:101:101:Oracle Super User:/export/home/oracle:/sbin/sh

# pwconv
# chown –R oracle:dba /export/home/oracle
# passwd –r files oracle
To check the oracle user ID, group use below command
(if output doesn’t match with example correct live machine according to example)

# id -a oracle
uid=101(oracle) gid=101(dba) groups=100(oinstall)
To change primary (-g) and supplementary (-G) groups

# usermod –g 101 –G 100 oracle
To create oracle user .profile follow the instructions below

#vi /export/home/oracle/.profile
umask 022 -> default permission
TMP=/tmp -> TMP to directory /tmp
TMPDIR=$TMP -> TMPDIR to same directory /tmp
DISPLAY=localhost:0.0 -> Display to local host
export TMP TMPDIR DISPLAY -> export to make available as env.
ORACLE_BASE=/oracle/app/oracle -> oracle products to installing dir.
ORACLE_HOME=/oracle/app/oracle/10.2.0/db1 -> oracle home dir. for executables
ORACLE_SID=orcl -> oracle instance (orcl is default)
PATH=$ORACLE_HOME/bin:$PATH -> dir. to search commands & prgs.
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH -> export to make available as env.

Configure Solaris 10 System Parameters Using
Resource Control Projects
#projadd oracle - Create a new resource project
Add new line to “/etc/user_attr" file
oracle::::project=oracle
#su – oracle
$ id –p - Check oracle user
uid=101(oracle) gid=101(dba) projid=100(oracle)
(if output doesn’t match with example correct live machine according to example)

$ prctl -n project.max-shm-memory -i project oracle - Check shared memory
project: 100: oracle
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.max-shm-memory
privileged 254MB – deny - To be increased for better performance
system 16.0EB max deny
To set the kernel system value for the shared memory parameter, open another root shell and
perform the following two commands, make sure at least one terminal session is still logged in as
the oracle user. Then from root user shell issue these commands to set shared memory to 4GB.

# prctl -n project.max-shm-memory -v 4gb -r -i project oracle
# projmod -s -K "project.max-shm-memory=(priv,4gb,deny)" oracle

The first dynamically resets the value, while the second makes changes to the "/etc/project" file
so the value is persistent between reboots. To see changes to /etc/project perform the following
# cat /etc/project
system:0::::
user.root:1::::
noproject:2::::
default:3::::
group.staff:10::::
oracle:100::::project.max-shm-memory=(priv,4294967296,deny)

Now to go back to the oracle shell command terminal and type the following again to see that
the project information has been update to 4GB for the shared memory kernel system
parameter.
$ prctl -n project.max-shm-memory -i project oracle
project: 100: oracle
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.max-shm-memory
privileged 4.00GB – deny - New value of Shared Memory
system 16.0EB max deny
If performed a new default Solaris installation, it is likely that this is the only system kernel
parameter you need to set is "max-shm-memory" for Oracle 10g.

Install Oracle® 10g
Logout from root and Login as user oracle
To install oracle on Solaris 10 first you have to transfer the zip (compressed) file to server
Insert CDROM containing oracle 10g ‘zip’ file (ex: 10202_database_solx86.zip)
NOTE : Recommended minimum free space required
Mount Total Free
--------- --------- ----------------------------------------------------
/ 6GB 3GB -> root
/oracle 6GB 6GB -> Oracle installing directory
/export/home 1GB -> Users home directories
/u01 3GB 2GB -> to transfer & unzip compressed file
/archive 8GB 8GB -> if only archiving is enabled

#cd /cdrom
#cp –R 10202_database_solx86.zip /u01
#cd /u01
#unzip 10202_database_solx86.zip
#cd database
#./runInstaller

Basic installation will be enough for the requirement
Insert & confirm ‘database password’ here
Keep system group name ad ‘dba’

If warning displays on below checks ‘check’ to ‘user verified’
Confirm to Install

Wait for installation completes,…..
Another screen you will see

Change if required a last minute password change,…

Installation seems to be successful
Once you see this pop-up window open a new terminal windows, log in as root and run the
specified scripts,…. Once complete come back to this window and press ‘ok’

Example screen dumps of above
CONGRATULATIONS !!! you have installed the Oracle 10g successfully.
Refer the web link on below window to “Enterprise Manager Control”
Ie,.. http://:1158/em

Press ‘Installed Products’ to check installed components

Install Oracle® 10g Web Administration
Logout from root and Login as user oracle to check and start listener control
# su – oracle
$ lsnrctl start
$ emctl start dbconsole
or
To Log into Enterprise Manager start your ‘web browser’

Tuesday, April 20, 2010

Installing gcc compiler on Solaris 10

1 Installing gcc compiler on Solaris 10
1.1 Extract Packges
After downloading create and move files to the directory /download and gunzipped them
bash-3.00# cd download
bash-3.00# gunzip gcc-3.4.6-sol10-x86-local.gz 
bash-3.00# gunzip libiconv-1.11-sol10-x86-local.gz

1.2 Install libiconv package
After that installed the libiconv package first, since that is a requirement.
bash-3.00# pkgadd -d libiconv-1.11-sol10-x86-local

Select package(s) you wish to process (or 'all' to process all packages).
(default: all) [?,??,q]: all


Do you want to install these conflicting files [y,n,?,q] y


1.3 Install gcc-3.4.6-sol10-x86-local
bash-3.00# pkgadd -d gcc-3.4.6-sol10-x86-local.gz

Select package(s) you wish to process (or 'all' to process all packages).
(default: all) [?,??,q]: all


Do you want to install these conflicting files [y,n,?,q] y  


1.4 Check gcc installation
bash-3.00$ gcc -v



1.5 Install & test GNU "make"
1.5.1 Extract and check
bash-3.00# gzip -d make-3.81-sol10-x86-local.gz 
bash-3.00# head make*

1.5.2 Install make into /usr/local/bin:
bash-3.00# rlogin localhost -l root (optional if you're already root)
bash-3.00# cd /download
.bash-3.00# pkgadd -d make-3.81-sol10-x86-local


1.5.3 Test the installation: 
bash-3.00# /usr/sbin/pkgchk -d make* SMCmake


1.6 Set class path
Add class path to .cshrc or .profile file
path= /bin/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/lib:/usr/ccs/bin:/usr/local/bin:/usr/bin: /usr/sfw/bin:$path

Note : check with ‘# env’ to make sure the PATH you enter is active

2 Test GCC and GMAKE
2.1 Test GCC
To test GNU "gcc" on a simple C src program
bash-3.00# mkdir /tmp/test 
bash-3.00# vi /tmp/test/hello.c #include main() { printf("Hello world.\n"); return 0; }

bash-3.00# gcc /tmp/test/hello.c -o /tmp/test/hello.exe
bash-3.00# /tmp/test/hello.exe


2.2 Test gmake
To test GNU "gmake" using a simple Makefile
bash-3.00# vi /tmp/test/Makefile


bash-3.00# cd /tmp/test 
bash-3.00# gmake hello 
bash-3.00# ./hello

Jboss-4.0.2 Application Server in Solaris 10

1 Jboss-4.0.2 Application Server in Solaris 10
1.1 Directory structure
1.2 Check pre condition
Check the disk space in /apps to make sure that it still have enough space for installation. ( put the JBoss folder inside /apps folder)

# bash
bash-3.00# df -h /apps

Filesystem size used avail capacity Mounted on
       /dev/dsk/c0d0s0 7.7G 3.7G 3.9G 49% /

1.3 Installation
1.3.1 Unzip the JBoss file to /apps folder:

bash-3.00# unzip /Desktopjboss-4.0.2.zip -d /apps/
Wait until the unzip process is finished. Then the JBoss folder (jboss-4.0.2.zip) should be exist in the /apps folder.

To verify the folder I type this command:
bash-3.00# ls -la
/apps/ drwxr-xr-x 6 root sys 512 Apr 20 21:12 .
drwxr-xr-x 41 root root 1024 Apr 20 20:16 ..
drwxr-xr-x 3 root bin 512 Apr 12 13:20 SUNWits
drwxr-xr-x 4 root bin 512 Apr 12 13:35 SUNWmlib
drwxr-xr-x 8 root root 512 Dec 4 21:28
jboss-4.0.2.zip.zip drwxr-xr-x 8 root root 512 Apr 12 13:45 staroffice8
bash-3.00#

1.4 Start Web Servewr
1.4.1 Start (run) the JBoss AS:
bash-3.00# cd /apps/jboss-4.0.2/bin/
bash-3.00# sh run.sh –c default

By default JBoss will use port 8080. If your port is conflict with other web server, you can change the JBoss port number to something else. Now, I open the browser then type in:

http://localhost:8080 or http://192.168.1.IP:8080

1.4.2 Stop (shutdown) the JBoss:
bash-3.00# cd /apps/jboss-4.0.2/bin/
bash-3.00# ./shutdown.sh –s
or
if started as a service
bash-3.00# sh shutdown.sh -s 127.0.0.1 -S
Server shutdown may take a while - check logfiles for completion

1.4.3 Delete work and tmp folders inside following folder
bash-3.00# cd /apps/jboss-4.0.2/server/default/
bash-3.00# rm –r tmp work


1.5 Deployment Web Application in jboss-4.0.2
1.5.1 Deploy web application in JBoss AS.
To deploy the web application, just copy the icard.war file to the /apps/jboss-4.0.2/server/default/deploy folder:
To verify that the file is copied successfully, use this command:
bash-3.00# cd /apps/jboss-4.0.2/server/default/deploy
bash-3.00# ls -la | grep war

drwxr-xr-x 6 root root 512 Dec 4 17:23 ROOT.war
drwxr-xr-x 6 root root 512 Dec 4 17:23 jmx-console.war
-rw-r--r-- 1 root root 4157406 Apr 21 12:30 Application_name.war

1.5.2 Start the application server:
bash-3.00# cd /apps/jboss-4.0.2/bin/
bash-3.00# sh run.sh –c default
or
bash-3.00# /apps/jboss-4.0.2/bin/run.sh -b 127.0.0.1

During the JBoss AS is running, it will automatically deploy the war file. Notice this message in the JBoss console: 13:40:37,159 INFO [TomcatDeployment] deploy, ctxPath=/icard, vfsUrl=icard.war

1.5.3 Application dependencies
If there is application dependencies put inside /server/default/libs folder

1.5.5 Enabling login module for jboss
1.5.5.1 jboss-web.xml 
bash-3.00# cd /apps/ jboss-4.0.2/server/default/deploy/jmx-console.war/WEB-INF/
bash-3.00# vi jboss-web.xml

Uncomment following
< -- Uncomment the security-domain to enable security. You will need to edit the html adaptor login configuration to setup the login modules used to authentication users. java:/jaas/jmx-console -- >

1.5.5.2 Web.xml - Jass enable 
bash-3.00# cd /apps/ jboss-4.0.2/server/default/deploy/jmx-console.war/WEB-INF/
bash-3.00# vi Web.xml Uncomment following

HtmlAdaptor An example security config that only allows users with the role JBossAdmin to access the HTML JMX console web application /* GET POST JBossAdmin -- >

1.5.5.3 User name, password and user roles
bash-3.00# cd /apps/jboss-4.0.2/server/default/conf/props
Edit jmx-console-roles.properties and jmx-console-users.properties

1.5.5.4 Start web application.
Now open the browser and type in http://192.168.1.IP:8080/Application_name/


1.5.6 To remove the web Application
What we need to do is just delete the war file. It can be done during the server is running or server is offline. Suppose here, the JBoss AS is running.

To remove the web application:
bash-3.00# cd /apps/jboss-4.0.2/server/default/deploy
bash-3.00# rm -rf Application_name.war

After deletion, in the JBoss console will automatically remove this web application. 13:42:57,274 INFO [TomcatDeployment] undeploy, ctxPath=/icard, vfsUrl=icard.war

Trouble shooting solaris Network Configuration

ADD NETWORK ON SOLARIS 10 x86


press ifconfig -a on terminal and find the network connection (eg –bnx0, elxl0,lo0)

lo0: flags=2001000849 mtu 8232 index
inet 127.0.0.1 netmask ff000000



elxl0: flags=1000843 mtu 1500 index 2
inet 192.168.1.220 netmask ffffff00 broadcast 192.168.1.255
ether 0:b0:d0:69:d5:e

Then use following command to assign ip address
            bash-3.00# ifconfig bnx0 192.168.1.55 netmask 255.255.255.0 up

use following command to assign default router
            bash-3.00# route add default 192.168.1.1

Trouble shooting

Check hosts file
         bash-3.00# cat /etc/hosts
         127.0.0.1 localhost
         192.168.1.IP mcbsol10

Check IP range (should appear as below)
         bash-3.00# cat /etc/netmasks
         192.168.1.0 255.255.255.0

Check default router
         bash-3.00# etc/defaultrouter
        192.168.1.1

Check nodename file
        bash-3.00# cat /etc/nodename
        LiveServer

If Network is not working, even after you up network, then follow bellow list of commands

      bash-3.00# ifconfig bnx0 down

Unbind existing IP address to a Network Interface Card
      bash-3.00# ifconfig bnx0 unplumb


Bind an IP address to a Network Interface Card
       bash-3.00# ifconfig bnx0 plumb


       bash-3.00# ifconfig bnx0 192.168.1.220 netmask 255.255.255.0 up
(optional)
       bash-3.00# /etc/default/inetinit start

Enable Ftp for root

      bash-3.00# vi /etc/ftpd/ftpusers
      remove# root

Also, don't forget to edit the file /etc/ftpaccess and comment out the 'deny-uid' and 'deny-gid' lines.
If the file doesn't exist, there is no need to create it.


Configure Telnet for root logins

edit the file /etc/default/log-in as follows:

        # If CONSOLE is set, root can only login on that device.
        # Comment this line out to allow remote login by root.
        #CONSOLE=/dev/console
        # PASSREQ determines if log-in requires a password.
        #
        PASSREQ=YES

       # ALTSHELL determines if the SHELL environment variable should be set
       #
       ALTSHELL=YES

       # PATH sets the initial shell PATH variable
       #PATH=/usr/bin:

       # to log all root log-in at level LOG_NOTICE and multiple failed login
       #
       SYSLOG=YES

Tuesday, February 16, 2010

Download Unix variations (derivatives)

Download Unix variations (derivatives)
Free derivatives of Unix can be easily downloaded via the Internet.The different versions of Unix and Unix-like operating systems available for download include FreeBSD, OpenBSD, Red Hat Fedora Linux, Debian Linux, Ubuntu Linux, and Sun Solaris.
You can still try these operating systems by using virtual machines, without worrying about your existing data or OS being affected. You can install your preferred version of Unix inside the virtual machine to get a separate “computer” running inside your existing OS. These virtual machines can be set up using software such as Sun Microsystems’ VirtualBox, which is available as a free download.
Download FreeBSD Unix
The FreeBSD operating system is meant for use on the following architectures:
1.       x86 machines, with Pentium or Athlon cores
2.       AMD64 compatible machines, which include Athlon 64, Opteron and EM64T
3.       Alpha/AXP
4.       IA-64, PC-98
5.       UltraSPARC
FreeBSD is an offshoot of BSD, the version of UNIX which was developed at the University of California, Berkeley.

Download OpenBSD Unix
A free, multiplatform 4.4BSD-based UNIX-like system is developed by the OpenBSD project. This system has the benefits of portability, standardization and integrated cryptography among key features. Binary emulation of programs from SVR4 (Solaris), FreeBSD, SunOS, Linux, BSD/OS and HP-UX is possible with OpenBSD Unix.
Download Solaris Unix
The Solaris OS exhibits good scalability, performance, and security on SPARC, Opteron, AMD and Intel Xeon-based systems. The latest version of the Solaris Unix has used exceptional technologies for facilitating robust computing infrastructures. The Solaris operating system integrates many popular open source applications, including Apache, Tomcat and Secure Shell. Open source packages are available on this platform, with the result that time needed for porting is cut down.
Download Ubuntu Linux
Ubuntu is good for laptops, desktops and servers and contains all the essential programs that you may require, from word processors to compilers for various programming languages. Users interested in Ubuntu can download, use and share Ubuntu with friends or associates free of cost.
Download Fedora Linux
The Fedora Project builds versions of a general purpose operating system made exclusively from free software. Fedora Linux is quite popular among open source software development enthusiasts.
Download Debian Linux
Debian uses the Linux kernel and many of its basic tools are derived from the GNU project. Debian GNU/Linux has more than 8710 packages and precompiled software bundled conveniently for easy installation.
Download Gentoo Linux
Gentoo Linux can be quickly and easily customized by end users. Among the highlights of the Gentoo Linux experience are the easy configurability and good performance. Also, ample developer support is available via the communities.Gentoo is called a metadistribution by many users because of its easy adaptability.
Download Slackware Linux
Slackware Linux is a UNIX-like system. It contains an easy to use installation program, extensive online documentation, and a menu-driven package system. A complete installation of Slackware allows you the X Window System, C/C++ development environments, an ftp server, the GNU Image Manipulation Program and Netscape Communicator among other key features.
Download Mandriva Linux
Mandriva Linux attempts to turn the regular Linux into a more user-friendly operating system. Mandriva Linux is easy-to-use and innovative. This is manifest in the numerous awards Mandriva has received.
Download openSUSE Linux
The openSUSE project is a community program which is sponsored by Novell. The openSUSE system is the most user-friendly of all the versions of Linux.This system is excellent for both developers and casual users to feel a great Linux experience.

Summary Unix Commands

Directories and Path:
/                              "root" directory
/usr                        directory usr (sub-directory of / "root" directory)

Moving around the file system:
pwd                       Show the current directory.
cd                            Change current directory to your HOME directory.
cd /usr/isura      Change current directory to /usr/isura.
cd INIT                  Change current directory to INIT which is a  sub-directory of the current directory.
cd ..                        Change current directory to the parent directory
cd $STRMWORK               Change current directory to the directory defined by the environment variable            
cd ~bob              Change the current directory to the user bob's home directory (if you have permission).

List directory contents:
ls                             list a directory
ls -l                         list a directory in long ( detailed ) format
ls -a                        List the current directory including hidden files.
ls -ld *                    List all the file and directory names in the current directory using long format.

Changing file permissions and attributes
chmod 755 file                   Changes the permissions of file.
chgrp user file                   Makes file belong to the group user.
chown cliff file                   Makes cliff the owner of file.
chown -R cliff dir              Makes cliff the owner of dir and everything in its directory tree.

Moving, renaming, and copying files:
cp file1 file2                        copy a file
mv file1 newname          move or rename a file
mv file1 ~/AAA/               move file1 into sub-directory AAA in your home directory.
rm file1                                 remove or delete a file
rm -r dir1                             recursively remove a directory and its contents
mkdir dir1                            create directories
mkdir -p dirpath               create the directory dirpath, including all implied directories in the path.
rmdir dir1                             remove an empty directory

Viewing and editing files:
cat filename                        Dump a file to the screen in ascii.
more filename                  Progressively dump a file to the screen:  ENTER = one line down
                                                SPACEBAR = page down               q=quit
vi filename                          Edit a file using the vi editor. 
emacs filename                Edit a file using the emacs editor. Not all systems will have emacs.

head filename                   Show the first few lines of a file.
head -n  filename            Show the first n lines of a file.
tail -n filename                  Show the last n lines of a file.

Shells
echo $SHELL                       You can find out what shell you are using by the command:
you can create a file with a list of shell commands and execute. This is called a shell script. This is in fact the primary purpose of most shells( bat files in Windows). 

Environment variables
You can teach your shell to remember things for later using environment variables.
For example under the bash shell:

export CASROOT=/usr/local/CAS3.0               Defines the variable CASROOT with the value
/usr/local/CAS3.0.           By prefixing $ to the variable name, you can evaluate it in any command:

cd $CASROOT         Changes your present working directory to the  value of CASROOT
echo $CASROOT       Prints out the value of CASROOT, or /usr/local/CAS3.0
printenv CASROOT    Does the same thing in bash and some other shells.

Redirection:
grep string filename > newfile           Redirects  the output of the above grep command to a file
grep string filename >> existfile        Appends the output of the grep command to the end of

Pipes:

ls -l | more         This commands takes the output of the long format directory list command
"ls -l" and pipes it through the more command (also known as a filter).

du -sc * | sort -n | tail 

The command "du -sc" lists the sizes of all files and directories in the current working directory. That is piped through "sort -n" which orders the output from smallest to largest size. Finally, that output is piped through "tail" which displays only the last few (which just happen to be the largest) results.

Command Substitution
You can use the output of one command as an input to another command in another way called command substitution. 
cat `find . -name aaa.txt`              which will cat ( dump to the screen ) all the files named aaa.txt that
exist in the current directory or in any subdirectory tree.

Searching for strings in files: The grep  command
grep string filename    prints all the lines in a file that contain the string

Searching for files : The find command

find search_path -name filename
find . -name aaa.txt    Finds all the files named aaa.txt in the current directory or any subdirectory tree.
find / -name vimrc      Find all the files named 'vimrc' anywhere on the system.
find /usr/local/games -name "*xpilot*"       Find all files whose names contain the string 'xpilot' which exist within the '/usr/local/games' directory tree.

Reading and writing tapes, backups, and archives: The tar
command 

tar xv      Extracts (x) files from the default tape drive while listing (v = verbose)    the file names to the screen.

tar tv      Lists the files from the default tape device without extracting them.    
tar xvf archive.tar                       extract from the archive file
tar cvfz archive.tar.gz dname      Create a gzip compressed tar archive containing everything in the directory 'dname'. This does not work with all versions of tar.

tar xvfz archive.tar.gz               Extract a gzip compressed tar archive.  Does not work with all versions of tar.

compress part.igs    Creates a compressed file part.igs.Z
uncompress part.igs  Uncompresseis part.igs from the compressed file part.igs.Z.
gzip usually gives better compression than standard compress,

gzip part.igs     Creates a compressed file part.igs.gz
gunzip part.igs   Extracts the original file from part.igs.gz

Looking for help: The man and apropos
commands
man ls      Shows the manual page for the ls command
apropos build     Shows a list of all the man pages whose discriptions contain the word "build"

Basics of the  vi editor
Opening a file      vi filename 
Creating text
i      Insert before current cursor position
I      Insert at beginning of current line
a      Insert (append) after current cursor position
A     Append to end of line
r      Replace 1 character
R     Replace mode

Terminate insertion or overwrite mode
Deletion of text
x      Delete single character
dd    Delete current line and put in buffer ndd   Delete n lines (n is a number) and put them in buffer
D     delete the remainder of the line, starting with current cursor position
J      Attaches the next line to the end of the current line (deletes carriage return).
Oops
u           Undo last command
yy         Yank current line into buffer
nyy       Yank n lines into buffer
p           Put the contents of the buffer after the current line
P           Put the contents of the buffer before the current line
cursor positioning
ctrl + d    Page down
ctrl + u    Page up
:n             Position cursor at line n
:$             Position cursor at end of file
ctrl + g    Display current line number
j               move cursor down one line
k               move cursor up one line
0(zero)    go to begging of the line
$               go to end of the line

:0(zero)   go to first line of the file
:$              go to last line of the file
string substitution
:n1,n2:s/string1/string2/[g]       Substitute string2 for string1 on lines n1 to n2. If g is included (meaning global),  all instances of string1 on each lineare substituted. If g is not included,only the first instance per matching line issubstituted.

:1,$:s/dog/cat/g               Substitute 'cat' for 'dog', every instance for the entire file - lines 1 to $ (end of file) Saving and quitting and other "ex" commands

:w                                          Write the current file.
:w new.file                          Write the file to the name 'new.file'.
:w! existing.file                   Overwrite an existing file with the file currently being edited.
:wq                                        Write the file and quit.
:q                                           Quit.
:q!                                          Quit with no changes.
:e filename                          Open the file 'filename' for editing.
:set number                         Turns on line numbering
:set nonumber                    Turns off line numbering

Searching and Determining line numbers
/string                        string search forward 
?string                       string search backward
n                               move next occurrence forward
N                              move next occurrence forward
:=                            Return the number of lines in the bottom of the screen

Read individual characters of a file(can be use to identify strange characters)
od -c filename

Compare 2 files and export difference 
cat file1.txt file2.txt | sort |uniq -u > out.txt

Convert Dos file to Unix
vi the document and type :set ff=unix

Show no of columns group by column length (delimiter 'tab')
$ awk -F '\t' ' {print NF+1 } ' unique_medical_0-55k.txt  | sort | uniq -c
Export no of columns in each line (delimiter 'tab')
$awk -F '\t' ' {print NF+1 } ' unique_medical_0-55k.txt  > /tmp/a
you can use /[^39]command to find out row no of column whose length except 39