Tuesday, December 10, 2013

Process and open files

There are situations where we may need to know :
1. Which files are opened by a given process
2. Which process is using a given file

If we are given a process and we need to find out the files opened by it then we can simply use
#pfiles <pid>

And if a file is given an we need to know which process has opened it then use
#fuser <file>

Convert shell script in binary

There are times when you want to hide the contents of your shell script to binary form so that it may not be read by others.
One such utility is called "shcomp"

shcomp - compile a ksh93 shell script

Using this utility you can compile/convert your ksh script to a binary script.

Tuesday, December 3, 2013

Run command in Parallel

We can run shell commands in parallel which can be very useful to utilize the power of system
Today system come with multiple CPU and each CPU has multiple cores.
 To utilize the full power of these CPUs you can run shell commands in parallel of different CPU at the same time.

Below is just a small example shows dd command running in parallel using pipe "|" on different CPU :


 # dd if=dev/zero of=/dev/null | dd if=dev/zero of=/dev/null

 #prstat
PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
5080 root     1636K 1040K cpu0    40    0   0:00:24  17% dd/1
5079 root     1636K 1040K cpu3    40    0   0:00:24  17% dd/1

Similarly,
we can gunzip and tar a file :
# gzcat  <file.tar.gz> | tar -xvf -
# gzcat  <file.tar.gz> | tar -xvf -
 

Wednesday, September 4, 2013

Hot-Pluggable Versus Hot-Swappable Devices

Many times you might have come across the terms hot-swappable or hot-pluggable.
But what are these same ? What is the difference ?

By Definition:

 Hot-Pluggable :
Devices that can be removed or installed while machine is running.
These devices requires administrative action to install or remove without need of reboot.
Eg: It may be required to offline a devie before you remove it.


Hot-Swappable:

Hot-swappable devices are on the other hand more user friendly as they don't need any user intervention or administrative action.
Just plugin to install or plugout to remove.

Sunday, August 18, 2013

Top free windows softwares

Recently my desktop running Windows 7 had some issues and i had to reimage it.
After basic installation i had to install software so i thought of sharing a list with you. These are free software that can be downloaded.

Here is my list of free software that i use frequently :

1. Open Office
2. Putty (self compiled with fixes ) + putty connection manager
3. Firefox and Chrome
4. Thunderbird
5. Pidgin
6. 7-zip
7. Java 7
8. Virtual Box : with Oracle ZFS appliance simulator, ubuntu, Solaris 11
9. Winscp
10. Virtual Desktop Client ( Oracle VDI )
11. Wireshark
12. Acrobat Reader
13. Notepad++
14. PrimoPDF
15. Glary utilities
16. VNC viewer
17. MinGW
18. Dual Monitor Taskbar : http://sourceforge.net/projects/dualmonitortb/files/Releases/
19. Windows 7 Logon Background Changer : www.julien-manici.com

Saturday, July 27, 2013

Expanding root / filesystem size online

To expand ext4 root filesystem size online is possible in Linux.

 Prerequisite is that to expand filesystem you should have free sectors available on the disk.
Here I am giving the example of ubuntu :

1. Change the partition size using fdisk
  a. Delete the partition "d"
  b. create a new partition "n"
  c. Give new size. Point to remember is that First sector should be same as it was before.
      In most cases it is default.
      Then give new size as +<size>G which should be bigger than original/previous root filesystem size.
  d. Confirm changed using print "p". Then save the changes.

2. For root filesystem we cannot say it is 100% online as new size will come into effect only after reboot.
  + If this is non-root partition then just "partprobe" will work after doing umount of mount point and it will read the new size into kernel.
3. Then do : e2fsck -f /dev/sda1
4. Now magic command resize2fs
  # resize2fs /dev/sda1

And we are all set !!
You can confirm the new size using df -h

Other quick dirty way would be to boot from Live CD then turn the swapoff and then resize root partition using gparted.

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.