How To: Configure Wireless with Ralink (RT2500) Level One WNC 0301 in Fedora Core 4

Yesterday after a lot of trials with Fedora Core 5 to activate my wireless LAN card, I switched to Fedora Core 4, which looked much more stable than FC5. Actually with FC5, I mainly faced problems with gui , my mouse which is Microsoft USB mouse and my wlan card which is level one Ralink RT2500. In FC5, I tried both with ndiswrapper and madwifi but nothing worked out for me. Also my mouse was not working well. I can click things but the pointer was not visible like microsoft gave me a invisible mouse or this microsoft mouse don’t want to work with Linux. After installing FC4, I felt very comfortable with guis and my mouse. They worked fine. But now there were two problems. One is that FC4 was not able to detect my soundcard and the wlan was not working again. Anyway soundcard is not a big problem, as it worked in FC5, I’ll make it work with some up-gradation or things like that. But the major problem is wlan. And here goes the methods which I tried to activate my wlan card.

Method 1. With rpms

I downloaded these rpms

1
2
3
madwifi-0.9.4.12-16.rhfc4.at.i386.rpm
madwifi-kmdl-2.6.11-1.1369_FC4-0.9.4.12-16.rhfc4.at.i686.rpm
madwifi-hal-kmdl-2.6.16-1.2111_FC4smp-0.9.6.0-20.rhfc4.at.i686.rpm

from the site atrpms and tried installing them but they failed the dependency /boot/vmlinuz-2.6.16-1.2111_FC4 , then i tried to find this rpm everywhere on google , rpmfind etc …. but I could not find it. Then I installed it with –nodeps option and configured according to the data given here .
But in vain.

Method 2. With ndiswrapper using Microsoft Windows XP drivers

I downloaded the ndiswrapper-1.16 from sourceforge.
I untarred it and used these commands.

1
2
3
make uninstall
make
make install

Please don’t forget to the read the INSTALL and README files in the ndiswrapper-1.* directory. Then I inserted my LAN card driver cd for XP and copied the drivers directory which contains .inf and .sys files to my root directory. Then I used the commands .

1
2
3
4
5
ndiswrapper -i Rt2500.INF
ndiswrapper -l
modprobe ndiswrapper
iwconfig "wlan0" key open "wep 128 bit hex key" ESSID "IIIT WLAN"
dhclient wlan0

I ran all this command and I am very happy to say that wireless LAN did not work. 🙂 Then I ran this command

touch /etc/sysconfig/network-scripts/ifcfg-wlan0

and then edited this file. I entered all the data suggested here except that second line I wrote

DEVICE=wlan0

OK. Then i ran

neat

and edited the properties of wlan device by double clicking it and gave the 26 letters wlan key there and activated the device and it worked 😀

 

Hack: Mail Filter – Shell Script

This is an attempt by me to filter mails on a Linux machine. You can run this file on your home directory at mail server and it will help you to sort mails on the basis of

  • From which user the mail has come or from which domain it came,
  • to which user or domain mail was sent and
  • the keywords in the subject part of the mail.

Actually its very slow as shell is very slow , I cant help it . It scan your entire mbox file in the home directory by default. Copy the code and paste in a file say filter.sh and change its permissions to executable. Place it in you home directory at the mail server and run.

Example
You want to see all mails from username@gmail.com just run and it will ask for input,
press 1
From: username [Enter]
It will display all the mails from that are lying there in your mbox one by one.

Get the script here or copy the code below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
#################################
#   Author - Kulbir Saini       #
#   Home - http://sain.ico.in/  #
#################################
 
#shell script to filter mails.
echo -e -n "\033[32mWelcome to the mail filter system \nWhat do you want to do? \nCheck mails on basis of \n1) Sender... \n2) Receiver... \n3) Subject... \n4) Quit... \nPress(1,2,3,4): \033[0m"
read int <&2
while [[ 1 ]];do
while [[ 1 ]];do
count=0;	line=""
if [[ $int == 1 ]];then
	echo -n -e "\033[32mFrom:\033[0m "
	read from <&2
	i=0
	clear
	while read line ;do
	loopbreak=0;	nextmessagestatus=1;	mailtostatus=1;		mailsubstatus=1;	stat=1;
	toecho=`echo $line | grep -E "^From:+" | grep -E "${from}"`
	if [ "$toecho" != "" ];then
		i=`expr $i + 1`
		echo -e "${toecho}"
		while read line ; do
		mailto=`echo $line | grep -E "^To:+"`
		mailsub=`echo $line | grep -E "^Subject:+"`
		if [[ "$mailto" != "" ]] && [[ $mailtostatus == 1 ]];then
			echo $mailto
			mailtostatus=0
		fi
		if [[ "$mailsub" != "" ]] && [[ $mailsubstatus == 1 ]];then
			echo $mailsub
			mailsubstatus=0
		fi
		if [[ $mailtostatus == 0 ]] && [[ $mailsubstatus == 0 ]] && [[ $stat == 1 ]];then
			echo -e "\033[33mStarting of the Message${i}:\033[0m"
			stat=0
		fi
		fromstatus=`echo $line | grep -E "^X-UID:+"`
			if [[ $fromstatus != "" ]];then
			while read line; do
				loopstatus=`echo $line | grep -E "^From +"`
				if [[ $loopstatus != "" ]];then
				loopbreak=1
				break
				fi
				echo $line
			done
			if [[ $loopbreak == 1 ]];then
			echo -e -n "\033[33mEnd of the Message${i}.\nDisplay next message(y/n):\033[0m"
			read messagestatus <&2
			if [[ "$messagestatus" == "y" ]];then
				clear
			else
				nextmessagestatus=0
			fi
			break
			fi
			fi
		done
		count=`expr $count + 1`
	fi
	if [[ $nextmessagestatus == 0 ]];then
		break
	fi
	done
	if [[ $count == 0 ]];then
		echo -e "\033[32mNo mail(s) From: ${from}.\n\033[0m"
	else
		echo -e "\033[32mTotal $count mail(s) From: ${from}.\n\033[0m"
	fi
elif [[ $int == 2 ]];then
	echo -n -e "\033[32mTo: \033[0m"
	read to <&2
	i=0
	clear
	while read line ;do
	loopbreak=0;	nextmessagestatus=1
	toecho=`echo $line | grep -E "^To:+" | grep -E "${to}"`
	if [[ "$toecho" != "" ]];then
		echo -e "$toecho"
		i=`expr $i + 1`
		while read line; do
			tostatus=`echo $line | grep -E "^X-UID:+"`
			if [[ $tostatus != "" ]];then
			echo -e "\033[33mStarting of the Message${i}:\033[0m"
			while read line; do
				loopstatus=`echo $line | grep -E "^From +"`
				if [[ $loopstatus != "" ]];then
				loopbreak=1
				break
				fi
				echo $line
			done
			if [[ $loopbreak == 1 ]];then
			echo -e -n "\033[33mEnd of the Message${i}. \nDisplay next message(y/n): \033[0m"
			read messagestatus <&2
			if [[ $messagestatus == "y" ]];then
				clear
			else
				nextmessagestatus=0
			fi
			break
			fi
			fi
		done
		count=`expr $count + 1`
	fi
	if [[ $nextmessagestatus == 0 ]];then
		break
	fi
	done
	if [[ $count == 0 ]];then
		echo -e "\033[32mNo mail(s) to: ${to}.\n\033[0m"
	else 
		echo -e "\033[32mTotal $count mail(s) To: ${to}.\n\033[0m"
	fi
elif [[ $int == 3 ]];then
	echo -n -e "\033[32mSubject:\033[0m "
 
	read subject <&2
	clear
	i=0
	while read line ;do
	loopbreak=0;	nextmessagestatus=1
	toecho=`echo $line | grep -E "^Subject:+" | grep -E "${subject}"`
	if [[ "$toecho" != "" ]];then
		echo "$toecho"
		i=`expr $i + 1`
		while read line; do
		substatus=`echo $line | grep -E "^X-UID:+"`
		if [[ $substatus != "" ]];then
		echo -e "\033[33mStarting of the Message${i}:\033[0m"
		while read line ; do
			loopstatus=`echo $line | grep -E "^From +"`
			if [[ $loopstatus != "" ]];then
			loopbreak=1
			break
			fi
			echo $line
		done
		if [[ $loopbreak == 1 ]];then
		echo -e -n "\033[33mEnd of the message${i}. \nDisplay next message(y/n): \033[0m"
		read messagestatus <&2
		if [[ $messagestatus == "y" ]];then
			clear
		else
			nextmessagestatus=0
		fi
		break
		fi
		fi
		done
		count=`expr $count + 1`
	fi
	if [[ $nextmessagestatus == 0 ]];then
		break
	fi
	done
	if [[ $count == 0 ]];then
		echo -e "\033[32mNo mail(s) with Subject: ${subject}.\n\033[0m"
	else
		echo -e "\033[32mTotal $count mail(s) with Subject: ${subject}.\033[0m\n"
	fi
elif [[ $int == 4 ]];then
	echo -e "\033[32mThank you for using this utility. \nPlease visit again.\033[0m"
	exit
else
	echo -e "\033[32mI could not understand that. \nPlease try again.\033[0m\n"
fi
echo -e -n "\033[32m1) Sender... \n2) Receiver... \n3) Subject... \n4) Quit... \nPress(1,2,3,4):\033[0m "
read int <&2
break
done < mbox 
done
 

How To: Troubleshoot SCP Command

Some times we face problems in transferring the data from one machine to other machine using scp. Actually the scp command is executed successfully but the data is not transferred. As the .bashrc and not the .bash_profile file of the system to which the data is being transferred is executed. If the .bashrc of the remote system contains any command or executable which output some data to the standard output then that command is executed and the output is flushed on the local machine and the scp command is terminated and data is not transferred.

For example if the remote machine has any ‘echo’ or ‘nfrm’ command in .bashrc file, the scp of the data will not be possible.
Also suppose the remote machine has a lines in .bashrc like this

./test.sh

where test.sh contains the data as below:-

1
2
#/usr/bin/sh
echo "Kulbir Saini"

Then also the scp will not be possible.

So if you are facing such problems please try to remove such lines from your .bashrc file and scp the data you want.
Anyway you can keep those lines in your .bash_profile because it is not executed while transferring the data.

Please report any other cases in which scp is not possible.

 

How To: Recover/Crack Root Password when Grub is Locked

The only essential thing is that you should have a Linux boot CD of the same operating system for which you want to crack root password. Some other Linux boot CD may work in some cases. If system is able to boot from the CD, it will take you to a command prompt as shown.

boot:

Type ‘linux rescue’ at this command prompt and enter as shown

boot: linux rescue [Enter]

It will take you to some interface with some questions, answer them properly. The system will go to temporary command prompt. Then issue the following commands

1
2
3
[bash$] chroot /mnt/sysimage [Enter]
[bash$] cd /boot/grub [Enter]
[bash$] vi menu.lst [Enter]

Now in this file you can see a line beginning with the word ‘password’ remove this line and save the file.

1
2
[bash$]exit
[bash$]exit

Now system will be rebooted and you can see the grub without a password. Don’t forget to remove the CD.

Press ‘e’ at boot screen and again by taking the pointer to the second line press e. Now you can see yourself on a command prompt. Remove ‘rhgb quiet’ from there and write single and press enter.

Now you will come back to the boot screen. Press ‘b’ and system will appear to boot and leave you in command line interface like this.

-bash2-$

Just type passwd like this

1
2
3
4
-bash2-$ passwd [Enter]
new password:
retype new password:
passwd: All authentication updated successfully.

Now you have set a new password. Now exit from the shell and system will boot properly in graphical interface.

-bash2-$ exit [Enter]

If there is any error in the procedure please post your suggestions.