09 July 2012

Redirecting console output to a pseudotty

Using the TIOCCONS ioctl one can redirect console output to a pseudotty.
This is what xterm -C and xconsole do.

get latest pseudocons.c
# gcc -Wall -o pseudocons pseudocons.c -lutil
# ./pseudocons
[pseudocons]got master
[pseudocons]got slave console
[cons]Hoera..
[cons][pseudocons]Got Ctrl+C; Exiting...

execute the below command from another window to get the above output
# echo Hoera.. > /dev/console

Reference:
http://www.win.tue.nl/~aeb/linux/lk/lk-2.html

06 June 2012

howto configure DNS on redhat 7

yum install bind 
yum install bind-utils
yum install caching-nameserver
service named restart
chkconfig named on

vi /etc/named.caching-nameserver.conf
options {
  listen-on port 53 { 127.0.0.1; machine-IP; };
  allow-query     { any; };
  forwarders { 8.8.8.8; 8.8.4.4; };
...
};

service named restart
dig www.google.com @machine-IP
;; ANSWER SECTION:
www.google.com.         101137  IN      CNAME   www.l.google.com.
www.l.google.com.       262     IN      A       74.125.225.177
www.l.google.com.       262     IN      A       74.125.225.178
www.l.google.com.       262     IN      A       74.125.225.179
www.l.google.com.       262     IN      A       74.125.225.180
www.l.google.com.       262     IN      A       74.125.225.176
...
vi /etc/named.caching-nameserver.conf
#view localhost_resolver {
#   match-clients      { localhost; };
#   match-destinations { localhost; };
#   recursion yes;
#   include "/etc/named.rfc1912.zones";
#};
include "/etc/named.humblesimple.com.zones";

cat > /etc/named.humblesimple.com.zones << EOF
zone "humblesimple.com" IN {
        type master;
        file "named.humblesimple.com-forward";
        allow-update { none; };
};

zone "10.21.168.198.in-addr.arpa" IN {
        type master;
        file "named.humblesimple.com-reverse";
        allow-update { none; };
};
EOF

cat > /var/named/named.humblesimple.com-forward << EOF
$TTL 1D
@       IN SOA  humblesimple.com.     root (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN      A       192.168.21.10
        IN      NS      192.168.21.10
server1 IN      A       192.168.21.11
EOF

cat > /var/named/named.humblesimple.com-reverse<< EOF
$TTL 1D
@       IN SOA  @ humblesimple.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        PTR     192.168.21.10.
EOF

service named restart
dig server1.humblesimple.com @machine-IP
;; ANSWER SECTION:
server1.humblesimple.com. 86400 IN      A       192.168.21.11
...
Reference:
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch18_:_Configuring_DNS

23 April 2012

Combine multiple PDFs into one file

we will see one example how to combine pdf files let us assume we have 001.pdf, 002.pdf files and now we need to combine this files using the following command

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 001.pdf 002.pdf

gswin32c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 001.pdf 002.pdf

In the above command after “-sOUTPUTFILE=” type whatever name you want for the merged file (don’t forget to append .pdf to the end of the file name).

After you run the above command, a new PDF file called combinedpdf.pdf will be created with your individual files merged according to the order you list.

Reference:
http://www.debianadmin.com/combine-multiple-pdfs-into-one-file-in-ubuntu-linux.html
http://www.rizauddin.com/2009/04/how-to-merge-or-combine-pdf-files-with-ghostscript