Tuesday, September 25, 2007

Dear Linux SysAd Blog Readers

Dear Linux SysAd Blog Readers,

To all my subscribers and readers, I do appreciate all your time reading my feeds from time to time. Thank you for all the comments, shouts, and emails that I have been receiving too. I also appreciate the nice chillers, stumblers and community diggers you have been contributing up until now. Those backlinks, blogrolls, relinks that you are sharing from your sites, I managed to have 268 feed readers and subscribers which started from 1st of July 2007 up to this date, I thank you for all that.

...

Honestly, now my mind suddenly just warped back into the black hole and forgot what to blog.

So I went back to my old Gmail and randomly selected one of my emails for today. And decided to publish this particular email:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hi I came across your blog
http://ilovetux.com/2007/08/create-your-own-linux-os-distro-howto.html


I got the information exactly that I was searching ,I need some more information in case you know some thing then tell as per the instructions given on the revisor it is possible to create a distribution based on fedora I want to know is there any way this creation of DVD can be done without using revisor ,actually I want to understand this process of creation of installation media or ISO for my own customised linux tell me some keywords that I should look in for google

I don't want to use revisor that way I wont be able to know what exactly revisor did to create the installation media similar tool exist for Suse that is Kiwi
http://liquidat.wordpress.com/2007/06/22/kiwi-opensuses-re-spin-creator/
http://en.opensuse.org/KIWI

I am a learner and not much experienced in programming give me some links that might be relevant or google keywords to look in for .

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sure, I gladly replied him back with

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if you want to build your own custom linux, the best reply i can give to you right now is to use google to search for


linux from scratch

do let me know if you plan to publish your new linux ISO, i would love to download it and watch it grow from distrowatch.org too :)

thanks for visiting my site, i appreciate your support.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Again, I may not have all the time blog posting here, there, check spell that and this, and replying back to all your email requests, queries, comments due to some *time constraints but am still around here, working and blogging the alternative way, trying to have them one at a time and publish them one by one. I may not post from time to time but will do sooner or later.

Linux had invited us into one common IT place of linux advocacy and interests regardless of age, sex, religion, cultures, desktop and servers specs. I am glad to see that linux community had grown tremendously and still growing every day, well done.

Hope you stay tuned and see more of your visits from time to time.

Thanks for reading.

Cheers,
VeRTiTO

Proactive monitoring from linux terminal

As I was watching several google search keywords being used by most site visitors around this linux blog, I noticed several search keywords that led most users into this site

One of the recent google keyword search from CA,USA was:

~~~~~~~~~~~~~~~~~~~~~~~~~~~
linux watch ls directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~

with equivalent google search URL:

google search keyword

and in turn, google replied with this URL

from one of my Linux SysAd blog entries as you can see.

However, the returned URL is about ls command usage but not watching directory and files proactively from display screen. Yes, it is somehow related but needs more command tweaking and another linux command.

So, I am creating this blog entry for monitoring directory and files proactively live from your display screen via command line terminal.

Here's several ways on how to watch live directory/files changes from your display screen.

Fire up your first terminal and issue
# cd /tmp
# watch ls -C

Then fireup your second terminal and issue the commands below
# cd /tmp
# touch A1
# touch A2
# touch Z1

During the creation of A1, A2, Z1 files using linux touch command, you need to switch and focus your screen display with the terminal which was first launched.

Here's a way to watch them change on the fly sorted by ctime or creation timestamp.

From the first terminal, issue
# watch ls -Cc

By default, 'watch' linux command refreshes every 2 seconds. You can modify it using -n watch parameter like so

# watch -n 0 ls -CC

which waits for 0.1 seconds for file changes to be displayed out from your screen terminal.


If you are only interested to file changes owned by user vertito, simply

# watch -n 0 'ls -Cc | grep vertito'


Note:
1. printing characters are being stripped by watch linux command
2. any terminal resize would not do screen repaint automatically but after the next watch update


Now, to watch your ethernet TX/RX packets from ethernet device using watch, simply

# watch -n 0 ifconfig eth0

The above is like the command line version of NIC network general properties in windoze. You can also use these when troubleshooting network card and ethernet link connectivity issues or any network congestion issue from your current broadcast network.


If somebody is transferring FTP files into one of your managed host or partition, or an external host is uploading large files into your shared SAMBA folder and you want to watch your current disk/partition space usage proactively while the transfer is occurring, simply

# watch -n 0 df -ah
# watch -n 0 du -sh


To watch your host memory and swap resources proactively using watch

# watch -n 0 free
# watch -n 0 cat /proc/swaps

partially similar to top linux command.


To watch your queued mail proactively from terminal (postfix or sendmail), simply
# watch -n 0 mailq


I guess I have monitored and reacted proactively from my blog site as well because of this entry name.

There's a lot more live monitoring of logs and statistics that can be combined with watch linux command, you can create your own combination of linux command and shell scripts too!

That's all folks, enjoy, thanks for the black box tip!

deleting new lines and return line from text file

How to delete new lines and return key characters from text file?
How to delete backspace and formfeed characters from text file?
How to delete horizontal tab and vertical tab character from text file?
How to remove backslash from text file?
How to delete specific set of characters from text file?

A sample text file.

# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The quick brown fox blogs over the Linux SysAd.



The quick brown fox blogs over the Linux SysAd.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To delete new lines and empty lines from text file
# tr -d '\n' < testfile.txt

How to delete backspace and form feed characters from text file?
# td -d '\b' < testfile.txt
# td -d '\f' < testfile.txt
# td -d '\b\f' < testfile.txt

How to delete horizontal tab and vertical tab character from text file?
# td -d '\t' < testfile.txt
# td -d '\v' < testfile.txt
# td -d '\t\v' < testfile.txt

How to remove backslash from text file?
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The quick brown fox blogs over the Linux SysAd.
\
\\
\\\
The quick brown fox blogs over the Linux SysAd.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# td -d '\\' < testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The quick brown fox blogs over the Linux SysAd.



The quick brown fox blogs over the Linux SysAd.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


How to delete specific set of characters from text file?
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The quick brown fox blogs over the Linux SysAd.



The quick brown fox blogs over the Linux SysAd.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# tr -d '=aeiou=' < testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Th qck brwn fx blgs vr th Lnx SysAd.



Th qck brwn fx blgs vr th Lnx SysAd.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


For more string and character manipulation of text file, read more tr arguments from here.

Saturday, September 22, 2007

Google chat setup using PSI howto

Related to my previous entry here, here's another blog entry on configuring your Google mail account to do Google Talk/Chat with your friends without having logging into your GMail (Google Mail) account from any internet browser.

PSI INSTALLATION STEPS:
~~~~~~~~~~~~~~~~~~~~~~~

Here are five easy steps on how to setup your PSI messenger to connect to Google Talk/Google Chat servers.

If you have not installed PSI yet, visit this link. Assuming you have successfully installed yum, follow the below easy installation steps and screenshots guides.

1. Launch PSI messenger. Click Account Setup as shown below.


2. Click Add button, enter your Google Chat Name to identify the PSI Group. Followed by your Gmail Account name or your GMail email address as shown below. Click Save.


3. Make sure you check the below similar option boxes. Enter talk.google.com as your connection server. Enter the same port number as shown below.


4. From PSI main menu, choosing Online would start and connect your PSI to the net. Click and enabble the PSI group name.


Clicking Online would prompt your for your GMail account password, enter as required.


PSI would then retrieve your existing GMail friends and contact from talk.google.com server. PSI would then display all your online and offline users from here.

Congratulations!!! You are now online with Google Talk using PSI messenger.

For more PSI info, visit PSI site here.

HTH.

Cheers

Related Posts:


How To See Invisible YM Users
How To Setup Chikka SMS Messenger using Kopete Messenger
How To Setup Chikka SMS Messenger using GAIM Pidgin
How To Block YM Messenger
How To Install GAIM Pidgin Messenger
How To Install KDE Kopete Messenger
How To Install AMSN Messenger
How To Setup and Install PSI Chat Messenger

PSI messenger - a truly promising open messaging application

In the Open Source world, linux gives us more freedom and alternatives on achieving things from simple to complex technical server and dsektop issues. Linux applications does not confine us into one corner spot of the room and learn from that corner spot alone all time through. Linux open source applications expands your knowledge from your own stand point of interest supported by worldwide community and not from a commercially grown application interests.

Here's another entry on how to install PSI on Fedora

What is PSI?
~~~~~~~~~~~~

This is the best description I could have from PSI application, a well defined description and application usage from both developer and user's stand point of view.

PSI description:
(lifted from PSI site)
Psi is the premiere Instant Messaging application designed for Microsoft Windows, Apple Mac OS X and GNU/Linux. Built upon an open protocol named Jabber, Psi is a fast and lightweight messaging client that utilises the best in open source technologies.

The goal of the Psi project is to create a powerful, yet easy-to-use Jabber/XMPP client that tries to strictly adhere to the XMPP drafts and Jabber JEPs. This means that in most cases, Psi will not implement a feature unless there is an accepted standard for it in the Jabber community. Doing so ensures that Psi will be compatible, stable, and predictable, both from an end-user and developer standpoint.

This does not mean that Psi will never have "cool new features". The dev team and community are power-users who look to Psi to keep up with the times. We always want to hear what the users of Psi would like, and if a feature that the dev team wishes to implement does not have an accepted standard, or would diverge from an existing one, we can work together to see the standards changed to accomodate everyone.


PSI INSTALLATION USING YUM:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# yum -y install psi psi-i18n psi-icons


APPLICATION LAUNCH:
~~~~~~~~~~~~~~~~~~~

# psi

Perhaps you have been considering Jabber, but don't want to abandon your friends? Jabber technologies are highly extensible, so Psi is able to interoperate with other, proprietory messaging systems such as AOL's ICQ and Microsoft's Messenger. You can keep in contact with your friends, regardless of whether they use AIM, ICQ, MSNM or YM. It's even possible to use Internet Relay Chat! *

Unlike other IM clients, Psi is small, fast and responsive. It uses a graphical toolkit called Qt, which takes on the appearance of whichever operating system you run it on. For this reason, Psi doesn't use 'skins'. We'd rather it blend with your desktop like any other application.


PSI Screenshots:




Final Note:
~~~~~~~~~~~
PSI internet chat messaging works smoothly with KDE and GNOME. PSI has extensive features available at its early age. PSI presents these features in user friendly appearance schemes systematically done, avoiding complex program menu structures and program options. This approach makes PSI messenger fun and easy to use. PSI is on its early version state yet but had already established as a true and very promising open internet messaging application.

So watch out for PSI growth. Enjoy!

Related Posts:


How To See Invisible YM Users
How To Setup Chikka SMS Messenger using Kopete Messenger
How to Install and Setup Google Chat Messenger
How To Setup Chikka SMS Messenger using GAIM Pidgin
How To Block YM Messenger
How To Install GAIM Pidgin Messenger
How To Install KDE Kopete Messenger
How To Install AMSN Messenger

Google chat setup using GAIM Pidgin howto

As per request, here's an entry that shows how to setup your Pidgin GAIM to use your Google Talk or GMail account.

Pidgin man:
Pidgin is a graphical modular messaging client based on libpurple which is capable of connecting to AIM, MSN, Yahoo!, XMPP, ICQ, IRC, SILC, SIP/SIMPLE, Novell GroupWise, Lotus Sametime, Bonjour, Zephyr, Gadu-Gadu, and QQ all at once. It is written using GTK+.


FIVE EASY STEPS:
~~~~~~~~~~~~~~~~

1. Make sure you have the latest pidgin software. To upgrade your current GAIM application using Fedora yum, simply connect to the internet and issue

# yum -y upgrade gaim

2. Make sure you already have an existing GMail account. Launch Pidgin GAIM software. Add a new your GMail account by clicking Account menu from GAIM and selecting Add from one of the dropdown menu.

3. A new Add Account window would appear. Click Add button. Simply select Google Talk from one of the Protocol dropdown selections. Complete the other required fields like screen name and password as shown below. Remember to click the Save button.


4. Now, back to pidgin window, press Ctrl+A keys to view all your Pidgin current account settings. A new Account window will appear. From the list being shown from your screen, you should be able to see your newly added Google Chat Pidgin account that makes use of XMPP protocol.

5. To start using Google chat from Pidgin, simply check or tick the Enabled tick box from the leftmost part of your Google chat account and enter your password when prompted. From here, you can starting adding your GMail friends and contacts.

Enjoy!

For more pidgin info, visit here.

Friday, September 21, 2007

Linux command line shell variables defined

Reading daily doze of linux commands makes our memory to remember their command usage and command scopes. Doze of commands refreshes part of our linux brain to easily apply simple but useful linux commands when needed. Remembering those thousand of commands is not really an easy task specially most linux commands are not being used and applied on our daily linux work routines.

Here are a few doze of linux shell variables that might be helpful and useful to some bash shell scripting.

Usually, when creating shell scripts, we make use of user input variables or command line parameters that server as input arguments to shell commands or shell executable scripts. Using these variables provides us a way to determine shell program function execution and directly reference a submitted command line parameters.

Below are several linux bash variables that we can integrate when parsing user-input command line parameters.

$$

The above linux shell variable can be used to display and fetch current PID number of the current shell script.

How to know your current shell PID number from command line?

# echo $$
~~~~~~~~~~~~~~~
25341
~~~~~~~~~~~~~~~

Usage Application:
~~~~~~~~~~~~~~~~~~

On terminating and remembering the PID number of the current running shell program. A sample shell script usage of the above command would be

~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
echo Current PID: $$
~~~~~~~~~~~~~~~~~~~~~

Next linux shell variable

When terminating a function, a proper way to determine if a function script had terminated properly is to determine its script exit code or status. This can be done by using the below linux shell variable

$?

Usage Application:
~~~~~~~~~~~~~~~~~~

When doing function or disk/file operations, or even executing another shell script, we can make use of this linux shell variable as shown below, which prints the exit code status of test_function
after finishing some stuff operations shown below.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
function test_function {
# do some stuff
echo Function Exit Code $?
}
# call the function
test_function
~~~~~~~~~~~~~~~~~~~~~~~~~~~


Next linux variable

$0

This variable displays how the current shell program is being called. This could refer also the current path location where the program has been executed. We can also make use of this to test for any filename changes with the shell and/or any changes with the working folder of the file executable to verify if the current working folder or filename had been tampered or changed.

Usage Application:
~~~~~~~~~~~~~~~~~~

The below script checks if the script is being called from /tmp and the script name is test.sh

# cat /tmp/test.sh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
echo $0
if [ "$0" = "/tmp/test.sh" ]; then
echo "Good starting folder and still the same shell filename"
else
echo "Alert: Script Name and/or source folder changed!"
fi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Next linux command variable would be

$1
$2


The above linux shell variable refers to arguments or parameters being passed to current shell script:

Usage Application:
~~~~~~~~~~~~~~~~~~

# cat test.sh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
echo Parameter No. 1: $1
echo Parameter No. 2: $2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ./test.sh firstname secondname
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Parameter No. 1: firstname
Parameter No. 2: secondname
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The above variable applies also to Nth variable.


The next linux shell variable:

$*

The above refers to all parameters or arguments passed with the current shell script

Usage Application:
~~~~~~~~~~~~~~~~~~

# cat test.sh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
echo Parameters Passed: $*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ./test.sh Linux SysAd Blog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Parameters Passed: Linux SysAd Blog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Passing variables makes it easy for varying input arguments for a shell script. This approach flexes input entries for specific shell script. It can also be used to trigger shell functions and shell program directions as well.

Now, the below command refers to the total number of command line parameters or argument passed together with the shell script

$#

Usage Application:
~~~~~~~~~~~~~~~~~~

# cat test.sh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
echo Number of Parameters supplied: $#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ./test.sh I have only 5 parameters.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Number of Parameters supplied: 5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Another shell variable is

**

This shell variable when used displays all files and directory folders located from where the shell script was called.

Usage Application:
~~~~~~~~~~~~~~~~~~

# cat test.sh
~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
echo **
~~~~~~~~~~~~~~~~~~~~~~

Looks useless but serves its purpose when used well.

Here's a tip:

Pressing ESC+* from command line list down all available binaries from current PATH variable of current box which the current user can make use of.


Final Note:
~~~~~~~~~~~

These linux shell variable can be handy when creating varying input arguments with your shell scripts. Making use of these variables creates convenience on passing parameters to a shell script.

Redirecting shell program direction when using these variables would then be easier assuming a single shell script that does two (2) different functions. Simply pass a trigger word that would redirect the shell program to call for a particular shell function defined inside that script like so:

# ./test.sh trigger2

That does the linux shell task as expected.

Happy weekend!

ls - displaying directory contents in many ways

Here goes another tutorial that would uncover samples of using the most commonly used linux command using the command line terminal.

This linux blog entry covers the tutorial of using one of the simplest command line in linux terminal.

LS Tutorial - Display Files and Folders in Linux

ls is a linux command that is basically being used from command line terminal to list down directory contents. Directory contents can are linux files, it can be typical directory files, special files, directories, hard and soft links or any other device contents.

File items and directory folders are usually the contents of current working folder. Linux directory usually contains folder locations the probably contains zero or more files inside it, while linux files are files, hard or soft links to files or device that contains zero or more data contents when viewed or referenced from.

Here are more ls samples that might be helpful on learning this ls command.

How to list down all files and directory folders of current working directory.

# ls

How to list down all files and directories using ls a short format form


# ls -a


How to list down all files and directories using ls a short format form

# ls -la

Using the above two commands shows linux files and folders. In a long format, ls shows directory contents with their corresponding file attributes and file ownership and permissions, date/time stamps and filesize .

Most linux distro uses command aliases.

To print the current alias for ls, simply

# alias ls

Using the above command would show the current ls alias and ls parameters when issued directly from the command line. This goes to any other linux command aliases.

To continue with ls command, here's how to list down all directory contents excluding . and .. in a short ls form

# ls -A

Combining the previous two commands of using ls to show the long format form and all directory contents but without . and ..

# ls -Ala

To list down directory contents in a more human readable form showing sizes like 1K, 2M 3G file sizes

# ls -h
# ls -hal
# ls -halA


To list down directory contents without showing ownership and group names would be done respectively like so

# ls -aG
# ls -aGg


To list down directories and folders only in ls short form

# ls -d */

To list down directories and folders only in ls long form would be

# ls -dl */

To list down directories and folders start starts with d displayed in ls short form would be

# ls -d d*/

To list down directories and folders start starts with d displayed in ls long form would be

# ls -dl d*/

ls always shows directory contents in a colored ls alias fashion. To ignore and display directory contents without screen colors would be

# ls -la --color=never


To list down directory contents with reverse matching pattern and hide a specified patterns from being displayed would be

# ls --hide=v*
# ls --ignore=v*


The above list down all directory contents except the ones that starts with the letter v

To list down directory contents with numeric user and group IDs using ls would be

# ls -n

To list down directory contents with index number of each item would be

# ls -lai

To list down directory contents showing also the link reference rather than the link itself would be

# cd /dev
# ls -laL


To list down directory contents recursively would be

# ls -R

To list down directory contents sorted by modification time would be

# ls -t
# ls -lat


The default ls tab stop is 8, if you want to customize the ls tab stop, simply specify it like so

# ls --tabsize=16

To list down directory contents separated by comma in a short ls form would be

# ls -m

To reverse the sort ordering display of directory contents using ls would be

# ls -r
# ls -lar


HTH

Thursday, September 20, 2007

Control of alternative linux executables

Here are simple tips on controlling which executables would be executed by your linux box when issued from command line terminal.

There are several ways to specify and control which binary executable file or linux shell command would be executed by your system when issued from the terminal.


SCENARIO APPLICATION
~~~~~~~~~~~~~~~~~~~~

This blog entry assumes the possible scenarios relating to this linux blog entry:

a. you just resume to your new job with these linux boxes and you found out that some binaries were installed manually from tar ballz (tar.gz) and some were from rpm (rpm) binary package installer

b. the linux box uses both opensource binary package version and the package distributed by commercial company, like for Java binaries.

c. a previous sysad created an executable with an exact filename similar to linux built-in commands.

d. simply you want to know specify which binary executables you want to execute


Let us assume that we currently have two binary executable files named nagios, which are currently located from two different location ofcourse.

# which dir
/usr/bin/nagios
/usr/local/bin/nagios


Here are some alternative approach on how to specify which binary file location to go into when executing a linux binary or executable file.


First scenario approach
~~~~~~~~~~~~~~~~~~~~~~~~

Be in charge of your linux bash environment. This includes setting all the needed environment variables into your desired needs. Reordering of default PATH shell environment from current user account is also advisable .

# echo PATH

Considering the two binary nagios path locations

/usr/bin/nagios
/usr/local/bin/nagios

And assuming you want your system to look first for /usr/local/bin/, simply specify and change your system PATH environment variable and make sure /usr/local/bin comes first before /usr/bin before executing the duplicated binary executable like so

# export PATH=/usr/local/bin:/usr/bin
# nagios


Second scenario approach:
~~~~~~~~~~~~~~~~~~~~~~~~~

Make use of linux command name aliasing. Linux bash aliases can be instructed to remember a particular path location when executing a specific linux command. This also applicable to specify further binary arguments when calling a default binary executables.

# alias nagios='/usr/local/bin/nagios'
# nagios

To specify additional argument for a binary
# alias nagios='/usr/local/bin/nagios --whatever'
# nagios

To print all linux aliases and verify the above specifed binary path location alias

# alias
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias nagios='/usr/local/bin/nagios'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Third scenario approach
~~~~~~~~~~~~~~~~~~~~~~~~~

Alternatives man definition:
alternatives creates, removes, maintains and displays information about the symbolic links comprising the alternatives system. The alternatives system is a reimplementation of the Debian alternatives system. Alternatives was rewritten primarily to remove the dependence on perl; it is intended to be a drop in replacement for Debian’s update-dependencies script.

It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice of editor to invoke if the user has not specified a particular preference.

The alternatives system aims to solve this multiple executables issues by using symbolic links to specify default command location using linux command alternatives.


Now, to install and add both nagios alternatives to alternatives config choices, simply

# alternatives --config nagios
# alternatives --install /usr/local/bin/nagios nagios /usr/local/bin/nagios 1
# alternatives --install /usr/bin/nagios nagios /usr/local/bin/nagios 2

To view current nagios alternatives config
# alternatives --display nagios

To view and select which binary nagios binary for linux to execute when issued from CLI
# alternatives --config nagios

Alternatives prioritizes binary command execution using alternatives command as shown above.


Final Note:
~~~~~~~~~~~

As you can see, there are lot of alternative ways to approach an issue using linux tool sets. Linux is quite powerful specially on these scenario on customizing basic tool command sets up to custom made kernels, that is why OpenSource tools are quite powerful and would continue to be so.

HTH
Appreciate your visit here, thanks for the tip!

Searching using whereis linux command

Now, another simple linux command for locating binary, source and manual pages using whereis.

From recent linux 'which' blog entry, here is another way to find and locate the location and full path of a particular binary, man pages and sources of a given program argument. Whereis locates the binary from the standard linux binary locations.

Whereis man description says:
whereis locates source/binary and manuals sections for specified files. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext, for example, .c. Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in a list of standard Linux places.



Whereis Usage and Explanation:
~~~~~~~~~~~~~~

# whereis cat
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cat: /bin/cat /usr/share/man/man1p/cat.1p.gz /usr/share/man/man1/cat.1.gz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From the above result, Whereis shows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a. cat binary location is /bin
b. cat man and source pages are currently located in
/usr/share/man/man1p/c
/usr/share/man/man1/c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


More Whereis Usage and Examples:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To locate a binary or executables location only using whereis
# whereis -b cat
~~~~~~~~~~~~~~~~~~~~
cat: /bin/cat
~~~~~~~~~~~~~~~~~~~~

To locate and search from manual pages or section of a binary using whereis from terminal
# whereis -m cat
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cat: /usr/share/man/man1p/cat.1p.gz /usr/share/man/man1/cat.1.gz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To limit the place where whereis would search location from
# whereis -B /sbin -b cat

which shows no result since we know that binary cat is located from /bin folder location and not /sbin which was specified above.

Now, here's another whereis example application

# cd /tmp
# touch cat
# ch700 cat
# whereis -B /tmp -b cat
result:
~~~~~~~~~~~~~~~~~
cat: /tmp/cat
~~~~~~~~~~~~~~~~~

# whereis abc123
# whereis cat echo

# whereis whereis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HTH

Witchy which linux command

Here's a simple linux command the give you the full path of of linux binary or executable command.

Which definition:
~~~~~~~~~~~~~~~~~~

Which Linux command shows the full path of any binary or shell command when executed. Which does the full patch searching by looking from the linux environment PATH variable. Which command can take one or more argument for processing. This 'which' linux comamnd follows the command line format as shown below:

which command1 command2


To list out your PATH environment variable from command line

# echo $PATH

Alternatively, you can grep PATH variable from your current environment shell like so

# set | grep PATH


Which Usage
~~~~~~~~~~~

Let us assume that you have a command named fixit that was installed from tar ball (tar.gz) and from rpm package (rpm). On which, fixit was probably installed into /usr/bin and /usr/local/bin .

To execute the command, simply issue

# fixit

The problem with this command is you don't know which binary has been executed by the system.
One way of resolving this issue is using which linux command by doing so

# which fixit

which then tells you which binary would be executed if fixit was issued from ther terminal. Which linux command also tells your the full path location of the command argument.

Final Which Note:
~~~~~~~~~~~~~~~~~

Using which, you can then know where would be the binary path location is when a command or executable shell would be executed. Which linux command is installed in Fedora by default system tools installation.

More which command line examples:
~~~~~~~~~~~~~~~~~~~~

# cd /home/me
# chmod 700 fixme
# which ./fixme
~~~~~~~~~~~~~~
/home/me/fixme
~~~~~~~~~~~~~~

# which which
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
/usr/bin/which
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cd /tmp
# touch cat
# chmod 700 cat
# which ./cat
~~~~~~~~~~~~~~~~~~
/bin/cat
~~~~~~~~~~~~~~~~~~

# which echo dir
~~~~~~~~~~~~~~~~~~~~~~~~~~~
/bin/echo
/usr/bin/dir
~~~~~~~~~~~~~~~~~~~~~~~~~~~


HTH

Tuesday, September 18, 2007

NeroLinux - diehard Nero burning software

For die-hard Nero burning software fans, Nero burning software also comes in Linux.

Nero Linux is a flexible application, which supports all important features of Nero Burning ROM on Linux Systems.

From Nero site:
Nero Linux 3 is the definitive burning application for the Linux operating system. Based on the award-winning Nero Burning ROM 7 platform, Nero Linux 3 is the most powerful and versatile burning application available for Linux, and the only application to offer Blu-ray Disc and HD DVD data burning support.

Main Nero for Linux features:
* Enjoy the same functionalities as in Nero Burning ROM 7
* Burn data using any optical disc format, including CD, DVD, Blu-ray Disc, and HD DVD
* Ensure a quick and easy setup using SmartDetect automatic drive support
* Take control of your music collection with integrated audio capabilities including high speed digital audio extraction and FreeDB to automatically obtain disc information over the internet

Nero Linux is able to burn the following formats:
- Data CDs and DVDs (using ISO9660, UDF and UDF/ISO9660 Bridge)
- Data HD DVDs and Blu-Ray discs (UDF)
- Bootable CDs/DVDs using the El-Torito standard
- Audio CDs from various audio formats
- Mixed-Mode CDs and Enhanced CDs (CD EXTRA)
- Disc Images (ISO, NRG and Cue Sheets)
- DVD-Video and miniDVD
- Multisession discs


NeroLinux also uses the embedded API from the widely used Nero burning software for windows. Another good thing about Nero's burnign software is simple but thourough application guide that comes from the installer which is also available from the web. If you wish to know more of its documentation and application operation, you can visit them here.


NERO FOR LINUX INSTALLATION:
============================

If you wish to give NeroLinux a try, download the rpm package NeroLinux in full trial version from here.

After downloading the package, simply use the rpm binary installer to install the package like so:

# rpm -ivh nerolinux-3.0.1.3-x86.rpm


NEROLINUX APPLICATION LAUNCH
============================

# nero


NeroLinux works in Fedora, see my own screenshots:
The first two initial screenshots would be prompted after a fresh installation.


Now, here comes my selection of files of data burning.



Yes, it is a full Nero for Linux version that offers a full feature Nero burning software in 30 days trial mode!

HTH

All products, trademarks, and companies mentioned here are all managed by their own respective owners and/or companies.

Monday, September 17, 2007

Google Sky - Explore and Rediscover the Sky

Now, I have a chance to post a 3D rendering related linux blog entry here that explores more of the Stars and Sky using Google Earth.

Three weeks ago, Google launched the latest addition and highlight features with Google Earth. The feature addons is being called Google Sky and is part of Google Earth version 4.2.

Google Sky button is available from one of the top menu palen from Google Earth application. Google Sky is referreing name on visualizing stars and galaxy using Google Earth. Impressively, this Google Sky enables you to visit any stars and galaxies around the universe, as if they are near you and you were travelling faster than the speed of light!

Google Sky also allows you to select from several variety of constellations, stars, planets, moon, galaxies, astronomy, and more technical info of current view such as object distance, size, diameter, history and life of the galaxy object being viewed.

GOOGLE EARTH INSTALLATION
=========================

Download the latest Google Earth from here.http://earth.google.com/download-earth.html

For more Google Sky info and feature flash demo, visit the site from here http://earth.google.com/sky/skyedu.html

After downloading GoogleEarthLinux.bin, simply

# chmod 700 GoogleEarthLinux.bin
# ./GoogleEarthLinux.bin

GOOGLE EARTH BINARY LAUNCH:
===========================

# googleearth

More Google Sky Video/Audio Brief Demo:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

My own Google Sky screenshot using Google Earth:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




Watch a Fascinating Google Sky Video Demo from YouTube files:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you can run Google Earth from your desktop, you can also run Google Sky pretty well.

I am giving the latest version of Google Earth and Google Sky feature an additional 5/5 feature rating!

Well done Google guys!

All trademarks and products mentioned here are all managed by their own respective company and owners.

Celestia - 3D Earth and Sky visualization

Here's another linux application that that lets you explore the sky, planets, stars, galaxy and universe in three dimensions (3D), also an alternative for MS Visual Earth.

Celestia is a real-time space simulation which lets you experience the universe in three dimensions. Celestia does not confine you to the
surface of the Earth only, but Celestia allows you to travel throughout the entire solar system, to any of over 100,000 stars, or even beyond the galaxy.

The Celestia has several features, one of them is exponential zoom feature that lets you explore space and galaxies across a huge range of scales and from galaxy clusters down to spacecraft only a few meters across. A 'point-and-goto' interface makes it simple to navigate through the universe to the object you want to visit, all these are displayed seamlessly in 3D rendered graphical display from GNOME or KDE.

Celestia is expandable. Celestia comes with a large catalog of stars, galaxies, planets, moons, asteroids, comets, and spacecraft. If that's not enough, you can download dozens of easy to install add-ons with more objects.

I have successfully installed Celestia from my intel-based motherboard and video adapter. And I have to say the 3d graphics was rendered by Celestia in an impressive seamless way making use of my 3d-enabled intel based vga adapter.


CELESTIA INSTALLATION
=====================

Celestia can be installed from Windows, Linux, and Mac OS X. Celestia is available also from Fedora 7 repos. The Fedora installation is very simple, as always.

# yum -y install celestia

This would download and install an approximate 18MB of package file.


CELESTIA BINARY LAUNCH:
======================

# celestia


My Celestia screenshots:
~~~~~~~~~~~~~~~~~~~~~~~~






Celestia webshots:
~~~~~~~~~~~~~~~~~~



For more documentation, you can visit here and addons documentation from here. And for more download platform/distro download, visit them here.

Enjoy the skies.

Earth3D - real-time 3D Earth visualization

Here's a linux alternative to Microsoft Visual Earth.

Earth3D is a linux application for visualizing the earth in realtime 3D view. Earth3D displays the recent satellite images and map data into your display screen live via data streaming using data servers from NASA, USGS, the CIA and the city of Osnabrück. This Earth3D application is available from many OS platforms like Linux, MacOS X and Windows and is under the GPL license.

Earth3d Main Features:
~~~~~~~~~~~~~~~~~~~~~~

* viewing the earth globe as a whole
* zooming with selected countries like Germany for now
* embedding external data like current earthquake positions or cloud data


Hardware Requirements:
~~~~~~~~~~~~~~~~~~~~~
Earth3D application uses OpenGL and QT to view the earth globe map. Earth3D downloads the texture and heightfield data on demand over the internet. You need at least DSL speed (about 768kbit) to use it. Earth3D was was tested from Athlon 850Mhz with an Nvidia Geforce 2 MX and from my Intel-based motherboard with built-in Intel-based display adapter/controller.


EARTH3D INSTALLATION:
=====================

As of this writing, the only available rpm package of Earth3D for Fedora distro is designed for Fedora Core 2. To install Earth3D in Fedora 7 using this version, you can download the rpm package for Fedora Core 2 from here.

# wget -c "http://newrpms.sunsite.dk/apt/redhat/en/i386/fc2/RPMS.newrpms/earth3d-1.0.1-1.rhfc2.nr.i386.rpm"

I have installed the FC2 rpm package successfully into my Fedora 7 without any issues. You've been warned that the binary rpm package was designed for Fedora Core 2. To install it into Fedora 7, simply

# rpm -ivh earth3d-1.0.1-1.rhfc2.nr.i386.rpm


If you want to see more download package for other linux distros, check the link from here.


BINARY EXECUTION:
~~~~~~~~~~~~~~~~~
Ctrl+F2, earth3d


Here's a sample screenshot that I had after installing Earth3D.




For FAQS and further readings, see more from here.

HTH

All products and companies mentioned here are all trademarks and managed by their own respective owners and company.

Sunday, September 16, 2007

GcStar - managing personal collection items

Here's another graphical tool for managing your personal collections item in Linux.

GCStar is a nice item management and GNOME based graphical application linux tool. Current version of GcStar supports management of the following items:

a. numismatic,
b. books,
c. music,
d. videos games and
e. movies

GCStar supports many features for database manangement application such as item search and query, item addition and deletion, item and user history logs items, language and display options, borrowers and lending user data and more. Gcstar presents these data in a nice user-friendly environment even grandma can handle them easily.

GcStar provides more details related to but not limited to:

a. Collections management
b. Creation of user models
c. Filtering
d. Borrowings management
e. Conversions
g. Data and item management


GCStar man says:
GCstar is an application for managing your personal collections. Detailed information on each item can be automatically retrieved from the internet and you can store additional data, depending on the collection type. And also who you've lent your them to. You may also search and filter your collection by criteria.


GCSTAR INSTALLATION
===================

GCStar makes use of some Perl libraries. Yum is capable of installing these perl libraries as GCStar dependencies. Simply

# yum -y install gcstar


Installation location are categorized from the following folder locations:
1. /usr/bin - GCstar executables
2. /usr/lib/gcstar - GCStar libraries
3. /usr/share/gcstar - GStar docs and images


GCSTAR APPLICATION LAUNCHER
===========================

# gcstar


Initial Program Launch ScreenShot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Webshot:


Gcstar is a desktop item management and personal collection tool and management to keep.

Saturday, September 15, 2007

DStat - resource statistics linux tool

DStat is a versatile replacement for vmstat, iostat, netstat and ifstat. Dstat overcomes some of their limitations and adds some extra features, more counters and flexibility. Dstat is handy for monitoring systems during performance tuning tests, benchmarks or troubleshooting.

Dstat allows you to view all of your system resources instantly, you can eg. compare disk usage in combination with interrupts from your IDE controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).

Dstat gives you detailed selective information in columns and clearly indicates in what magnitude and unit the output is displayed. Less confusion, less mistakes.

DStat features lifted from site based from

* Combines vmstat, iostat, ifstat, netstat information and more
* Shows stats in exactly the same timeframe
* Enable/order counters as they make most sense during analysis/troubleshooting
* Modular design
* Written in python so easily extendable for the task at hand
* Easy to extend, add your own counters (please contribute those)
* Includes about 10 external plugins to show how easy it is to add counters
* Can summarize grouped block/network devices and give total numbers
* Can show interrupts per device
* Very accurate timeframes, no timeshifts when system is stressed
* Shows exact units and limits conversion mistakes
* Indicate different units with different colors
* Show intermediate results when delay > 1
* Allows to export CSV output, which can be imported in Gnumeric and Excel to make graphs


DSTAT INSTALLATIN:
==================

As with any other linux tool from Fedora, DStat can be easily installed using yum like so

# yum -y install dstat


DSTAT BINARY LAUNCH
===================

# dstat -t -fa


My DStat screenshot in action:


Additionally, since Dstat supports generating stats directed to an output file, this logically means that DStat can be more useful when combined and launched within crontab utility.

Launching Dstat from crontab job provides another way on setting a new task for gathering top N resource statistics dumped by DStats to a file. Thus, we can generate report and long term statistical data from it done on chosen regular monthly or weekly basis, which can then be feed to MRTG config file for further server resource data graph.

Using DStat when properly used, enhances our server I/O capacity, load and server resource planning to scrutinize and analyze which point of time, time of the day, day of the week, and/or day of the month usually our linux box becomes more and/or less busy in terms of this resource statistical values dumped by DStats from regular point of interval time via cronjob.

FINAL NOTE:
-----------

Linux monitoring tools comes in many variety shapes and features, they are all created for specific task, just waiting for us to make use of it.

HTH

Might be interested kicking black boxes, thanks Joe.

Bandwidth Monitor-NG - terminal-based interface bandwidth monitoring tool

Here's another simple terminal-based tool for monitoring network interface and disk I/O ;ove bandwidth. This tool is currently available from Fedora yum repos.

Bandwidth Monitor NG (BMW-NG) network interface monitoring tool supports displaying TX/RX statistics of your network interface via terminal.

Besides from using other web-based linux monitoring and graphing tool, this bandwidth monitoring tool can be handy on linux boxes serving as internet gateway or acting as network proxy server of your network. Using this bandwidth monitoring tool, real-time internet and network bandwidth (TX/RX) consumption and usage can easily be displayed from your terminal session.

If you have a remote server and you wish to monitor per second real-time TX/RX statistics of your network interfaces and internet bandwidth of your linux gateway/proxy server, this bmw-ng fits perfectly into this scenario.

This bandwidth monitoring tool is capable also of generating network bandwidth statistic and dumps them either to text or HTML page for your further reading and reference.

Bandwidth Monitor NG (BWM-NG) is a small and simple console-based live network and disk I/O bandwidth monitoring tool for Linux, BSD, Solaris, Mac OS X and others.

BMW-NG major features lifted from site. These features are based from BW-NG 0.6 version.

* supports /proc/net/dev, netstat, getifaddr, sysctl, kstat, /proc/diskstats
/proc/partitions, IOKit, devstat and libstatgrab
* unlimited number of interfaces/devices supported
* interfaces/devices are added or removed dynamically from list
* white-/blacklist of interfaces/devices
* output of KB/s, Kb/s, packets, errors, average, max and total sum
* output in curses, plain console, CSV or HTML
* configfile


Bandwidth Monitoring Tool (BWM-NG) INSTALLATION
==============================================

# yum -y install bwm-ng


Application Launch:

# bwm-ng

BMW-NG screenshot in action:

KNemo - KDE network interface monitoring tool

Here's a KDE-based netwok interface monitoring tool similar to the one found in Windows. For every network interface from your linux box, KNemo displays network interface as icons from your desktop system tray using QT graphical interface.

KNemo displays for every network interface an icon in the systray. Tooltips and an info dialog provide further information about the interface. Passive popups inform about interface changes. A traffic plotter is also integrated. Knemo polls the network interface status every second using the ifconfig, route and iwconfig tools.

Knemo features lifted from site:
Features of version 0.4.5 include:
* support for ethernet (including wireless) and ppp connections
* the icon shows incoming/outgoing traffic
* hiding of icon when the interface is not available
* hiding of icon when the interface does not exist (useful for interfaces that
are dynamically created and and removed)
* automatic detection of wireless extensions for ethernet interfaces
* left-clicking on an icon displays a status dialog with information about the
selected interface (2nd click hides dialog)
* middle-clicking on an icon displays a traffic plotter that was taken from
KSysGuard (2nd click hides dialog)
* configuration via context menu or control center module (Internet & Network/
Network Monitor)
* customizable tooltip for quick access to often needed information
* custom entries in the context menu. Useful to start/stop/restart interfaces
or to configure them using external tools.
* automatic detection of available interfaces (click on 'Default' in the
configuration dialog and KNemo will look under /proc/net/dev for interfaces)
* support for notifications via sound and passive popups
* KNemo counts the number of transfered bytes and does not depend on the output
of 'ifconfig' for the total number of transfered bytes. This way KNemo can
even display a hugh amount of traffic while 'ifconfig' has an overflow at 4GB.
* support for different iconsets for every interface
* support for daily, monthly and yearly statistics
* configurable update interval for interface informations
* support for different backends to gather information


KNEMO INSTALLATION
===================

Knemo network monitoring tool can be installed using yum as follows:

# yum -y instal knemo


KNEMO APPLICATION LAUNCHER:
===========================

KNemo has to be started using KDE Control Center/Internet & Network/Network Monitor.

