The ‘!!’ command of the BASH shell with sudo

It’s good security practice to log in to your Linux system as an under privileged user, only to then use commands like sudo to execute the application that you want with root privileges. But what if you log in using a terminal client that isn’t configured to properly use keys like ‘Home’ or ‘End’? I’ve found this all too often when using a terminal client on the Windows platform. You’ll quickly know if the terminal isn’t set up for it because garbage text will appear inside the terminal screen or maybe even some other random behavior such as the line of text disappearing.

Now, what if you type a really long command into bash through such a terminal client and you forget to prefix it with sudo? You’d probably end up trying to retype the command or do some form of mouse copy-paste magic to get the command to follow sudo. There’s an easy solution to this problem! Instead, you can use a feature of the bash shell, ‘!!‘, to tell bash that you want it to execute your previously given command.

For instance, if you typed:
nano /etc/resolv.conf

But you really meant to type:
sudo nano /etc/resolv.conf

You can accomplish the same thing with:
adam@ad:~$ sudo !!
sudo nano /etc/resolv.conf
[sudo] password for adam:

Compiling RakNet With g++ 4.3 Fails

When choosing a networking library for a Crystalspace/CEL project of mine, my heart was set on RakNet. The RakNet library offers many features and does so in a way that makes it easy to integrate into almost any project.

Raknet is a cross-platform C++ game networking engine. It is designed to be a high performance, easy to integrate, and complete solution for games and other applications.

http://www.jenkinssoftware.com

Unfortunately, on my Ubuntu Jaunty system, g++-4.3 was installed by default which caused RakNet to fail on compilation. There were a bunch of errors in the DS_Map.h include file, including:

../Raknet/DS_Map.h:90: error: template argument 3 is invalid

After some trial and error I found that if you install the g++-4.2 development package and use the g++-4.2 binary, RakNet compiles and runs just fine.

From a terminal window:
sudo apt-get install g++-4.2

After installing the package above, I also needed to change which g++ binary my Eclipse project was using. I did this by going to the “Project” menu and clicking “Properties”. When the Properties window opens, click on “C/C++ Build” on the left side, then click on “GCC C++ Compiler” on the right. Where it shows the command to be run, change the command to read: g++-4.2.

eclipse_gcc_42

Eclipse CDT is very slow when using auto completion (content assist)

I enjoy playing around with the Crystalspace engine in my spare time but was disappointed when I first tried to use it on my Ubuntu Jaunty system. Eclipse was installed as the primary IDE, along with Eclipse CDT which is also known as the C/C++ Development Tools for Eclipse. Everything appeared to work alright except when it came to using the newly compiled Crystalspace libraries inside of a new project.

One of the best features about modern IDEs is auto completion, or as Eclipse calls it Content Assist. Its job is to monitor what you type and offer you possible functions that you have access to from within the current context. For example, if I had the following declared in my new CS project:

csRef<iPcDefaultCamera> pccamera = CEL_QUERY_PROPCLASS_ENT (player_entity, iPcDefaultCamera);

You would then be able to type pccamera followed by ->. When this is seen by the content assist, it builds a list of possible functions that the pccamera variable has access to call and displays them to you as a pop up listbox.

content_assist_1

The image of content assist in action shown above took about 1.5 seconds to appear, now that my system is fixed. However, before I discovered the fix content assist took at least 10-12 seconds to work! If you are having the same issue that I did, you can check out the post that helped me out here, or just follow the directions below which worked on my Ubuntu Jaunty 9.04 system.

From a terminal window:
sudo apt-get install eclipse-cdt sun-java6-jdk
sudo update-java-alternatives -s java-6-sun
sudo -b gedit /etc/jvm

When gedit opens up the /etc/jvm file, insert the following line at the top:
/usr/lib/jvm/java-6-sun

From a terminal window:
sudo -b gedit /etc/eclipse/java_home

When gedit opens up the /etc/eclipse/java_home file, insert the following line at the top:
/usr/lib/jvm/java-6-sun

If you have lots of RAM you can even play around with adjusting the heap size available to Eclipse. I’d suggest you read the original article here which talks more about it.

NVIDIA 9600GT Driver Install on Ubuntu (Follow Up)

Let me begin this post by saying “I’m sorry.” A year or two ago I wrote an article about how I got my NVidia 9600 GT graphics card to work correctly on Ubuntu 8.04. Since that time, I have restructured my website and no longer have the original article. It looks like there are still a lot of people needing help with getting drivers to work for the 9600 GT chipset because it is still actively being linked to from many different Ubuntu sites and forums. These are the people I’m writing this follow up post for.

My desktop system now runs the latest stable release of Ubuntu, which at the time of this writing is 8.10 with the release of Jaunty 9.04 right around the corner. Fortunately, I didn’t have to do anything special to get the 9600 GT to work with this version of Ubuntu. I would highly recommend anyone using an older version of Ubuntu to upgrade to the latest version, not only for the latest NVidia drivers but also for the large list of other software that is now available to you.

If you have Ubuntu 8.10 or later installed, you can use the “Hardware Drivers” program found under the System->Administration menu to properly detect and install the best drivers for your card. After doing this, I rebooted my system and had full use of my NVidia 9600 GT, along with all the compiz fanciness that comes with it.

Hope this helps.

My First Post!

I finally created my own website! For my first post, I wanted something of substance and value. What could be better than posting a video of my crazy cat Shadow running around in circles while trying to catch a plastic tie. Hope you enjoy :)

The video is 17MB in size, so it might take a minute or two to buffer….