Thursday, April 28, 2011

Linux Bluetooth File Transfer (mobile to pc)


Firstly, transfering a file from a bluetooth device to Linux Fedora Core 5 is easy. The FC5 kernel is 2.6.18-1.2200 on a 32 bit machine.
I have the following: A Motorola V360 with Bluetooth. My PC is connected to a bluetooth doggle (blue thunder). My desktop is on the default GNOME 2.14.3.

[OPTIONAL]
Install usbutils-0.71-2 as it helps to detect the USB bluetooth doggle.
As root
Code:
yum install usbutils
1. Ensure that the bluetooth clients are installed:
gnome-bluetooth
gnome-bluetooth-libs
Code:
yum -y install gnome-bluetooth gnome-bluetooth-libs
Dependency: libbtctl-0.6.0-5 and openobex-1.1-1
2. Ensure the Bluetooth service is running. Since my PC does not have Bluetooth, I need to plugin the bluetooth doggle now. Display the end of the log file.
As root
Code:
cat /var/log/messages
This will display some HCI device messages. Mine shows the following:
Oct 29 14:20:27 xcitebox hcid[27885]: HCI dev 0 registered
Oct 29 14:20:27 xcitebox kernel: hci_cmd_task: hci0 command tx timeout
Oct 29 14:20:27 xcitebox hcid[1630]: HCI dev 0 registered
Oct 29 14:20:28 xcitebox hcid[27885]: HCI dev 0 up
Oct 29 14:20:28 xcitebox hcid[27885]: Starting security manager 0
Oct 29 14:20:28 xcitebox hcid[1630]: HCI dev 0 up
Oct 29 14:20:28 xcitebox hcid[1630]: Starting security manager 0


As root
Code:
service bluetooth start
3. Test the connection by the following command:
As user
Code:
hcitool scan
4. At the phone
Select bluetooth link menu
->Set up ->Find Me

You should see that the hcitool scanning is able to find the phone.

5. Start the bluetooth client.

Application -> System tools -> Bluetooth File Sharing

On the phone send the image or any other data via bluetooth.
Example: On the phone select the Picture
-> menu -> copy -> bluetooth -> [Look for devices]
Select the Bluetooth doggle device

6. On the PC
When the bluetooth request is received a pop up box will appear
"Accept a file from <......your phone name...> "

Click "Accept"

Finally, you should be able to find the file in your home directory. Hope it works for you as simple as I have found it.

Linux Bluetooth File Transfer (pc to mobile)

This is continuation from the previous Howto I wrote. This assumes that you have manged to successfully transfer files from the bluetooth (phone) to PC. So now you want a file transfered to the bluetooth phone. Lets try this the simple way and that you have a standard setting on the bluetooth phone.
Before you start, check the following packages are installed:
gnome-utils-2.14.0-5.
gnome-bluetooth-0.7.0-2
gnome-bluetooth-libs-0.7.0-2
libbtctl-0.6.0-5
openobex-1.1-1

1. Ensure bluetooth service is running and detect services your phone provides
Code:

service bluetooth start
hcitool scan

Scanning ...
00:16:75:85:82:12 Moto V360 Nicholas

sdptool browse 00:16:75:85:82:12

2. On the FC5 PC.
As normal user.
Right click "Panel bar" -> "Add to panel" -> "Create a new launcher"
Click "Add" button and fillin as follows:

Name: Send via bluetooth
Generic name: gnome-obex
Command: gnome-obex-send %f
Type: Application
Icon: (Select the bluetooth symbol..looks like two arrow pointing to right on a blue pebble)

Click "Close"
Then Click "Close" button

3. Start bluetooth on the phone (I am using Motorola V360)
Menu -> bluetooth -> Setup -> Find Me

On the FC5 open Nautilus and search for a file type that the phone recognise. I am using JPEG file. Drag the file to the bluetooth icon on the panel.

