Wednesday, April 30, 2008

HowTo: Powerful Metric and Units Linux Conversion Tool

Does a scientific calculator scares you or your visitor aways from your seat? An online metric conversion site is miles away from your linux desktop internet connection? Worry not, here's a quick tip on how to have an offline metric conversion linux tool that could help most metric and scientific calculations that you might have. Read on.

Linux Metric Conversion Tool
On Fedora, there exist a linux application that can accomplish any metric conversion or most scientific calculations. This metric conversion linux tool can do a wide variety of mathematical conversion and calculations covering areas such as length, size, weight, time, linear, non-linear, speed, pressure, volume, temperature and more known mathematical unit conversions.

More specifically, this linux conversion tool can do 2439 units, 71 prefixes, 33 nonlinear units mathematical conversions in a flash!

What is Units

Units converts an amount from one unit to another, or tells you what mathematical operation you need to perform to convert from one unit to another. The units program can handle multiplicative scale changes as well as conversions such as Fahrenheit to Celsius.

Units Installation on Fedora
As small as 127K of bytes is needed to install units rpm on Fedora. Simply

# yum -y install units

If you want to the list of units this tool is capable of conversion, view /usr/share/units.dat.

Some sample usage:

# units 1hr+1minute seconds
result:

* 3660
/ 0.00027322404


The above basically means that 1 hour and 1 minute have 3660 seconds.

# units 3ft m
result:

* 0.9144
/ 1.0936133


More unit samples:

# units $5/yard cents/inch
# units 2btu+450ft lbf
# units 1/2kg kg/meter


Execute units without any parameters would give you interactive inputs and results like so

# units
You have: sqrt(acre)
You want:
Definition: 63.615034 m


Linux makes desktop operations complete. Enjoy!

Related Post:
Handy Network Linux Diagnostic Tool
Another GTK-based Linux Tool
Linux - Draw that thing from your Mind
Motion Picture and Animation Linux Tool

Tuesday, April 29, 2008

HowTo: Prevent Non-Root From Rebooting/Shutting Down The System

Have you experienced a scenario where your users make use of reboot or halt command? Did somebody user just reboot your own server? Do you want to prevent your users from shutting down your linux box or even rebooting it?

Here's a quick entry on how to prevent users from rebooting or shutting down your fedora linux box.

Prevent Non-Root From Using Reboot/Shutdown Commands

In order to avoid non-scheduled downtime of your linux box via reboot/halt/shutdown command usage by non-root users, carefully follow the below three steps

1. Edit /etc/inittab file, find the below line that says

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and edit the line to look like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ca::ctrlaltdel:ech0 Reboot/Shutdown is not possible at this time.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. Additionally, you can delete,rename, or move the files reboot, poweroff, and halt binary files from /etc/security/console.apps/ directory folder to another binary file names or to a different folder location.

3. Additionally, you can also remove, rename, or change file permissions to these files
/usr/bin/poweroff
/sbin/shutdown
/usr/bin/halt
/usr/bin/reboot

You can also apply these changes to folders where these binary resides, but be careful as some needed binaries are not suid-enabled and cannot be executed specially during boot time that might cause a problem to your setup. Alternatively, the renamed or moved binaries, or aliases can also be set to be immutable at your own discretion.

Take note that when renaming or moving binary files, make sure you remember their new names or command aliases. There are other patch up scenario to avoid users from executing them, but most likely the approach could be the same.

The above scenario are taken without any consideration to selinux settings, sudoers file or jailed ssh user environment or any X-based applications calling those mentioned root binaries.

Goodluck.

HowTo: UDP Connectivity Host Test

Are you wondering how would you be able to test and probe a port that listens for UDP connections? Or how would you test a listening UDP port?

How to test a listening UDP port

If you have managed to create a daemonized service that opens port for UDP connections, here's how to test that listening UDP port for UDP connections. Read on.

To test a listening UDP port, simply use nmap.

# nmap -p [port] -sU -P0 [host name | ip address]
# nmap -p 123 -sU -P0 example.com
# nmap -p 123 -sU -P0 123.123.123.123

From the command shown above, I am assuming that the host example.com is currently serving NTP service on UDP port 123.

