Disable Gnome-Panel on Ubuntu Karmic Koala

8 11 2009

Hey all. I’ve recently upgraded my home desktop to Ubuntu’s latest release, version 9.10 Karmic Koala. I’ve also spent some time messing with my desktop, and am now using AWN (Avant Window Navigator) as my main launcher/menu, so needed to stop Gnome Panel from starting on bootup.

This is done by running gconf-editor (either from a run dialog or from CLI), and navigating to Desktop –> Gnome –> Session –> Required-Components. Now you will have three values in the panel on the right. Change the value of “Panel” from “gnome-panel” to “” (blank). Note that in order for this to work, you’ll need to have another panel application (e.g. AWN) running and in your startup programs folder.

Just a quick one. Took me bloody ages to find this out, so hope this has made things easier for some of you!

n00b





Sending & Recieving SMS with a 3G device in linux

26 08 2009

Hi all!

Got something quite interesting (or at least I thought so!) for you today: Sending and recieving SMS with a 3G USB dongle and I also assume this will work with a PCMCIA/Express card, if possibly in a slightly different manner. If I get the chance to try it out I’ll update this post with info for them too.

It’s actually pretty simple. The only prerequisites are that you have the correct driver for your 3G device loaded, ie you have access to your 3G dongle via /dev entries, and that you have the ppp package installed, as this contains the chat program. I’d imagine if you’re already successfully using the 3G dongle, then you’ve already got this installed, though.

When you plug your 3G device into a USB slot, use the command dmesg to find out which /dev/ttyUSB slots have been used for the device. This information can be seen on lines which will read something along the lines of:

usb 3-2: GSM modem (1-port) converter now attached to ttyUSB2

Then you need to work out which of the ports is the command port. You can do this by using the command cat /dev/tts/USBn, where n is the number of the port you want to check. On the command port, but not the other(s), you will see messages coming through on regular intervals. They will read something like:

^BOOT:28385139,0,0,0,72

You may as well leave the terminal open watching the USB device as you attempt communication, as you will be able to see the data scroll past as you pass it to the device this way.

Something important to at least know, if not understand regarding SMS itself, is the difference between PDU and text mode, as this article will not go into the depth of all the encoding issues you’ll come across trying to deal with SMS in PDU mode.

The messages you will send to the device will all be in the same format. They are just basically a modem chat script all filled out into one command line. They will follow the format:

chat TIMEOUT x "" "Info to send to device" "OK" > /dev/tts/USBn

The USB device is referred to as /dev/tts/USBn, as /dev/ttyUSBn is just a symlink to /dev/tts/USBn.

For the ins and outs of the chat command, check out the man page, as it’s not particularly relevant to this article’s sphere of interest. I’m concentrating more on the specific AT commands used to control the device, as that’s what’s important, not the method of communication. You could just as well use a terminal emulator like minicom to achieve exactly the same result.

The only difference may be replacing x with a timeout value, n with the USB device number and the info to send to the device. For this example, I will use a standard TIMEOUT of 1 and I will assume your USB device is USB2.

Sending SMS

First of all, the simplest option is to put the device into text mode. This is done with the following command:
chat TIMEOUT 1 "" "AT+CMGF=1" "OK" > /dev/tts/USB2
The terminal on which you are running cat should come back wtih the result:

AT+CMGF=1
OK

If it doesn’t, then either you are not watching the correct device, or your USB dongle’s firmware does not support SMS.

The next step is to tell the modem what number to send the text message to. Note the escaped quotes in the following command. When nesting similar quotes in such a manner, we must tell the terminal to treat the inner quotes as plain text to avoid the command trying to process them as part of the command line. Replace the xxxxxxxxxxx with the telephone number you wish to send the SMS to.
chat TIMEOUT 1 "" "AT+CMGS=\"xxxxxxxxxxx\"" "OK" > /dev/tts/USB2

On your second terminal, you should see the response:

AT+CMGS="xxxxxxxxxxx"
>

This is a prompt to enter the SMS’s text in plaintext format. The command is simply:

chat TIMEOUT 1 "" "Message text goes here" "OK" > /dev/tts/USB2

To insert a new line of text, just repeat this command.

To finalise the message, normally you would press . To emulate this, we use the ^ character. This will cause the terminal to treat it as if you have pressed the CTRL key followed by the next character. The command reads as follows:

chat TIMEOUT 1 "" "^Z" "OK" > /dev/tts/USB2

After a couple of seconds, your watching terminal should respond with:

+CMGS: n

n will be a number corresponding to the number of sent messages from the device.

You should now have the text message arrive at the destination telephone number.

Simples.

Receiving SMS

First step, as with sending SMS, is to put the device into text mode. This is exactly the same command used before:

chat TIMEOUT 1 "" "AT+CMGF=1" "OK" > /dev/tts/USB2

As an optional step, you can list all of the SMS stored on the SIM like so:

chat TIMEOUT 1 "" "AT+CMGL" "OK" > /dev/tts/USB2

The only real requirement for reading SMS, however, is to choose the index number of the SMS you wish to read. This is done with this command:

chat TIMEOUT 1 "" "AT+CMGR=n" "OK" > /dev/tts/USB2

In order to delete a SMS, should you so wish, it is done via a very similar command:

chat TIMEOUT 1 "" "AT+CMGD=n" "OK" > /dev/tts/USB2

That’s all I’m gonna talk you through, but there are countless resources online for finding out what some other AT commands are, and it’s quite interesting just firing them at the device to see what the response is, and I encourage you to have a mess about… Be careful when messing around with the SIM PIN codes, though, and it’s not my fault if you lock yourself out of your kit!

Hope I’ve been of use!

As always… Any questions/mistakes I’ve made, just leave a comment.

n00b





Resizing a VirtualBox HDD

28 04 2009

Today I came up with a problem involving a VirtualBox VM which had run out of space. “Damn” I thought, as I read so many postings by so many nay-sayers telling me that it “Just Can’t Be Done”.

C’mon guys… There’s almost no such thing as can’t with the plethora of useful gadgetry that the world of FOSS has brought us.

A slightly more extensive search turned up this site. Exactly what I was looking for.

What I’m interested in finding out is if this will work on a real HDD… This could fix all of my pain-in-my-ass HDD upgrade problems if I can just clone a disk into a larger partition! Infinitely expandable storage!

I’ll post here when I get a chance to try it.

n00b

UPDATE 08/05/09

Nick Heppleston, the author of the original article, has confirmed that using this method to clone data from a smaller partition to a larger partition on either the same disk or a separate disk works! This is going to make my Windows administration a lot easier, that’s for certain.

Thanks Nick!





Nifty RAM Dump/Sort script

24 04 2009

Hello again! Second post in one day! Whooo! Just a quick one though because I want to go home! It’s 5 o’clock!

I’ve been charged recently with helping to track down somebody else’s (grr!) memory leak in a piece of software. The program was eating about 30% of our server’s 2Gb of RAM. It seemed to make sense to do some kind of RAM dump.

As with most things linux oriented, as soon as you know how to access the relevant doohickies, the entire thing’s a piece of cake, so I wrote a little script so I could do the entire process again. It really is simple, but it’s such a useful little doobrie that I had to post it.

WARNING: I have not written any error checking into this, so you may want to write some break points or something into it before running.

Stage 1: The script frees any unused memory by synchronising any loose data then passing a number to /proc/sys/vm/drop_caches.

Stage 2: It then uses dd as root to take a byte-for-byte copy of the current contents of the RAM from /dev/mem.

Stage 3: It then parses any ascii characters from it and passes it through various sorting procedures to come up with a list of strings found in the RAM sorted from least found to most commonly found.

Anyway… Here’s the script (special thanks to WordPress for utterly destroying any semblance of formatting):

#!/bin/bash
IMGFILE="ramdump-`date +%d%m%y`.img"
TXTFILE="ramdump-`date +%d%m%y`.txt"
echo "************************************************"
echo "* n00bsys0p's RAM dumper and sorter *"
echo "* written 04/2009 *"
echo "* Use it for whatever the hell you want *"
echo "* and don't blame me if you ruin your *"
echo "* computer by being a retard *"
echo "************************************************"
echo "Stage 1 (Freeing unused RAM). Requires root privileges."
if [ $UID == 0 ]; then
echo "Already root, continuing"
fi
su -c "sync; echo 3 > /proc/sys/vm/drop_caches"
echo "Stage 2 (RAM dump). Also requires root privileges..."
if [ $UID == 0 ]; then
echo "Already root, continuing"
fi
su -c "dd if=/dev/mem of=$IMGFILE && chmod a+rw $IMGFILE"
echo -e "\n\
RAM Dumped to $IMGFILE.\n\
Stage 3 (Sort $IMGFILE). This may take a very long time..."
strings $IMGFILE | sort -fd | uniq -c | sort -n > $TXTFILE
echo -e "\n\
RAM dump sorted in $TXTFILE.\n\
Items are listed and numbered by order of occurrence."

Hope it’s useful to someone.

n00b





Pirate Bay Justice Scandal

24 04 2009

Hi all!

I’m not usually one for speculation, but this is just disgusting… Check this link.

It was bound to happen, though. Don’t know why they even bothered with a trial. May as well have sent them straight to Guantanamo.

n00b





Non-interactive router reboot HOWTO

7 04 2009

Hi everyone!

I’ve recently been having trouble with a router getting all bunged up due to the high levels of data passing through it. Invariably, I come in in the morning and we’ve lost access to the Internet from some of our stations until I’ve rebooted it. While I’m in the process of building a routing box for the network, I wanted to know if I could automagically have the router reboot itself well before anyone would be wanting access.

As with almost EVERYTHING Linux oriented, the answer is OF COURSE I CAN!

There’s a nifty little utility within Linux called expect. It comes as standard with Slackware, so no installation needed for me. It allows pre-programmed non-interactive access to normally interactive shells. The script I’ve written looks like this:

#!/usr/bin/expect -f
set address [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set routercmd [lindex $argv 3]
spawn telnet $address
expect "Login:"
send -- "$username\r"
expect "Password:"
send -- "$password\r"
# This command gets us out of the default menu and into a shell
expect "> "
send -- "sh\r"
expect "# "
send -- "$routercmd\r"
#exit
send -- "^D"
send -- "^D"

As you can see, expect is used as the script handler with the -f flag, which would usually point to a script file to be run.

The script really is incredibly simple…

It takes 4 arguments in this order:
address – The router’s IP,
username – The router’s admin username
password – The router’s admin password
routercmd – The command which you wish to run

In my case, I’ve set up a cron job to run daily at 4.40am (the default for cron.daily) which runs the command /usr/local/bin/routercommand.exp 192.168.1.1 **username** **password** reboot. I am yet to see whether 4.40am is suitable, but it’s a step in the right direction!

Anyway, I hope this has been of interest or maybe even use!

n00b

UPDATE – 09/04/09

This has completely fixed our problems with the router. We have seen flawless behaviour since. Whoo! Now if I could only get Smoothwall doing PPPoA with the router in bridge mode! Any ideas would be very helpful!

n00b

UPDATE – 24/04/09

It seems that all of these modem/routers which claim to fully support bridge mode are at best exaggerating. The best results it is apparent that you can expect is intermittency, which is TOTALLY USELESS in a production environment. The way forward is using a true PPPoA to PPPoE bridge modem. I’m using a Draytek Vigor 110, because by all accounts it ACTUALLY WORKS (shock, horror!).

Anyway… Just thought I’d feed you all that useful little nugget of knowledge. Hopefully I’ve saved even one person from losing sleep over it.

n00b





Modifying the SSH ban list.

6 04 2009

Hi everybody!

How many times have you locked yourself out of your remote server by being too quick for your own good? My servers are all set to ban an IP after 3 connection attempts within a minute, so it happens quite regularly that I lock myself out.

The list of banned IPs is stored in /proc/net/ipt_recent. There are a couple of commands this ‘file’ understands…

To see what IPs are currently banned, use:

cat /proc/net/ipt_recent/BAN_LIST_NAME).

To remove an IP from the list use:

echo "-xxx.xxx.xxx.xxx > /proc/net/ipt_recent/BAN_LIST_NAME

To add a suspicious or known bad IP:

echo "+xxx.xxx.xxx.xxx > /proc/net/ipt_recent/BAN_LIST_NAME

To remove all entries (not really a very good idea):

echo "clear" > /proc/net/ipt_recent/BAN_LIST_NAME

That’s all for now.

n00b





Firefox over SSH

27 03 2009

Hi, just a little snippet of knowledge I’ve picked up. I was having all sorts of problems getting Firefox to run stably over an SSH connection to a remote machine I was helping someone out with. It just kept hanging after the initial screen was shown. The answer, as tends to be the case, was horrifically mundane… Wait for it…

I had a copy of Firefox open on another desktop. Moral of the story… If you’re planning on running Firefox from a remote location, make sure you haven’t got a copy open on the local machine.

Anyway, that’s all for now. Hope this is of use to someone!

n00b





Firefox? Windows? READ THIS IMMEDIATELY.

25 03 2009

If you use Firefox, you may have made the switch-over because of the enhanced security it provides. I’ve just found out that the .NET Framework 3.5 SP1, which is installed via Windows Update, creates a huge security hole in Firefox by installing an addon without your permission by modifying your registry. Here is a guide on how to remove it immediately.

Now if crap like this isn’t enough to urge you towards OSS, then I think you may well be doomed.

n00b





New Logo!

21 03 2009

I’ve got a new header for the blog! Sorry it’s not anything more interesting, but I frickin’ love it.

n00b