See how KNemo is being launched using KDE Control Center shown below.



Here's a sample KNemo screenshot showing my current network interface statistics. Knemo allows total control of data and statistics that can be shown using Knemo via KDE Control Center. See sample network stats below:


All trademarks and commercial title mentioned here are property and managed by their own company.

EtherApe - graphical network activity monitoring tool

There are times we need to monitor and analyze ongoing network traffic that passes from our current network and display it graphically in real-time mode from our GNOME desktop.

Here's another network activity monitoring tool available from Linux that can display current network connectivity links, traffic broadcast and network activities displayed in graphical mode using varying feature of colors, circle shapes, graphical link width and sizes from source to target traffic hosts.

Etherape is GNOME bases network monitong linux application that uses colors, link sizes and width on displaying network activity from source host to target host within a network. Etherape was created and modeled after etherman, another network monitoring linux tool.

EtherApe is a graphical network monitor for Unix modeled after etherman. Featuring link layer, ip and TCP modes, it displays network activity graphically. Hosts and links change in size with traffic. Color coded protocols display.
It supports Ethernet, FDDI, Token Ring, ISDN, PPP and SLIP devices. It can filter traffic to be shown, and can read traffic from a file as well as live from the network.

At the present time, EtherApe has enough functionality to be useful, but it's far from complete. It's still beta software, and new features and bug fixes are being added all the time. Here is the list of features, current as of version 0.9.5, in no particular order:

* Network traffic is displayed graphically. The more "talkative" a node is, the bigger its representation.
* Node and link color shows the most used protocol.
* User may select what level of the protocol stack to concentrate on.
* You may either look at traffic within your network, end to end IP, or even port to port TCP.
* Data can be captured "off the wire" from a live network connection, or read from a tcpdump capture file.
* Live data can be read from ethernet, FDDI, PPP and SLIP interfaces.
* The following frame and packet types are currently supported: ETH_II, 802.2, 803.3, IP, IPv6, ARP, X25L3, REVARP, ATALK, AARP, IPX, VINES, TRAIN, LOOP, VLAN, ICMP, IGMP, GGP, IPIP, TCP, EGP, PUP, UDP, IDP, TP, IPV6, ROUTING, RSVP, GRE, ESP, AH, ICMPV6, EON, VINES, EIGRP, OSPF, ENCAP, PIM, IPCOMP, VRRP; and most TCP and UDP services, like TELNET, FTP, HTTP, POP3, NNTP, NETBIOS, IRC, DOMAIN, SNMP, etc.
* Data display can be refined using a network filter.
* Display averaging and node persistence times are fully configurable.
* Name resolution is done using standard libc functions, thus supporting DNS, hosts file, etc.
* Clicking on a node/link opens a detail dialog showing protocol breakdown and other traffic statistics.
* Protocol summary dialog shows global traffic statistics by protocol.
* Scrollkeeper-compatible manual.



ETHERAPE INSTALLATION:
=======================

Etherape is available from Fedora 7 yum repos. Etherape network activity monitoring tool can be installed using yum as follows

# yum -y install etherape


ETHERAPE PROGRAM LAUNCH:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Ctrl+F2, etherape


ETHERAPE WEB SCREENSHOT IN ACTION:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





FINAL NOTE:
~~~~~~~~~~~~

Monitoring network traffic and hosts gives us better opportunity to further study and analyze several network issues, that maybe unknown to us, such as most broadcasting host, most busiest network host, source and target hosts of current network congestion, network activities of current time of the day and more. These network usage data gathering can lead us to further isolation of solving network congestion and latency issues. Furthermore, keeping records of these network statistics leads us to a deeper strategical network capacity planning, faster host traffic source and target isolation that probably cause network congestion and internal latency issues. Better to have these network activity monitoring tool that can be handy when needed.

Friday, September 14, 2007

Beauty of Math using Linux

This evening, I received an email showing me several beauty of math numbers, that fascinated me.

This email of Beauty of Math Numbers is not really related to my linux blog. However, my attempt for tracing the DNA relation of this beauty of math numbers to linux family genes has been successful for the past few minutes and I would like to share it here.

A set of number patterns will be shown one at a time and I would try to achieve the same effect using simple bash scripting as we move along live.

I have to copy and paste from the email that I received.

Here goes the first contestant of the Beauty of Math in Linux.

1 x 8 + 1 = 9
12 x 8 + 2 = 98
123 x 8 + 3 = 987
1234 x 8 + 4 = 9876
12345 x 8 + 5 = 98765
123456 x 8 + 6 = 987654
1234567 x 8 + 7 = 9876543
12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321

See the pretty number patterns above?

Now here's goes my freshly made linux bash script to achieve the same mathematical computation and match display shown above:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=1
constant=8
array=(1 12 123 1234 12345 123456 1234567 12345678 123456789)
while [ $x -lt 10 ] ;
do
let product=${array[$x-1]}*$constant+$x
echo ${array[$x-1]} x $constant + $x = $product
let x=$x+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Screen Output:
1 x 8 + 1 = 9
12 x 8 + 2 = 98
123 x 8 + 3 = 987
1234 x 8 + 4 = 9876
12345 x 8 + 5 = 98765
123456 x 8 + 6 = 987654
1234567 x 8 + 7 = 9876543
12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Now, the second contestant for the Beauty of Math using Linux bash scripting.

1 x 9 + 2 = 11
12 x 9 + 3 = 111
123 x 9 + 4 = 1111
1234 x 9 + 5 = 11111
12345 x 9 + 6 = 111111
123456 x 9 + 7 = 1111111
1234567 x 9 + 8 = 11111111
12345678 x 9 + 9 = 111111111
123456789 x 9 +10= 1111111111

And here's my equivalent bash script for that

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=2
constant=9
array=(1 12 123 1234 12345 123456 1234567 12345678 123456789)
while [ $x -lt 11 ] ;
do
let product=${array[$x-2]}*$constant+$x
echo ${array[$x-2]} x $constant + $x = $product
let x=$x+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Output:
1 x 9 + 2 = 11
12 x 9 + 3 = 111
123 x 9 + 4 = 1111
1234 x 9 + 5 = 11111
12345 x 9 + 6 = 111111
123456 x 9 + 7 = 1111111
1234567 x 9 + 8 = 11111111
12345678 x 9 + 9 = 111111111
123456789 x 9 + 10 = 1111111111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, the third contestant from the Beauty of Math in Linux:

9 x 9 + 7 = 88
98 x 9 + 6 = 888
987 x 9 + 5 = 8888
9876 x 9 + 4 = 88888
98765 x 9 + 3 = 888888
987654 x 9 + 2 = 8888888
9876543 x 9 + 1 = 88888888
98765432 x 9 + 0 = 888888888

which has an equivalent bash script code shown below:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=7
y=0
constant=9
array=(9 98 987 9876 98765 987654 9876543 98765432)
while [ $y -lt 8 ] ;
do
let product=${array[$y]}*$constant+$x
echo ${array[$y]} x $constant + $x = $product
let x=$x-1;
let y=$y+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Equivalent screen output:
9 x 9 + 7 = 88
98 x 9 + 6 = 888
987 x 9 + 5 = 8888
9876 x 9 + 4 = 88888
98765 x 9 + 3 = 888888
987654 x 9 + 2 = 8888888
9876543 x 9 + 1 = 88888888
98765432 x 9 + 0 = 888888888
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Brilliant isn't it?

Now, take a look at this next math symmetry.

1 x 1 = 1
11 x 11 = 121
111 x 111 = 12321
1111 x 1111 = 1234321
11111 x 11111 = 123454321
111111 x 111111 = 12345654321
1111111 x 1111111 = 1234567654321
11111111 x 11111111 = 123456787654321
111111111 x 111111111= 12345678987654321

Here goes its equivalent bash script for the above patterns:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=0
array=(1 11 111 1111 11111 111111 1111111 11111111 111111111)
while [ $x -lt 9 ] ;
do
let product=${array[$x]}*${array[$x]}
echo ${array[$x]} x ${array[$x]} = $product
let x=$x+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
which has an equivalent terminal output:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 x 1 = 1
11 x 11 = 121
111 x 111 = 12321
1111 x 1111 = 1234321
11111 x 11111 = 123454321
111111 x 111111 = 12345654321
1111111 x 1111111 = 1234567654321
11111111 x 11111111 = 123456787654321
111111111 x 111111111 = 12345678987654321
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Numerical Final Note:
~~~~~~~~~~~~~~~~~~~~

Numbers are interesting human-made and human-readable values that makes us real busy these computing days.

Any ideas who won this Beauty of Match Linux contest?

PS
Oh, I wonder how my black coffee with brandy (scotch coffee) helps me interpret these numbers into its equivalent bash script somehow.

Hope you enjoy reading them, cheers!

print leading/trailing lines before/after a matching string

Usually all mail log files specially SendMail, Qmail and Postfix, generates multi-lines of mail log files into its default log file. That is, a message line is being dumped to a log file from the time of a client's connection up to client's disconnection, there are already several lines dumped to its default mail log file, say /var/log/maillog.

Now, say we want to print a few lines before and after a matching string is found, here's a quick way of accomplishing this task using grep.

Grep can display leading and trailing lines before a string match is found.

Here's a quick way to do it.

# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~
123
456
678
Linux SysAd Blog
abc
def
ghi
~~~~~~~~~~~~~~~~~~~~

Now, let us try to print leading lines before a match to 'linux' string is found using grep.

# grep -B 2 Linux testfile.txt
output:
~~~~~~~~~~~~~~~~~~~~
456
678
Linux SysAd Blog
~~~~~~~~~~~~~~~~~~~~

The above comamnd displays 2 leading lines before the matched string.

Alternatively, let us print 2 trailing lines after a match is found. This can be done like so

# grep -A 2 Linux testfile.txt
Output:
~~~~~~~~~~~~~~~~~~~~
Linux SysAd Blog
abc
def
~~~~~~~~~~~~~~~~~~~~


As you can see, a specified number of trailing lines before the search string 'Linux' .


MORE GREP APPLICATION
~~~~~~~~~~~~~~~~~~~~~~

You can also apply this to commented text file. In a large commented config files, usually putting a marker string is helpful on editing large files. The above commands can be handy if you wish to view those trailing and leading lines before that marker string.

# cat testfile.cfg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# ..

# Two thousand config and commented lines before the next line
#
# here goes my marker string
# CHECK1
#
# here goes the actual config line
value1 = 1
value2 = 2
#
# another thousand config lines.

#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Without using an editor, grep can easily display lines of value1 and value2 using CHECK1 as my string marker.

Final Note
~~~~~~~~~~

Grep saves time and effort on handling these type of grep searching.

HTH

Thanks for today's support!

Nagios Monitoring - install and generic setup howto

A lot of powerful monitoring tools are freely available from linux world. One of them is Nagios.

Nagios is a fairly complex linux monitoring tool that determines current status of target host or equipment. Two good things about Nagios is that Nagios supports web-enabled administration page and user view-only mode account. The other one is that Nagios' task can be expanded variably using extended plugins and addons for Nagios.

This blog entry covers how to install and configure Nagios binary package from a Fedora box and make it act as part of a monitoring utility server for polling device status.

Nagios web pages says:
Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do. It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well. The monitoring daemon runs intermittent checks on hosts and services you specify using external "plugins" which return status information to Nagios. When problems are encountered, the daemon can send notifications out to administrative contacts in a variety of different ways (email, instant message, SMS, etc.). Current status information, historical logs, and reports can all be accessed via a web browser.


Here's how to install Nagios and Nagios-Plugins using yum


NAGIOS INSTALLATION
===================

The default nagios installation can be done by doing like so

# yum -y install nagios


This linux blog entry would only cover Nagios setup and installation aimed to generate a long-term uptime/downtime graph status of host and device based on ICMP echo replies sent against the target host IP address.

If you wish to install more Nagios plugins and addons.

# yum -y install nagios-plugins nagios-plugins-all



Additional Nagios Plugins
==========================


There are more Nagios addons and plugins available for downloads using yum. To name a several Nagios plugins and addons:

a. nagios-plugins-pqsql
b. nagios-plugins-ntp
c. nagios-plugins-ping
d. nagios-plugins-dns
e. nagios-plugins-disk
f. nagios-plugins-udp
g. nagios-plugins-mrtg
h. nagios-plugins-dig
i. nagios-plugins-log
j. nagios-plugins-dhcp
k. nagios-plugins-sensors
l. nagios-plugins-http
m. nagios-plugins-ups
n. nagios-plugins-rpc
o. nagios-plugins-game
p. nagios-plugins-icmp
q. nagios-plugins-real
r. nagios-plugins-nt
s. nagios-plugins-swap
t. nagios-plugins-overcr
u. nagios-plugins-tcp
v. nagios-plugins-users
w. nagios-plugins-mysql
x. nagios-plugins-ldap
y. nagios-plugins-perl
z. nagios-plugins-ide_smart

and a lot more!


Nagios Default Folder Locations
================================

By default Nagios yum installation, Nagios stores the following file location into your harddisk

a. /etc/nagios/ - Nagios configuration folder locations
b. /var/log/nagios/ - Nagios log and messages folder locations
c. /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations
d. /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location
e. /usr/bin - Nagios binaries
f. /etc/httpd/conf.d/ - Nagios Apache folder files
g. /etc/logrotate.d/nagios/ - Nagios log rotation file


As a blog entry example, I am going to take a sample of creating uptime/downtime graph say one of my remote broadband router with an IP address of 123.123.123.123 located remotely.

To create a Nagios configuration for this device and IP address, follow these simple steps.

# cd /etc/nagios/
do your backup kungfu

# cp nagios.cfg-sample nagios.cfg
# cp localhost.cfg-sample localhost.cfg
# cp cgi-cfg-sample cgi-cfg.cfg
# cp commands.cfg-sample commands.cfg



With old version of Nagios, Nagios configuration files are being stored separately. This separate config files refers to nagios functions, nagios services, nagios target host and nagios users. The recent Nagios rpm package version makes it more easy to configure Nagios configuration file.

A simple generic template can now be edited in less than three files assuming a basic Nagios setup with default Nagios feature values on RedHat-based distro like Fedora.

Sample Nagios Generic Template
==============================

Here's a generic basic template for that.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define host{
name DEVICE-NAME
use generic-host
check_period 24x7
max_check_attempts 10
check_command check-host-alive
notification_period workhours
notification_interval 120
notification_options d,u,r
contact_groups admins
register 0
}

define host{
use DEVICE-NAME
host_name DEVICE-NAME
alias DEVICE-NAME
address REMOTE-DEVICE-IP-ADDRESS
}

define service{
use local-service
host_name DEVICE-NAME
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can edit DEVICE-NAME to refer to group name of selected set of host with similar function. Say your FQDN name for a router is Gateway1.google.com , you can replace DEVICE-NAME and change it to Gateway1. Following the pattern, REMOTE-DEVICE-IP-ADDRESS can be replaced by a reachable host or device IP address.

More legends are shown below:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a. DEVICE-NAME - reference name for the target device or equipment that would appear from graph
b. REMOTE-DEVICE-IP-ADDRESS - the IP address of remote device or host being monitored
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This generic template should be inserted or appended into your /etc/nagios/localhost.cfg file.

As an example reference, I am assuming a default Nagios time period interval given from default config of its /etc/localhost.cfg in Nagios polling interval time. You may alter this time interval pattern that may fit your own GMT. If you decided to change the Nagios polling interval, this would affect how the device would be drawn to graph as well.

See a basic sample of Nagios polling interval below. The timeperiod is tagged as nonworkhours as shown:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define timeperiod{
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Now, proceed on creating a host group for that particular router.

Say for example, if you have 10 Ciscos router and 10 Non-Ciscos router, you can reference them with a single group name of Network-A


-Routers or Routers alone.

From /etc/nagios/localhost, find the line that says:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define hostgroup{
hostgroup_name DEVICE-NAME-GROUP-ALIAS
alias DEVICE-NAME-GROUP
members DEVICE-NAME
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and edit the BOLD characters shown above.

For reference:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEVICE-NAME-GROUP-ALIAS - Refers to the group alias
DEVICE-NAME-GROUP - Refers to group name. If you have say 10 routers, you can refer them
by this categorical group name. There are features in Nagios that
shows host or device sorted and shown in group name or alias
DEVICE-NAME - Refers to device or target host identity name in Nagios
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


NAGIOS CONFIG VERIFICATION
==========================


For sanity checking, make sure you verify Nagios config files. This can be done like so

# nagios -v /etc/nagios/nagios.cfg

The above command would show you for any erroneous lines frin Nagios config file.

NAGIOS LINUX SERVICE
==========================

Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.

Reload your apache service together with your Nagios service like so

# service httpd restart
# service Nagios stop
# service Nagios start
# service Nagios status


Nagios Further Configuration
============================


If you wish to customize more of the basic config shown above, continue editing /etc/nagios/localhost. Find these lines

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands notify-by-email
email YOUR-EMAIL-ADDR
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Legend:
YOUR-EMAIL-ADDR refers to admin's email address if you wish to receive email alerts.

If you wish to change more of Nagios default configuration setup files, this can be done by editing /etc/nagios/nagios.cfg file.

Besides from an extensible feature of Nagios having more plugins and addons, Nagios can also be configured to produce audio, SMS and email alerts for proactive response from admins.

Additionally, Nagios config files comes with helpful tips and comments inserted before the actual Nagios config lines. This is highly noticeable from nagios.cfg and localhost.cfg Nagios files as well.

Remember to verify all your Nagios config files before restarting the Nagios service.

And finally, point your browser to Nagios page. By default, it should be located from your apache root folder, say /var/www/html/nagios, the interface would be http://yourdoma.com/nagios/

Congratulations for browsing your Nagios page!


NAGIOS ADDITIONAL SECURITY
==========================

For additional package security, username and password authentication mechanism is highly supported by Apache config files. This mechanism also includes IP address access list. Being paranoid admin and enabling HTTPS would also enhance Nagios restrictions with Apache.

Launching Nagios daemon as normal nagios user is advisable as well. This can be changed from nagios.cfg file.

Unfortunately, further security with apache would not be covered here.


See my nagios screenshots in action:





Hope this helps and have a nice weekend!

ChRT- change real-time attribute process scheduling

With regards to linux blog entry posted last month about process scheduling prioritization, here's another way to schedule and modify real-time attributes of linux commands when launched or currently active application PIDs using linux command chrt.

In linux, all process runs with their own respective scheduling priorities and process attributes on every CPU cycle that simply affects how linux kernel sets CPU resources and process priorities to a particular PIDS. There are three categories of linux scheduling policies namely:

a. SCHED_OTHER - this is the default linux scheduling policy
b. SCHED_FIFO - stands for FIFO, first in first out policy scheme
c. SCHED_RR, or SCHED_BATCH - stand for linux round-robin schedule policy

This linux blog entry covers an alternative approach,besides from using nice and renice, on priority scheduling of linux process and threads. Process scheduling and application prioritization is a must to know specially on thousand server farms and/or enteprise world of linux computing.

Chrt man says:
Chrt sets or retrieves the real-time scheduling attributes of an existing PID or runs COMMAND with the given attributes. Both policy (one of SCHED_OTHER, SCHED_FIFO, SCHED_RR, or SCHED_BATCH) and priority can be set and retrieved.


Chrt linux command is installed by default installation. This process attribute linux tools is part of util-linux package. The util-linux package contains a large variety of low-level linux binaries that makes a Linux system to function steadily. Among others, util-linux contains the fdisk disk configuration tool and the user account and login programs.

How to install chrt and util-linux binary package?

INSTALLATION
============

# yum -y install util-linux


MORE CHRT USAGE
===============

Let's take for example, the PID of kswapd process

# ps axuw | grep kswapd0 | grep -v kswapd
returns
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
root 153 0.0 0.0 0 0 ? S< Sep10 0:01 [kswapd0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are minimim and maximum priority value of these linux scheduling policies as shown below:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SCHED_OTHER min/max priority : 0/0
SCHED_FIFO min/max priority : 1/99
SCHED_RR min/max priority : 1/99
SCHED_BATCH min/max priority : 0/0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let's make it work.

CHRT APPLICATION
-----------------

The process ID of kswapd swap daemon is 153 from the above case, to determine the scheduling policy for the currently running PID

# chrt -p 153
returns
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pid 153's current scheduling policy: SCHED_OTHER
pid 153's current scheduling priority: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let us apply changing the priority attributes of Squid PID 5555 for example.

# chrt -p 5555
returns
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pid 5555's current scheduling policy: SCHED_OTHER
pid 5555's current scheduling priority: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Changing scheduling attribute of PID 5555 to 5 using chrt would be

# chrt -p 5 5555


CHRT VERIFICATION USAGE
-----------------------

# chrt -p 5555
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pid 5555's current scheduling policy: SCHED_OTHER
pid 5555's current scheduling priority: 5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


As mentioned above, chrt uses other linux scheduling policies. In order to use and change the other schedule process attributes' value, simply follow as shown below

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a. SCHED_OTHER
# chrt -p 5 5555

b. SCHED_FIFO
# chrt -p -f 5 5555

c. SCHED_RR, or SCHED_BATCH
# chrt -p -r 5 5555
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Make sure you verify the schedule priority attribute using chrt PID chrt verification method.

FINAL NOTE
-----------

At times, we would have an enteprise process being exectuted on non-busy hour of the day that consumes most of server resources, implementing linux priority scheduling and contolling application policy attributes would do the trick.


XCESS:
Well, am not inactive, just trying to do harder from my work around here.

Wednesday, September 12, 2007

squeezed out multiple commented lines

Whooah, that is so fast.

Here's an email request to cover a simple and quick way on squeezing out multiple commented lines from config file as per email request. This is applicable to hundred lines of config file with a bunch of commented config lines.

# cat testfile.cfg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is not a comment
# this is a comment
## still a comment
#
This is another uncommented line
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# grep -v '#' testfile.cfg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is not a comment
This is another uncommented line
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HTH

UNIX to DOS text file format converter

Twelve years ago, I was creating a simple C++ program, as part of a job request, to convert a unix text file into a DOS text file format readable by some banks' data processing department.

Yes, here's an obsolete blog entry, but still would post it here before this linux binary command that does the same job would be phased out sooner or later.

This is a quick linux blog entry convering unix to dos file converter.

UNIX2DOS INSTALLATION
=====================

My current box has it, but if you wish to install unix2dos file converter, you can do so

# yum -y unix2dos

UNIX2DOS USAGE
==============

# unix2dos input.txt output.txt

Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode.

# unix2dos a.txt -c iso b.txt

# unix2dos -c ascii a.txt -c iso

Convert and replace a.txt while keeping original date stamp.

# unix2dos -k a.txt

# unix2dos -k -o a.txt

Convert a.txt and write to e.txt.

# unix2dos -n a.txt e.txt

Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt.

# unix2dos -k -n a.txt e.txt

Convert and replace a.txt. Convert b.txt and write to e.txt.

# unix2dos a.txt -n b.txt e.txt
# unix2dos -o a.txt -n b.txt e.txt

Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt.

# unix2dos -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt

Done.

totally squeezed out multiple blank lines

Well, just popped out from my mind based from privious linux blog entry.

Have you ever tried editing a thousand lines of configuration file and 70% of the lines were commented? Yes, you can filter out the commented lines using grep, but what about totally removing multiple blank lines between each config line?

Here's a quick way on how to remove all blank lines from a file using strings linux command.

A sample readable text file.

# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a long line of words that is useless for now.This file is an example of human readable text file.






I am going to paste this file into my Linux SysAd blog! This is a long line of words that is useless for now.This file is an example of human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To squeezed out and remove multiple or all blank lines from the text file using string linux command would be like so

# strings testfile.txt
EDITED:
# strings -n 1 testfile.txt

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.This file is an example of human readable text file.
I am going to paste this file into my Linux SysAd blog! This is a long line of words that is useless for now.This file is an example of human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

EDITED:
# strings -n 1 testfile.txt


HTH

squeezed multiple blank lines into single line

Here's a way to squeeze multiple blank lines of a text file into a single line using more.

# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.This file is an example of human readable text file.






I am going to paste this file into my Linux SysAd blog! This is a long line of words that is useless for now.This file is an example of human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To squeezed those multiple blank lines using more from command line would be

# more -s testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.This file is an example of human readable text file.

I am going to paste this file into my Linux SysAd blog! This is a long line of words that is useless for now.This file is an example of human readable tex
t file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

fmt - simple optimal text formatter

Here's a quick and simple command line drive text formatter using fmt.

Fmt binary file is part of fedora core utility package from GNU. Fmt reformats a a human readable file based on columnar value specified as argument. Fmt also supports splitting of long line, identation of first line, readjustment of file column width.

INSTALLATION
============

Core utils is installed by default fresh installation. However, if you had done a system cleanup, the package might have been uninstalled. Fmt can be installed to Fedora by installing core utils binary package using yum like so

# yum -y install coreutils


FMT USAGE
=========

# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.
This file is an example of human readable text file.
I am going to paste this file into my Linux SysAd blog!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Uniform spacing is also supported by fmt linux command. Uniform spacing is one space between words and 2 spaces after sentences.

# fmt -u testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now. This file is an
example of human readable text file. I am going to paste this file into
my Linux SysAd blog!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To change and adjust a standard column width or columnar line width to 5 would be like so

# fmt -w 5 testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a
long line of
words that
is useless
for now.
This file is
an example of
human readable
text file.
I am going
to paste this
file into my
Linux SysAd
blog!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, let's modify our text file to give way for more sample fmt usage
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.This file is an example of human readable text file.

I am going to paste this file into my Linux SysAd blog! This is a long line of words that is useless for now.This file is an example of human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using a crown-margin argument with fmt would be

# fmt -c testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.This file is an
example of human readable text file.

I am going to paste this file into my Linux SysAd blog! This is a
long line of words that is useless for now.This file is an example
of human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using a tagged paragraph with fmt would be
# fmt -t testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.This file is an
example of human readable text file.

I am going to paste this file into my Linux SysAd blog! This is a
long line of words that is useless for now.This file is an example of
human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Altenatively, using standard input would be like

# cat testfile.txt | fmt -u -
# fmt -u - < testfile.txt

For more fmt info, man fmt

HTH

Linux backup powered by RDiff-Backup

I have been covering linux back tools with my recent linux blog entries. Here's another alternative on doing linux backups using rdiff-backup.

Rdiff-backup is similar to rsync linux command. Rdiff-backup uses librsync algorithm library file which is also used by rsync linux command,, but rdiff-backup never uses rsync to do its backup functions. Rdiff-backup is also similar to rsnapshots as rdiff-backup creates a backup copy, an actul mirror/clone of the data being back up to a separate remote location, the difference is rdiff-backup creates a statistical file, sessions, and meta data to identify changed data for further incremetal backup operation. Rdiff-backup makes use of ssh connection during the data transfer between source and destination backup host.

Rdiff-backup backup utility also do incremental backup effectively and supports web-based backup administration using a different rdiff web interface to restore and pull backup data and files from remote host. This nice backup tool is available from Fedora repo, which can be installed using yum like any other open source linux backup tools.

Rdiff-backup man says:
rdiff-backup is a script, written in python(1) that backs up one directory to another. The target directory ends up a copy (mirror) of the source directory, but extra reverse diffs are stored in a special subdirectory of that target directory, so you can still recover files lost some time ago. The idea is to combine the best features of a mirror and an incremental backup.

rdiff-backup also preserves symlinks, special files, hardlinks, permissions, uid/gid ownership, and modification times.

rdiff-backup can also operate in a bandwidth efficient manner over a pipe, like rsync. Thus you can use ssh and rdiff-backup to securely back a hard drive up to a remote location, and only the differences will be transmitted. Using the default settings, rdiff-backup requires that the remote system accept ssh connections, and that rdiff-backup is installed in the user’s PATH on the remote system.

This linux blog entry covers another alternative on doing data backup using rdiff-backup with linux-based server environment.


RDIFF-BACKUP INSTALLATION
=========================

Installation is done on typical mode using yum like so

# yum -y install rdiff-backup


RDIFF SAMPLE USAGE
==================

Rdiff-backup can create a local mirror copy of source folder. Destination can be a mounted device, partition, external USB device, or even a separate harddisk. Destination can also be a remote host or a separate server location.

Below is how to create a data backup locally to a storage device.

To recursively backup data from a folder using rdiff-backup would be

# rdiff-backup source destination
# rdiff-backup /home /dev/sd01
# rdiff-backup /home /home2
# rdiff-backup /home/user1 /mnt/newharddisk
# rdiff-backup /home /mnt/mounted/partition

Make sure the destination device is writeable and accessible by local host. Rdiff-backup session data and statistics are being stored under rdiff-backup-data folder from the mirror copy.

To force a backup mode using rdiff-backup even the destination appeats to have a mirror copy already

# rdiff-backup -b /home /backup/folder

If you wish to exclude files and folders from being processed by rdiff-backup, this can be done like so

To exclude list of files in batch mode using rdiff-backup
# cat exclude.txt
~~~~~~~~~~~~~~~~~~~~~
/home/abc.txt
/home/folder1/hey.mp3
/home/user1/big-ISO.iso
~~~~~~~~~~~~~~~~~~~~~

# rdiff-backup --exclude-filelist exclude.txt /home /backup/folder

To exlude multiple files or shell patterns as input parameters for rdiff-backup can be done like so
# rdiff-backup --exclude "/home/user/*.mp3" /home/user/ /backup/destination

Alternatively, using stdin as input source can also be done to exclude files using rdiff-backup like so
# echo "/home/user/*.ISO" | rdiff-backup --exclude-filelist-stdin /home/ /mnt/backup/partition

A file glob exlustion is also supported directly from stdin to exclude files using rdiff-backup like so
# echo "/home/user1/*.mp3" | rdiff-backup --exclude-globbing-filelist-stdin /home/ /mnt/destination/disk

If you wish to exlude sockets files, special files, device files, and symbolic links from being included with the backup process, this can be done using rdiff-backup like so

# rdiff-backup --exclude-special-files --exclude-sockets --exclude-device-files --exclude-symbolic-links / /mnt/sata/harddisk

If you with to exclude other filesystem using rdiff-backup, that would be like so

# rdiff-backup --exclude-other-filesystems /home/apps /home /mnt/backup/destination

If you wish to exclude hard links from being processed into rdiff backup, this can be specified like so

# rdiff-backup --no-hard-links /home/ /mnt/destination/device

The exclude rdiff-backup parameter can also be applied to all inclusion parameters. Rdiff-backup supports file list inclusions from batch file or stdin as input source as shown with the below samples

# rdiff-backup --include-filelist exclude.txt /home /backup/folder

To backup multiple folders using rdiff-backup would be simple like so

# rdiff-backup --include /usr/local /home /data /config /backup-destination

To include multiple files or shell patterns as input parameters for rdiff-backup can be done like so
# rdiff-backup --include "/home/user/*.mp3" /home/user/ /backup/destination

Another usage for multiple shell patters would be

# rdiff-backup --include ignorecase:'/home/[a-z]/*/*.txt' /home /backup/points

Alternatively, using stdin as input source can also be done to include files using rdiff-backup like so
# echo "/home/user/*.ISO" | rdiff-backup --include-filelist-stdin /home/ /mnt/backup/partition

A file glob inclustion is also supported directly from stdin using rdiff-backup like so
# echo "/home/user1/*.mp3" | rdiff-backup --include-globbing-filelist-stdin /home/ /mnt/destination/disk

If you wish to include special files, and symbolic links to the backup process, this can be done using rdiff-backup like so

# rdiff-backup --include-special-files --include-symbolic-links / /mnt/sata/harddisk


For a more verbose listing of backup process using rdiff-backup, you can specify more arguments like so

# rdiff-backup --print-statistics /home /backup/folder

which gives you detailed data that has been changed from source files like so
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------[ Session statistics ]--------------
StartTime 1189595421.00 (Wed Sep 12 12:10:21 2007)
EndTime 1189595421.88 (Wed Sep 12 12:10:21 2007)
ElapsedTime 0.88 (0.88 seconds)
SourceFiles 8
SourceFileSize 11602 (11.3 KB)
MirrorFiles 8
MirrorFileSize 11602 (11.3 KB)
NewFiles 0
NewFileSize 0 (0 bytes)
DeletedFiles 0
DeletedFileSize 0 (0 bytes)
ChangedFiles 0
ChangedSourceSize 0 (0 bytes)
ChangedMirrorSize 0 (0 bytes)
IncrementFiles 0
IncrementFileSize 0 (0 bytes)
TotalDestinationSizeChange 0 (0 bytes)
Errors 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you are backing very large data and you wish to avoid file statistics to be written with rdiff-backup data folder and you wish to run rdiff-backup slightly faster with lesser disk space, you can optionally specify --no-file-statistics as an argument.


RDIFF-BACKUP DATA RESTORE
=========================

Since the samples above covers the usual parameters


with rdiff-backup, here are several ways to restore rdiff-backup data.

Let us assume that you did rdiff-back up of /home to /backup/home 7 days ago and you wish to restore the files 7 days ago to a differnt destination folder like /home7daysago , this can be done like so

# rdiff-backup -r 7D /backup/home /home7daysago

Altenatively, you can go to /backup/home/rdiff-backup-data/increments/home..dir /home7daysago like so

# rdiff-backup /backup/home/rdiff-backup-data/increments/home..dir /home7daysago

-r rdiff-backup parameter can also take time strings like

a. now
b. epoch time in seconds like "123456890"
c. date and time stamp format like "2007-09-12T01:00:00+01:00
d. a number followed by m,h,D,W,M,Y for minutes, hours, days, weeks, months and years respectively.
6h55m means 6 hour and 55 minutes ago, 1h2m3D would mean 3 days, 1 hour and 2 minutes ago .
e. a date format like YYYY/MM/DD, or YYYY-MM-DD or MM/DD/YYYY or MM/DD/YYYY can also be specified to rdiff-backup


DATA RESTORATION WITH RDIFF-WEB WEB INTERFACE
=============================================

Here's a nifty web interface that provides smooth data restoration done via rdiff-backup binary.
Rdiff-web supports web-based interface with RSS feeders for data restoration of rdiff-backup file.

rdiffWeb is a web interface for browsing and restoring from rdiff-backup repositories. It is written in Python and is distributed under the GPL license.

To see more rdiff-web screenshots in action, click here.

For more download info and documentation, click here.

USING SSH
=========

Optionally, when backing up to remote location or servers, it is adviseable to do the backup using compressed, or encrypted or tunnelled connection via any other means like SSH.

Trasferring backup rdiff-backup files from source host to destination host requires user account and/or access from both end. When doing this, you can follow a data pull model or dump model combined via SSH security and connectivity features.

This is also supported by rdiff-backup feature which can be done like so:

# rdiff-backup /home/ backupuser@123.123.123.123::/home/backup/

Transfer a rdiff-backup file /home to remote host /home/backup/ with an IP address of 123.123.123.123. Data transfer was done using authorized backupuser account details.

Any ssh access list and account restrictions would not be covered here unfortunately.

DATA BACKUP LISTINGS
====================

To see which rdiff-backup backup increments that are available for data restoration for multiple file restoration from multiple increments

# rdiff-backup -l /mnt/backup/destination


BACKUP DATA WITH RDIFF-BACKUP AUTOMATICALLY USING CRON
=======================================================

Further linux scheduling has been covered here using crontab and at linux utility.

Crontab and at linux utility has been very useful assistance on most users managing linux boxes as they are working server robots that does the your job very well when configured properly.



FINAL NOTE:
===========

Do backup regularly as it removes the chance of losing vital data and important company files as discussed earlier with the first linux backup entry taken here. Backup destination, strategic approach, source file(s), storage capacity. scheduled backup interval and expected time varies from system to system, company to company and from ground to ground.

Bottomline, make sure you have incremental backups of the past for proper filing and reference.

Joe, take a look at the black box around.

Cheers



Related Posts:

Linux Backup using RSnapShot
Linux Backup using Tar
Bandwidth-Effificent and Encrypted Linux Backup

Tuesday, September 11, 2007

Linux Ping command explained

We have always been using ping command ever since the network begun. Ping has been in the service for gazillions of echo requests and replies locally and/or from the web. Almost everybody doing link connectivity test between two points is familiar with ping command. Ping command is available in many worlds of operating system and IP address domain. You can easily find them installed by default OS installation. Not only sysads, even newbies and non-techies who's currently beginning to enter the world of connectivity troubleshooting never crawl google index to search for more ping explanation.

Ping command as compared to a new kid's world is like a new bike, just hit the pedal with your feet and your bike will move forward then. Ping results is more likely provides the same concept of the bike. The ping command result, host reachable or not reachable is what matter most.

As ping command is so easy and widely used, even grandma can manage to ping grandpa from the other room, this entry is here to explain and document more of ping arguments and usage details, which might be helpful to others hopefully.

PING definition
~~~~~~~~~~~~~~~~~
Wikipedia says:

ping is a computer network tool used to test whether a particular host is reachable across an IP network. It works by sending ICMP “echo request” packets to the target host and listening for ICMP “echo response” replies. ping estimates the round-trip time, generally in milliseconds, and records any packet loss, and prints a statistical summary when finished.

The word ping is also frequently used as a verb or noun, where it can refer directly to the round-trip time, the act of running a ping program or measuring the round-trip time.



PING USAGE
~~~~~~~~~~~

The simplest way to use ping from any operating system is to supply it with an IP address without further consideration to DNS issue and current IP address of working host, like so:

# ping 192.168.0.1

This is the usual way to ping an IPv4 based host. The above assumes that 192.168.0.1 is the host we wish to get ICMP ECHO RESPONSE reply from.

To send a specified or limited number of ECHO REQUEST packets, simply use -c argument like so

# ping -c2 192.168.0.1

-c followed by 2 is the number of ICMP ECHO REQUEST we wish to send forth against the target host . The above command sends out 2 ICMP ECHO REQUEST to target host.

To ping a broadcast address using ping on a subnetted IP network or network class, simply

# ping -b 192.168.0.31

The above command assumes a broadcast IP address of 192.168.0.31 for /27 subnet class.

To send ping with interval mode between each ping, this can be done like so

# ping -i 3 192.168.0.1

which sends out a single echo request every 3 seconds against the target host. This is also handy as some target host are too sensitive and have too high ping thresholds against echo request that immediately triggers ping flood attack, which might cause blockage to your current host.

A ping source address can also be specified with ping. This is where ping echo request would be released from ifever your current host has several virtual IP address or multiple network card interface.

# ping -I eth0:0 192.168.0.1
# ping -I eth1 192.168.1.1

To use ping flood would be

# ping -f localhost

which display . for every ping echo request sent and prints a backspace for every ICMP reply received

To send out ping packets while displaying host route path found along the round trip travel of ping packets would be like so

# ping -R 192.168.0.1

This could be visually handy with those hidden routers, firewalls, or gateways that has transparent port forwarding enabled and being supported.

To customize and change the default IP time to live or TTL values with ping would be like

# ping -t 1 192.168.0.1

Ping sends out ping echo request packet size of 64 ICMP bytes including data headers. To send out a customized ping packet size

# ping -s 24 192.168.0.1

changes ping echo request packet size from 56 down to 24, excluding the ICMP data header.

To specify in seconds a forced termination of ping commands would be

# ping -w 5 192.168.0.1

which forcefully but gracefully terminates the issue ping command after 5 seconds.

To ping an IPv6 IP address would be as follows

# ping6 -I eth0 fe80::203:47ff:fe31:5569
# ping6 -c 3 -I eth1 fe80::203:47ff:fe31:556a

Ping arguments can be combined when needed so.

A sample ping command would be

# ping 192.168.60.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64 bytes from 192.168.60.1: icmp_seq=1 ttl=255 time=4.19 ms
64 bytes from 192.168.60.1: icmp_seq=2 ttl=255 time=1.05 ms
64 bytes from 192.168.60.1: icmp_seq=3 ttl=255 time=1.02 ms
--- 192.168.60.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 1.025/2.092/4.197/1.488 ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Legend:
Notes: that icmp_seq displays the number of ping echo request being sent which appears in consecutive number patterns for normal ping echo replies.

From above results, 3 ICMP echo request packets have been transmitted, and 3 ICMP echo replies have been received with default 255 TTL. A round trip icmp echo reply average of 2.092 ms for the whole ping round trip transmitted and received, that is 0% packet loss in total stats.

Multiple host pinging using ping is not possible via command line unless you create a script to feed in IP address from it. However, there are alternatives to ping multiple host, one of them is using the linux command fping.

For a more verbosed mode would be the usual verbose mode parameter -v and for more a quite mode would be -q, the usual parameter with most handy linux tools.

By default, ping is installed as world executable and and readable binary.

FINAL NOTE:
~~~~~~~~~~~

Remember that issuing ping command can not guarantee anybody a reachable host connectivity between two or more hosts. Any failed ICMP reply does not mean a dead target host as well. Ping does not consider target host's setup, firewalls, and routers in between the travel path. Ping ignorantly assumes that the target host and the path is open for ICMP echo replies from requesting ICMP echo request host.

So happy pinging!

Monday, September 10, 2007

read and display text file from terminal

A simple request to read and display text file from terminal as always been used from this linux blog site.

Here are a few approach to achieve that:

# cat testfile.txt
# more testfile.txt
# less testfile.txt


HTH

Related Post:

Learn Bash Scripting Guide

URLView - URL and email extractor

Although we can make use of combining linux commands like cut, awk and grep to parse URL and email address string from a file, here's an entry to parse URL link and email address from a file. A lot of this email and URL extractor program is available in windows world, most of them are commercial and not free.

Spider crawling of URLs and email address from a page or text file in linux can be done using URLview. URLView linux command comes as part of mutt linux package, which handles email operations from command line.

urlview is a screen oriented program for extracting URLs from text files and displaying a menu from which you may launch a command to view a specific item.


URLView extracts URLs string and email address link from a file interactively presented in a grid type and numbered view. Selecting one from the list, launches your browser to browse the particular selected site from URLView.

URLView USAGE:
--------------

Here's a few usage of using URL and email extractor as shown below

# urlview pagefile.txt
# urlview pagefile.html

Besides from extracting URL strings from file or web page, again linux I/O redirection creates an additional way to use the command. URLview provides a way to fetch and extract URL links and email address from a site too. This is possible using linux I/O linux command redirections like shown below:

# wget -c "http://www.domain.com/contacts.html"
# urlview contacts.html

This command, when executed from a loop from a shell script and feeding the script with batches of URLs from a text file would give you the concept of email and URL extractor softwares that are commercially and widely around the windows world.

These are the URL and email regular expressions that urlview linux command is designed to fetched for:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a. (((https?|ftp|gopher)://
b. (mailto|file|news):)[^’ <>"]+|(www|web|w3).[-a-z0-9.]+)[^’ .,;<>":]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This blog entry is not here for creating an army of email and URL extractor group that spams and email-bombs the web.


HTH

TFTP server - setup and install howto

The Trivial File Transfer Protocol (TFTP) is normally used only for booting diskless workstations. The tftp-server package provides the server for TFTP, which allows users to transfer files to and from a remote machine. TFTP provides very little security, and should not be enabled unless it is expressly needed. The TFTP server is run from /etc/xinetd.d/tftp, and is disabled by default on Red Hat Linux systems.

The TFTP protocol is extensively used to support remote booting of diskless devices. The server is normally started by inetd, but can also run standalone.

Here's an entry that covers few easy steps on creating a working TFTP server from Fedora.

First, install TFTP software using yum

# yum -y install tftp-server

If you have an existing TFTP server, you can upgrade tftp by issuing

# yum -y upgrade tftp-server

Using xinetd, configuring tftp config file /etc/xinetd.d/tftp would be like so

# cd /etc/xinetd.d
# cat tftp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
service tftp
{
socket_type = dgram
protocol = udp
wait = no
user = root
server = /usr/sbin/in.tftpd
server_args = -s -c /tftpboot -u nobody
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


TFTP Additional Security
========================

Be informed that TFTP access and services does not require account authentcation from the server. Due to the lack of authentication information, tftpd will allow only publicly readable files (o+r) to be accessed, unless the -p option is specified.


TFTP with TCPWrapper
~~~~~~~~~~~~~~~~~~~~

/etc/hosts.allow allows a specific IP address for accessing the TFTP server and /etc/hosts.deny denies any other IP address via TCP wrappers. Similar lines should be presentr from both files.

# echo "in.tftpd: 123.123.123.123" >> /etc/hosts.allow
# echo "in.tftpd: ALL" >> /etc/hosts.deny


TFTP with IPTables
~~~~~~~~~~~~~~~~~~

Here's a single entry from my /etc/sysconfig/iptables . This line allow TFTP access into a TFTP server via port 69. A similar line should exists from your /etc/sysconfig/iptables or firewall as shown below:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A RH-Firewall-1-INPUT -p udp -m udp --dport 69 -j ACCEPT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


TFTP CLIENT TO SERVER CONNECTIVITY TEST
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Make sure the TFTP client is not being being block by the TFTP server like so

# ping tftp.client.ip.address
# route del -host tftp.client.ip.address reject


By default TFTP package installation, all uploaded files to TFTP server are being stored under /tftpboot folder. By default installation, /tftpboot are owned by root with root group access.
Let's modify that to look like

# chown nobody.nobody /tftpboot -R
# chmod 600 /tftpboot


TFTP SERVICE VERIFICATION
~~~~~~~~~~~~~~~~~~~~~~~~~

Simply verify your TFTP service and port if they are currently being served and active, like so

# netstat -lap | grep ftp
# ss -ua | grep tftp


Launch TFTP daemon service
~~~~~~~~~~~~~~~~~~~~~~~~~~

Restart your iptables firewall and xinetd daemon service like so

# service xinetd restart
# service iptables restart

Try to upload a file to your TFTP server using a tftp client software.

With the above settings, you should be able to access, upload and download files from and into your TFTP server. This can be handy also when backing up data from your appliances like cisco routers and the like, which supports TFTP upload and download access.

Did you noticed an intersting floating half-rounded black box around this site too?

Sunday, September 9, 2007

NMap - Linux port scanning

How to know which port is open from unmanaged remote host?
How to determine running application and services from remote host?
How to do basic port scanning against a host?
How to confirm ports opened from remote host?

Here are a several ways to do port scanning and know which port/services are currently opened from remote host.

Determining opened ports from remote hosts enables somebody to check which service and known applications are currently running from a remote host. Considering that you are not currently managing a particular remote host, this gives confirmation if a specific application service is properly running from specific ports of a particular IP address or host. This can be handy at times when needed to verify some running services on host ports.

Linux Port Scanning
-------------------

This blog entry does not intend to discuss of any misuse or abuse usage of a powerful linux command line tool like nmap. However, in hope to explain more of basic nmap usage, this blog entry is here for further basic nmap references.

Take for example, a client is allowed to send and receive mail from his box and considering all changes have been done from your server and still the client can't receive emails. Further client phone conversation informs you that the issue was working fine recently and suddently, he just cannot send and receive emails. Although you can verify that the destination host is currently up, and you are not currently with the client's site, this blog entry is another step on expanding your troubleshooting arm to confirm some ports from remote host without having total access from it.

One way to approach this issue is by using one of the linux port scanning packages named nmap.
Nmap man says:

Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.


Here's how to verify if a port is open from remote host using NMap.

Port Scanning with Nmap

# nmap remote-IP-address
# nmap -P0 123.123.123.123

The output from Nmap is a list of scanned targets, with supplemental information on each depending on the options used. Key among that information is the “interesting ports table”. That table lists the port number and protocol, service name, and state. The state is either open, filtered, closed, or unfiltered. Open means that an application on the target machine is listening for connections/packets on that port. Filtered means that a firewall, filter, or other network obstacle is blocking the port so that Nmap cannot tell whether it is open or closed. Closed ports have no application listening on them, though they could open up at any time.

Ports are classified as unfiltered when they are responsive to Nmap’s probes, but Nmap cannot determine whether they are open or closed. Nmap reports the state combinations open|filtered and closed|filtered when it cannot determine which of the two states describe a port. The port table may also include software version details when version detection has been requested. When an IP protocol scan is requested (-sO), Nmap provides information on supported IP protocols rather than listening ports.

To issue nmap OS and version detection using nmap

# nmap -A 123.123.123.123

If you wish to do UDP scan against the remote host

# nmap -sU 123.123.123.123

If you wish to do specific port scanning using nmap

# nmap -v -p port_number 123.123.123.123

If you wish to probe open ports for service and version

# nmap -sV 123.123.123.123

Ping scanning can also be done using nmap

# nmap -sP 123.123.123.123

Sometimes you wish to scan a whole network of adjacent hosts. Nmap supports CIDR-style addressing. Nmap scanning to group of host or multiple IP address can also be done like so

# nmap -v -P0 123.123.123.123; 111.222.111.222-230
# nmap -v -P0 192.168.0.0/24; 192.168.1.0/27

When doing group port scanning, exclusing of a particular IP from command line

# nmap -v -P0 v -P0 123.123.123.123; 111.222.111.222-230 --exclude 111.222.111.222.228

Using nmap to exclude multiple host from batch text file can be done like

# nmap -v -P0 -P0 123.123.123.123; 111.222.111.222-230 --excludefile textfile.txt

When doing large number of multiple host port scanning using nmap, a delay can also be specified like so

# nmap -v -P0 123.123.123-254.123-254 --scan-delay 5

Nmap is capable of reading IP address as a batch from text file. This can be done like so

# nmap -v -iL ip-address-text.txt

Nmap also supports resuming an aborted nmap scan by specifying nmap parameter like so

# nmap -v -P0 123.123.123.123-150 --resume

Nmap is so great and handy as it also supports MAC address spoofing for probing remote host. This can be specified using the below nmap argument

# nmap -v -P0 123.123.123.123 --spoof-mac 00:03:47:31:55:69

All nmap shown above were scanning IP address, since nmap knows any DNS presence, you can also specify hostname or domain name as a target remote host for scanning

# nmap -v -P0 my.domain.com

Timing values for nmap can also be specified. Timing nmap values can be useful for IDS alert from target hosts that usually takes longer results to appear. For such a long scan, you may prefer to set the exact timing values you need rather than rely on the canned -T0 and -T1 values. Other values are shown below:
0 1 2 3 4
-T
1 = Paranoid
2 = Sneaky
3 = Polite
4 = Normal
5 = Aggressive
6 = Insane

# nmap -P0 -T1 123.123.123.123

Source host port can also be spoofed trying to achieve same scanning effect from a cloned source host. This can also be specified with nmap as shown below

# nmap -p 110 123.123.123.123 --source-port 110

Generally, collecting opened ports from multiple target hosts can be redirected to physical file using linux I/O as well, this is when you are doing host port monitoring and gathering opened ports statistics in a long-term basis.

Nmap works like sending out a series of TCP and UDP packets to a target host and then examines the returning response bits coming from the target host. The response bits are also classified based on the specified arguments from the person doing the port scanning.

However each version of nmap keeps track of its own port database file. So, it is highly advisable to upgrade your nmap version. Upgrading of nmap package can be easily done like so

# yum -y update nmap

If you wish to know more of known linux defined service ports, you can see more /etc/services.

Basically, nmap offers more arguments depending on the needed nmap service. I find it quite handy, as it does the job very well specially when I need them so. Use nmap with your good thoughts of linux port scanning, and be careful with scanning target host, as you might leave a mark while you are scanning them too!

HTH

removing garbage characters from screen terminal

You were playing with linux commands and special files, then suddenly all screen characters from current ssh session becomes unreadable. Unreadable in such a way that all string screen characters becomes non-printable characters or in short becomes garbage or garbles characters.

Here's a simple tip on how to remove non-printable and garbage characters from your screen and reset all characters to normal view without disconnecting your current ssh session.

This tip is quite handy and useful when you are encounter these scenario from playing with special linux files.

An example of garbage or non-printable characters are shown below.


And here is how to reset and clear them from your screen, simply issue

# reset

Reset linux command initialize your current terminal session including character mapping and control character from your screen terminal.

How to achieve a garbage or garbled screen character? Simply do as follows

# cat /dev/urandom

Hit Ctrl+C, and executing the above command shows a continuous garbled characters being scrolled up from your screen.

Another way to reproduce a garbled and scrambled set of screen characters is to issue

# cat /etc/localtime

To reset your terminal screen characters, use this reset command. Reset linux command clears those garbage away.

invert string match using grep

Man grep
A regular expression is a pattern that describes a set of strings. Regular expressions are constructed analogously to arithmetic expressions, by using various operators to combine smaller expressions.

Grep understands two different versions of regular expression syntax: “basic” and “extended.” In GNU grep, there is no difference in available functionality using either syntax. In other implementations, basic regular expressions are less powerful. The following description applies to extended regular expressions; differences for basic regular expressions are summarized afterwards.



Here's a simple way to invert matches from string using grep.

You will noticed that this command was being used here for quite sometime now and was never been explained why this parameter had been used from samples covered from this site.

To invert string match, here are several usage how to invert string match or string expression.

To invert a regular string match using grep

# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~
abc
bcd
efg
ab
#abc
#bcd
efg

xyz
~~~~~~~~~~~~~~~~~~~~~~~~~~

# grep -v abc testfile.txt
Results:
~~~~~~~~~~~~~~~~~~~~~~~~~~
bcd
efg
ab
#bcd
efg

xyz
~~~~~~~~~~~~~~~~~~~~~~~~~~

How to grep all string that does not starts with # character? This is handy specially when filtering conf that contains strings that start with # (comment character) and you wish to extract those lines that does not start with # character only

# grep -v '#' testfile.txt
~~~~~~~~~~~~~~~
abc
bcd
efg
ab
efg

xyz
~~~~~~~~~~~~~~~

Another usage for multinested and multiple string searchi using grep command can be done like so

# grep -v ab testfile.txt | grep -v bcd

Alteratively

# grep -v 'ab\|bcd' testfile.txt

Now, how to count the occurences of inverted string matches using grep command would be like so

# grep -cv 'ab\|bcd' testfile.txt

The above command can be useful of counting string matches occurrences from a text file for further string manipulation from bash script. This can be applied on parsing multiple system log files looking for multiple matches of string.

Linux input/output redirection of this grep command can also be applied.

Let us say your current linux box had blocked an IP address from thousand IP address lines from /etc/hosts.deny and you wish to remove it from the list, using linux I/O redirection with inverted string matching using grep can be hand with this situation. Here is an example on how to apply the inverse string matches using grep

# grep -v '123.123.123.123' /etc/hosts.deny > newhosts.deny
# mv newhosts.deny > /etc/hosts.deny

This two commands had removed a single blocked IP address from thousand lines of /etc/hosts.deny without editing it interactively or via string manipulation using sed.

Simple tip using reversed or inverted string matches using grep.

Saturday, September 8, 2007

RDesktop - remote desktop howto

We can never remove the fact that some companies still use any other desktop operating systems from their network. Several reasons for these are due to commercial and propriety softwares and customized applications that currently being managed and needed by certain specific company departments, whether those clients are located remotely or just a single department hop, providing support with these clients is never been at rest.

Here's a document entry on managing and connecting to Windows (TM) based operating systems (Windows 2000/2003, XP Terminal servers, Windows NT) from Linux box using a remote desktop tool called RDesktop.

rdesktop is an open source client for Windows NT Terminal Server and Windows 2000/2003 Terminal Services, capable of natively speaking Remote Desktop Protocol (RDP) in order to present the user's NT desktop. Unlike Citrix ICA, no server extensions are required.

rdesktop currently runs on most UNIX based platforms with the X Window System, and other ports should be fairly straightforward.

rdesktop was initially written by Matthew Chapman based on various scarce documentation, wire sniffs, and trial-and-error. It is released under the GNU Public Licence (GPL). Please send feedback, bug reports and patches to the appropriate mailing list. Patches can also be submitted to the SF patch tracker.

This X client for remote desktop to windows machine makes use of RDP on establishing protocol with Windows OS machines. Rdesktop connects to remote machines extremely fast compared to other remote desktop tools. By default, rdesktop establishes TCP/UDP connection to host's port 4899. Extreme works have been done to make Rdesktop to cover a lot of nice features that would be very usable with remote connection to window-based client machines.

RDESKTOP INSTALLATION
=====================

# yum -y install rdesktop

BINARY LAUNCH:

Ctrl+F2, rdesktop

RDESKTOP USAGE
==============

# rdesktop windows-machine-host
# rdesktop 123.123.123.123


The command issued above attempts to connect to a windows machine with an IP address of 123.123.123.123 . If no firewall exists between the connecting host, and the client, a successful rdesktop connection would be established immediately prompting rdesktop machine for username and password details.

If you wish to connect with supplied username and password using rdesktop

# rdesktop 123.123.123.123 -u username -p password

The above command connects remotely to windows XP machine and supply the needed username and password. This command does not work by default to Windows 2000 terminal machines as the default auto login configuration from Windows 2000 needs further tweaking. This tweaking method would not be discussed here. However, the command above works out right with Windows 2003 terminal server machines.

Rdesktop also features domain authentication during the remote connection attempt. The authentication attempt queries domain servers for centralized user authentication. This can be possible using rdesktop parameters.

# rdesktop 123.123.123.123 -d domain.com

Screen geometry can also be specified before remote connection is being made. Here's a sample example of using rdesktop geometry parameter

# rdesktop 123.123.123.123 -g 80%

which uses 80% of client screen to be displayed from connecting host.

Data transfer between the two host using rdesktop can also be encrypted by passing toggle rdesktop parameter like do

# rdesktop -E 123.123.123.123

For data compression during rdesktop data transfer can be done like so

# rdesktop -z 123.123.123.123

Audio sounds from rdesktop server can also be redirected to rdesktop machines. This can be handy if you would like to have livestream audio sounds and dumps it live to rdesktop client machines, which can be done like so

# rdesktop -r sound:remote 123.123.123.123

Alternatively, audio sound from client can be heard from rdesktop server by toggling the remote audio parameter like so

# rdesktop -r sound:local 123.123.123.123

Remote desktop protocol version can also be specified manually to rdesktop connection using the followinf rdesktop parameters

~~~~~~~~~~~~~~~~~~~~~~~~~~~
-4 uses RDP version 4
-5 uses RDP version 5
~~~~~~~~~~~~~~~~~~~~~~~~~~~


Remote client's disk, device, COM ports, LPT ports, printer details can also be specified from rdesktop command.

Using rdesktop, here is my captured simulataneous rdesktop screenshots with two remote machines Windows XP and Windows 2000 from Fedora 7 desktop:


Rdesktop Summary
===========

Works and task between two or more remote hosts can be done in a more effective, and efficient manner using X based remote desktop tool like rdesktop.

Goodluck and have a nice weekend!

All windows operating systems are products, propriety and trademarks managed and owned by their own respective company.

Related Post:

Passwordless Remote Connection with XP

Friday, September 7, 2007

Graveman on Linux - burn baby burn burn

Linux is full of alternatives. Having a lot of free opensource alternatives is what makes Linux world go interestingly round and round.

Here's another alternative on handling DVD/CD linux tasks.

DVD/CD Task management
~~~~~~~~~~~~~~~~~~~~~~

Graveman is a frontend for cdrtools, dvd+rw-tools and sox that provides a graphical user interface for handling common CD/DVD burning tasks like burning Audio CDs, Data CDs and DVDs, duplicate CDs, and clean rewritable CD/DVD media. Currently runs in GNOME and KDE very well and also uses GTK2 library from its interface.


Graveman feature:
* burn audio cd (from wav, ogg, mp3, flac, m3u and pts)
* burn data cd and dvd
* duplicate cd
* do copy on the fly
* clean rewritable cd and dvd
* burn multissessions cd

Upcoming features:
* copy dvds (DVD9 to DVD9, DVD9 to DVD5)
* burn data cd and dvd on the fly
* burn mixte cd
* burn .bin/.cue
* burn video DVD
* view past sessions in multissessions cd


Graveman automatically detect and scan your DVD/CD drives. Alternatively, graveman utility supports manual addition of CD/DVD drives not yet known to linux kernel. Graveman also supports several ISO image character sets when writing to disk media. Erasing and formating CDRW and DVDRW is also supported by this graveman DVD/CD utility tool.

Graveman CD utility is so nice and sweet that it can even support these linux CD/DVD disk operations and commands:

1. cdrecord
2. cdrdao
3. mkisofs
4. sox
5. growisofs
6. dvd+rw-mediainfo
7. dvd+rw-format
8. flac

INSTALLATION:
~~~~~~~~~~~~~

What more yum can do, just issue

# yum -y install graveman


BINARY LAUNCH
~~~~~~~~~~~~~

Ctrl+F2, graveman


Different Graveman operation screenshots:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




For more FAQ, see more from this site.

HTH

HTOP - interactive process viewer alternative

HTOP

This is HTOP, an interactive process viewer for Linux. It is a text-mode application (for console or X terminals) and requires ncurses. Tested with Linux 2.4 and 2.6. HTOP process viewer is not designed to replace the current well used linux 'top' command, but htop is an alternative with newly added and enhanced features that might be useful to other users too.

Htop operates interactively, using keyboard keys, arrows, and mouse driven operations. Htop also comes with its own progress meter that moves back and forth based on current values taken from CPU, memory and swap statistics. Htop process viewer views linux process and threads the same way like top command does, however, htop displays them in a faster way and much more interfactively compared to well known top command.

Since HTOP process viewer is text-based user-friendly interface. Tasks related to process killing, renicing can be done directly using keyboard arrow keys and mouse controls, as the PIDs can be selected by mouse or keyboard function keys and arrows without any further need for specifying PID numbers,

Cool HTOP, works nice and alternatively easy.


Comparison between HTOP and TOP:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* In 'htop' you can scroll the list vertically and horizontally to see all processes and complete command lines.
* In 'top' you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
* 'htop' starts faster ('top' seems to collect data for a while before displaying anything).
* In 'htop' you don't need to type the process number to kill a process, in 'top' you do.
* In 'htop' you don't need to type the process number or the priority value to renice a process, in 'top' you do.
* 'htop' supports mouse operation, 'top' doesn't
* 'top' is older, hence, more used and tested.



HTOP INSTALLATION
=================

HTOP process viewer can be installed in a flash, simply by issuing

# yum -y install htop


BINARY EXECUTION
================

# htop


HTOP INTERACTIVE COMMAND SHORTCUTS
==================================

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Space - Tag": mark a process. Commands that can operate on multiple processes, like "kill", will then apply over the list of tagged processes, instead of the currently highlighted one.

U "Untag" all processes (remove all tags added with the Space key).

s Trace process system calls: if strace(1) is installed, pressing this key will attach it to the currently selected process, presenting a live update of system calls issued by the process.

F1, h Help screen

F2, S Setup screen. There you can configure meters displayed on the top side of the screen, as well as set various display options,choose among color schemes and select the layout of the displayed columns.

F3, / Incremental process search: type in part of a process command line and the selection highlight will be moved to it. While insearch mode, pressing this key will cycle through matching occurrences.

F4, I Invert sort order: if sort order is increasing, switch to decreasing, and vice-versa.

F5, t Tree view: organize processes by parenthood, and layout the relations between them as a tree. Toggling the key will switch between tree and your previously selected sort view. Selecting a sort view will exit tree view.

F6, > Select field for sorting. The sort field is indicated by a highlight in the header.

F7, ], -
F8, [, + Decrease selected process priority (add to ’nice’ value)

F9, k "Kill" process: sends a signal which is selected in a menu, to one or a group of processes. If processes were tagged, sends the signal to all tagged processes. If none is tagged, sends to the currently selected process.

F10, q Quit

u Show only processes owned by a specified user.

M Sort by memory usage (top compatibility key).

P Sort by processor usage (top compatibility key).

T Sort by time (top compatibility key).

F "Follow" process: if the sort order causes the currently selected process to move in the list, make the selection bar follow it.
This is useful for monitoring a process: this way, you can keep a process always visible on screen. When a movement key is used, follow" loses effect.

K Hide kernel threads: prevent the threads belonging the kernel to be displayed in the process list. (This is a toggle key.)

H Hide user threads: on systems that represent them differently than ordinary processes (such as recent NPTL-based systems), this can hide threads from userspace processes in the process list. (This is a toggle key.)

Ctrl-L Refresh: redraw screen and recalculate values.

Numbers PID search: type in process ID and the selection highlight will be moved to it.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



HTOP web screenshot:

My HTOP screenshot in action:


HTOP FAQs can be seen here.

For more, man htop

HTH

Caching DNS server install howto

BIND DNS are nameservers responsible basically for resolving domain names or hostnames into their equivalent IP addresses. Websites or domain names have their own equivalent IP addresses that are usually managed and provided by the same website firms. If somebody is browsing a website from his browser, this website is being resolved, looked up and converted to its equivalent IP address by the DNS nameservers from your box or from your provider.

To achieve a faster resolving of domains, local dns cache or a caching nameserver can be created and installed right from your linux boxes. Once a domain has been cached, the next request for the same domain would be lookup and resolved locally and not from the provider anymore. Thus, this approach makes browsing more faster. resolves hostnames and websites relatively at a faster rate.

If you are using dialup connection from your linux box, or your desktop is a gateway from a number of hosts inside your area, or you just want to achieve a faster DNS resolving, you might as well consider creating a caching nameserver or caching DNS server locally from your box.

Here is an entry on how to create a Caching DNS server in Fedora.


The caching-nameserver package includes the configuration files which will make the ISC BIND named DNS name server act as a simple caching nameserver. A caching nameserver is a DNS Resolver, as defined in RFC 1035, section 7. ISC BIND named(8) provides a very efficient, flexible and robust resolver as well as a server of authoritative DNS data - many users use this package along with BIND to implement their primary system DNS resolver service. If you would like to set up a caching name server, you'll need to install bind, bind-libs, and bind-utils along with this package.



CACHING NAMESERVER INSTALLATION:
================================

The installation is quite easy. The DNS caching nameserver is available both from distro DVD or CD and from yum repo. To install caching nameserver from the internet using yum, you can simply issue the next command like so:

# yum -y install caching-nameserver

This command installs the caching only nameserver.


CACHING NAMESERVER SERVICE
==========================

To start your caching nameserver, simply issue

# service named start


# service named status



Caching nameserver uses default config file stored in /etc/named.caching-nameserver.conf by default. For chrooted caching nameserver, the config file is usually located in /var/named/chroot/etc/named.caching-nameserver.conf. Further configuration of this file is required to allow other host on using the caching DNS server.

Below is the default caching nameserver config file under F7
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options {
listen-on port 53 { 127.0.0.1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost; 83.229.64.3; 192.168.200.1; 192.168.200.0/24; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { localhost; };
match-destinations { localhost; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


You can alter this file if needed so.

Let us say, we want to grant DNS caching request to a host from your network with an IP 192.168.1.254, simply append it
from this line

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
allow-query { localhost; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

like so
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
allow-query { localhost; 192.168.1.254; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can specify multiple hosts or group of IP address like so

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
allow-query { localhost; 192.168.1.254; 192.168.1/26; 192.168.2/27; 192.168.3/24; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

that allows everybody from your network that starts with an IP address 192.168.1.X .


To bind caching nameserver on multiple ethernet interface or IP address
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
listen-on port 53 { 127.0.0.1; 192.168.1.1; 192.168.2.1; 192.168.3.1; 192.168.4.1; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Just make sure these IP adresses do exist from your caching nameserver host.


Group access list can also be created from caching nameserver. This makes use of caching nameserver word ACL as shown below

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl my-networks { localhost; 192.168.1.254; 192.168.1/26; 192.168.2/27; 192.168.3/24; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and referring to them from the line

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
allow-query { my-networks; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you wish to disable IPv6 caching nameserver, simply comment the line like so

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// listen-on-v6 port 53 { ::1; };
// query-source-v6 port 53
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Additionally, from your caching nameserver, you may want to edit your /etc/resolv.conf and add your new caching nameserver IP address from there like so

# cat /etc/resolv.conf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nameserver 192.168.1.1
nameserver your-ISP-provider-DNS-IP
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Optionally, you are allowed to use more than two nameserver IP address. You can also add the LIVE or public IP address of your caching nameserver as well.


DEFAULT VALUES
~~~~~~~~~~~~~~

The default caching nameserver has several default arguments, as shown below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
query-source address * port 53;
directory "/var/named";
statistics-file "named.stats";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Legend:
* binds caching server on all current interface
port 53 binds caching server on port 53
directory define the default working folder
statistics-file define where all DNS statistics would be written to


CACHING NAMESERVER LOG FILE
~~~~~~~~~~~~~~~~~~~~~~~~~~~

To monitor DNS caching server, simply use tail

# tailf /var/log/messages


NAMESERVER SERVICE RESTART
~~~~~~~~~~~~~~~~~~~~~~~~~~

# service named restart

Remember to put them permanently, so caching nameserver starts up between reboot like so

# chkconfig --levels 35 named on


CACHING NAMESERVER TEST
~~~~~~~~~~~~~~~~~~~~~~~

To check if your caching nameserver is currently running

# service named status
# netstat -panut | grep named
# ss -l |
grep domain


From the caching nameserver, simply try to resolve a domain like so

# nslookup google.com localhost

should give your resolved hostnames of google.com using the local interface of your caching nameserver.


Alternatively, using another private IP address as shown with the above IP examples

# nslookup google.com 192.168.1.1


That is all for now.

BitTorrent - downloading large files made easy

Want to download Harry Potter The Order of the Phoenix the movie in Linux desktop?

Linux is free, Harry Potter The Order of the Phoenix movie is free as well?

Suffering from slow internet dialup connection on downloading large DVD movie or ISO files?

Movie files corrupted due to disconnection problems on internet connections?

Worry not, BitTorrent is here to the rescue!

BitTorrent, an extremely handy tool on downloading large torrent files regardless of internet speed rate you have with interruption between connection breakups.

There are linux desktop users who might have fast internet connections, but connection breakups happens in the middle of nowhere, most probable tendency is that the file being downloaded is now useless and corrupted. No time for redownloading restarts? Bittorrent makes downloading large files easier and without interruption headaches.

BitTorrent is a tool for distributing files. It's extremely easy to use - downloads are started by clicking on hyperlinks. Whenever more than one person is downloading at once they send pieces of the file(s) to each other, thus relieving the central server's bandwidth burden. Even with many simultaneous downloads, the upload burden on the central server remains quite small, since each new downloader introduces new upload capacity.

With the genuine BitTorrent client, you get:

* Dynamic bandwidth management -- download without disrupting other applications
* Detailed stats let you monitor the health of your downloads
* No hardware configuration - reduced hassle of fast downloads



BITTORRENT INSTALLATON
======================

With yum around, bittorrent makes RPM-based binary installation easy and seamlessly. Bittorrent can be installed by yum like so:

# yum -y install bittorrent-gui bittorrent

Alternatively, bittorrent RPM installer file can be downloaded from this site.


BINARY LAUNCH:
--------------

Ctrl+F2, bittorrent

Bittorrent has been around serving happily Linux desktop GUI users as well. I find this useful on Linux desktop clients sufferring from downloading large files on slow internet connections. The GUI interface is very simple even grandma is able to keep up with it. Any downloading interruptions are handled very well without affecting data CRC and file integrity during internet connection breakups.

If you are have more Bittorrent issues, a well written DOCS and FAQs is around for a nifty guide, which can be found here.


BitTorrent in action web screenshot:

Sample BitTorrent GUI interface:


So what are you waiting for?

Fire up your BitTorrent, and get Harry Potter The Order of the Phoenix Movie for free. Simply copy and paste the bittorrent file from here into your BitTorrent URL, and you're good to go!

Thursday, September 6, 2007

PHPAlbum - web photo album install howto

PHPAlbum is an easy to install and run photo album and gallery script. It doesn't require a database and features automatic installation on an FTP server with just a few clicks. It generates thumbnails and resized photos and supports password directory protection, access logs, short and longer description of directories and photos, and an admin section for creating new directories, uploading photos, and deleting them. HTML layout is separated from the functional code, and two themes are available.

PHPAlbum is ofcourse powered by PHP source codes. The current version installs smoothly manually or via live FTP installation as I have tested from one of my box around here.

These are the features which PHPAlbum offers you:

* Automatic generation of thumbnails and resized
* Commenting of pictures with antispam security code
* NEW! IPTC Support, import of keywords and picture description, showing other IPTC-tags
* NEW! E-Card - you can now send e-cards to your friends and family
* Screenshots for files to be downloaded, movie, audio, exe or whatever
* Password protection for your private galleries
* Admin section for creating new directories, uploading photos (works even with PHP safe_mode=on),Uploading ZIP Files preserving directory structure
* Short and long description of galleries/directories and photos
* Highly customizable layout, separated layout(HTML) from functional code, this allows easy creation of new themes
* Caching of all generated thumbnails and resized photos
* Transparent logo and icon processing with any background color, including IE6
* Access logging, with exclude strings
* And last but not least, you can help us with your suggestions to create usable, easy to install, php photo album script.

PHPALBUM INSTALLATION
==============

You can do the installation from web or locally from your box. If you wish to manually download the installation file here with phpAlbum_v0.4.1.14_fix01.zip as its current filename. But if you wish to install the file online, you can start by pointing your browser here.

PHPAlbum Manual Installation
----------------------------

Assuming you have downloaded the installation zip file phpAlbum_v0.4.1.14_fix01.zip , you start unzipping the files like so

# unzip phpAlbum_v0.4.1.14_fix01.zip

This would create a folder named phpAlbum_v0.4.1.14 and extract all PHPAlbum files into the said folder. If you wish to rename this folder, you may do so. Assuming we want to view the page from your http://domain.com/album, simply do so

# mv phpAlbum_v0.4.1.14 /var/www/html/album

Remember to start your apache service at this point.

# service httpd start

And point your browser on that page location. You will find the next instructions from there, it is so fairly easy.

EDITED as per request:
Simply,

Move the default PHPAlbum config file like so

# mv config_change_it.php config.php

And edit the file config.php, change the line from

$data_dir="data/";

to

$data_dir="data_something/";

and save. Follwed by creating the specified data folder from PHPAlbum root folder location like so

# mkdir /var/www/html/album/
# chmod 777 /var/www/html/album/


and browse PHPAlbum page. You may see a page like that you are not allowed to view the page.
Login and user the below default user credentials:

username: admin
password: admin

and you're in! Click on Setup link, and remember to change the default admin password. All the setup configurations are all there to manage.

After uploading images into your folder location, and you are still seeing some empty images from PHPAlbum site, you need to install a required PHP image library, which is available from Fedora repos like so

# yum -y install php-gd

and that's it, simple and easy web photo album and management.

Besides from easy installation, another good sides about the web photo album is you can create albums instantly, view images on three size (small, medium, large), auto-scans folders of images, allows access restrictions for particualar users and for several access privilege. All images are stored as flat files from folders. All frames, display of columns, comments moderation are all configurable from admin page.

Different image sizes are shown below:




If you wish to create a new album using admin user, simply create the folder and uploaded all files into that foler, phpalbum can scan the folder on schedules interval. This photo album also makes use of apache caching, so images loads faster than normal viewing rate.

Further FAQS and documentation can be read here and oh, install link from here.

Take a look at my screenshot:

Website screenshot:


Grab the PHPAlbum installer now, it's yummy free!

MRTG graph creation with Cisco routers

MRTG graph creation routers and devices
=======================================

From my recent blog entry of MRTG install howtos, which can be found here. Here is another entry to cover several steps on creating MRTG graph against Cisco router's ethernet and serial interfaces.

This blog entry assumes that your routers support SNMP or SNMP-enabled by configuration setup. The steps that will be taken here works perfectly with all the cisco routers currently scatterred around me. This blog entry hopes that the steps that would be covered here would also work with your non-cisco routers too. Assumming here also that this MRTG package is currently installed
from your box as well. If not, just follow the recent entry posted here.

Here is how to create and generate graph for Cisco interfaces.

Simply issue

# cfgmaker community@cisco-router-ip-address

# cfgmaker public@123.123.123.123 --output=cisco.cfg

The above command creates MRTG config file cisco.cfg and polls Cisco router's IP 123.123.123.123 for SNMP-enabled interface. The above command uses a default IPv4 polling with no special MRTG parameters and special output file format specified. Similarly, this MRTG command should work just fine with different distros.

Detail steps on enabling your router to support SNMP and configure them to have read-only community type would not be covered here. For security reasons, make sure your community name is a read-only community type.

Now an exact command that would do same function but with filters to remove all lines that starts with # character (commented lines) and all empty lines using grep would be like so

# cfgmaker public@123.123.123.123 | grep -v '#\|^$' > cisco.cfg

Similar output would be like so
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Target[123.123.123.123_1]: 1:public@123.123.123.123:
SetEnv[123.123.123.123_1]: MRTG_INT_IP="123.123.123.12393"
MRTG_INT_DESCR="FastEthernet0/0"
MaxBytes[123.123.123.123_1]: 12500000
Title[123.123.123.123_1]: Traffic Analysis for 1 -- core_link2
ifName:
Fa0/0
Max Speed:
12.5 MBytes/s
Ip:
123.123.123.12393 ()
Target[123.123.123.123_2]: 2:public@123.123.123.123:
SetEnv[123.123.123.123_2]: MRTG_INT_IP="123.123.123.123"
MRTG_INT_DESCR="FastEthernet0/1"
MaxBytes[123.123.123.123_2]: 12500000
Title[123.123.123.123_2]: Traffic Analysis for 2 -- core_link2
PageTop[123.123.123.123_2]: Traffic Analysis for 2 -- core_link2
...
snipped
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The above command would simply display SNMP polling resulting lines from the polled cisco router. If ethernet and and serial interfaces exist from the SNMP-enabled cisco routers, MRTG should give the resulting MRTG config lines.

Now, the next thing to do is to create MRTG index.html page using MRTG indexmaker binary tool. If you have an existing MRTG index.html file, you can simply copy and paste the needed portion of this new index.html file our output the file on a different file name like so

# indexmaker cisco.cfg --output=device.html

The file device.html is the equivalent browseable MRTG page for cisco.cfg.

It is done. The command is also basic to other devices that needs to be polled.

Most opensourced and linux packages are simple and handy.

MRTG is so nice creating highly configurable MRTG usage graphs, that so far it also works great with these boxes, as I expected, with Cisco 16xx, 17xx, 26xx, 36xx, 50xx, AS53xx, MC38xx routers, Cisco 26xx/16xx switches, Cisco PIX 50X firewalls, Cisco Content Engine box, Cisco ATA boxes, SkyStream DVB 16xx/55xx routers, Huwei Quidway 16xx routers, Planet wireless boxes, Senao wireless boxes, DLink/LinkSys wireless routers/switches, IDirect modem routers, SysMaster boxes, NetEnforcer Allot AC-20X/40X boxes, Packeteer box, HP/Compaq/Dell Gigabit ethernet interfaces, VYYO wireless modems, IP Planets, and even Quintum PABX box too! Most probably, it should work out fine with other boxes too.

Do let me know if MRTG did not work properly with these boxes from your side. I hope MRTG works with these black rounded boxes around too.

All products and other commercial boxes mentioned here are all propriety trademarks and products managed by their own companies. They were mentioned here for my own personal MRTG reference alone and does not guarantee MRTG would work perfectly with the others. You may need to check their own site for proper and more detailed SNMP documentation of their own respective boxes.

See sample screenshots

Wednesday, September 5, 2007

Tree view of directories and file listings from command line

A detailed run down of one command mentioned from one linux tips link posted here, was the linux command tree.

Man says:
Tree is a recursive directory listing program that produces a depth indented listing of files. Color is supported ala dircolors if the LS_COLORS environment variable is set, output is to a tty, and the -C flag is used. With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn. Upon completion of listing all files/directories found, tree returns the total number of files and/or directories listed.


This is a handy little utility to display tree view of directories. An overview of how files and directories are expanded and traversed can be misleading and confusing when we are referring to thousand of files and folders. Tree comes as a handy tool to peruse those deep directory tree structures and files, especially when someone is trying to hide something from you.

With my fresh virtual Fedora 7 box, I have managed to count all directories and display them in tree view from it. By default installation, Fedora has more than 11,600 directory folders.

INSTALLATION
====================

In case, tree is not installed from your current Fedora box, here's a quick yum install howto

# yum -y install tree

TREE USAGE
====================

Here are more parameter sample using Tree
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To display files and directories in a tree view mode

# tree

To display directories only would be like

# tree -d
Sample output:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|-- [apache apache ] ./LICENSE.txt
|-- [apache apache ] ./_install.php
|-- [apache apache ] ./_upgrade.php
|-- [apache apache ] ./admin
| |-- [apache apache ] ./admin/index.php
| |-- [apache apache ] ./admin/js
| | |-- [apache apache ] ./admin/js/AmiJS.js
| | |-- [apache apache ] ./admin/js/ajax_editing.js
| | |-- [apache apache ] ./admin/js/greybox.js
| | |-- [apache apache ] ./admin/js/lightbox.js
| | |-- [apache apache ] ./admin/js/plogger.js
| | `-- [apache apache ] ./admin/js/prototype.js
| |-- [apache apache ] ./admin/plog-admin-functions.php
| |-- [apache apache ] ./admin/plog-admin.php
| |-- [apache apache ] ./admin/plog-feedback.php
| |-- [apache apache ] ./admin/plog-import.php
| |-- [apache apache ] ./admin/plog-manage.php
| |-- [apache apache ] ./admin/plog-options.php
| |-- [apache apache ] ./admin/plog-rpc.php
| |-- [apache apache ] ./admin/plog-themes.php
| |-- [apache apache ] ./admin/plog-thumb.php
| |-- [apache apache ] ./admin/plog-thumbpopup.php
| `-- [apache apache ] ./admin/plog-upload.php
|-- [apache apache ] ./captcha.ttf
|-- [apache apache ] ./css
| |-- [apache apache ] ./css/admin.css
| |-- [apache apache ] ./css/gallery.css
| |-- [apache apache ] ./css/greybox.css
| |-- [apache apache ] ./css/lightbox.css
| `-- [apache apache ] ./css/tabs.css
|-- [apache apache ] ./dynamics.js


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To view and display every file and folders including hidden ones in a tree mode display would be

# tree -a

To view files with UID, GUID, filesize, file location would be like so

# tree -ugfs

Sorted view of tree display is also possible by using tree parameters like

reversed sorting order
# tree -ugfsr

sorted by modification time
# tree -ugfst

To view and display all files and directories with UID and GID

# tree -gd

To use tree with enabled colorization would be

# tree -C

You can notice that using tree parameters, you can search files in a tree view mode of display using tree from command line terminal. Remember that these results can be combined further using other linux command.

Using linux command tree combined with grep would create another alternative way on grep'ing all files that has a modification time stamp of this month, September.

# tree -D | grep Sep

Alternatively, using tree to search or files and folder owned by a particular user or group ID like so

# tree -ugf | grep 'root\|user1'

Since tree traverses director folder, the depth of directory tree can also be specified like so

# tree -L 2

which traverses 2nd level down directories.

Another nice feature of tree linux command is that it can generate output in HTML file format with reference to base. This is done like so

# tree -H 'http://yourhost.domain.com' > index.html

Here's a sample of the generated tree view in web page file format:


Here's a sample screenshot of tree output from command line:


Enjoy.

MAC address packet filtering using IPTables

Wikipedia says:
Media Access Control address (MAC address) or Ethernet Hardware Address (EHA) or hardware address or adapter address is a quasi-unique identifier attached to most network adapters (NICs). It is a number that acts like a name for a particular network adapter, so, for example, the network cards (or built-in network adapters) in two different computers will have different names, or MAC addresses, as would an Ethernet adapter and a wireless adapter in the same computer, and as would multiple network cards in a router. However, it is possible to change the MAC address on most of today's hardware.

There are situations from our local network that requires control and management of packets going IN and OUT of your proxy interfaces coming and requested usually by internal hosts. Proxy servers are usually configurable linux gateway machines serving internal or client host as their front-end host from the web.

Implementing IP-based policies and access list restrictions from linux-based firewall is one of the many approaches to resolve and filter host based from MAC address. This situation can also be resolved by implememting a MAC address filters from the router level, or from firewall appliances, first hop bandwidth monitoring appliances, VLAN switches, other proxy software packages like Squid, other linux-based firewalls like IPCop and a lot of them from opensource list.

Considering the costly fees from acquiring these not so cheap appliances and routers, we can make use of iptables out of an existing proxy server or proxy gateway to filter out host based on their MAC address. In short, do MAC address packet filtering using iptables of an existing proxy linux box.

Iptables man says:
Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Several different tables may be defined. Each table contains a number of built-in chains and may also contain user-defined chains.

Linux IPtables is currently the default firewall package that comes from RedHat, CentOS and Fedora, right after ipchains dominated them long time ago. Iptables supports different types of filters. To name a few, iptables can do filters and firewall rules by usernames, by group IDs and user profiles, by source and destination ports, by source host and destination hosts, by URLs, by IP addresses, by packet ID flags, by protocols, and a lot more including filtering by MAC address.

This entry assumes that an existing proxy server is currently in place inside your network and you want to filter linux/windows client machines behind the proxy server using MAC address packet filtering by iptables.

Here's an entry on how to filter out MAC address using Linux IPTable firewall.


IPTABLES INSTALLATION
=====================

# yum -y install iptables


IPTABLES FIREWALL PACKAGE VERIFICATION
======================================

# rpm -qa iptables


IPTABLES MAC ADDRESS FILTERING
==============================

Here's an iptables sample lines to filter out host based on MAC address using the currently in place proxy server or linux proxy gateway. Make sure you insert them from one of your existing iptables INPUT chains like so

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# iptables -A INPUT -m mac --mac-source 00:02:A5:EC:00:8B -j DROP

Alternatively,

# -A RH-Firewall-1-INPUT -m mac --mac-source 00:02:A5:EC:00:8B -j DROP

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The command above would block a host with MAC Address 00:02:A5:EC:00:8B regardless of current IP address and packet/port source and destinations.


Extending MAC Address Filters via Iptables
==========================================

If you want to allow port 80 for a host with MAC address 00:02:A5:EC:00:8B , simply insert this line to your existing /etc/sysconfig/iptables firewall rules right after your INPUT chain

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# iptables -A INPUT -p tcp --destination-port 80 -m mac --mac-source 00:02:A5:EC:00:8B -j ACCEPT

Alternatively,

# -A RH-Firewall-1-INPUT -p tcp --destination-port 80 -m mac --mac-source 00:02:A5:EC:00:8B -j ACCEPT

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Iptables is one powerful linux packet filtering firewall specially when properly tweaked and modified to fit your needs. If you wish to know more of iptables, read the man page. Further iptables reading can be found here.

May the iptables keeps your linux boxes protected as always.

HTH

Tuesday, September 4, 2007

GTK-based GNOME Linux Tools

GTK-based GNOME Linux Tools
===========================

As this blog entry aims to provide more linux information and tool sets specially to RedHat based distro like Fedora, CentOs, Fox, WhiteOs, with audience consideration from linux friendly newbies up to long time linux users, here's another set of simple linux tool.

UserMode-GTk package comprises of simle GTK-based GUI tool aimed to do certain user account tasks and disk function. Install usermode-gtk if you wish to have a GTK-based front tools on managing certain GNOME tasks. Usermode-Gtk is included from Fedora repositories, which means installation is smooth and easy using yum installer.

Usermode-Gtk is composed of several GTK-based binaries namely

a. userinfo - Userinfo allows users to change their finger information.


b. usermount - Usermount lets users mount, unmount, and format filesystem

c. userpasswd - Userpasswd allow
s users to change their passwords.


d. userformat - Userformat formats, mounts, and unmounts mounted partition and devices
UserFormat is a simple GUI based linux tool to mount and unmount partitions and mounted device. Userformat also formats detected mounted device as well.


All these binaries is easy to use, simple and user-friendly GTK-based tools with GUI interface.

INSTALLATION
============

# yum -y install usermode-gtk


BINARY EXECUTION
================

# userformat
# usermount
# userinfo
# userpasswd

Easy to remember binary names too!

Linux backups powered by RSnapShot

For more linux backups alternatives, which was covered here and here,.

RSnapShot, as mentioned to be a future entry, is now here as an alternative backup tools in linux.

RSnapShot is a linux filesystem snapshot backup utility. One of the nicest thing about rnsnapshot backup utility is that rsnapshot can do incremental snapshots of local and remote file systems for unlimited number of machines as long as the destination storage capacity can handle the backup snapshot output size. Rsnapshot utilizes rsync package to capture a snapshot of a filesystem. Rsync even saves more disk space by using linux hardlinks when creating snapshots.
Rsync becomes more powerful combined with large capacity media and network storage device. Rnapshot can create an exact duplicate of data from partition or folder locally or remotely.

Rsnapshot makes use of /etc/rsnapshot.conf conf file on creating filesystems snapshot backup.

RSNAPSHOT INSTALLATION:
=======================

# yum -y install rsnapshot rsync

This program should work on any reasonably modern UNIX compatible OS. It has been tested successfully on the following operating systems:
- Debian: 3.0 (woody), 3.1 (sarge), unstable (sid)
- Redhat: 7.x, 8.0, Enterprise Linux 3.0 ES
- Fedora Core 1, 3
- CentOS 3, 4
- WhiteBox Enterprise Linux 3.0
- Slackware 9.0
- SuSE: 9.0
- FreeBSD 4.9-STABLE
- OpenBSD 3.x
- Solaris 8 (SPARC and x86)
- Mac OS X
- IRIX 6.5


BINARY EXECUTION
================

Once rsnapshot has been installed, you will need to configure rsnapshot default config file. But first it is highly advisable to backup the original config file before doing any changes. Back it up as usual with the linux copy file command

# cp /etc/rsnapshot.conf /etc/rsnapshot.conf.bak


RSNAPSHOT PARAMETERS
====================

From command line, rsnaphot can be executed like so

# rsnapshot -v -t [interval] -c /var/backup/rsnapshot.conf [number]

Legend:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-t for time interval parameter
interval can be hourly, daily, weekly, monthly backup

Optional arguments:
-v enabled verbosity mode
-c custom config file
-V more verbosity
-q silent mode
-D full blown diagnostic verbose mode
number numerical interval identification number
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


RSNAPSHOT CONFIG FILE SETUP
===========================

Remember that variable and value inside rsnapshot.conf are separated by tab space. All folders are ended by / character.

By default, all snapshots would be stored under /.snapshots/ . For a different snapshot destination, you can edit the line that says

snapshot_root /.snapshots/

If you are backing up to a removable external media, it is advisable to enable this line

no_create_root 1

Now, for backup intervals
interval hourly 6
interval daily 7
interval weekly 4
interval monthly 12

From the above conf lines, hourly interval backups can have 6 snapshots before rotating the snapshot backup file. The daily interval has 7, this means that when rsnapshot is executed, rsnapshot would keep 7 daily snapshots before rotating the backup snapshot files.

For example

interval hourly 8

This means that every time "rsnapshot hourly" is run, it will make a new snapshot, rotate the old ones, and retain the most recent eight (hourly.0 - hourly.7) snapshots. This would be clearer when we combine rsnapshot with cron utility later on.

If you are specifying these intervals from command line, make sure you commented them out from rsnapshot.conf. However, global parameters are supposed to be on a centralized configuration file, that is why it is included from the rsnapshot.conf file as shown with the above sample.

For compatibility issues, leave this line uncommented

cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
du_args -csh

If you have specific file glob patterns you can include them using this directive like so

include /home/ver/*.mp3

and excluding file blog patterns for example, like so

exclude /home/hisfolder/*.ISO

Here are the backup points that needs to be modified as an example

backup /home/ localhost/

/home/ is the snapshot destination folder under /.snapshot/ located from my current box. As you have noticed, folder locations are ended with / character and separated by tab key.

localhost would be the snapshot identification folder name that would be stored under the default snapshot destination folder, for this case is /.snapshot/ . For convenience of understanding, an hourly rsnapshot with the config sample shown above would be stored to

/.snapshots/hourly.0/localhost/home

Saving snapshot backup file to a remote host can also be specified from rsnapshot config file. This can be specifed as an example like so

backup user@backup-server2.com:/ backup-server2.com/

Passwordless and passphaseless ssh connection can be helpful here.

At this point, considering the setup above, rsync would create a local backup snapshot of /home and store the backup file to /.snapshots/ as its snapshot destination folder. Snapshots backup file includes /home/ver/*.mp3 files, /home/ partition folder and excluding /home/hisfolder/*.ISO files. Rsync would be run with default verbose logging dumped to /var/log/rsnapshot .

Here's a screenshot of rsnapshot in action considering the above configuration file together with rsnapshot log file:





Here's a rsnapshot disk usage of the above example.

# rsnapshot du localhost/home
~~~~~~~~~~~~~~~~~~
1.3G /.snapshots/hourly.0/localhost/home
1.3G total
~~~~~~~~~~~~~~~~~~

Now, compare it with using du (disk usage linux command) like so

# du -chs /home
~~~~~~~~~~~~~~~~~~
1.3G /home
1.3G total
~~~~~~~~~~~~~~~~~~


VERIFICATION OF RSNAPSHOT CONFIG FILE
======================================

For sanity checking of rsnapshot configuration file, this can be done from command line terminal like so

# rsnapshot configtest

If everything is fine, the below line should appear from executing the above command like so
~~~~~~~~~~~~~~~~
Syntax OK
~~~~~~~~


~~~~~~~~


RSNAPSHOT LOG MONITORING
~~~~~~~~~~~~~~~~~~~~~~~~

To monitor the latest rsnapshot log messages

# tailf /var/log/rsnapshot


RSNAPHOT ON CRONTAB UTILITY
===========================

Backup procedures are effective when done automatically without any user interactions.

Now, let us combine rsnapshot with crontab utility. Here's a sample crontab job with rsnapshot

00 00 * * * /usr/bin/rsnapshot daily
00 04 * * 6 /usr/bin/rsnapshot weekly
00 04 1 * * /usr/bin/rsnapshot monthly

This specifies a daily rsnapshot at midnight, a weekly snapshot on Saturdays at 4:00AM and a monthly rsnapshot at 4AM on the first day of each month.


Rsnapshot just created the first exact replica of /home . You are probably thinking that snapshots are actually exact data replica which just consumes your disk space. No, it is not.

Rsnapshot creates snapshots with differential and incremental algorithm in mind. Only changed contents of file and folder are saved into snapshots destination folders. Linux command du (disk usage) would report the same disk or folder size, which might confuse you later on.

Rsnapshot-diff to the rescue. Here is where rsnapshot-diff disk usage reporting tool comes in.

Try deleting some unimportant files or moving it to different folder location from the source backup location and compare the snapshot using rsnapshot-diff like so

# rsnapshot-diff /home /.snapshots/hourly.3/localhost/home/

which gives you a similar output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comparing /home to /.snapshots/hourly.3/localhost/home/
Between /home and /.snapshots/hourly.3/localhost/home/:
13081 were added, taking 1279034992 bytes;
13075 were removed, saving 1162911380 bytes;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After moving some file, and did the rdiff comparison, you will see the difference from there.

For more FAQs.

Final Note:

Backing up data is critical that it needs critical and detailed attention. Any single byte differences can probably make the backup copy unusable. Implementing proper backup policy, backup documentation and procedures is one good attitude towards attaning an efficient and effective backup and recovery do's and dont's.

Goodluck then. Happy black boxes kicking and happy reading too!

Related Posts:

Linux Backup using Tar
Linux Backup using RDiff

Bandwidth-Effificent and Encrypted Linux Backup

MRTG tutorial, install and howtos

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network-links. MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic.


MRTG is basically used for generating graphs to a device, network host, IP-based appliances for monitoring usage, live data and statistics usage. This monitoring software package is not installed by default installation. MRTG is written in Perl and comes for free. MRTG supports several SNMP version and even 64 bit counters. All graphs produced by MRTG are highly configurable and customizable to fit one's needs. MRTG works on most Linux, Windows and UNIX platform. Check out more info from the site.


MRTG INSTALLATION
==================

Here's an entry how to install MRTG from Fedora using yum

# yum -y install mrtg


USAGE AND PROCESS
=================


Verify that MRTG is currently installed.

# rpm -qa mrtg


Here are several steps on how to configure MRTG and start a new graph for you devices, or network host.

By default installation, MRTG uses /etc/mrtg/mrtg.cfg as its default configuration file. It is adviseable to a backup copy of the said original config file for future preference like so

# cp /etc/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg.bak

On creating MRTG graph, the first step to take is to determine if the target host is SNMP enabled or supports SNMP. Additionally, the target polling host or device should be currently reachable or accessible by polling host via direct or network connectivity.

Polling host is where the MRTG is currently installed to. If the target host being polled does not support SNMP polling, the resulting data results may vary from systems to system depending upon the technique and approach used to retrieve variable values from the host being polled .

To cover a basic MRTG usage sample, this entry would cover using MRTG on linux to create and generate MRTG graph of ethernet interfaces from a windows machine. Windows machine is assumed to be located inside the broadcast network where linux host is currently residing. It is also assumed that the windows machine has SNMP enabled from its TCP/IP properties.


MRTG GRAPH CREATION
===================

Here's the basic foundation instructions on creating MRTG graph taking the above scenario.

MRTG config file can be manually created using one of MRTG tools that comes from installing MRTG package. Here, we are going to use cfgmaker which is responsible for automatic creation of config files readable by MRTG.

The basic cfgmaker parameters requires 2 arguments
a. hostname or IP address of the host being polled. This should be reachable by broadcast from the polling host.
b. community access name defined from the host being polled. This can be public, private or user-defined community host.

As an example using linux terminal, here's a basic sample that shows the above requirements

# cfgmaker public@windows-IP-address

The above command would display from your screen similar results shown below

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--base: Get Device Info on public@target-host-ip:
--base: Vendor Id:
--base: Populating confcache
--coca: populate confcache public@target-host-ip:
--coca: store in confcache public@target-host-ip_ Descr MS TCP Loopback interface --> 1
--coca: store in confcache public@target-host-ip_ Descr Realtek RTL8139 Family PCI Fast Ethernet NIC - Packet Scheduler Miniport --> 2
--coca: store in confcache public@target-host-ip_ Type 24 --> 1
--coca: store in confcache public@target-host-ip_ Type 6 --> 2
--coca: store in confcache public@target-host-ip_ Ip target-host-ip --> 2
--coca: store in confcache public@target-host-ip_ Ip 127.0.0.1 --> 1
--coca: store in confcache public@target-host-ip_ Ip target-host-ip2 --> 2
--coca: store in confcache public@target-host-ip_ Eth --> 1
--coca: store in confcache public@target-host-ip_ Eth 30-78-30-30-31-34-38-35-64-31-39-39-30-30 --> 2
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifMtu
--base: Walking ifSpeed

Target[target-host-IP-address]: 2:public@target-host-IP-address:
SetEnv[target-host-IP-address]: MRTG_INT_IP="target-host-IP-address" MRTG_INT_DESCR="Realtek-RTL8139-Family-PCI-Fast-Ethernet-NIC---Packet-Scheduler-Miniport"
MaxBytes[target-host-IP-address]: 12500000
Title[target-host-IP-address]: Traffic Analysis for 2 -- ORG NAME
PageTop[target-host-IP-address]: Traffic Analysis for 1 -- ORG NAME
..
snipped.
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As shown above, you can now copy and paste the line that starts with

Target[target-host-IP-address]: 2:public@target-host-IP-address:

and ends with [/div]

into your /etc/mrtg/mrtg.cfg file. All lines that starts with # character is found to be disabled from the host being polled and is not required to be included from /etc/mrtg/mrtg.cfg unless you further need them being uncommented.

There are several cfgmker arguments that is available from the command line. Here are a few argument alternatives:

# cfgmaker --enable-ipv6 --noreversedns --community=mycommunity --dns-domain target-IP-address

Legend:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--enable-ipv6 enables polling using IPv6
--noreversedns avoids doing reverse lookup for IP address found from device polling
--community defines custom community name to use with creating MRTG config file
--dns-domain appends custom domain name from the name of the device/host being polled

You can also overwrite the following variable directly from the command line
--ifdesc=nr interface description uses Interface Number (default)
--ifdesc=ip uses Ip Address
--ifdesc=eth uses Ethernet Number
--ifdesc=descr uses Interface Description
--ifdesc=name uses Interface Name
--ifdesc=catname uses CatOS Interface Name
--ifdesc=alias uses Interface Alias
--ifdesc=type uses Interface Type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


After updating /etc/mrtg/mrtg.cfg, an index HTML file should be created. MRTG index file are the main index file where all the graphs can be viewed from the browser.


MRTG INDEX FILE CREATION
========================


MRTG comes with another binary tool called indexmaker. This indexmaker creates MRTG index files automatically using /etc/mrtg/mrtg.cfg as an index file basis for MRTG web site. This MRTG index file can be generated using indexmaker as shown below

# indexmaker /etc/mrtg/mrtg.cfg

With the above command, this would dump the actual index file from your screen. Using linux output redirection, the result from issuing the above command can be redirected to a file like so

# indexmaker /etc/mrtg/mrtg.cfg > index.html

Alternativety, using indexmaker parameters

# indexmaker /etc/mrtg/mrtg.cfg --output=index.html

MRTG index file is highly configurable using a variety of parameters available from indexmaker parameters. You can statically define MRTG title, number of columns, width, height, sections, MRTG log file, MRTG subtitle and headlevel number, MRTG leg


ends, sort display method, which interval graph to show, and more.

Now, you need to copy or move index.html file into a browseable location of your web server. As an example, you can create a folder directory and move it to /var/www/html/mrtg .


MRTG POLLING INTERVAL
=====================

With previous crontab entry here, you can now create an interval polilng schedule . Normally, advisable polling would be done every 5 minutes.

Here's a sample MRTG crontab sample that polls all defined variables and host from /etc/mrtg/mrtg.cfg with log output redirected to /var/log/mrtg.log done every 5 minutes time interval.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


MRTG LOG MONITORING
===================

MRTG log monitoring can be done basically like so

# tailf /var/log/mrtg.log

mrtg.log was defined from crontab utility shown above.

Make sure your web server is currently running and browseable. Simply fire up your browser and point it to your webserver default MRTG folder like http://MRTG-server-IP-address/mrtg/

And sample screenshot of one of my device using MRTG:



MRTG SECURITY
=============

Access to MRTG pages can be done from linux using apache security access list, user and password authentication, tcp wrapper and more using linux and apache. Unfortunately, this security issues and means would not be covered here as MRTG issues but would be done so sooner or later.

Kick the black box and thanks for reading!

FindSMB - view shared folders from network

Here's another tool to list out all shared folder from network neighborhood.

Findsmb is a perl script that prints out several pieces of information about machines on a subnet that respond to SMB name query requests or nmblookup.

findsmb can be handy when you need to mount shared folders or drives within your current subnet network or shared folder/drive from your network or machine near you.

If you want to list out all shared folders from your current network broadcast or subnet broadcast address from command line terminal, you can just simply issue findsmb without any parameter like so

# findsmb

Sample result:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IP ADDR NETBIOS NAME WORKGROUP/OS/VERSION
---------------------------------------------------------------------
192.168.1.41 CC2 +[MSHOME] [Windows 5.1] [Windows 2000 LAN Manager]
192.168.1.200 HIPOLITE [HIPOLITE] [Windows 5.1] [Windows 2000 LAN Manager]
192.168.1.1 LINUXBOX *[MYGROUP] [Unix] [Samba 2.0.6]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Findsmb Legend:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
first column - shows IP address that responds to SMB name queries or nmblookup request
second column - host name or computer name
third column - workgroup, netbiso name and OS information from responding client machines
or SMB server version
+ - indication of local master browser for that specific workgroup
* - indication of domain master browser for that specific workgroup


Alternatively, you can issue findsmb to probe for smblookup name queries from specific subnet broadcast like so

# findsmb 192.168.1.0

HTH

Squid - upgrade and install howto

If you are currently running a rpm-based squid binary, and you have just made a fresh fedora installation, here's an on how to upgrade and install your currently running Squid proxy web caching server.

By definition:
Squid is a high-performance proxy caching server for Web clients, supporting FTP, gopher, and HTTP data objects. Unlike traditional caching software, Squid handles all requests in a single, non-blocking, I/O-driven process. Squid keeps meta data and especially hot objects cached in RAM, caches DNS lookups, supports non-blocking DNS lookups, and implements negative caching of failed requests

PACKAGE VERIFICATION:
~~~~~~~~~~~~~~~~~~~~~

# rpm -qa squid


SQUID INSTALLATION
~~~~~~~~~~~~~~~~~~

# yum -y install squid


SQUID UPGRADE
~~~~~~~~~~~~~~

# yum -y update squid

Remember that doing yum downloads and installs squid binary with all default compile arguments. If you wish to have a customized compile arguments, you need to download the latest stable tar ball squid.

One of my next entries would discuss more of customizing squid configuration file.

HTH

prompt and press a key between script lines

Ever wonder how this simple mechanism goes where in an installation script prompts you a question and waits for you to press any key at a give time interval?

Here's a quick entry on how to prompt for a single key from a script with time interval.

Getkey is one linux command that waits until a keyboard key is pressed. This is useful on installation or even from a simple bash script. If your script is programmed to ask a user simple questions answerable by single keystroke, you might find this nice getkey tool script useful.

USAGE:
~~~~~~

Waits for user to press any key and display the pressed key
# getkey

Waits for a user to answer a question by Y or N within 5 seconds and display the pressed key
# getkey -c 5 -m "Press a kay within %d Continue the process Y or N?"

Waits for a user to answer a question by Y or N within 5 seconds and display the pressed key but ignores any special control keys except Ctrl+C and Ctrl+D
# getkey -i -c 5 -m "Press a kay within %d Continue the process Y or N?"

Another usage is for pausing between bash script lines like for 5 seconds instead of using sleep. But ignores any pressed key
# getkey -c 5

HTH

Monday, September 3, 2007

Devede - DVD/VCD video authoring and creation tool

Here's an entry to cover a linux tool on creating video DVDs and CDs, super VCDs, CVD, DIVX and MPEG-4 DVDs/CDs in Fedora 7 using a small linux tool called Devede.

DeVeDe is a program to create video DVDs and CDs (VCD, sVCD or CVD), suitable for home players, from any number of video files, in any of the formats supported by Mplayer. The big advantage over other utilities is that it only needs Mplayer, Mencoder, DVDAuthor, VCDImager and MKisofs (well, and Python 2.4, PyGTK and PyGlade), so its dependencies are really small.


INSTALLATION:
~~~~~~~~~~~~~

# yum -y install devede

BINARY LAUNCH
~~~~~~~~~~~~~

Ctrl+F2, devede

From its initial program launch, devede immediately prompts you to choose from the different media disk you wish to be created. From current devede version, you can choose from

a. Video DVD
b. Video CD
c. Super Video CD
d. CVD
e. DIVX / MPEG-4

as shown with the below image



Devede video creator also provides you with menu GUI interface for offering a variety of video authoring parameters shown below:


Here are the current features being supported by the linux video authoring tool:

a. titles, menu with titles, graphical images that comes with the title,
b. autoplayed subtitles
c. ISO/MPEG file output redirection
d. disk structure feature
e. several disk size to choose from
f. video output format (PAL/SECAM, NTSC)
g. video and audio rate, video images
i. video output size
j. trellis and deinterlacing feature
k. video encoding types
l. optional memcoder arguments
m. MBD mode or rate distortion
n. video quality options, aspect ratios, and scaling modes

and much more as seen with below screen shots


A sample video startup image:



There are more than more or less around 15,000 linux software and tools currently available from different linux distros, and this one is a must to install video authoring tool specially for those whose works involves video and audio media creations.

This devede is just starting and yet has already offered many benefits from its current version compared against having a commercially available non-free DVD authoring tools around.

Devede is neat, nice and most of all, free. You get a global wide community support from using GPL'd linux softwares.

display file and file system status

Display of file or file system status

Linux is totally comprised of different file types. Here's an entry on display more file info or file system info status using the linux command stat.

# stat /dev/sda1
# stat /dev/cdrom
# stat testfile.txt
# stat program.rpm
# stat test.iso

A sample output of issuing stat to test.iso
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File: `test.iso'
Size: 360448 Blocks: 712 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 4325435 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 500/ ver) Gid: ( 500/ ver)
Access: 2007-09-03 06:27:13.000000000 +0100
Modify: 2007-07-29 03:40:54.000000000 +0100
Change: 2007-09-02 12:14:12.000000000 +0100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Determine status info of a partition
# stat /dev/sda1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File: "/dev/sda1"
ID: 0 Namelen: 255 Type: tmpfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 63395 Free: 63386 Available: 63386
Inodes: Total: 63395 Free: 62934
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From the given result, you can acquire more information on the queried object such as fundamental block size, file system type, Inodes, IO block types, file blocks covered, permissions and modes, user (UIDs) and group (GUIDs) ownerships and more.

determine file type

determine file type

An entry on how to determine file type.

This linux command file determine file types classification in three different ways namely filesystem tests, magic number tests, and language tests. The first test that succeeds causes the file type to be printed.

Determining file types are usually being used inside bash or perl script before any file read/write operation takes place. By doing so, any file validation algorithm can be performed first before any file or write access can be granted or continued.

Simple Usage
~~~~~~~~~~~~

# file /dev/sda1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/dev/sda1: block special (8/1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# file F7.ISO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.iso: ISO 9660 CD-ROM filesystem data UDF filesystem data (unknown version, id 'NSR0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# file textfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
textfile.txt: ASCII English text
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# file /dev/cdrom0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/dev/cdrom: symbolic link to `scd0'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GNOME GUI task scheduler install howto

As per recent entry, here's another alternative on managing at and cron jobs utility from GNOME using a friendly GUI interface.

Gnome man:
Gnome-schedule is a grapichal user interface to 'crontab' and 'at', both used to schedule tasks. It supports periodical tasks and tasks that happens once in the future. It is written in python using pygtk.

Gnome-schedule supports both 'vixie-cron' and 'dcron', it has been developed and tested on a variety of distributions.

Gnome-schedule also supports titles and icons for your tasks so that they are more easily to keep track of. And you can create templates so that you won't have to create the same task again and again. So that if you want to schedule a virus check at 03:00 today, you can save it as a template and choose it from an dropdown box when you want. Or want to compile the kernel.. again.. at 00:00. This is saved in gconf and may easily be shipped with each distribution.

Major features
- If run as root you can edit any users 'crontab' and 'at' tasks.
- A parser that translates 'crontab' entries into human readable strings like 'Every hour' and not '0 * * * *' which might seem confusing to some.
- An applet where you from an dropdown menu can choose to add a task, manage tasks and get help.
- You can choose to use advanced mode which will display the tasks in a different way, where you can see the 'crontab' entries like you are used to.
- As mentioned you can set a title and an icon for tasks.
- Create templates like 'Virus check' or 'Compile kernel'.
- Predefined common expressions like: every minute, every week, tomorrow, next week.
- You may use an calendar to browse for the day you want a task executed.

GNOME-SCHEDULE INSTALLATION

# yum -y install gnome-schedule


BINARY LAUNCH: Ctrl+F2, gnome-schedule

This GUI based cron utility creates a chance for new comers with cron utility mechianism to achieve the same cron utility control done from command line by using a user friendly GUI interface via GNOME.

During program execution, gnome-scheduler scans for active cronjobs from cron spool utility and list them our from gnome-scheduler main pane. Toolbar and iconified menus are also available from Gnome-scheduler as shown with the below screenshots.

By creating a new job using gnome-schedule, you will be prompted by interactive wizard type of window prompts. Gnome-scheduler then prompts you for additional task requirements as listed below:

a. the name of the program or script to execute
b. interval time and/or number of program execution desired
c. descriptive comment for the desired cron job
d. output destination when executing the cron job
e. user account to be used for executing the cron job

See a newly created job for listing files from root folder location:


My screenshot in action:


Editing cron job using GNOME-scheduler in action:



All is done.

Saturday, September 1, 2007

Linux backups powered by Rsync

Backup like a PRO using one most popular linux backup tool alternatives called rsync.

RSync backups data and does it very clean and well. Rsync only transfers those data that have been modified and changed so that the destination host has an exact replica from the source host. Rysnc is a command line backup tool that handles data transfers in an effective and secure manner like any other known commercial backup softwares around. Rync blends in and integrates flawlessly with linux shell commands combined linux I/O redirections.

Here's an altenative approach based from recent entry on creating data backups from simple one to an enterprise backup data sets using rsync.

Man Rsync:

Rsync uses a reliable algorithm to bring remote and host files into sync very quickly. Rsync is fast because it just sends the differences in the files over the network instead of sending the complete files. Rsync is often used as a very powerful mirroring process or just as a more capable replacement for the rcp command. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm.


INSTALLATION:
~~~~~~~~~~~~~~~~

Rsync installation is installed by default System Tool group installation. If rsync is not available from command line and from rpm database, you can install from yum repo using yum like so

# yum -y install rsync

To verify that rsync has been installed successfully

# rpm -qa rsync

There are two different approach on establishing rsync communication between two hosts.

First is by using a remote-shell program such as ssh or rsh. If you want to use this approach, it is required that openssh server or an active ssh connection is present from both sending and receiving host. Openssh installation and configuration would not be covered from this entry. This entry would assume that ssh daemon service is currently configured and listening properly to assigned host port.

Secondly, is by using rsync listening INETD service directly.

This entry hope to cover both of them two worlds.

Rsync usage from command line terminal
======================================

Transfer and/or update files from local host into a remote host using rsync
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Basic rsync argument is to specify file glob, a source and a destination folder. Destination can be a local host or a remote host. A basic example to transfer from local to remote would be

# rsync -t *.mp3 remoteusername@remotehost:remote_destination_folder

The above would transfer, using rsync, all *.mp3 files from current local directory into remote_destination_folder of remotehost using remoteusername for authentication. A destination host can be locally or remote host and can be specified as hostname or IP address.

Legend:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-t preserve time of selected files
*.mp3 selected files to be transferred
remoteusername bash enabled user account from destination host
remotehost destination host where remoteusername is allowed to have access
remote_destination_folder destination folder from destination host owned and accessible
by remoteusername
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For recursive traversing of directory folders for transferring data from current host to another host using rsync, this would be like so

# rsync -avrzt /var/www myuser@server1:/var/backup/
Legends:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-a archived mode enabled
-v verbosed mode enabled
-t preserve time stamp
-z compression transfer enabled
-r resursive mode enabled
/var/www selected folder or files glob source location
myuser user account from destination host
server1 destination host
/var/backup destination folder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The above command would issues rsync with verbose mode enabled, compression enabled, arhived mode of rsync data transfer/update. Rsync transfers files and folders from /var/www (including the www folder) into /var/backup folder of server1 host using myuser as login credentials. The /var/backup from destination host is owned or writeable by myuser . All rsync files are created with file ownership and permission owned by myuser having 600 file mode. The transfer would be done preserving symbolic links, devices, attributes, permissions and ownerships of files.

# rsync -avz /var/www/ myuser@server1:/var/backup/www

Appending / from selected file glob like the above command issues the same rsync command with same argument. The only difference is that source folder is not created .

Transfer files from remote host to local host using rsync
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# rsync -avrzt remoteusername@remotehost:remote_source_folder destination_folder
# rsync -avrz myuser@server1:/var/backup/www /var/www/

To transfer multiple files with different file extension from local host to remote host using rsync with file glob would be

# rsync -avrz file1.mp3 *.doc myuser@server1:/home/folder/location

To transfer multiple files from multiple directory sources using rsync would be

# rsync -avz `find /etc -name *.conf` user@remotehost:/user/folder

Linux command line tools when combined with each other creates another set of power tools. The above command searches all *.conf files from /etc folder and transfer them to /usr/folder of remotehost via rsync and using user the user login name. This can be handy if you like to backup specific pattern of files from your system or user accounts individual address books, files like that.

To transfer multiple files from multiple directory with some file excemptions using rsync and grep from local to remote would be like so:

# rsync -avz `find /etc -name *.conf | grep -v yum.conf` user@remotehost:/user/folder

Alternatively,

# rsync -avz $(find /etc -name *.conf | grep -v yum.conf) user@remotehost:/user/folder

and for multiple file rsync with multiple file from multiple source location with multiple file transfer exceptions would be like so

# rsync -avz `find /etc -name *.conf | grep -v 'yum.conf\|xorg.conf'` user@remotehost:/user/folder

To transfer of all your back up files ending in .tar file extension from any location would be like so

# rsync -avz `find / -name *.tar` user@remotehost:/user/folder

You will noticed that rsync can transfer data at high speed rate using rsync algorithm specially if those files and folders to be transferred are existing already from remote host.

To transfer multiple file(s) with multiple exclusions using rsync would be like so:

# rsync -avz * user@remotehost:/location --exclude=*.php --exclude=*.mp3

To transfer files in batch mode based from file lists using rsync would be

Assuming listing.txt is created with contents like below

# cat listing.txt
~~~~~~~~~~~~~~~~~~~~~
files0123.txt
files0124.txt
files6124.txt
files6126.txt
...
snipped
...
files32126.txt
~~~~~~~~~~~~~~~~~~~~~

and feeding the above file to rsync as batch mode input like so

# rsync -avzt --files-from=listing.txt user@remotehost

:/destination/

To rsync multiple folder source location using rsync would be like so

# rsync -avz --files-from=/home1 /home2 user@remotehost:/destination/

If both location contains abc.txt, the latest abc.txt would be transferred to remote host. If /home1/www exist and /home2/www exist, the files from both source kicatuib would be merged into /destination/www .

Fire up two new terminal windows, and from the first window, establish ssh connection from local to remote rsync destination. Then from the second windows try to issue these rsync command. You will notice that rsync never ask any password any more since there is an existing ssh connection with local host to remote host.

More rsync arguments
====================

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-W transfer the whole files without considering any update changes from existing destination file or folder
--progress show progress bar and/or percentage
-4 prefers IPv4
-6 prefers IPv6
--bwlimit=KBPS execute rsync with bandwidth limit rate in KBPS
-h display a more human readable screen output
--log-file=FILE dumps file activity into a file
--ignore-existing ignores already existing copy from destination host
--max-size tells rsync to avoid transferring files larger than specified size like
--max-size=10m avoid file transfer with 10MB in filesize
--port tells rsync to connect to rsync server with a different port, default is 873
--stats tells more file transfer info and rsync algorithm stats on the fly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

At this point, be reminded to kick the black ninja box to refresh possible monitor related eye strains.





Using Rsync in Daemon Xinetd Mode
=================================

Edit /etc/xinetd.d/rsync and modify

disable = yes
to
disable = no

To run rsync in deamon mode via xinetd, make sure you have similar lines from your /etc/xinetd.d/rsync file like shown below:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon --config=/etc/rsync/rsyncd.conf -v
log_on_failure += USERID
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create /etc/rsync/rsyncd.conf as a default conf file for rsync in daemon xinetd mode.

Sample rsyncd.conf file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uid = rsync-user
gid = rsync-user
use chroot = yes
read only = yes
pid file = /var/run/rsyncd.pid

# access list, edit the IP network block to suit your needs
hosts allow=192.168.0.0/255.255.0.0 192.168.1.0/255.255.255.0
# deny anything else
hosts deny=*

# limit connections
max connections = 5
#greeting file
motd file = /etc/rsync/rsyncd.motd
#log file
log file = /var/log/rsync.log

#rsync shared folder
[myrsync]
#make your UID/GUID above owns the below folder and files
#all files and folder would be seen by rsync client
path=/home/rsync-user/rsync-folder
comment = Linux Rsync Server
exclude = *.mp3

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create rsync greeting MOTD file like so

# cat /etc/rsync/rsyncd.motd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Welcome to my Rsync Server!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Restart xinetd service for the changes to take effect like so

# service xinetd restart

Verify that rsync is running as xinetd daemon service mode using one tool like ss

# ss -a | grep rsync
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LISTEN 0 0 *:rsync *:*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Rsync uses port 873 as its default port for xinetd service. Make sure it is also open from your current firewall settings. A sample firewall rule for opeing rsync from your firewall would be like so

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# service iptables restart

If you wish to have a passwordless rsync, you need to refer to passwordless/passphraseless ssh from one of last month's entry.

Rsync in daemon mode via command line
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An alternative to run rsync in daemon mode is by specifying it from command line. Like so

# rsync --daemon --address host-IP-address --config=/etc/rsync/rsyncd.conf -v --port=873

Legend:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--daemon enables rsync to be run as daemon mode from terminal
--port specifies port number to use
--config specified rsync conf file
host-IP-address IP address where to bind rsync from
-v enables verbose mode
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Listing out files and folder from rsync server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To list out the files from rsync server, simply point your rsync client to the host running rsync in daemon mode or server mode. To test your rsync server from a client linux host would be like so

# rsync host-IP-address::

Alternatively,

# rsync rsync://host-IP-address/myrsync
# rsync rsync://host-IP-address/myrsync/folder1

From the above rsync command, you should be seeing files from /home/rsync-user/rsync-folder folder from rsync server you defined from /etc/rsync/rsyncd.conf.

Syncing File and Folders from Rsync Server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To sync and download files from rsync server.

# rsync rsync://host-IP-address/myrsync/folder1 .

The above command downloads files including the whole folder1 folder from rsync server and saves it to current directory

# rsync rsync://host-IP-address/myrsync/folder1/ .

The above command downloads only files from folder1 to current folder location

Rsync Log Monitoring
~~~~~~~~~~~~~~~~~~~~

Monitoring rsync server messages for any errors or system messages would be like so

# tail -f /var/log/rsync.log

Final Note:

Rsync can also be used for source code control and management for delivering a centralized and distributed sync source codes from rsync server to group of programmers or source developers among departments, more like a CVS approach.

Using rsync linux command provides many abilities and benefits. To name a few, mirror an entire harddisk or partitions, folders and files, entire domain websites, mail spools for replica servers, user's home folder, a mirror FTP site and much more.

Backup like the enterprise way, use RSync.

Have a nice day ahead!

Related Posts:

Linux Backup using RSnapShot
Linux Backup using Tar
Linux Backup using RDiff
Bandwidth-Effificent and Encrypted Linux Backup

KPackage - GUI package administration and management alternative

Linux administration of RPM packages from linux boxes is basically required for keeping up and maintaining your package database tight, neat, and clean linux boxes. This has been possible from command line terminal ever since RedHat become well know. The linux command RPM is a very powerful well known binary originally from RedHat, that makes a tedious job of application installation easier and straightforward dependency and compatibilities assessment, and smoother binary package installation as compared with early days with RedHat distro.

Package clean up is part of maintenance functions. This can be considered as post-install maintenance funcion. The clean up process does not only refer to package deletions, package updates and management, clearing downloaded cache and header files but also gives way to library package definitions and usage familiarity.

This document entry gives way for another alternative for package management, KPackage.

Kpackage is one GUI-based KDE administration tool for installing, viewing and uninstalling RPM packages for many distros. The formats supported includes RPM, Debian, Slackware and BSD package manager. KPackage is part of kdeadmin rpm package available from many distros, which was an entry recently from here.


INSTALLATION
~~~~~~~~~~~~~~~~

# yum -y install kdeadmin

This package manager makes use of GUI-enabled features that is easily viewed and managed interactively by simple clicks and search selection. Kpackage comes with a nice panel presentation making use of dropdown tree-like menus, toolbars, fast rpm search for package addition, deletion, updates using X in GNOME or KDE.

BINARY LAUNCH: Ctrl+F2, kpackage

See screenshot
About:

Main Panel:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy