Tuesday, July 17, 2007

digikam - KDE photo management install howto

Do you know that Fedora is known to be first distro to make use of Linux Directory server, SELinux, mono-based program/tools, with most attention to 2.6.X kernels and more?

What do you know, I intent to have KDE audience too!

Here's a quick way to install KDE-based photo management tool called DigiKam .

A few nice things I also like with DigiKam are

* Tags, rating, date/time, comments, photographers ID, and copyrights are stored in EXIF and/or IPTC metadata tags embedded in pictures. Comments are also stored in JPEG files to JFIF section.

A lote more features are available for viewing here

What do you know, it also detects plugged USB devices too! Also runs under Gnome environment.

Linux world is wonderful, takes you to a variety of application choices.

Here's a quick preview:



I almost forgot, here's the install commands:

# yum -y install digikam
Hope you enjoy it too!

gnome floppy formatter

I am not really sure why Gnome floppy formatter is not shown from one of system menus by default, or was it me being lazy to look deeper from my panels.

Here is another gnome way of having a floppy formatter. This gfloppy linux program can format in different filesystem types including DOS(FAT) with a variety of floppy density types too. And I noticed it is installed by default.

Just make sure you're floppy drive is properly connected and enabled.

Just press Ctrl+F2, enter the command "gfloppy" and you're good to go.

f-spot Gnome photo manager install howto

Do you know that Gnome personal photo manager F-Spot is copyrighted by Novell Inc.?

Yes it is.

F-Spot is a nice application designed to provide personal photo management to your GNOME desktop. Some features include photo tags, import, export, printing and advanced sorting of digital images.

F-spot Photo Manager Installation

How to install it :

# yum -y install f-spot

When installed, my USB devices like digicams, videocams and USBs are automatically detected. Therefoe, f-spot makes use of dbus session bus. This would require you to turn on your message bus service like so

# service messagebus start

Great Gnome photo management alternative.

VLC media player install howto

How to I play CD / DVD?
How to install VLC?
How to play MPEG, MP#, OGG, other video and audio format?
How to play audio streaming in firefox browser?
How to install cross-platform media player?

There are a lot of opensourced alternatives playing media . One of my favorite is VLC .

Most features are:
* It is a free cross-platform media player
* It supports a large number of multimedia formats, without the need for additional codecs
* It can also be used as a streaming server, with extended features (video on demand, on the fly transcoding, and more)
* It plays MPEG-1,MPEG-2,MPEG-4,DivX, mp3, ogg, DVD, VCDs, and more video and audio formats!

Here's how to yum install :

# yum -y install vlc

and for firefox plugins

# yum -y install mozilla-vlc.i386

VLC in action from their site:



Goodluck!

VLC - GNU/GPL

ping IP subnet block howto

Here's a quick way on how to send ICMP echo request to a group of host to determine if they are responding or unreachable.

There are only a few advantage of using fping instead of ping linux command. One is you don't need to create a shell script that pings list of IP address from a batch files. With fping, you can try to ping a group of consecutive IP address in just a single command. Another benefit from using fping is it jumps on sending the next ICMP echo request to a host on a round-robin fashion, just like calling ping while feeding it with another IP address.

Like so:

# fping -g 192.168.1.0/24

# fping -g 192.168.1.0 192.168.1.255

which sends ICMP echo requests to the full block of CLASS C IP address from 192.168.1.1 to 192.168.1.254.

You might want to try

# fping -g 192.168.1.0/27

TIP: find and delete files recursively

Quick and dirty way of deleting a file named "vertito" recursively starting from / .

Let's find those files named "vertito" and list them out first:

# find / -name vertito -exec ls -la {} \;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r-- 1 root root 0 2007-07-17 22:52 /home/ver/vertito
-rw-r--r-- 1 root root 0 2007-07-17 22:52 /home/folder2/vertito
-rw-r--r-- 1 root root 0 2007-07-17 22:52 /home/folder1/vertito
-rw-r--r-- 1 root root 0 2007-07-17 22:52 /home/folder3/vertito
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/ = find the file starting from this folder
vertito = the name of the file
-exec = and execute the next command when item is found
ls -la = list more file's info
\; = loops back for a command redo

You can use wildcard but be very careful with it as you might delete critical files using this.

Once confirmed for deletion, delete them recursively:

# find / -name vertito -exec rm -rf {} \;

Cheers

list out opened host ports howto

Opened host ports are usually the most non-physical direct way of forcing entry remotely.

Here you would see several tools and ways how to list out your currently opened ports from your managed linux box.

Let's view our first attempt to list out those opened and used ports.

