Thursday, June 6, 2013

Vi Editor : Movements

Cursor Movement :

h (left), j (down), k (up), l (right)

End of Line: 
$ --> End of line
A --> Append at End of line

Start of Line:
"^ "
Begin of previous line:  "H" (shift +h)
Begin of next line : "L" (shift + l)

End of File :
Shift + g

Join two lines:
"J" --> Go to End of line then press "J"

Go to :
:n --> go to line no. "n"

Word movement :
End of current word: e
Start of current word: b
Next word: w

You may also want to know how to work with multiple files using vi split

Wednesday, May 15, 2013

Vi Editor : Working with multiple files : Split screen


Creating Multiple Screens :

:split --> Split Horizontally
:vsplit  --> Split Vertically
:new  --> to open new file
:w filename  --> to save a new file with a name filename
or :new filename --> open new file with name filename

Movements between screens :

(Remember with Control Windows : Ctrl+W)
"ctrl+w" + arrow key  ( Arrow keys easy to move between screens)
or
"ctrl+w" + [h | j | k | l ]
h --> move to left screen
l --> move to right screen
j --> move to down screen
k --> move to upper screen

Not much difficult to remember as keys "h" , "j", "k", "l" are in sequence on keyboard.

:only  --> Full screen

You may also want to know useful vi cursor movements

https://linuxhint.com/how-to-use-vim-split-screen/

Monday, April 22, 2013

lsof for Solaris 11

 Solaris 11 default repository does not contain lsof package. So i headed for sunfreeware and downloaded lsof v4.80 and tried compiling it on Solaris 11 box. But it was not successful and seems not supported.


  If you want to download binary please find the compiled lsof below :
Download lsof for Solaris 11 x64 v 4.87 lsof_x86
Download lsof for Solaris 11 Sparc v 4.87 lsof_sparc


Later I found the latest source 4.87 at :
ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
Same source file should work for sparc and x64.

I downloaded it; and it compiled like a charm.

Steps:
Required packages:

I used compiler gcc-45 ( older may work) :
developer/gcc-45
system/library/gcc-45-runtime

Header files:
system/library/gcc-45-runtime

After downloading the latest source file unzip it and compile as below :

  1. # gunzip lsof_4.87.tar.gz
  2. # tar -xvf lsof_4.87.tar
  3. # cd lsof_4.87/
  4. # tar -xvf lsof_4.87_src.tar
  5. # cd lsof_4.87_src
  6. # ./Configure solaris
  7. # make
  8. # make install
  9. # ./lsof





Enjoy !!

Wednesday, February 27, 2013

Solaris core dump recovery

A dump is the image of kernel at the time of issue. Sometimes it is generated intentionally by user or may be kernel itself decide to panic and generate dump.

Dump is very important for root cause analysis ( RCA) to figure out what was wrong with the Operating System.

Most important aspect is the size of dump. The maximum size of the dump can reach is equal to size of physical memory or RAM. But most of the time it will be smaller than that.
So we need some space to save the dump on filesystem. Incase of insufficient space core dump may fail to get save after the panic.

No dump available: Jan 20 01:37:41 <hostname> savecore: [ID 976488 auth.error] not enough space in /var/ak/core (0 MB avail, 10223 MB needed)

If you are using ZFS filesystem you can increase the quota of dump device as:

# dumpadm
 Dump content: kernel and current process pages
 Dump device: /dev/zvol/dsk/system/dump (dedicated) <------ dump device
 Savecore directory: /var/crash    <----- directory where core will be saved 
 Savecore enabled: yes
 Save compressed: on


# zfs list |egrep "core|dump"
system/cores                                       48.0G      0  48.0G  legacy
system/dump                                        12.0G   264G  12.0G  -


We can see above that cores directory is already filled up with old dump files and eating upto 48G. So i will delete them and get some space.
If still space is insufficient then i will increase the quota of system/cores as:
# zfs set quota=100GB system/cores


You can recover the core dump image by doing the following as soon as the system reboots after panic:
1. Increase the filesystem size or find some other location to save dump
2. run command
# savecore -v              //incase you want to save dump on same location configured by "dumpadm"
OR
# savecore -dv <new_location>   //save dump to new location


Tuesday, February 12, 2013

Upgrading to Solaris 11 Update 1

Upgrading from Solaris 11 to Solaris 11 update 1 is not a difficult task especially with the new pkg utility which internally uses Image Packaging system.

You can directly refer to Oracle blog for the same as each step is mentioned clearly, it mentions several exceptions while upgrading like if ldom packages are present then you need some workarounds.

Also please note that Solaris 11u1 may still contain old version some of the packages as compared to the latest SRU (Support Repository Updates) for Solaris 11.

So we will not cover those details but just a let us summarize the basic steps :
1. # pkg update --be-name s11.1new --accept   // it will update to latest available SRU of S11u1
2. # reboot

*If you are running Solaris on Vbox then you after update you may need to uninstall vbox addition packages and install new ones.

Tuesday, December 11, 2012

NFS client for Windows

Have you tried using NFS on Windows. I have mentioned below some of the ways to use NFS on windows.
 It may be useful to access a Unix share on windows.

1 .Built-in NFS client : Only for Win7 Ultimate / Enterprise. It doesn't work for Win7 Professional
 To enable NFS Service:
Control Panel > Programs and Features > Tun Windows Feature on or off > Services for NFS > click Client for NFS > ok

eg: net use <mount to drive>: <IP addr>:/share /persistent:no   // to connect
     net use <drive>: /delete          // To disconnect

http://support.microsoft.com/kb/324055
http://technet.microsoft.com/en-us/library/cc772015.aspx
http://www.microsoft.com/en-us/download/details.aspx?id=2391
http://technet.microsoft.com/en-us/library/cc754350.aspx

For Windows XP/2000/2003 : http://www.microsoft.com/en-us/download/details.aspx?id=274

2. Nekodrive :

3. nfsAxe :

Please let me know if you find any other ways to use NFS client on windows.


Monday, December 3, 2012

deleting all files except except one

I came across a situation where i wanted to delete all files and directories in current directory and just leaving one of the files.
You may have other solutions as well. I used xargs for this purpose as:

#ls |grep -v symantec.tar.gz | xargs rm -rf -

It will list all files then do a "grep -v" to filter out a given file. Then piped that output to xargs to delete the files and directories.