Archive for the ‘UNIX’ Category

How to find the IP/MAC addresses of devices on your network

December 28, 2009

Every once in a while I need to find out the IP & MAC addresses of various devices in my home network. Here is a small shell script that will find this information. It takes a while to run. Without the initial ping, the arp command will not return the necessary data on an IP address that you’ve never visited from the machine that you’re running this script on.

Perhaps there is a better way of finding the IP/MAC addresses of devices on your network. If so, please let me know.

#!/bin/sh

for (( i = 0; i < 256; i++))
do
    ping -c 1 10.0.1.$i
    arp 10.0.1.$i
done

How to change the hostname in Fedora 8

February 26, 2008

Depending on whether you’re using DHCP or a static IP, you may need to edit one or both of these two files: /etc/hosts and /etc/sysconfig/network. For static IP I edited both files. Once you’ve made the change, you’ll need to restart Fedora.

How to prepare the disk for Fedora 8 and Xen

February 24, 2008

You should install a minimal Fedora 8 on a server that you plan to run Xen on. This includes a minimal logical volume for the host; this way you can add additional logical volumes: one for each Xen guest. Before you can do this you’ll need to understand the Fedora Logical Volume Manager (LVM2).

Let’s start with a bit of introduction. On UNIX a file-system is a structure that is defined on a set of storage devices. A storage device must be partitioned before you can create a file-system or a logical volume. Once a file-system has been created, it can be mounted on a directory.

Linux supports different types of file-systems. For example, local file-systems such as ext2, ext3, ext4, FAT, NTFS, HFS, HFS+, JFS and XFS; or network file-systems such as NFS, OpenAFS and GFS.

For Xen, a file that contains an image of a file-system is easiest for a para-virtualized virtual machine. Files that contain an image of a file-system are accessed via Xen blktap or the loop-back mechanism.

A file that contains an image of a hard disk is the easiest for a hardware virtual machine (e.g., if you plan to run an unmodified guest such as Windows). These files are accessed via hard QEMU disk emulation.

Before you can create a logical volume, you need to partition the physical drive. You do this by using the fdisk command. Next you’ll need to create a physical volume for each partition using the pvcreate command. After you’ve created a physical volume, you’ll need to add the physical volume to a volume group. You create a volume group using the command vgcreate. Next you’ll need to create a logical volume on the volume group. Finally, after you’ve created a logical volume, you are ready to create a file-system in it.

But first, here is the summary of the commands:

  1. fdisk /dev/hda
    Use the fdisk command to create one or more logical disks called partitions on the first IDE disk (hda).
  2. pvcreate /dev/hda1
    Creates a physical volume on each partition
  3. pvdisplay
    Displays the status and size of the physical volumes
  4. vgcreate VM /dev/hda1
    Add physical volume to a volume group
  5. vgdisplay VM
    Displays the status of a volume group
  6. lvcreate -L10G -n UBUNTU VM
    Creates a 10GB logical volume called UBUNTU on volume group VM. This command also creates an entry in /dev/mapper that maps the logical volume to the physical volume that it was created from. You can access a logical volume from /dev/VM/UBUNTU
  7. lvdisplay
    Displays the status and size of logical volumes

How to tail log file on a SSH site

January 14, 2008

Quite often I need to tail a server log file on a site that I need to login to using SSH. The task of opening a terminal, creating a SSH session, login, and then tail does get tedious. So here comes ssh with the -t option. Here is an example, where you CD to the appropriate folder and then tail the log:


ssh -t root@myserver.com 'cd /var/log/tomcat/myserver; tail -f catalina.out; $SHELL -i'


Follow

Get every new post delivered to your Inbox.