# netstat -panut | grep LISTEN

We used the linux command grep to filter LISTENing ports only from the resulting output.

or

# netstat -ntl

Take a look of the sample output from issuing the above command :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6536/sshd
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1819/named
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1819/named
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With reference to the first resulting line, basically explained below:

0.0.0.0:* = basically means that the port is opened from all host's IP address
tcp = would be the protocol used by the daemon service for establishing communication
22 = is the specific port for which the service is currently listening from
sshd = the daemon/application service which is currently listening from that specific port

You can squeezed out more likely the same info when issuing:

# ss -a | grep LISTEN

Let's use a deeper port scanning commands here and use it with our localhost IP address like so:

# nmap -P0 localhost
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting Nmap 4.20 ( http://insecure.org ) at 2007-07-17 22:29 WAT
Interesting ports on yourhost.domain.com (127.0.0.1):
Not shown: 1693 closed ports
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
778/tcp open unknown
953/tcp open rndc

Nmap finished: 1 IP address (1 host up) scanned in 0.082 seconds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Linux command nmap is referred to as a handy swiss knife for probing a particular host for possible opened ports, that reminds me of netcat as well, but the blog would not be covering any of that hacking stuff here. :) Going back, check out moer nmap parameters

# man nmap

Try

# nmap -v localhost

So how do you verify further that the port you are referring to is actually open. This is simply done again by one of the most famous tool mostly used with linux and routers

# telnet localhost 22

Telnets you to locahost on port 22 for testing if the actual host's port is really open.

If the port is actually open, you would be dropped inside that port daemon service for further awaiting service commands. Press ctrl+], enter and quit. As you are not inside to do something harmful!

So, basically, you can now list out your opened ports and develop a more likely tools and approach on getting further info with the host and its ports using these linux commands.

Be reminded that most linux commands used have always more and better command line parameters that simply comes with it.

Have a nice day ahead!

TIP: linux process priority scheduling management

One way to alter process priority is by using renice linux command.

RENICE!

Renice says:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Renice alters the scheduling priority of one or more running processes. The following who parameters are interpreted as process ID’s, process group ID’s, or user names. Renice’ing a process group causes all processes in the process group to have their scheduling prior-ity altered. Renice’ing a user causes all processes owned by the user to have their scheduling priority altered. By default, the processes to be affected are specified by their process ID’s.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can basically apply renice linux command to currently running process and linux daemon, in which, you are trying to avoid service or daemon restart/reload, in a nice way. If you wish to make a currently running program or daemon faster, renice could be one of your friends here.

Let us say, your proxy uses squid service and by default, squid service was launched as a daemon by linux with a 0 (zero) nice value.

Let us view it:

# top -b -n 1 | grep squid
shows

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1849 squid 13 0 311m 307m 2172 S 0 30.5 51:16.42 squid
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, let us modify its priority process nice value with -2

# renice -3 1849
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1846: old priority 0, new priority -3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

EDITED: (+19 instead of +20)
Remember, the lower the value it becomes, minimum (-20), the higher priority and attention it gets from linux OS. That means +19 is the least priority. Anything negative, the thread process or group of process runs faster.

Now, you proxy users would somehow enjoy more of your squid proxy aside from optimizing your squid.conf values.

Now, let us not forget the nice word here.

NICE!

By default, you could also launch a program with a default priority value using "nice" linux command combined with your scheduled midnight cron jobs like your backup shell scripts. By default, a zero priority (0) value is being used when launching any linux application.

Wonderfully issue:

12 01 * * * nice +5 /root/backup.sh > /dev/null 2>&1

which runs the backup shell script without being noticed during midnight hours, while doing the backup script thing.

Lovely.

TIP: spammer sending email using squid

Have you spotted your squid log files of any spammer attempts trying to send email from squid port?

Well, one dirty way of checking your squid logs of these spammer attempts trying to send emails using tunnelled SMTP via squid port.

# cat /var/log/squid/access.log* | grep '\:25'

Here's a few line samples:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1179265950.734 0 220.137.80.170 TCP_DENIED/403 1342 CONNECT msa-mx4.hinet.net:25 - NONE/- text/html
1178647576.706 1 222.156.67.109 TCP_DENIED/403 1346 CONNECT maila.microsoft.com:25 - NONE/- text/html
1180721897.385 146 220.137.85.214 TCP_DENIED/403 1344 CONNECT msa-mx10.hinet.net:25 - NONE/- text/html
...
truncated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Well, they are basically denied by squid.

But some provider and other websites automatically blocked these attemtps from their logs.
Logically, that could be a reason why your proxy IP address is being blocked by those providers and sites.