Wait until a Window "Choose Bluetooth device" appears with your phone name. Click on the phone name and click "OK". On the phone you should see it is connecting and an "Incoming transfer" box appear". Click on "Accept" and wait for the file to be sent to the phone. Then click on "Save"

How to change the default run level of a RedHat 9.0 or Fedora Core Linux system

During the boot process for Redhat 9.0 and Fedora Core systems the init command opens the /etc/inittab file to decide what "runlevel" the system should be booted to. The /etc/inittab file is a plain text file that can be opened with your favorite text editor.

The relavent section of a sample /etc/inittab file is as follows:

# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

The key line in the example above is:

id:3:initdefault:

This tells the init process that the default run level for the system is run level 3. To change to a different run level simply change the number and save the /etc/inittab file. Before doing this, however, be absolutely sure you know which run level you want. Selecting the wrong runlevel can have serious consequences. To help with this a detailed description of the individual run levels is outlined in the table below:
Runlevel 0---> The halt runlevel - this is the runlevel at which the system shuts down. For obvious reasons it is unlikely you would want this as your default runlevel.
Runlevel 1---> Single runlevel. This causes the system to start up in a single user mode under which only the root user can log in. In this mode the system does not start any networking or X windowing, X or multi-user services. This run level is ideal for system administrators to perform system maintenance or repair activities.
Runlevel 2---> Boots the system into a multi-user mode with text based console login capability. This runlevel does not, however, start the network.
Runlevel 3---> Similar to runlevel 2 except that networking services are started. This is the most common runlevel for server based systems that do not require any kind of graphical desktop environment.
Runlevel 4---> Undefined runlevel. This runlevel can be configured to provide a custom boot state.
Runlevel 5---> Boots the system into a networked, multi-user state with X Window System capability. By default the graphical desktop environment will start at the end of the boot process. This is the most common run level for desktop or workstation use.
Runlevel 6---> Reboots the system. Another runlevel that you are unlikely to want as your default.

Creating iso images in linux


In windows XP, you would most probably use DVD/CD burning software such as Nero or Deep Burner to make ISO images, and software like alcohol 120% or daemon tools to mount the images.

In Linux, you can use the command line to both make and mount ISO images.

Firstly, the program ‘dd’ which comes standard on any Linux distro can be used to make an ISO image.

the program syntax is relatively simple, here is an example that would make an ISO image of my cdrom0 drive and save it in my home folder as backup_image.iso:
dd if=/dev/cdrom0 of=~/backup.iso
now to explain the command,

the first bit “dd” is the program name (note: dd stands for dataset definition, not data dump as it is mistakenly known as).

the next part of the command “if=/dev/cdrom0″ specifies the input for the program, in this case it is the device cdrom0 (my first CD/DVD drive)

the last bit of the command “of=~backup.iso” specifies the output path and name for the program, in this case the output is a file named backup.iso that is stored in my home directory. the tilde (~) specifies the home directory.

so there you go, a relatively simple method of creating an iso file in linux. You can even put this in a bash script and have the iso file tarballed and gziped and sent off to your file server for archiving, but thats for another article to cover.

the command dd has many more options than what I have shown such as the ability to select block size and write at a certian number of bytes at a time, all these options grant dd great flexibility. Infact, you could use dd to backup entire harddrives and make 1:1 copies of their filesystems. Even damaged drives can be recovered somewhat using dd as it is low-level and works with the raw data on the drive.

Now that you know how to make iso images using dd, you will want to know how to mount them. In linux this is easily achieved using the ‘mount’ command. The first thing you will want to do however, is to create a mount point for your iso image, so as root go ahead and create a directory named iso in /mnt. try using this command if your distro supports sudo -
sudo mkdir /mnt/iso
this creates a directory named iso in your /mnt directory , we will use this directory as a mount point for out iso image.

now mount the image -
sudo mount -o loop ~backup.iso /mnt/iso
this command mounts the backup.iso file found in your home directory to the mount point /mnt/iso the -o loop part of the command allows the iso file to be treated as a block device.

now that you have mounted the iso, go to your /mnt/iso directory and you should see that the iso contents are readable and usable. :D

to unmount the iso image, type in this command :
umount ~backup.iso

How do I reinstall a corrupted boot partition in Red Hat Enterprise Linux?

Issue

In a system where the "/boot" partition is a separate partition, when /boot is corrupted or be formatted mistakenly, you can not boot the system but do not want to reinstall the whole system.

Environment

  • Red Hat Enterprise Linux, all versions
  • /boot partition is installed on the first partition of your first disk
  • x86 architecture

Resolution

Reinstall /boot partition manually with the following steps:

1. Boot the system into rescue mode:

Insert the Red Hat Enterprise Linux CD #1 and boot your system. At boot prompt, type "linux rescue". This will start the rescue mode program.

You will be prompted for your keyboard and language requirements. Enter these values as you would during the installation of Red Hat Enterprise Linux.

Next, a screen will appear telling you that the program will now attempt to find a Red Hat Enterprise Linux installation to rescue. Select "Continue" on this screen.

At the "sh-3.1" prompt, chroot to /mnt/sysimage:

# chroot /mnt/sysimage

2. Make sure the boot partition is labeled as described in /etc/fstab. (Assuming the boot partition is /dev/sda1):

# e2label /dev/sda1 /boot

3. Make sure the boot partition is mounted:

# mount /dev/sda1 /boot

4. Mount the CD to install the following rpms:

# mkdir /mnt/iso 
# mount -o loop,ro /dev/hdc /mnt/iso
# cd /mnt/iso/Server
# rpm -Uvh --replacefiles --replacepkgs grub-0.97-13.i386.rpm
# rpm -Uvh --replacefiles --replacepkgs redhat-logos-4.9.16-1.noarch.rpm
# rpm -ivh --replacefiles --replacepkgs kernel-2.6.18-8.el5.i686.rpm

5. Install the GRUB:

# grub-install /dev/sda

6. If /boot/grub/grub.conf is lost, you need to create it manually. The following is a sample of grub.conf, please make sure the the file "vmlinuz-2.6.18-8.el5" and "initrd-2.6.18-8.el5.img" exist under the directory of /boot (which should be installed after step 4).
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu

title Red Hat Enterprise Linux (2.6.18-8.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/
        initrd /initrd-2.6.18-8.el5.img

7. Make a soft link to grub.conf:
# cd /boot/grub 
# ln -s grub.conf menu.lst

Mounting NFS Filesystems

NFS Client Configuration Files

Any NFS share made available by a server can be mounted using various methods. The share can be manually mounted, using the mount command. However, this requires that the root user type the mount command every time the system restarts. Two methods of configuring NFS shares to be mounted automatically at boot time include modifying the /etc/fstab or using the autofs service.

Mounting NFS Filesystems using /etc/fstab

 Placing a properly formatted line in the /etc/fstab file has the same effect as manually mounting the exported file system. The /etc/fstab file is read by the /etc/rc.d/init.d/netfs script at system startup and any NFS shares listed there will be mounted.

A sample /etc/fstab line to mount an NFS export looks like the following:

<server>:</path/of/dir> </local/mnt/point> nfs <options> 0 0
The <server-host> corresponds to hostname, IP address, or fully qualified domain name of the server exporting the file system.
The </path/of/directory> is the path to the exported directory.
The </local/mount/point> specifies where on the local file system to mount the exported directory. This mount point must exist before /etc/fstab is read or the mount will fail.
The nfs option specifies the type of file system being mounted.
The <options> area specifies mount options for the file system.

Mounting NFS Filesystems using autofs

One drawback to using /etc/fstab is that, regardless of how infrequently a user may access the NFS mounted file system, the system must dedicate resources to keep that mount in place. This is not a problem with one or two mounts, but when the system is maintaining mounts to a dozen systems at one time, overall system performance can suffer. An alternative to /etc/fstab is to use the kernel-based automount utility, which will mount and unmount NFS file systems automatically, saving resources.
The autofs script, located in the /etc/rc.d/init.d/ directory, is used to control automount through the /etc/auto.master primary configuration file. While automount can be specified on the command line, it is more convenient to specify the mount points, hostname, exported directory, and options in a set of files rather than typing them all by hand. By running autofs as a service that starts and stops in designated runlevels, the mount configurations in the various files can be automatically implemented.
The autofs configuration files are arranged in a parent-child relationship. A main configuration file (/etc/auto.master) refers mount points on your system that are linked to a particular map type, which take the form of other configuration files, programs, NIS maps, and other less common mount methods. The auto.master file contains lines referring to each of these mount points, organized like this:
<mount-point>    <map-type>
 The <mount-point> element of this line indicates the location of the mount on the local file system. The <map-type> relates to the way in which the mount point will be mounted. The most common method for auto mounting NFS exports is to use a file as the map type for the particular mount point. The map file, usually named auto.<mount-point>, where <mount-point> is the mount point designated in auto.master, contains lines that look like this:
<directory>  <mount-options>  <host>:<exported-file-system>
The <directory>refers to the directory within the mount point where the exported file system should be mounted. Much like a standard mount command, the host exporting the file system, as well as the file system being exported, are required in the <host>:<exported-file system> section. To specify particular options to be used when mounting the exported file system, place them in the <mount-options> section, separated by commas. For NFS mounts that use autofs, place -fstype=nfs in the <mount-options>
section.

Common NFS Mount Options

The following options are the most popular for NFS mounts:
  • hard or soft — specifies whether the program using a file via an NFS connection should stop and wait (hard) for the server to come back online if the host serving the exported file system is unavailable, or if it should report an error (soft).
    If hard is specified, the user cannot terminate the process waiting for the NFS communication to resume unless intr option is also specified.
    If soft, is specified, the user can set an additional timeo=<value> option, where <value> specifies the number of seconds to pass before the error is reported.
  • intr — allows NFS requests to be interrupted if the server goes down or cannot be reached.
  • nolock — is occasionally required when connecting to older NFS server. To require locking, use the lock option.
  • noexec — does not permit the execution of binaries on the mounted file system. This is useful if the system is mounting a non-Linux file system via NFS that contains incompatible binaries.
  • nosuid — does not allow set-user-identifier or set-group-identifier bits to take effect.
  • rsize=8192 and wsize=8192 — may speed up NFS communication for reads (rsize) and writes (wsize) by setting a larger data block size, in bytes, to be transferred at one time. Be careful when changing these values; some older Linux kernels and network cards may not work well with larger block sizes.
  • nfsvers=2 or nfsvers=3 — specify which version of the NFS protocol to use.

BIND Setup (GUI CONFIGURATION)

BIND is an open-source software that implements the Domain Name System (DNS) protocols for the Internet. The name BIND stands for “Berkeley Internet Name Domain”. This article describes how to install and configure BIND in Red Hat Enterprise Linux 5 or CentOS 5.

Installing BIND

The steps below will install the chrooted BIND and the GUI configuration tool.

1. Type in the command below to install BIND.


yum install bind-chroot system-config-bind
 
 
2. Start the named service
 

 


 
3. Open the TCP port 53 and UDP port 53.
 
 


 

Configuring BIND

The steps shows how to configure BIND using the GUI configuration tool.
1. Click System, select Administration and click Domain Name System. This will launch the BIND Configuration GUI window.






2. Click Ok to initialize BIND with default values.
 



3. BIND has now been initialized. We can now create a DNS zone and add DNS records.






Creating a DNS Zone

The steps below will show you how to create a DNS zone named “acme.local”.
1. To create a DNS zone, right click DNS Server, select Add and click Zone.  






2. In the New Zone window, click the Ok button under Class





3. Next, click the Ok button under Origin Type.






4. Provide the name of the zone and click Ok.






Here you Go , now y0ur BIND Service is Setuped :D

If you have any Questions then feel free to Contact : bilal.rhce@gmail.com