Showing posts with label gnu/linux. Show all posts
Showing posts with label gnu/linux. Show all posts

Sunday, October 9, 2011

Wavelab with GNU Octave

GNU Octave is the Free Software used for mathematical computation. With an extensive support for versatile library functions, and code compatibility with Matlab, GNU Octave is a sweet treat to every engineer and researcher.

Apart from the officially supported libraries and application toolboxes, GNU Octave also has abundant support and addons from extraneous efforts.

The Signal processing toolboxes, are exhaustive enough and consist of speech processing, image processing and video processing functionalities, which provide a common, stable and evolving platform for any of these domain specific applications.


Taking signal processing to the next level, when one is looking for some advanced signal processing functions, rendezvous with Wavelet Transforms is assured.


While GNU Octave does not officially, as yet , support a Wavelet Transform toolbox, the Wavelab toolbox from the Stanford University project works like a charm. With this extensive background to the toolbox itself, I present the procedure for incorporating this Wavelab toolbox with GNU Octave.
  • Unzip the archive; A folder Wavelab850 will be created with the contents of the toolbox
  • Create a directory /usr/toolbox to dump the Wavelab toolbox
sudo mkdir /usr/toolbox
  • Copy the unzipped contents to the location /usr/toolbox 
sudo cp -r Wavelab850 /usr/toolbox
  • To link the Wavelab library to GNU Octave, open the GNU Octave interpreter in the GNU/Linux terminal, and add the path of the previously added Wavelab850 directory, so that GNU Octave can fetch the Wavelab library files when the function call is made 
octave:2> addpath /usr/toolbox/Wavelab850
  • Now, invoke the functions from Wavelab by running the Wavelab file WavePath.m in the octave terminal, by just typing WavePath in the interpreter.
octave:2> WavePath
  • If the WaveLab has been invoked a welcome message as shown below would appear  

  • Now all the amazing Wavelab functions are available in GNU Octave! 
  • To take a stroll into WaveLab, type WTBrowser. "Chapter 2 Fourier Kingdom" is something every science enthusiast must look into and understand! 

  • Further one particluar example code I was deeply impressed with is the 2-D analysis of synthetic objects ( like images). Type in toon0231 in the interpreter to have some pleasing revelations of Wavelet Transforms
octave:2> toon0231
 Happy Hacking, Happy Learning !
PS: In subsequent posts I will try to regress and give some more fundamental features of GNU Octave. 

Friday, August 12, 2011

GRUB and Reinstalling GRUB : Debian/Ubuntu

GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn. 

And playing around with GRUB to get multiple Operating Systems indexed and to make them available for booting is as awesome as it could get. 
The sheer scalability GRUB has to offer in terms of the number of OS'es it can index is superb. I have gone up to six different operating systems at one point of time, and currently am running five. And that doesn't still represent the number of OS'es that can be multi-booted via GRUB. It is only constrained by the space on your hard drive!

My current Grub entry
While trying the tricks of installing multiple operating systems, if care is not taken the latest OS will overwrite the GRUB and if it ain't a GRUB based bootloader (as would be the case when the last OS is M$ Windoze, or sometimes even Redhat!) the entries of other OS will be lost. 

GRUB on the top of Ubuntu/Debian are the best to retrieve and index all the installed OS. 

Here are the steps for reinstalling GRUB at the MBR for an Ubuntu/Debian distro. 

  • Get hold of a Live CD/Live USB stick with either Debian or Ubuntu
  • After entering the Live user environment, spot the ext4 partition of the Ubuntu/Debian
  • To get to know the partition where the hidden Ubuntu/Debian is installed, usually   
sudo fdisk -l
would suffice. Or gparted is another tool which could be of help
  •  Once you've got to know the ext4 partition, then mount it in the Live environment 
sudo mount /dev/sda5 /mnt (assuming that the ext4 partition of the hidden Ubuntu/Debian install is on sda5)

  • Now, reinstall GRUB :)
