Hacking with walking a process tree with pstree

pstree is a small, command line (i.e., all-text mode) program that displays the processes (i.e., executing instances of programs) on the system in the form of a tree diagram. It differs from the much more commonly used (and more complex) ps program in a number of respects, including that the latter shows the processes in …

How to manipulate packages with dpkg (Enabling Muilti-Arch in Multi-Arch support) ?

$dpkg –print-architecture amd64 $dpkg –print-foreign-architectures $dpkg –add-architecture i386 dpkg: error: unable to create new file ‘/var/lib/dpkg/arch-new’: Permission denied $sudo dpkg –add-architecture i386 [sudo] password for jeffrin: $dpkg –print-foreign-architectures i386 $sudo dpkg –add-architecture itest386 $dpkg –print-foreign-architectures i386 itest386 $dpkg –remove-architecture itest386 dpkg: error: unable to create new file ‘/var/lib/dpkg/arch-new’: Permission denied $sudo dpkg –remove-architecture itest386 $dpkg …

Hacking with runit and sv ( sv – control and manage services monitored by runsv(8) ) commands

ABOUT runit runit is a cross-platform Unix init scheme with service supervision, a replacement for sysvinit, and other init schemes. It runs on GNU/Linux, *BSD, MacOSX, Solaris, and can easily be adapted to other Unix operating systems ABOUT sv The sv program reports the current status and controls the state of services monitored by the …

How to write an algorithm to swap values ?

/* part of work copied from http://www.sanfoundry.com/c-program-swap-values/ */ #include <stdio.h> swap_values() { int temp; int *ptr1, *ptr2; int a, b; printf(“Enter integer values to be swapped: “); scanf(“%d %d”,&a,&b); ptr1 = &a; ptr2 = &b; temp = *ptr1; *ptr1 = *ptr2; *ptr2 = temp; printf(“Swapped values are: %d %d \n”,a,b); } /* http://www.programmingsimplified.com/c-program-swap-two-numbers */ /* …

How to check exit status of a command ?

$stat stat: missing operand Try ‘stat –help’ for more information. $echo $? 1 $stat popen1-p1.c File: ‘popen1-p1.c’ Size: 473 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 5245647 Links: 1 Access: (0644/-rw-r–r–) Uid: ( 1000/ jeffrin) Gid: ( 1000/ jeffrin) Access: 2014-06-16 23:31:58.746088758 +0530 Modify: 2014-06-16 23:31:27.649735653 +0530 Change: 2014-06-16 23:31:27.649735653 +0530 Birth: …