Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

2011-02-21

Perl - How to find out what Core Modules installed

Perl comes with a set of core modules. Perl core modules comes with default installation.
E.g. :
- Env
- File::Spec
- File::Basename
- Time::localtime

These are just some of the gems to a system administrator. So, how to find out what core modules are included with your perl installation?




Here's how :

2010-10-01

FreeBSD - How to watermark image or picture using command line

Watermark is a technique to impose image or words using light shades. Digital watermark on image is use for the purpose of copyrights, comments or notices. Watermark image can be accomplish using tools from Image Magick suite of programs.

Firstly, install the ImageMagick port using portmanager :
portmanager graphics/ImageMagick -l

2010-09-29

FreeBSD - The ps command output is truncated from the terminal width

There are a few commands that can list current process activity, "top" & "ps" are the most common one in use. The command "top" give an interactive view of the list of process running currently. But the command "ps" gives a more friendly output for scripting or text parsing. It also gives a lot of parameters to filter the output. One of the common parameters that I've always use is "ps aux". It list all the current process running with headers and information. By the way, "ps" stands for process status.

Usually, the process status output is pass to "less", a pager for ease of reading. Often, the "COMMAND" column of "ps aux" output, is truncated at the end of the terminal width. This behavior prevents the full process name from displaying. One thing good about this is, the output are not wrap so it won't mess up the output display. But most of the time, we'll want to view the full output.

There are 2 things to try in order to get the full output. First, try telling the pager (in this case, "less") don't chop the long lines after the terminal width, using parameter "-S".

2010-06-16

N900 - A phone running open source OS & programs

N900 is the latest offering from Nokia that answers the open source crave for software freedom, it runs Maemo, an OS based on linux, specifically Debian. Maemo also uses "apt" as package manager. Its GUI is fantastic, with accurate touch screen experience. Command line comes with it by default, to access the very core of the OS. And not like some other OS that hides hard to NOT let user touch it (even that, users managed to "jailbreak" it so to access the command line :p).

The N900 hardware runs a fast ARM cortex A8 processor (overclockable), 32GB internal storage with expandable micro MMC external storage card, touch screen with 800 × 480 pixel resolution, QWERTY slide hardware keyboard, 3.5 mm audio jack, A-GPS, WiFi, bluetooth, 3G internet connectivity and the long list goes on.

A big note here, the Maemo community is active & generous to its user that wants to have software freedom. Freedom to choose software from a community that offers alternatives, community that patches and write software just so that we all can use freely and not bow our heads to companies that charges software, even minor function. The Maemo community is active in providing patches both to the OS & 3rd party programs.

We all know that Debian is a hacker friendly linux distribution that seems more and more linux distribution derived from. e.g. Ubuntu family, Knoppix, Damn Small Linux, here & here. Maemo is based on Debian.

The price is unbeatable consider that it comes with such fast & furious hardware, OS and most importantly, the active & friendly open source community.

This post will list out my other blog post that's written based on N900. Here are some of it :
  1. N900 - How to ssh into N900 using OpenSSH
  2. Perl - A happy note, on N900 
  3. N900 - How to overclock the processor speed of N900
  4. N900 - How to clear all the phone data & settings
  5. Stay tuned, this list will be update periodically.

Adios !!!

2010-06-11

N900 - How to ssh into N900 using OpenSSH

Since the Nokia N900 runs on Maemo, Debian based Linux, it also offers open source programs. The secure shell is one of open source gems. Maemo offers the OpenSSH variety of secure shell.

OpenSSH on Maemo not only offers encrypted secure remote shell, it also comes with functions that runs like the desktop version. Such as ssh socks 5 tunneling, that can be used to encrypt traffic transmit of the programs that supports socks 5 proxy.

Here's how to do it :

2010-04-03

Perl - How to change @INC to include non-standard path

Have been playing around with local::lib and bootstrap a few directories. After switching a few local::lib directories, I tend to forget which cpan module is installed in which local::lib directory and this make perl don't know where to find the cpan module. This is how to set the environment variable @INC so that perl can quickly locate the cpan module.

2010-03-27

Perl - How to list installed modules

A note for myself. This is how to list out what perl modules are installed.
Way 1 :
perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'

Way 2 :
perldoc perllocal


*** these are all taken from http://perldoc.perl.org/perlmodlib.html

Das Vidanya !!!

2010-03-20

Perl - How to install perl module without root or super user

By default, perl modules installed through cpanX (cpanm, cpanp & cpan) utilities are install into system wide perl directory. Although this will make the module available through out all users on this box, it also means if there's a problem with particular module, it affects all users. Some other problem hit me as well :

Problem 1 - bloated with perl modules :
Some modules installed because it was needed to fulfill some dependencies (not necessary useful though), testing purpose or other reasons. This resulted the system wide perl directory is bloated with modules that aren't used as often as it should & should be removed. Removing modules in perl aren't easy as removing packages through a package manager. Because a typical package manager will check for dependencies to make sure that removing 1 package won't break another package.

Removing perl modules typically means manually remove the .pm files (or directory) in perl system wide directory. And this means there is a risk that removing a module might break some program or modules that depends on it.

Problem 2 - no root privileges :
In a hosting environment, normally one doesn't have root or sudo account, which installing CPAN modules needs it to add or change files in perl system wide directory. How nice if a normal users can have their own perl module directory.

Problem 3 - development environment :
Developers likes to setup individual perl projects to test & work on different environment. Naturally sets of modules that can be install into few different directories to serve as environment, switching between these directories are ideal for this situation. In this case, messing up an environment doesn't means messing up the entire perl modules.

Given the above situation, local::lib fits into the picture by solving the problems. Local::lib creates a directory resides in ~/ and cpan modules are install into here afterwards. Local::lib does that by changing the environment parameters @INC & system's $PATH variable.

The below instruction uses the "bootstrap" method of local::lib installation. This is useful on hosting environment where no access for root or sudo execution to install local::lib perl module.

2010-03-12

Perl - How to install CPAN module, the easier way

Following IronMan Challenge posts not only for the sake of seeing What Color of Hair & Shirt ends up with Matt but the posts have been much enlightening. Recently in IronMan Challenge, there's been much talk about one of Miyagawa's project, App::cpanminus. Basically, cpanminus is a tool to install perl module from CPAN, without the verbosity of cpan|cpanplus, which also means, more newbie friendly. :)

The beauty of cpanminus is, it does not ask dozens of question before it installs. Instead, cpanminus will use the most suitable defaults & start downloading dependencies and install it. By default, cpanminus will not tell every action and result on the screen, which "scare" less.

In short, cpanminus improves or makes perfect the experience of installing modules from CPAN. Since the first time trying cpanminus, love it and loving it more seems inescapable :p

*** Some assumptions, perl 5.8 at least exist.

Enough talking, here's how to install cpanminus :

2010-01-07

Gimp - How to convert background of logo or picture into transparency

Gimp stands for "GNU Image Manipulation Program", which is an open source image editing problem. It's capability often compare to professional software but fortunately, Gimp acceptance as Pro image editing software is getting better. Even so, Gimp is still popular among beginner up to hobbyist user.

Gimp's available on multiple platform and since it is open source, you can bet it's available on BSDs.

This post will brief through how to transform a logo or picture to transparent background, suitable for dark or colored web page background.

2009-10-15

Perl - Connect using SSH with Perl & CPAN module

It has been weeks since the last time blogging about Perl. My day to day job has been tying most of my free time and blah blah blah excuses ... :p

My job deals with FreeBSD server, 90% of my time. Daily routines includes checking server health status. FreeBSD has these periodic scripts that will report server health status to sysadm daily, but the emails are always being "ignore" as the info in it are too vast. So, i decided to cough out a simple Perl script that will use SSH to connect to the servers and pull some health status report. This post will talk about using cpan module's, NET::SSH::Perl, to execute commands then print out the results.

Purpose of this script :
  • connect to server using ssh
  • authenticate only using public key
  • run a command and print out the result

Perl modules used :
  1. Perl::Critic = perl's best practice
  2. Net::SSH::Perl = the basic of using ssh in perl
  3. Net::SSH::Perl::Key::RSA = authenticate using public key
  4. Class::ErrorHandler = needed by Net::SSH::Perl::Key::RSA module

To reduce the hiccups, install the modules listed above by using CPAN client.

Here is the script :

2009-09-25

vim - Commenting multiple lines, block comment

Perl does not have block comment feature. The Acme::Comment module was the easiest way to make Perl do block commenting, with additional features, it allows customization of open & close punctuation mark.

Until yesterday, my first Perl code got some problem and had to seek help from the IRC channel perl-help @ irc.perl.org (these guys are really helpful, thanks dudes!). Just when they were helping me to solve the problem, Caelum tip me on how to block comment in Perl using vim. I thought it was a good idea as it doesn't need to load additional module to handle the block comment thing, which save some CPU processing.

Here it is :

2009-09-14

Perl - How to install Perl module using CPAN shell

One of Perl's strength is it's repository of modules, thousands of modules. No need to re-invent the wheel, just think of what you wanna do and search for it (http://cpan.perl.org).

The CPAN modules are available through the CPAN shell. In this post, we will talk briefly about how to install the CPAN shell and show an example of installing a module.

2009-08-24

Apache - [warn] _default_ VirtualHost overlap on port 80, the first has precedence

Virtual Host. A feature that enables Apache to configure multiple domain into one web (http) server. This feature saves the need to run multiple instances of web server and thus saves resources.

After configuring the <VirtualHost> directives, some may encounter an error message :
Error : [warn] _default_ VirtualHost overlap on port 80, the first has precedence

This is due to the missing of a parameter, before any <VirtualHost> directives:
NameVirtualHost

2009-08-18

ssh - How to encrypt/tunnel internet traffic through ssh

When using an insecure internet connection (e.g. wireless), it is a good practice to tunnel internet traffic through ssh. Tunneling through ssh provide encryption of the traffic starting from local computer to the point ends where ssh server is. It is especially important to encrypt the traffic out of the local PC when using un-secure connection as other malicious intent users might be able to sniff packet off the current connection.

How does ssh tunneling works?

2009-08-15

SmokePing - How setup logging (or debuging)

SmokePing is an utility to keep track of the network latency from your network to various site. Its output are recorded in graph, for analysis purpose. Its configuration are simple and easy to setup. But some times, logging are needed to debug some probes failed to output to graph. The logging setup will need to edit some files to make sure it rotate itself and syslog needs to be notified.

Here is how you get your hands dirty :

2009-07-29

Linux - Shorewall firewall with PPTP VPN dialup client

PPTP VPN uses protocol GRE on two way, both inbound and outbound. Setting up the firewall to allow PPTP VPN dialup client (e.g. Ubuntu's NetworkManager) to use protocol GRE is just a few steps in adding rules and interfaces. This post is based on the previous post "How to set up Shorewall firewall (alternate to FireStarter)", which is a quick tutorial on setting up Shorewall firewall on a single network interface. Here it is :

2009-07-28

Linux - How to set up Shorewall firewall (alternate to FireStarter)

There are a few option of firewall interface available on Linux for iptables, both GUI (Graphical User Interface) and CLI (Command Line Interface). FireStarter user interface on GUI is easy to use and configure. The only problem is it does not work properly with PPTP VPN dialup, it blocks protocol GRE. It does provide a workaround (dont ask, it is too painful to remember) but the steps are too tedious and involve the mixture of setup in command line and GUI, and this kind of setup always spells trouble.

Shorewall is another firewall interface that operate on CLI. This is taken from the Shorewall's introduction :

"The Shoreline Firewall, more commonly known as “Shorewall”, is high-level tool for configuring Netfilter. You describe your firewall/gateway requirements using entries in a set of configuration files. Shorewall reads those configuration files and with the help of the iptables, iptables-restore, ip and tc utilities, Shorewall configures Netfilter and the Linux networking subsystem to match your requirements. Shorewall can be used on a dedicated firewall system, a multi-function gateway/router/server or on a standalone GNU/Linux system. Shorewall does not use Netfilter's ipchains compatibility mode and can thus take advantage of Netfilter's connection state tracking capabilities."

Shorewall's way of configuring iptables firewall made easy by just describing the rules and interfaces into a few files and the firewall is ready to go. Shorewall's website also provides extensive documentation on how it works and how to setup.

This post's intended to setup Shorewall in a few simple steps and thus, it is not really suitable to implement it on medium to large enterprise. Here it is :

2009-06-27

How to check hard disk transfer speed or timing

Storage are getting cheaper and cheaper. Almost a year ago, a 250 GB 2.5" portable hard disk would cost 120 bucks. But now, it only cost 100 bucks for a 500 GB hard disk. Size are getting bigger and bigger with the same monetary value but does the hard disk spins fast enough to fetch the big "gigabytes" in time? Of cause, given "enough" time, any rate of spin could fetch any size of data. Files are getting larger and larger, especially audio & video files. Fetching the files in an reasonable time is crucial.

Before we proceed to check out the command on how to check hard disk transfer speed or read timings, we will need to familiarize our self with hard disk naming convention. Here is a simple guide on how to identify hard disk naming convention in /dev (where device node are store) :

2009-06-26

Mozilla Firefox - common keyboard shortcut keys

Firefox have all the bells & whistles to make our internet life happy. Tabs, plugins, portability and keyboard shortcuts. Firefox keyboard shortcuts make browsing addictive, especially to system administrator, which our hands are on the keyboard most of the time. We could use mouse to browse it but wouldn't you think by keeping your hands on the keyboard would increase productivity? :)

Below are the list of keyboard shortcuts plus a few combination of mouse clicks which commonly used in Firefox. There are of cause other shortcuts available but this post only attempt to introduce you with the efficiency of using keyboard shortcuts (almost mouse-less) rather then trying to exhaust your brain memory in crunching the full list of keyboard shortcuts. You can print the below list of Firefox keyboard shortcut keys out and act as a Cheat Sheet. It can be useful in getting familiar initially using the keyboard shortcut keys. Here are the list :