You could block those harsh IP address by probably script kiddies trying to test your squid and smtp port or atleast alerts you by email.

# route add -host IP-ADDRESS reject

does that.

remount partition as read only howto

Here's a tip on remounting partitions. Usually /boot is mounted as read-write linux filesystem by default installation. If you also feel that your /boot should not be changed, modified or upgraded, you can just remount them as read only partition without booting your linux system.

As root:

Go to /boot partition
# cd /boot

Create a dummy file
# touch newfile
# mount -o remount,ro /boot

Try adding and deleting some files now

# touch newfile2
# rm newfile

Error: Read-only file system

Now, your /boot is mounted as read-only filesystem. Make it permanently using /etc/fstab.

Cheers

additional swap file howto

First, we need to know what is swap memory?
Generally, this is a temporary memory storage for an OS to utilize while the OS is trying to get more busy process managing another separate threads from another running applications.

Assuming you already have an existing swap partition, which is usual by default installation, and we would like to have additional swap memory by adding swap file, say on a different partition or harddrive, here's how to do it while inside your redhat based ditro:

VIEW CURRENT SWAP :

# cat /proc/swaps

Similarly, you'll see

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 3904 -1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Currently, I am using a swap partition located from /dev/sda6. Take note of this.
Alternatively, here are the other ways to get the same swap info further:

# free
# fdisk -l | grep swap
# cat /etc/fstab | grep swap
# top -b -n 1 | head -5 | tail -1

CREATE SWAP FILE ON EXISTING PARTITION:

Since we already have a swap memory using swap partition, let us try to add and create additional swap memory using swap file. But this time, we would create it in an already existing linux (after installation), and into a different partition separate from existing swap partition.

Our current swap partition was /dev/sda6. From here, and for a test, let us try to create additional swap memory using a new swap file and placed it to /home/swap .

# cd /home/swap

Here, create a 2 MB swap file named newswap like so

# dd if=/dev/zero of=newswap bs=1024 count=20000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20000+0 records in
20000+0 records out
20480000 bytes (20 MB) copied, 0.115077 s, 178 MB/s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ls -la newswap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r-- 1 root root 20480000 2007-07-17 17:07 newswap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, set it up and inform linux its a swap file

# mkswap newswap
Result:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Setting up swapspace version 1, size = 20475 kB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Before we add the new swap file, let's note of our current swap info

# free
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Swap: 2104472 7288 2097184
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# cat /proc/swaps

shows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 7288 -1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, activating the new swap file under /home/swap, still as root

# swapon newswap


SWAP VERIFICATION:

# cat /proc/swaps

will now show
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 7288 -1
/home/swap/newswap file 19992 0 -3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The same with
# free


shows your newly created swap file from a different / partition

Basically, this goes the same with a new swap file from a different harddrive. Simply mount the new harddrive and prepare a new folder with it for new swap file

# mount /dev/sdb1 /mnt/newharddisk
# cd /mnt/newharddisk
# mkdir newswapfolder
# cd newswapfolder
# dd if=/dev/zero of=newotherswap bs=1024 count=20000
# mkswap newotherswap
# swapon newotherswap

# cat /proc/swaps
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filename Type Size Used Priority
/dev/sda6 partition 2104472 7288 -1
/home/swap/newswap file 19992 0 -3
/mnt/newharddisk/newotherswap file 19992 0 -4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now you have 3 swap files working :) which is not adviseable, but taken and hereby shown for the sake of creating and deleting swap files.

DISABLING SWAP

Turning off is as easy as

# swapoff swapfilename
# rm -rf swapfilename

HTH

Monday, July 16, 2007

CrossOver install howto

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CrossOver linux allows you to run many popular office productivity software applications and games, such as Microsoft Office, Lotus Notes, Microsoft Project and Visio, graphics applications like Macromedia Dreamweaver MX, Flash MX, and Adobe Photoshop, games such as World of Warcraft and Half-Life 2, and many more. Not only that, but CrossOver Linux also allows you to use many Windows Web browser plugins, such as QuickTime and Shockwave, directly on your Linux browser. No Windows Operating System license required; CrossOver is a complete replacement for your Windows OS as far as your applications are concerned.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Short word - lets you run windows-based software using linux environment including M$ Office products without critical error executing window$ EXE and DLL files.

Here's a quick way to install CrossOver software by CodeWeavers

Assumming you have already purchased and downloaded your commercial crossover rpm installer file, say crossover-pro-6.0.0-1.i386.rpm. To install, simply as root:

# rpm -ivh crossover/crossover-pro-6.0.0-1.i386.rpm