sudo grub-install --root-directory=/mnt /dev/sda
(GRUB will be installed on the MBR of sda)

And you're done!

  • Now, boot into your Ubuntu/Debian distro which was running on sda5 (in the example) and run  
sudo update-grub

This will generate a new grub.cfg file as shown in the image above.

Wednesday, July 27, 2011

DNS and DNS flushing in Ubuntu

The Domain Name System (DNS) is a hierarchical naming system built on a distributed database for computers, services, or any resource connected to the Internet or a private network. Most importantly, it translates domain names meaningful to humans into the numerical identifiers associated with networking equipment for the purpose of locating and addressing these devices worldwide. (Wikipedia)

Translating URL's to point at the IP addresses of servers is an important portion of the Internet browsing. There could be multiple levels of DNS resolutions happening to expedite the browsing experience of users.

On a GNU/Linux machine, if the user is aware of the URL and IP address of a host, he/she can make a manual DNS entry on the /etc/hosts file.


To view and add the DNS servers the host machine is using, the file to look at is
/etc/resolv.conf

Further, caching the DNS entries ( mapping of URL's to IP addresses) is a feature used to avoid the repeated Domain Name resolution iterations. But sometimes, when a single URL points to multiple servers ( like google mail etc..), and when secure sessions on different servers are established the chances that one of the servers would not resolve might occur.


During such instances, the DNS cache has to be flushed. The first and simple command which has to be manually run to flush the DNS cache is dns-clean.
It can be invoked by the following command:

raghu@fossphosis:~$ sudo /etc/init.d/dns-clean


But, repetitive invoking of this command might get on to the nerves of the users, and a daemon to automate this task is NSCD (Name Server Cache Daemon).
NSCD automates the DNS table flushing and refreshing process at the back end.
NSCD on Ubuntu can be installed by the following apt-get command.

raghu@fossphosis:~$ sudo apt-get install nscd

Fine tuning of the refresh rate and time-to-live of the DNS entries can be altered by changing the values in the configuration file /etc/nscd.conf

Monday, June 20, 2011

Running SMTP server on two ports concurrently in Ubuntu

The Simple Mail Transfer Protocol(SMTP) server in Ubuntu is available via the package "Postfix", which is the most widely used SMTP server in UNIX-like systems including AIX, BSD, HP-UX, Linux, MacOS X, Solaris, and more environments.

SMTP as a service runs on Port 25.


fossphosis@fossphosis:~$ cat /etc/services | grep smtp
smtp         25/tcp          mail
ssmtp        465/tcp        smtps        # SMTP over SSL

To get Postfix running on Ubuntu, all one needs to do is apt-get the package.

fossphosis@fossphosis:~$ sudo apt-get install postfix

Once, Postfix is installed, in case of configurations apart from the default ones, reconfigure the settings by running the dpkg-reconfigure, to set the parameters matching the network requirements.

fossphosis@fossphosis:~$ sudo dpkg-reconfigure postfix

I wanted my SMTP instance available on the local network for all the machines on the 192.168.1.X subnet. To accomplish this the only change, or the appendage to the existing default configuration is to add the subnet in the entry, as shown below:
Adding 192.168.1.0/24 subnet for reachability of the SMTP server on my network
In case of applications, like the one I was faced with, where i wanted the SMTP to run on an alternate port other than Port 25  parallely, all you need to do is add the port entry in the following postfix configuration file.

Edit /etc/postfix/master.cf,

I wanted SMTP to run on port 2525, so added the following entry just, as shown below:

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
2525      inet  n       -       -       -       -       smtpd

Once editing is done, restart the Postfix server

fossphosis@fossphosis:~$ sudo service postfix restart
[sudo] password for fossphosis:
 * Stopping Postfix Mail Transport Agent postfix           [ OK ]
 * Starting Postfix Mail Transport Agent postfix           [ OK ]

To verify if SMTP is running on both the ports,perform a basic telnet to the ports.
Testing on port 25
fossphosis@fossphosis:~$ telnet localhost 25
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 Comp ESMTP Postfix (Ubuntu)


Testing on port 2525

fossphosis@fossphosis:~$ telnet localhost 2525
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 Comp ESMTP Postfix (Ubuntu)

And, that's it!


Saturday, October 9, 2010

SNMP based Network monitoring

This is an introductory post to the SNMP based network management series of posts. In this post I would want to elaborate on the Network monitoring tools, which use SNMP(Simple Network Management Protocol)  to poll and map network devices with statistics and graphs.

Before delving into tools such as net-snmp, mrtg, cacti and nagios, a brief insight into the concepts and terminologies of SNMP in this post would help us appreciate the tools better.

Simple Network Management Protocol (SNMP) is a UDP-based network protocol. It is used mostly in network management systems to monitor network-attached devices for conditions that warrant administrative attention. (wiki)

Simple Network Management Protocol is highly useful in monitoring the health, statistics and graphing resource utilization of network devices like switches, routers, data-multiplexers,  Ethernet-access devices, modems, servers and most of the other electronic devices which are part of the network.

In GNU/Linux machines, by default the ports 161 and 162 are used for SNMP.



An SNMP-managed network consists of three key components:
  • Managed device, the device to be monitored/managed like a switch/router
  • Agent — software which runs on managed devices, like snmpd on Linux machines
  • Network management system (NMS) — software which runs on the manager, like nagios, cacti
To enhance the functionality of the snmp tools to incorporate additional features like configuration of specific devices, the concept of MIB is very helpful. MIB stands for Management Information Base, which increases the feature accessibility of devices being managed by SNMP.

SNMP protocol has had its growth with three versions until now.


SNMPv1: This is the first version of the protocol

SNMPv2c: This is the revised protocol, which includes enhancements of SNMPv1 in the areas of protocol packet types, transport mappings, MIB structure elements but using the existing SNMPv1 administration structure ("community based" and hence SNMPv2c).

SNMPv3: SNMPv3 defines the secure version of the SNMP. SNMPv3 also facilitates remote configuration of the SNMP entities.

In the posts to follow, we shall take a look at each of the important GNU/Linux utilities pertaining to SNMP

Tuesday, September 28, 2010

Configuring SSL on Apache2 with self signed SSL certification

Apache is one of the coolest things that has happened in FOSS, and now that about 70% of web servers run Apache, it is now a nondetachable component of the Web.

Apart from its ubiquity, Apache is very handy to simulate and test network conditions.
Like recently, I had to work with two local Secure Socket Layer (SSL) web servers, i.e, servers which can be accessed only by "https://URL". The servers using SSL protocol are different from conventional HTTP protocol for they operate on port 443 instead of port 80 (for http), and are by design more secure.

Configuring Apache2 is straight forward, and I was already running it on my system. To get it serve content on port 443 (SSL), I had to perform a few simple steps.

(Presumptions: Apache2 is already configured and running on a Debian based Linux machine)
(You should perform all these operations as root/ or perform as sudo as shown below)

1. Creating self-signed certificates for SSL

* Install ssl-cert package, if not installed already. In Debian based machines

raghu@fossphosis$ sudo apt-get install ssl-cert

* Creating a default self-signed certificate, in the default directory /etc/ssl/certs

raghu@fossphosis$ sudo make-ssl-cert generate-default-snakeoil --force-overwrite

2. Enabling the locations which can be accessed by clients on SSL

To use the default option, perform

raghu@fossphosis$ sudo a2ensite default-ssl

This lets users access content from /var/www on SSL

3. Enabling SSL module itslef for Apache2

raghu@fossphosis$ sudo a2enmod ssl

4. Finally, restart Apache2 server for the changes to take place

raghu@fossphosis$ sudo /etc/init.d/apache2 restart

5. Test it by requesting for a https URL in your browser
https://localhost/
SSL Error - Google Chrome
Do acknowledge the signature verification of the certificate to browse the content;
https:--localhost - Google Chrome
Happy Secure Socket Layer serving :)