How to automatically change to directories with very long full path using easy to remember aliases

2 comments

My laptop's 160GB hard disk is partitioned into more than six logical partitions and I multi-boot Windows 7, Windows XP, Kubuntu, Mandriva and Fedora. So you can imagine how I must have butchered the 160GB. I have managed to logically organize my files on the system, I put my iso image files in Kubuntu and Mandriva, my documents are in Windows XP and Windows 7. This makes it inevitable for me to frequently access documents on the Windows partitions and also copy documents to them while working in Linux. Occasionally, while working in commandline I need to mount images on the Kubuntu partition or read a file I saved in the Windows partition. Unfortunately, Fedora has a terrible way of naming my partitions that are not part of its filesystem, for example the full path to my Windows XP partition is /media/8E9C64209C640555 and the one for my Windows 7 partition is /media/925C181C5C17F9A5. After getting sick of having to copy and paste the path, I decided to do something permanent that will help me get round the problem.
Well what I eventually did was to add a four aliases to automatically change to any partition without bothering about its full path. All I did was to edit the /home/freeman/.bashrc file, I appended the following --
# User specific aliases and functions
alias kubuntu='cd /media/0f83fb7e-7810-489d-ad1d-1cfeb50e1ff2'
alias mandriva='cd /media/d06a0246-9501-4e55-8162-146e500cd2a0'
alias windowsxp='cd /media/8E9C64209C640555'
alias windows7='cd /media/925C181C5C17F9A5'

Voila! Now everytime I enter windowsxp on my command prompt, I am automatically switched to the Windows XP partition.

Interactive script to mount iso images

0 comments

My laptop's DVD drive is bad, so I prefer copying images of CD/DVDs through a friends computer DVD drive and pasting it in my cd_image folder (a special folder I created for just iso images).
The command I use for copying CD/DVD images is
dd if=/dev/sr0 of=/home/freeman/cd_image/cdname.iso
This command is pretty straight forward,  the dd stands for disk dump, if stands for input file and of stands for output file. I do not have problem with remembering the command. But I often have problem remembering the exact mount options for iso file (which is the cd image file).
So I decided to write a shell script for interactively mounting any iso image in any mount point point (which is often an empty folder).
The following is a step-wise description of the shell creation

STEP 1
I created a special folder in my home folder and named it shell, using the following command
[freeman@freeman ~]$ mkdir shell
I changed directory to the shell subdirectory I just created
[freeman@freeman ~]$ cd shell

STEP 2
I created a new file (named it mountiso) and entered the script in in using vi editor
[freeman@freeman shell]$ vi mountiso
#!/bin/bash
#This shell is for mounting cd images from anywhere to any empty folder
echo -n "Enter the full path of the iso image: "
read image
echo -n "Enter the full path of the mount point, an empty folder: "
read folder
mount -t iso9660 -o loop $image $folder
exit 0

STEP 3
I made the mountiso file executable by changing it's file permissions
[freeman@freeman shell]$ chmod a+x mountiso
I also included the /home/freeman/shell path in the PATH environment variable
[freeman@freeman shell]$ PATH=$PATH:/home/freeman/shell
To make is global, I exported the new PATH
[freeman@freeman shell]$ export PATH

So that was all, to run the new script I just enter mountiso (regardless of my current working directory) and enter both the image location and mount point without bothering about the mount options.

How to use ZTE MF627 USB modem on linux

0 comments

I just bought a ZTE MF627 USB modem (it supports GPRS/EDGE/3G/HSDPA) to serve as my internet highway, the stuff works great with little configuration on Windows. Actually it came with MTN Nigeria internet settings but I could use it with other networks via Windows Dial-up.
The major problem was that in my Ubuntu and Fedora linux, I just could not use it. When I enter dmesg at the Commandline terminal, it detects it as a CD drive.
So after seeking lots of help online I finally got a way to go round the issue.
In my windows XP, the device manager alloted COM19 to the modem. I went straight to hyperterminal and connected to COM19 using the usual "8-N-1 None" settings, you can put the baudrate at any value. In the terminal I simply entered
AT+ZOPRT=5
AT+ZCDRUN=8
This will change the default mode of the modem from the CD drive to the modem mode. But you will not be able to install the software that came preloaded into the device, so if you want to use it on a new windows system, you might have to run AT+ZCDRUN=9 to enable you install the MTN or any other proprietary software that came with the modem.
After that your Linux system will now identify the modem and make it available as /dev/ttyUSB2 or /dev/ttyUSB3 ( I think /dev/ttyUSB2 if you do not have 3G or HSDPA and /dev/ttyUSB3 if you have the service on the network). You can now use your preferred Point-to-Point Protocol connection tool.
If you are using Fedora 11 or 12, you can go to System, Preference and Network connection for very easy configuration of the modem.



Just click on Mobile Broadband and Add.

 Enter the internet settings as given you by the network provider, in the PPP setting untick all the compression methods, and the allowed authentication method should be PAP alone (except if your provider specifies any additional one).
With this done, you are ready to go, just click on the network icon on the task bar and choose the network you just configured.
For Ubuntu, mandriva and other distros including fedora, you can use any PPP tool -- gnome-ppp, kppp and wvdial. Just specify the right device address.

 
Follow me on Twitter | About me | Terms of Service | Privacy Policy