Your display should be similar to this:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Preparing... ########################################### [100%]
1:crossover-pro ########################################### [100%]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Click Applications and choose CrossOver and you are good to go.

To initialize, go Applications - CrossOver - then select Install Windows Software".You might need to choose from 3 different options. Here, I am going to choose Private Multi-User Mode. You can alternatively use the first option offered. This would bring you to this window:



I have managed to skip some window screen installation so as to have a brief screenshots too!



For testing, we need to download and have a windows-based installer. I would choose remote administration software called Remote Admin. The file was in zip file format, so I have to unzip them to temp folder using linux unzip, and made the EXE file executable in linux so I could execute them as binaries in fedora.

# chmod 755 radmin.exe

Quickest way is to fire it up!
# ./radmin.exe

Here goes my screen radmin (tm) installation screen:


CrossOver (TM)website here

I smiled when the installation advised me to reboot my linux system, just like in window$ LOL :)

After successful installation, you can now proceed to launch the window$-based software. Just click Applications from your taskbar, select Windows Applications - Programs - and choose the program you wish to launch, wonderful.


All software mentioned are owned, managed and licensed by their own trademarks. This document is here to serve as my own personal crossover install howto. It works for me. Use at your own risk, you've been warned !

:)

system-config-securitylevel-tui and lokkit howto

Here is a text-based user interface you can use on modifying and changing your system security level settings. This comes very helpful specially to those who are yet newbies with regards to system security and/or firewall basic settings.

Issue

# lokkit

alternatively

# system-config-securitylevel-tui


Launched as root, this would use a text-based user interface which customizes your firewall security settings including basic SELinux . SELinux customization using this approach is basically simple, just letting you choose among Enforcing, Permisive, and Disabled.

Sample of lokkit main menu:



By clicking "Customize", you'll arrive to further firewall setting customization like so:



This gives you the opportunity to add and open more specific ports so they could be public. Have extra care on opening ports. As much as possible, avoid opening ports that you don't usually need to be open on regular and daily basis. These could increase the chance of other host probing and trying to connect with that specific ports for whatever reasons they might have.

After having made additional changes, click OK and exit. Now check out your newly saved firewall settings.

# more /etc/sysconfig/iptables
# less /etc/selinux/config

Launching as root

# system-config-securitylevel

would give you the GUI version captured below:



After doing it over and over again, you can now begin directly editing and customizing the iptables file /etc/sysconfig/iptables

# service iptables restart

would restart and reread your newly edited firewall settings.

Was this helpful?

format a windows partition from linux hadrdisk

Oh, here's the quickest way to make ext2/ext3 filesystem from an existing windows partition of your linux-enabled harddrive.

First step is to make sure your windows partition is not currently mounted.

Let'us use an alternative way like

# df -ah

which shows file system disk space usage. Sample result

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17G 13G 3.7G 78% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 248M 0 248M 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
/dev/sda4 19G 6.5G 13G 35% /win
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# mount -l

that shows currently mounted partitions and devices. You'll see similar lines

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw) [/boot]
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda4 on /win type fuseblk (rw,nosuid,nodev,noatime,allow_other,blksize=4096)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# fdisk -l

now shows us all available and detected storage devices and their corresponding partitions like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Disk /dev/sda: 40.0 GB, 40019582464 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 13 104391 83 Linux
/dev/sda2 14 2431 19422585 8e Linux LVM
/dev/sda4 * 2432 4864 19543072+ 7 HPFS/NTFS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, the windows partitioned needs to be umount before we proceed making it as ext2/ext3 filesystem. As root

# umount /dev/sda4
# mkfs.ext3 /dev/sda4

Why /dev/sda4? Check out the result of your fdisk -l and current mounted points. This partition
is also the partition we want to initialize and reformat with linux ext3 filesystem.

More details
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2443200 inodes, 4885768 blocks
244288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
150 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Simply remount it

# mkdir /mnt/newdisk
# mount /dev/sda4 /mnt/newdisk

And make the newly mounted partition permanently by adding similar lines to /etc/fstab

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/dev/sda4 /mnt/windows ext3 defaults 0 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/dev/sda4 = your newly formatted partition
/mnt/windows = mount points
ext3 = filesystem type
0 0 = which means fsck does not need to check it


# cd /mnt/windows
# ls -la

That is all.

TIP: monitoring while mounting USB devices

Here are a few basic pointers you can consider when having problems mounting your USB flash disk.

Login with your terminal and be ready as root before you plug your USB disk. Fire up your message monitoring command like so

# tail -f /var/log/messages

Plug your USB into any USB ports, and watch the changes with the monitoring command

You are going to see similar lines like these:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jul 16 16:44:03 ver kernel: scsi 6:0:0:0: Direct-Access USB 2.0 Flash Disk 2.00 PQ: 0 ANSI: 2
Jul 16 16:44:03 ver kernel: SCSI device sdc: 2070527 512-byte hdwr sectors (1060 MB)
Jul 16 16:44:03 ver kernel: sdc: Write Protect is off
Jul 16 16:44:03 ver kernel: sdc: assuming drive cache: write through
Jul 16 16:44:03 ver kernel: SCSI device sdc: 2070527 512-byte hdwr sectors (1060 MB)
Jul 16 16:44:03 ver kernel: sdc: Write Protect is off
Jul 16 16:44:03 ver kernel: sdc: assuming drive cache: write through
Jul 16 16:44:03 ver kernel: sdc: sdc1
Jul 16 16:44:03 ver kernel: sd 6:0:0:0: Attached scsi removable disk sdc
Jul 16 16:44:03 ver kernel: sd 6:0:0:0: Attached scsi generic sg3 type 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From the last 3 lines, sdc1 is your working USB without any error:

You can see device and bus details like

# lsusb

and a more verbose

# lsusb -v

Now mount it:

# mkdir /mnt/usb
# mount /dev/sdc1 /mnt/usb

Mounting USB disk as easy as 1, 2, 3.

Try to redo it again using different USB port and carefully watch the messages log. You'll notice the it was detected on different USB ports, take note of that port, say /dev/sdd1, and use it as reference to your mounting command.

You can do this with any USB devices like digicams, webcams, videocams, external USB harddisk and DVD/CD writers etc, it helps.

There you go.

zero-sized a file without permission / ownership changes

Let us assume we have 120GB mail spool file named "bigfile" located somewhere in /var/spool/mail .

The objective here is to initialize the file, so that it would have zero (0) filesize. This should be achieved with the following conditions without changing the file's permission and ownership , or even deleting and re creating the file.

Here is an old one liner trick that does the job:

Just CD to that working directory and view the file first like so

# cd /var/mail
# ls -la

-rw-rw---- 1 vertito mail 120000000000 2007-07-16 16:24 bigfile

Simply as root

# cp /dev/null bigfile

This would copy nothing and just overwrite the file with zero-sized data.

# ls -la

-rw-rw---- 1 vertito mail 0 2007-07-16 16:24 bigfile

See the difference?

:)

TIP: auto create mail spool when adding user

The linux command "useradd" creates a new user or update default new user information from your linux box.

By default behaviour, useradd does many other default things besides from creating the user account.

Man says:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line and the default values from the system. Depending on command line options, the useradd command will update system files and may also create the new user’s home directory and copy initial files. The version provided with Red Hat Linux will create a group for each user added to the system by default .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

One thing that useradd does not do is create var mail spool during the creation or adding of new user accounts. Changing this behavious is as easy as:

# cd /etc/default

# cat useradd

You will then see similar lines like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Simply append the below line:

CREATE_MAIL_SPOOL=yes

and save.

TO TEST:

# useradd -d /home/vertito vertito
# cd /var/spool/mail
# ls -la vertito
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-rw---- 1 g mail 0 2007-07-16 16:24 vertito
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You'll now have a zero-sized (0) mail spool file owned by the newly created user.

Hope this helps.


CREATE_MAIL_SPOOL

md5sum checksum howto

What is md5sum?

From Wikipedia:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
md5sum is a computer program which calculates and verifies MD5 hashes, as described in RFC 1321. The MD5 hash (or checksum) functions as a compact digital fingerprint of a file. It is extremely unlikely that any two non-identical files will have the same MD5 hash (although it is certainly possible).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let us try to use it then to verify the file integrity of an image file named F7 DVD ISO, for example.

# md5sum F-7-i386-DVD.iso

Since we are comparing md5 checksums, the result of this command should be exactly the same with the ones we get from the site of where we dloaded the ISO image file.

Now, if we want to do it for multiple files, say 3 or more ISO image files, we can create a check.txt text file and populate the file with the correct values:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
355bdb01b0268a4bb7c757f2737dcf7c F-7-i386-DVD.iso
89d337f5543474532027950b44ecbdd5 FC-6-i386-DVD.iso
b5633ee6ee3b2e10d92672c74e594d75 CentOS-5.0-i386-bin-DVD.iso
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** Notice the 2 spaces between the two columns.

First column is the md5 string and second column is the location of the file. To check all of them, do this:

# md5sum -c check.txt

It would give you similar lines like this

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F-7-i386-DVD.iso: OK
FC-6-i386-DVD.iso: OK
CentOS-5.0-i386-bin-DVD.iso: OK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remember, if the md5sum result doesnt match, it is not adviseable to burn that ISO image.

HTH

IP address to country lookup howto

Using the web, you would find sites that can provide you the country location of a particular IP address. Those site are making use of an IP address to country lookup mechanism incorporated with their site.

Now, how you can do it without going to those IP to country lookup converter sites?

GeoIP is one way to do it.

It is a C library that enables the user to find the country that any IP address or hostname originates from. It uses a file based database that is accurate as of March 2003. This database simply contains IP blocks as keys, and countries as values. This database should be more complete and accurate than using reverse DNS lookups

Here's a way on how install and use it using fedora box. As root:

# yum -y install GeoIP

Let us test the software and lookup the country of this particular IP 198.6.1.2 .

# geoiplookup 198.6.1.2

Output:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GeoIP Country Edition: US, United States
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TIP:
Remember that we have tackled issues that covers calling OS binaries, bash scripts, and/or perl scripts from a web page? You can make use of that to achieve this web-based IP to country lookup.

Have a nice day!

Sunday, July 15, 2007

gnome mail notification install howto

Busy with the phone support? And don't have time to login and check your emails remotely?

Here you go, a gnome mail notification that notifies you visually with popup notifications and sounds for your newly arrived emails !

Just make sure you are using X, then simply run as root:

# yum -y install mail-notification

It works like a kling!

MORE : Site for Mail Notification

Saturday, July 14, 2007

add new harddisk to existing linux system

This page is intended for everyone who has existing rpm-based linux system from their harddrive and wants to add and install a new harddisk for more storage capacity. I am going to cover the simplest way to add a new harddisk in temrinal mode.

First, you need to confirm that you have physically connected the new harddisk to your system and you are currently inside the existing linux system.

Let us show your current harddisk parameter using fdisk.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@ver ~]# fdisk -l

Disk /dev/sda: 80.0 GB, 80025280000 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 5864 47102548+ 83 Linux
/dev/sda2 * 5865 5877 104422+ 83 Linux
/dev/sda3 5878 8185 18539010 83 Linux
/dev/sda4 8186 9729 12402180 5 Extended
/dev/sda5 8186 9467 10297633+ 83 Linux
/dev/sda6 9468 9729 2104483+ 82 Linux swap / Solaris

Disk /dev/sdb: 40.0 GB, 40019582464 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 2422 19454683+ 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sdb2 2423 4865 19622925 f W95 Ext'd (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sdb5 2423 4865 19622893+ 7 HPFS/NTFS

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

As you can see, /dev/sda is my existing harddisk with linux installed from it and
my newly plugged harddisk /dev/sdb with existing 3 window$ partition on it namely
/dev/sdb1, /dev/sdb2, /dev/sdb5 .

I am going into more detailed contents of the new harddisk by doing so:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@ver ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 4865.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

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

And press M for menus:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

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

Press p to view current partition tables with the new harddisk like so


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40019582464 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 2422 19454683+ 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sdb2 2423 4865 19622925 f W95 Ext'd (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sdb5 2423 4865 19622893+ 7 HPFS/NTFS

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


which shows 3 window$ partition. Let us erase them by press d for deletion like so:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Command (m for help): d
Partition number (1-5): 1

(1 stand for first partition)

Command (m for help): d
Partition number (1-5): 2

(2 for second partition and view the partition back again.)

Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40019582464 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


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

which shows and confirms that those partitions were deleted from fdisk memory table. We need to write them permanently to disk like so:


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

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Drops you back to shell.

Since the partition were now deleted, here I am going to create a new linux ext3 partition like so :


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@ver ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 4865.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40019582464 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


p show no partition at all, so we are going to proceed on creating a new table by pressin n .

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4865, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865):
Using default value 4865

and using the maximum storage capacity that fdisk found, which is 4865. I just hit ENTER for default values. Let me examine the partition table again:

Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40019582464 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 4865 39078081 83 Linux

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


As you can see, /dev/sdb1 is now added with type ext3 (83) as chosen file system .

Back to shell, let us view all the harddisk and their parition again by issuing

# fdisk -l

which would show us similar lines like these

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Disk /dev/sda: 80.0 GB, 80025280000 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 5864 47102548+ 83 Linux
/dev/sda2 * 5865 5877 104422+ 83 Linux
/dev/sda3 5878 8185 18539010 83 Linux
/dev/s


da4 8186 9729 12402180 5 Extended
/dev/sda5 8186 9467 10297633+ 83 Linux
/dev/sda6 9468 9729 2104483+ 82 Linux swap / Solaris

Disk /dev/sdb: 40.0 GB, 40019582464 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 4865 39078081 83 Linux

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


which show my first and second hardisk with their corresponding partition tables and numbers.

Basically, we have just prepared the harddisk and allocates the number of partition we need.
For now, we have just created a single partition with the new installed harddisk . The old
window$ parition were totally deleted as well.

We are not done yet, we need to initialize and format the hardisk with journaling system while checking for bad blocks as well, like so:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@ver ~]# mkfs.ext3 -c -j /dev/sdb1

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4889248 inodes, 9769520 blocks
488476 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
299 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624

Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you are in a hurry, you can just issue :

# mkfs.ext3 /dev/sdb1

Now, the harddisk is ready. You can mount it like

# mkdir /mnt/new

# mount /dev/sdb1 /mnt/new

Adding them to /etc/fstab would make the mounting permanently.

Now, enjoy your new harddisk.

Hope this helps.

EDITED:
Attached is another redo of adding a new harddisk uploaded to youtube. :)



Friday, July 13, 2007

TIP: block an IP address

Here is a basic way to block a particular IP address using iptables

Say the IP address is 192.168.0.254, just launch your terminal editor and make sure you have these line

# iptables -I INPUT -s 192.168.0.254 -j DROP

To view them and other rules

# iptables -L -n

Alternatively, you might want to use the route command like so:

# route add -host 192.168.0.254 reject

to block the same IP address from conncting to your host.

These comes very hand when used inside shell scripts by batches, let's say you want to block non-consecutive 512 sets of IP address from the server, you can just create file and throw it to the script that process them, like so


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/sh
for i in $(< bad-ip.lst) ; do
iptables -I INPUT -i eth1 -s "$i" -j DROP
# OR
route add -host $i reject
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

File bad-ip.lst filr contains the list of IP addresses separated by lines like so:

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

192.168.0.252
192.168.0.233
192.168.0.212
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Basically, that's it.

disk space report

Diskspace reporting is as easy as

# df
# df -ah
# df -vh

which would show you something like these

/dev/cciss/c0d0p2 4.8G 419M 4.1G 10% /
/dev/cciss/c0d0p1 97M 16M 76M 18% /boot
/dev/shm 252M 4.0K 252M 1% /dev/shm
/dev/cciss/c0d0p6 59G 26G 30G 47% /home
/dev/cciss/c0d0p7 3.8G 2.6G 1.1G 71% /usr
/dev/cciss/c0d0p5 62G 34G 25G 58% /var

If you are using LVM for spanning disk support, you might be seeing lines like these

Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p2 22G 12G 9.2G 56% /
/dev/cciss/c0d0p3 43G 32G 8.5G 80% /backup
/dev/cciss/c0d0p1 99M 20M 75M 21% /boot
/dev/mapper/VolGroup00_home-LogVol00_home 67G 14G 49G 22% /home
/dev/mapper/VolGroup00_var-LogVol00_var 67G 16G 47G 26% /var


Sending email via CLI was covered basically, so these data could be helpful to you when combined with shell scripts, that checks for certain harddisk capacity thresholds and alerts your group email via SMS/email if that specific unsafe threshholds were met. It could be accomplished using a combination of string manipulation and parsing linux commands inside a simple bash script.

Here is a basic shell script sample:

#!/bin/bash
umask 077
df -vh | mail -s "My Server 1 Disk Space Report" isp@gmail.com

and add it to your cron like so

01 05 * * * /myscripts/diskspace

which sends email on daily basis.

Furthermore, you could create a script that spits out those numeric values where MRTG can chomp them and reflect them to your MRTG graph.

HTH

more trace route command alternatives

Here are alternatives on tracing a host or IP address. Basically, these linux commands print every hops taken going to a particular host or ip address - routes.

Am going to use 198.6.1.2 as the host we want to trace.

# trace 198.6.1.2

Basically prints the trace hops going to host 198.6.1.2

# traceroute 198.6.1.2

# tracepath 198.6.1.2

does tracing with MTUs discovery, and for IPv6

# tracepath6 198.6.1.2

# mtr 198.6.1.2

mtr uses the combination of traceroute and ping commands and shows more details such as packet loss,average/best/last and more latency stats.

You can make use of other advanced command line parameter these commands support.

Wednesday, July 11, 2007

changing your hardware / software clock howto

Every system has a hardware clock besides from system clock. Hardware clock is hardware and software clock is software. Software clock stops when you do system poweroff and while hardware clock continues to tick.

View your hardware clock by issuing as root

# hwclock

and your software clock

# date

Should you find any differences between these two, here is how you could change them and make them show the same values together.

# hwclock --systohc

to sync hardware clock from software clock.

And vice versa, syncing software clock from hardware clock would be:

# hwclock --hctosys

HTH

other interesting ping commands

One of the most commonly used linux commands when trying to reach a host is the ping command.

Basically ping commands tries to reach a host by sending out ICMP ECHO_REQUESTT and wait for a particular ECHO reply packets to know if the network host is reachable or not. However, if ICMP command is being blocked, it gives you a "Reply time out".

Here are alternative linux commands for determining a network/internet host.

# yum -y install fping
# fping 198.6.1.2

gives you a human readable status of the host, like the lines below

198.6.1.2 is alive
198.6.1.254 is unreachable

# arping 198.6.1.2

sends out ARP REQUEST and return with MAC address and average latency reply. Mainly used for getting the MAC address if the host is confirmed alive.

# ping6 198.6.1.2

for ping IPV6 network address

# irdaping

sends out irDA test frames. I never tried out this one yet due to limited resources.

# l2ping -i hci1

sends out L2CAP echo request to the bluetooth device #1, the first available bluetooth device


HTH

send email via CLI howto

Here are a few ways on how to send email using terminal - CLI mode.

We are going to use mail command, as root:

# mail -s "test email" isp@google.com -c owner@google.com -b staff@google.com

This would send a blank email with "test email" as its subject. The email would be send to isp@google.com with CC to owner@google.com and blind CC to staff@google.com

# echo "How are you" | mail -s "test email" isp@google.com -c owner@google.com -b staff@google.com

would include "How are you" line as the body message of the email. This could be useful and incorporated from your shell scripts that does a particular function and informs you by email of its function result.

Another way is to

# mutt -s "test email" -a /root/pic.jpg isp@google.com -c owner@google.com -b staff@google.com

would send email with "test emai" as subject name. Email is addressed to isp@google.com, with CC to owner@google.com and BCC to staff@google.com. You will noticed the new parameter. This email would attached /root/pic.jpg picture to this email.

Now, piping it like so

# echo "How are you" | mutt -s "test email" -a /root/pic.jpg isp@google.com -c owner@google.com -b staff@google.com

would include "How are you" as body of the email.

Alternatively, you can install the old text based mail user agent pine

# yum -y install pine
# pine

Interactively, pine gives you text based menus to create, send and even check your current mails via terminal.

adding static route howto

A route is is used by your kernel to determine how to get someplace on a network. Routes are stored in the linux kernel and are accessible for viewing and editing to users.

Working with routes.

To view your current default route

# route -n

The result table would look like this

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

To add a route you must first know the network address of the network you wish to add, and the gateway to that network. Let us say we need to add the network of 10.0.0.0 with netmask 255.255.255.0 to be routed to 192.168.1.254 as its default gateway. here is how to do it:

# route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.1.254

This would add the network 10.0.0.0 with a netmask of 255.255.255.0 and a gateway routed to 192.168.1.254.

Basically that's it.

You can also try an anternative route command

# ip route


HTH

Tuesday, July 10, 2007

send message to all logged in users

here's a quick way of sending messages to all currently logged in users via their terminal.

# wall
I need to reboot this server - sysad #1

press control + d

linux makes things smooth and flexible

# wall "I need to reboot this server - sysad #1"

If you want to appear the message repeatedly until terminated

# yes "I need to reboot - sysad #1"

press control+d to kill it

Sweet combination.

# yes "I need to reboot - sysad #1" | wall

Works out right.

unzip zip untar tar bzip2 bunzip2 gzip gunzip files in linux howto

Well, I receievd an email which fairly ask me about zipping in linux. Here are simple ways to package, compress and uncompressed files in linux. For simplicity, only the basic parameters were used from the sample issued commands.

Let us change folder first and go to /tmp temporary and create 3 zero-sized files.

# cd /tmp
# touch file1 file2 file3

Now, do our thing

# zip zipped.zip *
# ls -la
# unzip zipped.zip
# rm -rf *.zip


# tar zcvf tarred.tgz *
# ls -la
# tar zxvf tarred.tgz
# rm -rf *.tgz

# bzip2 *
# ls -la
# bunzip *
# rm -rf *.bz

# gzip *
# ls -la
# gunzip *
# rm -rf *.bz

Most of them would accept CLI parameters. Appending --recursion or -r or -R would try to traverse the directory structure recursively.

HTH

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