Sample opened UDP port output:
~~~~~~~~~~~~~~~~~~~
Starting Nmap 4.52 ( http://insecure.org ) at 2008-04-29 10:56 WAT
Interesting ports on host.example.com (123.123.123.123):
PORT STATE SERVICE
123/udp open|filtered ntp
MAC Address: 00:02:A5:EC:00:8C (Compaq Computer)

Nmap done: 1 IP address (1 host up) scanned in 1.043 seconds
~~~~~~~~~~~~~~~~~~~

Not only you get to test and scan the UDP port, you also get the host's current MAC address.

If you have a closed UDP port, you should be seeing similar lines as shown
~~~~~~~~~~~~~~~~~~~
Interesting ports on localhost (127.0.0.1):
PORT STATE SERVICE
123/udp closed ntp
~~~~~~~~~~~~~~~~~~~

Goodluck.

Similar Posts:
Nmap Port Scanning
Install NMap GUI FrontEnd
List Out Opened Linux Ports
MAC Address Network Scan

HowTo: Secure SSH by Disabling Root Logins

Securing SSH is one major thing on server boxes regardless of server location. Here's one quick tip of adding security to your SSH connection by disabling any root logins.

How to secure SSH by disabling root logins?

To disable direct root logins, edit /etc/ssh/sshd_config file and replace this line

#PermitRootLogin yes

with the below line

PermitRootLogin no

Remember to remove the # comment character. Then restart SSH service

# service sshd restart

Quick tip, enjoy.

HowTo: Retrieve Current Latitude and Longtitude from Linux

Do you know your exact zone longitude and latitude coordinates? Knowing your current zone coordinates won't hurt a bit. Here's how to retrieve latitude and longitude coordinates inside your linux box via terminal.

To pinpoint your latitude and longitude of your current location from your Fedora box, follow the following command sample

How to Retrieve Latitude/Longitude Coordinates from Linux box

# grep -i manila /usr/share/zoneinfo/zone.tab
result:
PH +1435+12100 Asia/Manila

Legend:
First Column : Country Code
Second Column: Latitude and Longitude Coordinates
Third Column: Time Zone (usually following the continent/city format)

Let's try another one.

# grep -i singapore /usr/share/zoneinfo/zone.tab
# grep -i new_york /usr/share/zoneinfo/zone.tab

result:
SG +0117+10351 Asia/Singapore

That's it.

Friday, April 18, 2008

HowTo: Install Wallpapoz

What is Wallpapoz?

Wallpapoz application enables you to configure Gnome desktop wallpapers in unique way. You could have Gnome desktop wallpaper changes when the specified time has passed. The most important feature is you could have Gnome desktop wallpaper changes when you change workspace. This simply means you could group your wallpapers into specific workspace. Wallpapoz offers quick orientation cues where you are. You can manage it so when you change to first workspace, your desktop wallpaper will be picked from wallpapers group for that workspace. When you change to second workspace, it will be picked from wallpapers group for second workspace. So you could have situation like this. You change to third workspace and you will get cartoon desktop wallpaper (wallpapers group for that workspace consists of cartoon wallpapers only). You change to fourth workspace and you will get abstract desktop wallpaper (wallpapers group for that workspace consists of abstractwallpapers only). I think you get the idea. Off course you can disable this feature if you just want your desktop wallpaper changes when the specified time (specified by you) has passed and does not change when you change workspace.

Wallpapoz Run Time
Wallpapoz application consist of two programs.

First is "wallpapoz". "wallpapoz" is the program to make the configuration file. What wallpapers
do you want to use? It just like that. So before doing anything else, run this program first. The file configuration is located in $HOME/.wallpapoz/ .wallpapoz.xml. Although you can edit the file with text editor, I don't recommend it. If the file is corrupted, then remove it first before run
"wallpapoz" again. Don't run "wallpapoz" if the file is corrupted.

Second is the daemonized wallpapoz version. "daemon_wallpapoz" is the "real" program it self. The program will read the configuration file and will change the wallpaper if you change the work-
space or the specified time has passed (depended on your options in configuration file).

You can run the "daemon_wallpapoz" from "wallpapoz" program.You can terminate it too from there.
If you are happy enough, you can start automatically running this program when you load the gnome desktop by adding "daemon_wallpapoz" to gnome session start up program.

Wallpapoz Fedora Installation
Wallpapoz is python based linux application that can easily be installed into Fedora desktop via yum like so

# yum -y install walpapoz

Wallpapoz Webshots



Wallpapoz is here!

That is all folks. Check this out.

HowTo: Join Two Text Files with Common Columnar Field via Terminal

From my recent post, we have covered to merge data contents two text files without a common columnar field. We have also covered joining two text files into one text file separated by a delimiter character. Now, from this post, we are going to go thru merging two text files with a common columnar field. Read on.

HowTo: Join Two Text Files with Common Columnar Field via Terminal
Say we have two text files, namely test1.txt and test2.txt, with data content as follows

# cat test1.txt
first Fedora
second Redhat
third CentOS


# cat test2.txt
first Core 9
second Enterprise Version
third Free OS


Now, the simplest approach to merge data contents of text-based file is by using linux join command like so

# join test1.txt test2.txt
result:
first Fedora Core 9
second Redhat Enterprise Version
third CentOS Free OS


As you noticed, the two text files are basically merged using the common columnar fields namely first, second and third words.

To make it a little bit complex, here we would be joining the first field of the first text file with the second field of the second text file, that would simply be

# join -o 1.1 -o 2.2 test1.txt test2.txt
result:
Fedora Core
Redhat Enterprise
CentOS Free


The above join command matched the first field of first text file with the second field of the second text file.

Here's another one matching the second columnar data field of the first text file with the third columnar field of the second text file.

# join -o 1.2 -o 2.3 test1.txt test2.txt
result:
Fedora 9
Redhat Version
CentOS OS


Basically, using this approach, text files with and without common field can be joined and merged together with or without consideration to specific field columns,and saved to as another set of data text file. This could also be useful to UNIX text files mostly used by banks and to text files that needs to be merged and joined for a common data use.

Cool. Today is Friday, have a nice weekend!

If you have just subscribed recently and you are new around here, here are my old linux quick tips.
50 Quick Linux Terminal Command Tips Part 1
50 Quick Linux Terminal Command Tips Part 2
50 Quick Linux Terminal Command Tips Part 3
50 Quick Linux Terminal Command Tips Part 4

And if you are more on linux gaming, check out these 113 amazing fedora games. Thanks!

Wednesday, April 16, 2008

HowTo: Copy and Paste A Text File into Another Text File via Terminal

Yes, you read correct. This time around, we are going to paste data content of one text file into another text file and we are going to approach this issue using linux command via terminal. This one could be easily done inside X or GNOME, but let us assume we are going to do it from a linux system without X, say server or remote non-X linux box, something like that.

Let's start.

Let us view two example of text files namelyh textfile1.txt and textfile2.txt

# cat textfile1.txt
RedHat
Fedora
CentOS

# cat textfile2.txt
Enterprise Version
Core Version 9
Linux Distro


Now, let us merge or combine two text files using the linux paste command

# paste textfile1.txt textfile2.txt
result:
RedHat Enterprise Version
Fedora Core Version 9
CentOS Linux Distro


Making it permanent as file would be as easy as

# paste textfile1.txt textfile2.txt > output.txt

Did you noticed that the contents of textfile2.txt was merged with the data contents of textfile1.txt? Noticed also the fixed columnar width making the 2nd column word vertically aligned.

Merging two text file using paste could be very useful on specific scenarios of merging related data contents.

Here's another scenario.

# cat test1.txt
Citybank
Citybank
BPI Bank
Citybank

# cat test2.txt
New York, USA
San Francisco, USA
Manila, Philippines
London, UK

Again, using paste to merge contents of first file and second text file

# paste test1.txt test2.txt
result:
Citybank New York, USA
Citybank San Francisco, USA
BPI Bank Manila, Philippines
Citybank London, UK

If you want to insert a delimeter character between two columnar data or data field, that could be done using the same linux paste command like so

# paste -d", " test1.txt test2.txt
result:
Citybank,New York, USA
Citybank,San Francisco, USA
BPI Bank,Manila, Philippines
Citybank,London, UK


Neat and nice, isn't it? Hope you enjoy it, and oh, it was an old idea reminded to me by pinoyskull.

Merging two text files with a common field or column marker would be my next post, so watch out for it. And sorry for late updates, been very busy these past few weeks.

Related Posts:
Merging Linux Non-Text and Binary Files
Concatenating Multiple Linux Files
Simple Linux Text Line Formatter
Math the Beauty and Linux the Beast
Retrieve MySQL data via Bash Shell

Saturday, April 12, 2008

HowTo: Install Ioncube PHP Encoder/Decoder

Are you a PHP geek coder by profession or by hobby? Do you ever wish to hide your PHP source codes but still sell it to the market without even buyers having to view your PHP source codes?

If your intention is to hide PHP codes of your work and still distribute it, read on.

How To Install IonCube PHP Encoder in Fedora 8

1. Register and download the latest Ioncube PHP Encoder from here. We are going to go through installing Ioncube PHP Encoder via .tar.gz installation method.

2. Unpack the files and copy to default PHP module folder location like so

# tar ioncube-encoder.tar.gz
# cd ioncube

Copy the latest .so file into your PHP module folder like so

# cp ioncube_loader_lin_5.2.so /usr/lib/php/modules/

The module name, module version and PHP module folder could be different from your platform.

3. There are two ways to install Ioncube PHP Encoder, one is via PHP. Edit your /etc/php.ini
After the line [PHP], insert the next line

zend_extension = /usr/lib/php/modules/ioncube_loader_lin_5.2.so

Save and exit.

4. Now, if you are serving your web pages from /var/www/html/test1 , simply copy

# cp ioncube-encoded-file.php /var/www/html/test1
# cp ioncube-loader-helper.php /var/www/html/test1

5. Restart Apache and browse the above two Ioncube PHP Encoder PHP test files

# service httpd restart

If you installation is successful, you should be seeing similar lines like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This file has been successfully decoded. ionCube Loaders are correctly installed.
An ionCube encoded file has been loaded successfully.
Encoded files should now function correctly.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If Ioncube encoder tells you that your code has expired, simply re-register and download a new copy of the Ioncube PHP encoder file for evaluation purposes.

If problem persist, consult Ioncube but basically, browsing ioncube-loader-helper.php should be helpful enough.

Get a grip of Ioncube here. That is all, enjoy the weekend.

Wednesday, April 2, 2008

HowTo: Identify your IPv4/IPv6 Loopback Address

Most likely, administrators are familiar with IPv4 and IPv6 loop back address. The need to identify and reach IPv4/IPv6 loop back IP addresses remains basic but a need to know knowledge.

Here's a quick entry on how to identify IPv4/IPv6 loop back address status. Read on.

IPv4 Loop back Address

IPv4 loopback address typically refers to your network interface IPv4 loop back address. Here's how to identify and test your loopback address from linux terminal.

# ping localhost
# ping 127.0.0.1

The above ping commands gives you similar lines shown below

64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.026 ms

More detailed explanations of ping results has been bloged here.

IPv6 Loop Back Address

The loopback address on an IPv6 network however is 0:0:0:0:0:0:0:1 which is basically abbreviated as ::1. If you want to test your network interface from your platform where IPv6 is enabled by default, you can type

# ping ::1

That is all, thanks.

Tuesday, April 1, 2008

HowTo: Get Disk, Partition And Folder Space Usage

Quick and brief.

Here's a swift blog entry on how to retrieve and get disk usage of the following items:

a. directory folder
b. mounted disk partition
c. disk

To get the disk usage of a folder and return a human readable summarized usage

# du -sh /folder1
# du -sh /folder1/folder2
# du -sh /folder1 /folder2


To get the disk usage of a mounted partition

# du -sh /mnt/windows
# du -sh /mnt/ISO
# du -sh /mnt/USB


To get the disk usage of each folder on current working directory

# du -sh .

To get the disk usage of a folder excluding specific files, like excluding all MP3 files.

# du -sh /folder1/folder2 --exclude='*.mp3'
# du -sh /folder1 --exclude='*.jpg'


To get the disk usage of disk partition or mounted partition

# df -ah
# df -ah /dev/sda1
# df -ah /dev/sda1 /dev/sda2


To get the default partition usage where a system user belongs to
# df -ah ~username

The above shows the total usage of the partition where the user's default home partition belongs to.

That is all. Enjoy.


Related Articles:
More Disk Usage on Linux
Monitoring Large MailBox Users
Linux Resource Monitoring Tool
Disk Report Usage Tool
Harddisk Monitoring Linux Tool
Watching How Linux Log File Grows

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy