TimeLinux1

Monday, December 16, 2013

Software Licensing Terms and Meanings

Free Open Source Software Licensing Terms and Meanings.

Note: The following discussion is based on my personal software industry experience and observation. This is not a legal advice. Any comments/corrections/suggestions for improvements are welcome.

In context of Computer Software:

Copyright = Owner has Exclusive ownership of work. No one else does. Copyright is automatic--ie, if you write an original software program, create an original art, write a new book, etc, you are automatically the default Copyright owner of the that work. You dont have to apply for your Copyright (unlike Patents). You can do whatever with it. You can patent it (and make it exclusive) or you can free it by allowing others to freely copy/replicate your work (this is what Copyleft attempts to do--see below).
Patent = Superset of Copyright in terms of restrictions. It disallows even 'similar' works attempted by others. You have to apply for it with the Patents office for it. It gives you exclusive rights over your work. You can legally sue anyone who tries to copy it or steal it.
Public Domain =  No copyright. No one person owns it. Everyone collectively owns it. No cost. (Think of a public road or park).
Free s/w = Source Code + Binary. NOT no cost. Although it can be granted for no money..(IF the software Copyright owner so desires).
Note: Software in Public Domain is essentially Free s/w. It can also be made closed.
Note: this is because NOone owns Public Domain s/w. It is 'use it as you like'.

Copyleft = Copyright + Copyright owner Frees it (ie source code + binary) using a Free software license (like GPL, Apache, etc) + All Derivatives required to be Free (ie source + binary)
Note: FSF and GNU encourage Copylefting. They dont encourage Public Domain s/w. This is because Public Domain s/w can potentially be turned closed (use it as you like) where as Copyleft s/w can NOT be closed.

Note: NOT all Free s/w (in Public Domain) is Copyleft. Copyleft is Free s/w with that cannot be closed. (eg X Windows is Free but not Copyleft). infact, many Free s/w licenses like Apache, Mozilla, MIT, LGPL etc are NOT Copyleft. This means that s/w (or their derivatives) under such licenses can be turned into closed. This is what Android and ZFS are.

Specific Cases:
GNU GPL v2 and GNU GPL v3 are BOTH Copyleft Licenses.
GPLv3 is more restrictive in that it forbids only a certain version of Copyleft s/w to be run on a certain h/w.
In other words, GPLv3 says, end user can run any version of a Copyleft s/w on a certain h/w.
This is in response to DVR maker TiVo who allowed ONLY a certain version of their Copyleft s/w to run on their h/w. Under GPLv2, this would be ok--because GPLv2 only mandates s/w being Free+Copyleft--it doesnt talk of what hardware it should or should not be run on.
GPLv3 is designed to prevent DRMs.

DRM = short for Digital Rights Management.
DRM comprises of  Digital signatures placed in h/w &/or s/w (Free or Closed) to restrict what h/w a s/w can run on.
DRM is used by hardware vendors to control what software runs on their hardware.
DRM is used by software vendors to control what hardware their software runs on.
DRM is essentially not CopyLeft. It is extreme CopyRight.

Tuesday, December 3, 2013

Business Legal Musings - 1



Some commonly used Business Terms regarding Intellectual Property:

Invention = Any new Idea or Creative work or improvement in existing product/idea.
   eg: A new recipe for Ketchup.

Intellectual Property = An Invention legally owned by Inventor.
   eg: Inventors copy of the recipe for the Ketchup with legal evidence to show ownership.

Patent = Exclusive legal right to own and use an Invention.
   eg: Legal Evidence & Acknowledgement by Patent Office to the Inventor of the Ketchup's Recipe.
Note: Patents Expire. Usually granted for 15-20 years.
Note: Patents are usually for Design/Technical/Science related IP. 
Note: The equivalent term for Patents For Artistic IP (eg Music, Literature or Recipe) is Copyright. Like Patents, Copyrights too expire after certain time but usually after longer time(70-100+ years).
Note: The concept of Patents is a superset of Copyright in terms of legal rights.
   eg: whereas copyright will protect against verbatim copy of the Ketchup Recipe (ie Plagiarism) it wont protect if there is minor differences in the wording of two recipes. 
   Patent will actually prevent anyone but the IP owner to even attempt to make a similar Ketchup Recipe.
   This is especially true in case of Computer Software Patents.

Innovation = Popularizing an Invention usually through Marketing, Sales & PR.
   eg: Mass production and sale of the new Ketchup.

Trademark = A Symbol for an Innovation (for exclusive use by someone).
   eg: a logo for the Ketchup.

Royalty = Fee paid to the Inventor or Innovator for sharing their Intellectual Property.
   eg: Fee paid to the Inventor or Innovator to gain access to their Ketchup Recipe.

Public Domain = Public property; Allowing Unrestricted Access to an Invention/Innovation.
   eg: Once the Ketchup Recipe Patent (or rather Copyright) expires, the Recipe becomes Public Property; i.e., Royalties no longer need be paid for using the Recipe.

Sunday, December 1, 2013

Pointer Refresher in C Language:

Here is a short Pointer Refresher in C Language:

-pointers: variables that hold the 'memory address' of another variable
-They are declared using '*' operator and initialized using '&' operator.
-eg:
$ cat -n ptr0.c 
    1 #include <stdio.h>
      2
      3 int main()
      4 {
      5 int num;
      6 int *pnum; /* pointer declaration */
      7 pnum=&num; /* pointer initialization */
      8 num=57;
      9 printf("\n Value of variable num = %d.", num);
    10 *pnum=23; /* indirect invocation of value of variable num via pointer */
    11 printf("\n New value of variable num = %d.", num);
    12 printf("\n The first value was direct invocation of variable.");
    13 printf("\n The second value was an indirect invocation of variable, using a pointer.");
    14 printf("\n Good bye.\n");
    15 return 0;
    16 }

-advantages of Pointers:
.allow dynamic allocation of mem /* see '*pum=23;' in above code */
.allow functions to modify calling argument

-void pointer:
.is defined as 'void *pointervar'
.its type is unknown and can thus receive a parameter that receive any type of pointer argument
.in other words, during value assignment, no explicit cast is required.
-see below code for void pointer illustration:
$ cat -n voidptr.c 
      1 #include <stdio.h>
      2
      3 int main()
      4 {
      5 int i=5;
      6 char ch='M';
      7 void *ptr; /* declaring a void pointer */
      8
      9 ptr=&i; /* initialize ptr with an integer var addr */
    10 printf("\n Pointer ptr now points to an integer %d.", *(int *)ptr);
    11 ptr=&ch; /* initialize ptr with an character var addr */
    12 printf("\n Pointer ptr now points to a char %c.", *(char *)ptr);
    13 printf("\n The same pointer was used to point to an integer and then to a char.");
    14 printf("\n This was possible only due to a void pointer.");
    15 printf("\n Good bye.");
    16
    17 return 0;
    18 }
    19

Wednesday, October 2, 2013

Linux Howto: Missing curses/ncurses Library Ubuntu 12.04

So I tried this simple program to test a Text-screen based program on my Ubuntu 12.04:

mrinal@ms-dell:~/C_Progs$ cat screen1.c 
#include <unistd.h>
#include <stdlib.h>
#include <curses.h>

int main()
{
initscr();
move(5,15);
printw("%s","Hello World");
refresh();
sleep(5);
endwin();
exit(EXIT_SUCCESS);
}

When I try to compile it using the Text-screen library system curses, I get the following error:

mrinal@ms-dell:~/C_Progs$ gcc screen1.c -o ans -lcurses
screen1.c:3:20: fatal error: curses.h: No such file or directory
compilation terminated.

Turns out I dont have the curses.h header file (nor the new ncurses.h)
mrinal@ms-dell:~/C_Progs$ ls -l /usr/include/*curs*
ls: cannot access *curs*: No such file or directory

This means the packages for curses (and/or ncurses) library are missing. To fix this, I did this:

mrinal@ms-dell:~/C_Progs$ sudo apt-get install libncurses5-dev libncursesw5-dev
[sudo] password for mrinal:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
 ...
After this operation, 2,971 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main libtinfo-dev amd64 5.9-4 [103 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ precise/main libncurses5-dev amd64 5.9-4 [222 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ precise/main libncursesw5-dev amd64 5.9-4 [255 kB]
Fetched 581 kB in 9s (64.0 kB/s)                                                                                                                  
...
Setting up libtinfo-dev (5.9-4) ...
Setting up libncurses5-dev (5.9-4) ...
Setting up libncursesw5-dev (5.9-4) ...
mrinal@ms-dell:~/C_Progs$ 

After this, the curses header file is now available in my /usr/include directory:

mrinal@ms-dell:~/C_Progs$ ls -l /usr/include/*cur*
-rw-r--r-- 1 root root  6582 Nov 18  2011 /usr/include/cursesapp.h
-rw-r--r-- 1 root root 27630 Nov 18  2011 /usr/include/cursesf.h
-rw-r--r-- 1 root root 76291 Nov 18  2011 /usr/include/curses.h
...
-rw-r--r-- 1 root root  7304 Nov 18  2011 /usr/include/cursslk.h
-rw-r--r-- 1 root root  3925 Nov 18  2011 /usr/include/ncurses_dll.h
lrwxrwxrwx 1 root root     8 Nov 18  2011 /usr/include/ncurses.h -> curses.h

/usr/include/ncursesw:
total 352
-rw-r--r-- 1 root root  6591 Nov 18  2011 cursesapp.h
-rw-r--r-- 1 root root 27648 Nov 18  2011 cursesf.h
-rw-r--r-- 1 root root 93685 Nov 18  2011 curses.h
-rw-r--r-- 1 root root 19522 Nov 18  2011 cursesm.h
... 
-rw-r--r-- 1 root root 40299 Nov 18  2011 term.h
-rw-r--r-- 1 root root 12534 Nov 18  2011 tic.h

-rw-r--r-- 1 root root  3108 Nov 18  2011 unctrl.h

And the program compiles successfully:

mrinal@ms-dell:~/C_Progs$ gcc screen1.c -o ans -lcurses

And executes successfully too.

mrinal@ms-dell:~/C_Progs$ ./ans


Sunday, September 8, 2013

How to do Group Video Meeting on Google Hangout

With Google Hangout we can do a Group Video Meeting of upto 10 users for FREE.
Heres how:

Pre-requisites for Video Meeting on Google Hangout:

1- a Google Gmail account
2- a computer/device with video camera, mike and speakers*
3- high speed Internet (at least 1Mbps is recommended)

*If using external camera, mike and speakers, make sure they are the default in Google (see below)

How to use:

1- Login to your Gmail account -- make sure you are not logged into any other video service like Skype as it can interfere with Google when it tries to access your camera, mike or speaker.

2- Click Contact -- On the left side of your Gmail screen, you have all your contacts. Click the contact name you want to video with. A new window will pop up--this is the Hangout window.

3- Settings -- On the top right of the Hangout window, click the 'Settings' icon -- it looks like a gear.
3a- When you click the Settings, you will see your default camera, mike and speakers -- make sure they are are listed and are the correct device. For eg, if your computer has an integrated camera and you are using another USB camera, then choose which camera Google should use.

4- Invite -- To add more people to the meeting, click the 'Invite People' on the left side of the hangout window.

5- Meet -- Once they accept the invite everyone would be in the same Hangout video meeting and would be able to see each other.

6- To End -- To end the meeting, click the icon on the 'Exit' button on the top right (Telephone receiver with a downward pointing arrow)

Note: When doing video meetings, the recommendation is that same person who starts the hangout meeting, adds the remaining invitees. If everyone tries to invite everyone else, Google gets confused.

Wednesday, May 8, 2013

Linux - Compiling a kernel steps:


[root@redhat4 ~]# cd /tmp
[root@redhat4 tmp]# mkdir mskernel
[root@redhat4 tmp]# cd mskernel
[root@redhat4 mskernel]# uname -a
Linux redhat4 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

[root@redhat4 mskernel]# wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.12.tar.xz

--2013-05-08 09:56:32--  https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.12.tar.xz
Resolving www.kernel.org... 198.145.20.140, 149.20.4.69
Connecting to www.kernel.org|198.145.20.140|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71001428 (68M) [application/x-xz]
Saving to: “linux-3.8.12.tar.xz”

100%[===========================================================================>] 71,001,428  5.21M/s   in 12s  

2013-05-08 09:56:44 (5.70 MB/s) - “linux-3.8.12.tar.xz” saved [71001428/71001428]


[root@redhat4 mskernel]# tar xvJf linux-3.8.12.tar.xz 
linux-3.8.12/
linux-3.8.12/.gitignore
linux-3.8.12/.mailmap
linux-3.8.12/COPYING
linux-3.8.12/CREDITS
linux-3.8.12/Documentation/
linux-3.8.12/Documentation/.gitignore
linux-3.8.12/Documentation/00-INDEX
linux-3.8.12/Documentation/ABI/
linux-3.8.12/Documentation/ABI/README
linux-3.8.12/Documentation/ABI/obsolete/
linux-3.8.12/Documentation/ABI/obsolete/proc-sys-vm-nr_pdflush_threads
linux-3.8.12/Documentation/ABI/obsolete/sysfs-bus-usb
linux-3.8.12/Documentation/ABI/obsolete/sysfs-class-rfkill
linux-3.8.12/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus
linux-3.8.12/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus
linux-3.8.12/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra
linux-3.8.12/Documentation/ABI/removed/
linux-3.8.12/Documentation/ABI/removed/devfs
linux-3.8.12/Documentation/ABI/removed/dv1394
linux-3.8.12/Documentation/ABI/removed/ip_queue
linux-3.8.12/Documentation/ABI/removed/o2cb
linux-3.8.12/Documentation/ABI/removed/raw1394
linux-3.8.12/Documentation/ABI/removed/video1394
.....



[root@redhat4 linux-3.8.12]# make menuconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 ***
 *** Install ncurses (ncurses-devel) and try again.
 ***
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2

To overcome this error, I ran -
[root@redhat4 linux-3.8.12]# yum install ncurses-devel -y
This installed the missing packages and then re-ran menuconfig (see below):


[root@redhat4 linux-3.8.12]# make menuconfig
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf Kconfig
#
# using defaults found in /boot/config-2.6.32-220.el6.x86_64
#
/boot/config-2.6.32-220.el6.x86_64:555:warning: symbol value 'm' invalid for PCCARD_NONSTATIC
/boot/config-2.6.32-220.el6.x86_64:2567:warning: symbol value 'm' invalid for MFD_WM8400
/boot/config-2.6.32-220.el6.x86_64:2568:warning: symbol value 'm' invalid for MFD_WM831X
/boot/config-2.6.32-220.el6.x86_64:2569:warning: symbol value 'm' invalid for MFD_WM8350
/boot/config-2.6.32-220.el6.x86_64:2582:warning: symbol value 'm' invalid for MFD_WM8350_I2C
/boot/config-2.6.32-220.el6.x86_64:2584:warning: symbol value 'm' invalid for AB3100_CORE
/boot/config-2.6.32-220.el6.x86_64:3502:warning: symbol value 'm' invalid for MMC_RICOH_MMC

The menuconfig option allows gui based kernel configuration (see sample config menus here)

...
Once satisfied, save changes

...

#
# configuration written to .config
#

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.


Then run make..
[root@redhat4 linux-3.8.12]# make
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_32_ia32.h
  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_64_x32.h
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_64.h
  HOSTCC  arch/x86/tools/relocs
  WRAP    arch/x86/include/generated/asm/clkdev.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  HOSTCC  scripts/genksyms/genksyms.o

.....
after about 2 hours...
.....

 IHEX    firmware/mts_gsm.fw
  IHEX    firmware/mts_edge.fw
  H16TOFW firmware/edgeport/boot.fw
  H16TOFW firmware/edgeport/boot2.fw
  H16TOFW firmware/edgeport/down.fw
  H16TOFW firmware/edgeport/down2.fw
  IHEX    firmware/edgeport/down3.bin
  IHEX2FW firmware/whiteheat_loader.fw
  IHEX2FW firmware/whiteheat.fw
  IHEX2FW firmware/keyspan_pda/keyspan_pda.fw
  IHEX2FW firmware/keyspan_pda/xircom_pgs.fw
[root@redhat4 linux-3.8.12]#

[root@redhat4 linux-3.8.12]# make modules_install
  INSTALL Documentation/connector/cn_test.ko
  INSTALL Documentation/filesystems/configfs/configfs_example_explicit.ko
  INSTALL Documentation/filesystems/configfs/configfs_example_macros.ko
  INSTALL arch/x86/crypto/ablk_helper.ko
  INSTALL arch/x86/crypto/aes-x86_64.ko
  INSTALL arch/x86/crypto/aesni-intel.ko
  INSTALL arch/x86/crypto/crc32c-intel.ko
  INSTALL arch/x86/crypto/ghash-clmulni-intel.ko
  INSTALL arch/x86/crypto/salsa20-x86_64.ko
  INSTALL arch/x86/crypto/twofish-x86_64.ko
  INSTALL arch/x86/kernel/cpu/mcheck/mce-inject.ko
  INSTALL arch/x86/kernel/microcode.ko
  INSTALL arch/x86/kernel/test_nx.ko
  INSTALL arch/x86/kvm/kvm-amd.ko
  INSTALL arch/x86/kvm/kvm-intel.ko
  INSTALL arch/x86/kvm/kvm.ko
  INSTALL arch/x86/oprofile/oprofile.ko
  INSTALL crypto/ansi_cprng.ko
  INSTALL crypto/anubis.ko
  INSTALL crypto/arc4.ko
  INSTALL crypto/async_tx/async_memcpy.ko
  INSTALL crypto/async_tx/async_pq.ko
  INSTALL crypto/async_tx/async_raid6_recov.ko
.....
  INSTALL /lib/firmware/ti_3410.fw
  INSTALL /lib/firmware/ti_5052.fw
  INSTALL /lib/firmware/mts_cdma.fw
  INSTALL /lib/firmware/mts_gsm.fw
  INSTALL /lib/firmware/mts_edge.fw
  INSTALL /lib/firmware/edgeport/boot.fw
  INSTALL /lib/firmware/edgeport/boot2.fw
  INSTALL /lib/firmware/edgeport/down.fw
  INSTALL /lib/firmware/edgeport/down2.fw
  INSTALL /lib/firmware/edgeport/down3.bin
  INSTALL /lib/firmware/whiteheat_loader.fw
  INSTALL /lib/firmware/whiteheat.fw
  INSTALL /lib/firmware/keyspan_pda/keyspan_pda.fw
  INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fw
  DEPMOD  3.8.12
[root@redhat4 linux-3.8.12]# 

[root@redhat4 linux-3.8.12]# make install
sh /tmp/mskernel/linux-3.8.12/arch/x86/boot/install.sh 3.8.12 arch/x86/boot/bzImage \
System.map "/boot"
[root@redhat4 grub]# 

Then you can cd to /boot dir and verify the new kernel is present there..
[root@redhat4 boot]# cd /boot
[root@redhat4 boot]# ls -lart
total 45631
-rw-r--r--.  1 root root      166 Nov  9  2011 .vmlinuz-2.6.32-220.el6.x86_64.hmac
-rw-r--r--.  1 root root  2312369 Nov  9  2011 System.map-2.6.32-220.el6.x86_64
-rw-r--r--.  1 root root   100943 Nov  9  2011 config-2.6.32-220.el6.x86_64
-rwxr-xr-x.  1 root root  3938800 Nov  9  2011 vmlinuz-2.6.32-220.el6.x86_64
-rw-r--r--.  1 root root   171087 Nov  9  2011 symvers-2.6.32-220.el6.x86_64.gz
drwx------.  2 root root    12288 Jun 19  2012 lost+found
drwxr-xr-x.  3 root root     1024 Jun 19  2012 efi
-rw-r--r--.  1 root root 15558855 Jun 19  2012 initramfs-2.6.32-220.el6.x86_64.img
-rw-------.  1 root root  4301773 Jun 19  2012 initrd-2.6.32-220.el6.x86_64kdump.img
dr-xr-xr-x. 25 root root     4096 Mar  5 08:56 ..
-rw-r--r--.  1 root root  4272784 May  8 11:36 vmlinuz-3.8.12
lrwxrwxrwx.  1 root root       20 May  8 11:36 vmlinuz -> /boot/vmlinuz-3.8.12
-rw-r--r--.  1 root root  2621147 May  8 11:36 System.map-3.8.12
lrwxrwxrwx.  1 root root       23 May  8 11:36 System.map -> /boot/System.map-3.8.12
dr-xr-xr-x.  5 root root     1024 May  8 11:37 .
-rw-r--r--.  1 root root 13406914 May  8 11:37 initramfs-3.8.12.img
drwxr-xr-x.  2 root root     1024 May  8 11:37 grub

[root@redhat4 grub]# cd /boot/grub
[root@redhat4 grub]# ls -lart
total 279
-rw-r--r--. 1 root root   1341 May  6  2010 splash.xpm.gz
-rw-r--r--. 1 root root  13964 Jun 19  2012 xfs_stage1_5
-rw-r--r--. 1 root root  11364 Jun 19  2012 vstafs_stage1_5
-rw-r--r--. 1 root root  12024 Jun 19  2012 ufs2_stage1_5
-rw-r--r--. 1 root root    512 Jun 19  2012 stage1
-rw-r--r--. 1 root root  14412 Jun 19  2012 reiserfs_stage1_5
-rw-r--r--. 1 root root  11956 Jun 19  2012 minix_stage1_5
lrwxrwxrwx. 1 root root     11 Jun 19  2012 menu.lst -> ./grub.conf
-rw-r--r--. 1 root root  13268 Jun 19  2012 jfs_stage1_5
-rw-r--r--. 1 root root  11756 Jun 19  2012 iso9660_stage1_5
-rw-r--r--. 1 root root  11748 Jun 19  2012 ffs_stage1_5
-rw-r--r--. 1 root root  12620 Jun 19  2012 fat_stage1_5
-rw-r--r--. 1 root root  13380 Jun 19  2012 e2fs_stage1_5
-rw-r--r--. 1 root root     63 Jun 19  2012 device.map
-rw-r--r--. 1 root root 125976 Jun 19  2012 stage2
dr-xr-xr-x. 5 root root   1024 May  8 11:37 ..
-rw-------. 1 root root   1172 May  8 11:37 grub.conf
drwxr-xr-x. 2 root root   1024 May  8 11:37 .
[root@redhat4 grub]# 

You can verify that the new kernel is now in the grub.conf:
[root@redhat4 grub]# vim grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (3.8.12)
        root (hd0,0)
        kernel /vmlinuz-3.8.12 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-3.8.12.img
title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-2.6.32-220.el6.x86_64.img
~                                                


And thats it.
There is tons of useful links on the net eg: this one at wikihow





Tuesday, May 7, 2013

Linux - Installing packages from source tarballs:

Installing a package using - tar.gz, configure, make, make install steps:

1- Download the tarball:

[root@redhat2 linux-2.6.39]# wget http://www.sqlite.org/sqlite-autoconf-3070603.tar.gz
--2013-05-07 15:48:52--  http://www.sqlite.org/sqlite-autoconf-3070603.tar.gz
Resolving www.sqlite.org... 67.18.92.124, 2600:3c00::f03c:91ff:fe96:b959
Connecting to www.sqlite.org|67.18.92.124|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1720314 (1.6M) [application/x-gzip]
Saving to: “sqlite-autoconf-3070603.tar.gz”

100%[==========================================================================================>] 1,720,314    802K/s   in 2.1s  

2013-05-07 15:48:54 (802 KB/s) - “sqlite-autoconf-3070603.tar.gz” saved [1720314/1720314]

2- Extract the tarball:

root@redhat2 linux-2.6.39]# tar xvfz sqlite-autoconf-3070603.tar.gz 
sqlite-autoconf-3070603/
sqlite-autoconf-3070603/tea/
sqlite-autoconf-3070603/tea/doc/
sqlite-autoconf-3070603/tea/doc/sqlite3.n
sqlite-autoconf-3070603/tea/win/
sqlite-autoconf-3070603/tea/win/rules.vc
sqlite-autoconf-3070603/tea/win/makefile.vc
sqlite-autoconf-3070603/tea/win/nmakehlp.c
sqlite-autoconf-3070603/tea/aclocal.m4
sqlite-autoconf-3070603/tea/README
sqlite-autoconf-3070603/tea/configure
sqlite-autoconf-3070603/tea/configure.in
sqlite-autoconf-3070603/tea/tclconfig/
sqlite-autoconf-3070603/tea/tclconfig/install-sh
sqlite-autoconf-3070603/tea/tclconfig/tcl.m4
sqlite-autoconf-3070603/tea/generic/
sqlite-autoconf-3070603/tea/generic/tclsqlite3.c
sqlite-autoconf-3070603/tea/Makefile.in
sqlite-autoconf-3070603/tea/license.terms
sqlite-autoconf-3070603/tea/pkgIndex.tcl.in
sqlite-autoconf-3070603/depcomp
sqlite-autoconf-3070603/sqlite3.pc
sqlite-autoconf-3070603/aclocal.m4
sqlite-autoconf-3070603/README
sqlite-autoconf-3070603/ltmain.sh
sqlite-autoconf-3070603/configure
sqlite-autoconf-3070603/shell.c
sqlite-autoconf-3070603/configure.ac
sqlite-autoconf-3070603/config.guess
sqlite-autoconf-3070603/install-sh
sqlite-autoconf-3070603/config.sub
sqlite-autoconf-3070603/missing
sqlite-autoconf-3070603/sqlite3.1
sqlite-autoconf-3070603/sqlite3.c
sqlite-autoconf-3070603/sqlite3.h
sqlite-autoconf-3070603/Makefile.am
sqlite-autoconf-3070603/Makefile.in
sqlite-autoconf-3070603/sqlite3ext.h
sqlite-autoconf-3070603/INSTALL
sqlite-autoconf-3070603/sqlite3.pc.in
[root@redhat2 linux-2.6.39]# cd sqlite-autoconf-3070603
[root@redhat2 sqlite-autoconf-3070603]# ls
aclocal.m4    config.sub  configure.ac  INSTALL     ltmain.sh    Makefile.in  README   sqlite3.1  sqlite3ext.h  sqlite3.pc     tea
config.guess  configure   depcomp       install-sh  Makefile.am  missing      shell.c  sqlite3.c  sqlite3.h     sqlite3.pc.in

3- Configure the source:

[root@redhat2 sqlite-autoconf-3070603]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for ranlib... ranlib
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... no
checking for g95... no
checking for xlf95... no
checking for f95... no
checking for fort... no
checking for ifort... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for ftn... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... (cached) ranlib
checking for strip... strip
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
appending configuration tag "F77" to libtool
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for fdatasync... yes
checking for usleep... yes
checking for fullfsync... no
checking for localtime_r... yes
checking for gmtime_r... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... no
checking for library containing tgetent... no
checking for library containing readline... no
checking for readline... no
checking for library containing pthread_create... -lpthread
checking for library containing dlopen... -ldl
checking for whether to support dynamic extensions... yes
checking for posix_fallocate... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: executing depfiles commands
[root@redhat2 sqlite-autoconf-3070603]# ls
aclocal.m4    config.status  configure.ac  install-sh  Makefile     missing  sqlite3.1     sqlite3.h      tea
config.guess  config.sub     depcomp       libtool     Makefile.am  README   sqlite3.c     sqlite3.pc
config.log    configure      INSTALL       ltmain.sh   Makefile.in  shell.c  sqlite3ext.h  sqlite3.pc.in

4- Compile the source:

[root@redhat2 sqlite-autoconf-3070603]# make
if /bin/sh ./libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.7.6.3\" -DPACKAGE_STRING=\"sqlite\ 3.7.6.3\" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.7.6.3\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -I.    -D_REENTRANT=1 -DSQLITE_THREADSAFE=1  -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -MT sqlite3.lo -MD -MP -MF ".deps/sqlite3.Tpo" -c -o sqlite3.lo sqlite3.c; \
then mv -f ".deps/sqlite3.Tpo" ".deps/sqlite3.Plo"; else rm -f ".deps/sqlite3.Tpo"; exit 1; fi
mkdir .libs
 gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.7.6.3\" "-DPACKAGE_STRING=\"sqlite 3.7.6.3\"" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.7.6.3\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -MT sqlite3.lo -MD -MP -MF .deps/sqlite3.Tpo -c sqlite3.c  -fPIC -DPIC -o .libs/sqlite3.o
 gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.7.6.3\" "-DPACKAGE_STRING=\"sqlite 3.7.6.3\"" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.7.6.3\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -MT sqlite3.lo -MD -MP -MF .deps/sqlite3.Tpo -c sqlite3.c -o sqlite3.o >/dev/null 2>&1
/bin/sh ./libtool --tag=CC --mode=link gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1  -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2   -o libsqlite3.la -rpath /usr/local/lib -no-undefined -version-info 8:6:8 sqlite3.lo  -ldl -lpthread 
gcc -shared  .libs/sqlite3.o  -ldl -lpthread  -Wl,-soname -Wl,libsqlite3.so.0 -o .libs/libsqlite3.so.0.8.6
(cd .libs && rm -f libsqlite3.so.0 && ln -s libsqlite3.so.0.8.6 libsqlite3.so.0)
(cd .libs && rm -f libsqlite3.so && ln -s libsqlite3.so.0.8.6 libsqlite3.so)
ar cru .libs/libsqlite3.a  sqlite3.o
ranlib .libs/libsqlite3.a
creating libsqlite3.la
(cd .libs && rm -f libsqlite3.la && ln -s ../libsqlite3.la libsqlite3.la)
if gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.7.6.3\" -DPACKAGE_STRING=\"sqlite\ 3.7.6.3\" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.7.6.3\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -I.    -D_REENTRANT=1 -DSQLITE_THREADSAFE=1  -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -MT shell.o -MD -MP -MF ".deps/shell.Tpo" -c -o shell.o shell.c; \
then mv -f ".deps/shell.Tpo" ".deps/shell.Po"; else rm -f ".deps/shell.Tpo"; exit 1; fi
/bin/sh ./libtool --tag=CC --mode=link gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1  -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2   -o sqlite3  shell.o ./libsqlite3.la  -ldl -lpthread 
gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -o .libs/sqlite3 shell.o  ./.libs/libsqlite3.so -ldl -lpthread  -Wl,--rpath -Wl,/usr/local/lib
creating sqlite3
[root@redhat2 sqlite-autoconf-3070603]# 

5- Install the source:

[root@redhat2 sqlite-autoconf-3070603]# make install
make[1]: Entering directory `/tmp/Django-1.5.1/linux-2.6.39/sqlite-autoconf-3070603'
test -z "/usr/local/lib" || mkdir -p -- "/usr/local/lib"
 /bin/sh ./libtool --mode=install /usr/bin/install -c  'libsqlite3.la' '/usr/local/lib/libsqlite3.la'
/usr/bin/install -c .libs/libsqlite3.so.0.8.6 /usr/local/lib/libsqlite3.so.0.8.6
(cd /usr/local/lib && { ln -s -f libsqlite3.so.0.8.6 libsqlite3.so.0 || { rm -f libsqlite3.so.0 && ln -s libsqlite3.so.0.8.6 libsqlite3.so.0; }; })
(cd /usr/local/lib && { ln -s -f libsqlite3.so.0.8.6 libsqlite3.so || { rm -f libsqlite3.so && ln -s libsqlite3.so.0.8.6 libsqlite3.so; }; })
/usr/bin/install -c .libs/libsqlite3.lai /usr/local/lib/libsqlite3.la
/usr/bin/install -c .libs/libsqlite3.a /usr/local/lib/libsqlite3.a
chmod 644 /usr/local/lib/libsqlite3.a
ranlib /usr/local/lib/libsqlite3.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
test -z "/usr/local/bin" || mkdir -p -- "/usr/local/bin"
  /bin/sh ./libtool --mode=install /usr/bin/install -c 'sqlite3' '/usr/local/bin/sqlite3'
/usr/bin/install -c .libs/sqlite3 /usr/local/bin/sqlite3
test -z "/usr/local/include" || mkdir -p -- "/usr/local/include"
 /usr/bin/install -c -m 644 'sqlite3.h' '/usr/local/include/sqlite3.h'
 /usr/bin/install -c -m 644 'sqlite3ext.h' '/usr/local/include/sqlite3ext.h'
test -z "/usr/local/share/man/man1" || mkdir -p -- "/usr/local/share/man/man1"
 /usr/bin/install -c -m 644 './sqlite3.1' '/usr/local/share/man/man1/sqlite3.1'
test -z "/usr/local/lib/pkgconfig" || mkdir -p -- "/usr/local/lib/pkgconfig"
 /usr/bin/install -c -m 644 'sqlite3.pc' '/usr/local/lib/pkgconfig/sqlite3.pc'
make[1]: Leaving directory `/tmp/Django-1.5.1/linux-2.6.39/sqlite-autoconf-3070603'
[root@redhat2 sqlite-autoconf-3070603]# 

-Test it out-

[root@redhat2 sqlite-autoconf-3070603]# sqlite3 mrinal.db
SQLite version 3.7.6.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table mrinal (id integer, name varchar(20));
sqlite> insert into mrinal values(1,'MS');
sqlite> select * from mrinal;
1|MS
sqlite> insert into mrinal values(1,'MS');
sqlite> insert into mrinal values(1,'MS');
sqlite> insert into mrinal values(1,'MS');
sqlite> insert into mrinal values(1,'MS');
sqlite> select * from mrinal;
1|MS
1|MS
1|MS
1|MS
1|MS
sqlite>

Wednesday, April 10, 2013

Configuring X11 for RHEL server and OSX client

Problem:
We have a remote Red Hat Enterprise Linux (RHEL) server; We have a OSX (Apple) laptop. We want to connect from the laptop client to the RHEL server over ssh and then run graphical utilities (like system-config-users) on the RHEL server but have its graphical output be shown on the laptop.

Approach:
To accomplish this task, we make use of a very handy tool called X. To read more about X, go here.
Now for the X to work properly in our case we need a few things on both the server (RHEL) and client (OSX):
  -ssh configuration to allow XForwarding on RHEL
  -X server on client.

Note:
The way X treats client and server are opposite to the way ssh treats client and server.
For ssh, the client is OSX laptop, and the server is the remote RHEL host we are trying to connect to.
For X, the client is the RHEL host we are going to run the graphical tools on, and the server is the OSX laptop where the X software will run.

Steps:
1- On RHEL server edit the ssh configuration file (/etc/ssh/sshd_config) and uncomment/edit the following lines to look like this:


X11Forwarding yes                    ###This allows X output to be forwarded over ssh
X11UseLocalhost yes                 ###This allows X to use the localhost (OSX client) to display

2- Then restart ssh service:

[root@redhat2 ~]# service sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                               [  OK  ]

3- On the client (OSX laptop) side, install X server:
Note: In recent versions of OSX, X server is not installed by default and you need to download (and install) X software called XQuartz from here.
4- Once the download of XQuartz is completed, you need to install it by double clicking the file.
5- Once installed you need to enable remote login for ssh. To do so, open 'System Preferences' > click 'Sharing' and check 'Remote Login' as shown.





6- Then open a terminal on your OSX laptop and ssh to the RHEL server:

msarkar$ ssh -X root@10.10.80.102
root@10.10.80.102's password:
Last login: Wed Apr 10 22:31:38 2013 from 10.250.0.223
[root@redhat2 ~]#

This will put you on the remote RHEL server whose graphical output you want to see on your laptop over X system.
To verify that the Display is properly set, echo the display--this should be localhost or the IP address of the laptop as shown below:

[root@redhat2 ~]# echo $DISPLAY
localhost:10.0
[root@redhat2 ~]#

7- To test out that everything related to X working fine run a sample X application like xeyes or xclock

[root@redhat2 ~]# xeyes &
[1] 24575
[root@redhat2 ~]#

It should show you the applet running on your laptop (here xeyes).
If that works out fine, simply invoke your graphical application whose output you want to see on your local client (here OSX laptop).


[root@redhat2 ~]# system-config-users &
[2] 27604
[root@redhat2 ~]#

And thats it!
Hope you found this useful.

Note:
If you encounter errors like "xhost:  unable to open display" or "Error: Can't open display:", make sure the /etc/ssh/sshd_config file is properly configured (see step #1 above) and you have restarted sshd service after that (step #2) before you attempt to login over ssh.




Wednesday, April 3, 2013

How to Password Protect your Folder in Linux

In Linux (like most other Unix), file permissions under DAC (Discretionary Access Control, ie rwx combination on user,group and world/others) are usually enough to protect files at a high level. And since Folders are nothing but special files, it applies to them aswell.
That said, sometimes (especially when using the GUI on a desktop), it is desirable to have a mechanism where users simply cant open a folder because they had read permissions on it (even if you yourself are the owner of the files in that folder). This can be handy when dealing with sensitive data.
The catch though is that you cant actually password protect a folder unless you zip it. If you dont zip it, it can still be protected with the DAC permissions).
Now, back to the password protection -- there are two ways to do this -- via GUI or via CLI (command line interface).

By GUI, its simple: right click on the folder you want protected, choose 'encrypt', choose password ' 'protect' and provide a secret password. This will create a zip file of the folder with its underlying directories and files in the current directory. You would then go on to delete the folder you zipped (because now you have a copy of it in the zip file).

By CLI, a little more extra hoops but the same result as shown below:

~# mkdir -p /home/mrinal/secdir   <----- you want to password protect this folder called secdir
~# cd /home/mrinal/secdir
secdir# touch a b c d e                   <----- create afew files in secdir
secdir# echo hello world > a          <----- populate the files with some words here 'hello world'
secdir# echo hello world > b
secdir# echo hello world > c
secdir# echo hello world > d
secdir# echo hello world > e

secdir]# cd ..                                   <----- go one folder up
mrinal# zip -e -r secret /home/mrinal/secdir/              <----- zip encrypt recursively the secdir dir/folder

Enter password:
Verify password:
  adding: home/mrinal/secdir/ (stored 0%)
  adding: home/mrinal/secdir/d (stored 0%)
  adding: home/mrinal/secdir/c (stored 0%)
  adding: home/mrinal/secdir/b (stored 0%)
  adding: home/mrinal/secdir/e (stored 0%)
  adding: home/mrinal/secdir/a (stored 0%)
mrinal# ls -l
total 8
drwxr-xr-x. 2 root root 4096 Apr  3 13:51 secdir
-rw-r--r--. 1 root root 1228 Apr  3 13:58 secret.zip

mrinal# rm -rf  secdir                    <----- remove the dir as you have a protected copy in the zip [Relax, its safe!]

Now you can access the file via GUI or the CLI, either way you would be prompted for a password.
When you provide the right password, it unzips the folder and puts it back for you to view.

For instance on CLI:

mrinal# unzip secret.zip
Archive:  secret.zip
   creating: home/mrinal/secdir/
[secret.zip] home/mrinal/secdir/d password:
 extracting: home/mrinal/secdir/d  
 extracting: home/mrinal/secdir/c  
 extracting: home/mrinal/secdir/b  
 extracting: home/mrinal/secdir/e  
 extracting: home/mrinal/secdir/a  
mrinal#

Hope this helps.

Sunday, March 17, 2013

Tainted Kernel - What to do?

Tainted Kernel:

In the Linux world, where Opensource drivers and modules rule the roost, you may happen to receive a message in your system alerts saying that your kernel is 'Tainted'. Before we go further its useful to understand what it means.

Because of the Opensource model, Linux kernel modules and drivers are designed, developed and maintained by the Linux Opensource community. Some Linux flavors like GNU Hurd are strict about their principles about Free Open Source software fundamentals and therefore would not include any non-Free drivers and modules in their distribution. On the other hand Linux distributions like Ubuntu and LinuxMint are not so strict. They emphasise functionality and ease of use over Principles of FSF. Their driver and module inclusion policy in their distributions is more relaxed. What that means is that often in these distributions would include proprietary drivers and modules to make something work. This is especially true in case of Graphical, Audio or Wireless drivers. For instance the Graphic Drivers from AMD (Radeon) could be included in a certain Linux distribution.
Now, whenever proprietary drivers are included, they come only as binary code--no source code.
Which means if there is any problem or bug detected in that (proprietary) softwar, the Linux community cannot  access the source code and therefore cannot fix it. This fix can only come from the vendor who provided that proprietary driver or module. This is lack of visibility in the source code of a proprietary driver or module that is having problems working with Linux kernel is said to have 'Tainted the Linux kernel'.

Great, now we know what it means, how do we confirm it? How do we fix diagnose and fix it?
Well, it varies, but in almost all cases, you would know that your kernel is Tainted if you receive a popup/warning or alert from the system. On Fedora, the distribution that I use all the time, the 'Tainted kernel' alert is easily visible from the system alerts on the bottom right corner of the GUI screen. From the command line, its visible under the kernel message utility dmesg, as follows:


[root@ms-vaio ~]# dmesg | grep -i taint
[83346.433966] Pid: 31775, comm: kworker/u:0 Tainted: G        W    3.7.6-102.fc17.x86_64 #1

This can also be confirmed by looking into the file /proc/sys/kernel/tainted:


[root@ms-vaio ~]# cat /proc/sys/kernel/tainted 
512

Typically (for an un-tainted kernel), this file is empty. But as you can see, in my case its not. And in this case the process id 31775 is causing the kernel to be tainted. To dig into what that process is you can look into the process listing as follows:

[root@ms-vaio ~]# ps -efly | grep 31775
S root      4330  1539  0  80   0   872 27350 pipe_w 17:52 pts/0    00:00:00 grep --color=auto 31775
[root@ms-vaio ~]# 

As you can see, the process with pid=31775 does not exist in my case, which means the process was shortlived, it caused a kernel warning and then it was termintated.


For a detailed discussion on the meaning of each Taint Flag like 512, G, W etc, go here and search for 'tainted'.

Now what to do to fix it?

Typically there is, Nothing to fix.

All it means is that your kernel has a device driver that is not open source. It may be wireless, or video driver (either are common) or you have some slightly unusual hardware that doesn't have a kernel supported driver.

The only time it causes a problem is if a kernel failure/panic occurs. The kernel developers cannot debug such a failure because they are not able to trace the entire problem. It may have been caused by a bug in the proprietary driver either directly (it happens to be in the traceback) or indirectly by modifying some kernel data that other drivers depended on.

So a reboot usually clears the warning and resets the /proc/sys/kernel/tainted file to zero bytes.


Friday, March 8, 2013

Allow users to connect to remote MySQL database

When you are working with MySQL, chances are that your client and server are on two different hosts.
In such a case, its natural to want to connect to a remote MySQL database.
Lets say your local host (or client) is 10.10.80.103 and your remote host (or server) is 10.10.80.102.
So when you try connecting from client to server, default behavior of MySQL is to deny access:


[root@10.10.80.103 /root]# mysql -u myuser -p -h10.10.80.102
Enter password: *****
ERROR 1045 (28000): Access denied for user 'myuser'@'redhat3.maprtech.com' (using password: YES)

In such a situation, to allow access from remote hosts, go to the server (in this case 10.10.80.102), and do this as the admin user (root):


[root@10.10.80.102 /root]# mysql -u root -p
Enter password:*****

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7982
Server version: 5.1.52 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> grant all on *.* to myuser@'10.10.80.103' identified by 'mypass';
Query OK, 0 rows affected (0.00 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


Then go back to the client side (here 10.10.80.103) and make a connection attempt to the server (here 10.10.80.102):


[root@10.10.80.103 /root]# mysql -h 10.10.80.102 -u myuser-p 
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8340
Server version: 5.1.52 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>                          [[[ connection succeeds and you are in.]]]


Note: Ensure that the firewall settings are permissive on the server side or simply turn off firewall if you want (using 'service iptables stop' command).





Thursday, March 7, 2013

How to install MySQL on Linux

MySQL is a FOSS database that is available in a free community edition and a paid commercial edition from Oracle corp. Oracle acquired MySQL from Sun Microsystemes acquisition. MySQL is an integral part of LAMP Stack and is used for a majority of web applications. Infact, MySQL is a choice DB platform for many Internet Applications like Facebook, Twitter, Yahoo etc.

Its very simple to install and run MySQL on Linux using yum, as shown below.

1- Check status of MySQL prior to install:


[root@redhat2 bin]# service mysqld status
mysqld: unrecognized service
[root@redhat2 bin]#

As you see mysql doesnt exist. You can also verify using rpm.

[root@redhat2 bin]# rpm -qa | grep mysql
[root@redhat2 bin]#

2-To install:

[root@redhat2 lib]# yum install -y mysql-server
Loaded plugins: product-id, security, subscription-manager
Updating certificate-based repositories.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.52-1.el6_0.1 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.52-1.el6_0.1.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================
 Package                           Arch                      Version                              Repository                  Size
===================================================================================================================================
Installing:
 mysql-server                      x86_64                    5.1.52-1.el6_0.1                     mynew                    8.1 M
Installing for dependencies:
 perl-DBD-MySQL                    x86_64                    4.013-3.el6                          mynew                    134 k

Transaction Summary
===================================================================================================================================
Install       2 Package(s)

Total download size: 8.2 M
Installed size: 24 M
Downloading Packages:
(1/2): mysql-server-5.1.52-1.el6_0.1.x86_64.rpm                                                             | 8.1 MB     00:00  
(2/2): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                                | 134 kB     00:00  
-----------------------------------------------------------------------------------------------------------------------------------
Total                                                                                               48 MB/s | 8.2 MB     00:00  
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                               1/2
  Installing : mysql-server-5.1.52-1.el6_0.1.x86_64                                                                            2/2
Installed products updated.

Installed:
  mysql-server.x86_64 0:5.1.52-1.el6_0.1                                                                                        

Dependency Installed:
  perl-DBD-MySQL.x86_64 0:4.013-3.el6                                                                                            

Complete!

3- Verify installation:

[root@redhat2 lib]# rpm -qa | grep mysql
mysql-libs-5.1.52-1.el6_0.1.x86_64
soci-mysql-3.1.0-1.el6.x86_64
mysql-5.1.52-1.el6_0.1.x86_64
mysql-server-5.1.52-1.el6_0.1.x86_64

[root@redhat2 lib]# ls /etc/init.d/mysqld 
/etc/init.d/mysqld
[root@redhat2 lib]# 

4- Post install config:

root@redhat2 lib]# /usr/bin/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h redhat2 password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!


[root@redhat2 ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): *****
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y    
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

[root@redhat2 ~]#

5- Start using MySQL:

[root@redhat2 lib]# service mysqld status
mysqld (pid  10324) is running...

[root@redhat2 lib]# mysql -u root -p
Enter password: xyzxyz

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.52 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql;

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
23 rows in set (0.00 sec)

mysql> exit
Bye

Enjoy!


Wednesday, March 6, 2013

Heredoc to automate shell scripts

Ever wondered if there was a way to automate passing multiple bash commands to run non interactively?
For instance, if you wanted to create a shell script to start vi editor, get into insert mode and populate some commands based on some condition and then escape, save and exit out of the editor all while being in the shell script--how would you do it?

The answer is what is called heredoc. The concept of heredoc comes from C programming language and which was later borrowed into Unix/Linux tradition. Basically what a heredoc does is to accept commands from a stream starting with a start-signature and ending with the same signature. So all the commands or interactions with the shell between those start-end signatures are non-interactive.
For a more detailed discussion visit heredoc pages here and here.

An Example:

#-------------


[root@redhat2 mrinal]# cat myscript
#!/bin/bash

tfile=$1

vi $tfile << bye                      /* start vi with a file argument $tfile by user & start signature = bye*/
i                                              /* invoke 'insert' mode of vi */
echo `date`                              /* run a command */
`uname -a`                              /* run another command */
`ls -l`
^[                                            /* escape to command mode of vi, passed by Ctrl+v on keyboard */
wq                                          /* save file */
bye                                      /* end non interactive mode when sees the signature = bye */

#------------

The above shell script will open vi non-interactively and run a bunch of commands between the start-end signature, here in our case the word 'bye'. It could be anything you choose, as long the start and end signatures are the same.