Sunday, September 7, 2008

How to Turn an Older Tablet Notebook Into a Functional Machine: Part 2 Configuring Wireless and Choosing Programs

This is the second part of the mini-series of how-tos on making good use of an older laptop. See Part 1 for information about installing Ubuntu on a laptop with no bootable media options using a network connection.

Now that you have a command line interface and a full blown operating system it's time to get things working the way you want them to. I designed this laptop to be a mobile development platform so all of the choices I made were not just skewed to my personal preferences but also to that end. If you're going to use your laptop for something else your decisions in this regard may vary substantially.

The first thing to do is enable wireless networking. After all, what good is a portable computer if you have to plug in to access the internet. Luckily activating your wireless connection from the command line is fairly straight forward. For the duration of this article a $ is your user name's prompt and a # is the root prompt.

First thing I like to do in Ubuntu before performing admin takes is to sudo into root. This saves a lot of time and potential frustration if you forget to type 'sudo' before a lengthy command that requires it. One of the biggest complaints I hear from more advanced users is the lack of a root account in Ubuntu and the need to sudo into everything. Well this isn't actually the case. There are two easy ways to access the root prompt in Ubuntu. One that uses global settings:

$ sudo su root

And one that preserves any locally set variables you may have:

$ sudo su -l root

Either of these commands will bring you to a root prompt that you can then exit from by typing 'exit' or hitting Ctl-d.

Now that your in a root prompt you can configure your network interfaces without having to sudo every time. If you know the essid of the wireless network you need to access you can skip the steps involving iwlist and go straight to iwconfig. Otherwise type:

# iwlist scanning | more

The pipe to more is optional but if there are a lot of networks in range it can be a good idea. Find the one you want to use and note the essid and if it needs an access key or not. Then type:

# iwconfig $eth essid $essid key $key

Where $eth is your wireless interface, discoverable by typing simply iwconfig and viewing the output, $essid is the essid of the network your attempting to connect to and $key is the network access key if required. If the key is in hex you can type it in as is but if it's a passphrase start the key with 's:'. Now when you type 'iwconfig' you should see the choices you made visible for your interface but no ip address. To connect and get an ip assigned via dhcp type:

# dhclient $eth

Where again $eth is your wireless interface. This will broadcast a dhcp request via port 67 to the ap for the essid you specified. One it's complete your internet is up and running.

The next thing to do is install some appropriate applications. I'm going to refrain from discussing window managers or desktops here and save that for part 3. Remember that this laptop was designed to provide essentials for programming and development and not much else.

It should be telling, however, that the first program I install on any new system is Nethack. I just really love to play Nethack. It's also the way I take breaks when things aren't going as planned and I need to relax for a few minutes. For this reason I actually consider it a tool. It's my 'keep phil from breaking the computer' tool. After Nethack there are a few essentials that almost any system ought to have. One of those being an editor. I'm not going to open the can of worms that is the endless debate between vi and emacs. Suffice to say that I use and installed both. For packages whose name you already know and that you know can be found in the Ubuntu repositories you can simply type:

# apt-get install $package

Where $package is the package you want. This will fetch the package from the repositories and install it for you. Otherwise you can launch aptitude by typing 'aptitude' and search for what you want.

Some may ask why I'm bother to go over something as simple as how to install packages if the first part of this how-to required successfully performing a network installation, far from a simple task, and the answer is simply; because you never know. Someone who has little or no command line experience can still figure out how to do a net-boot but may not know how to work with Linux with nothing but a command line handy. It happens. I've seen it.

Some other packages I ensure are installed are gcc, g++, gcj, gfortran, g77, bsh, clisp and associated libraries, a variety of major and minor modes for emacs, octave, maxima, clamav, ruby, perl, python and supporting documentation for all of the above. To break that down a bit:

gcc - The Gnu C Compiler, a true must have for any Linux programmer
g++ - The Gnu C++ Compiler
gcj - The Gnu Java Compiler
gfortran - The Gnu Fortran Compiler
g77 - The gnu Fortran 77 Compiler (I like Gnu compilers what can I say)
bsh - Bean Shell, a java scripting shell
clisp - Common Lisp, an amazingly handy programming language
octave - Octave 2.9.x (The version I'm currently using), a math and science scripting program
maxima - Another math scripting program
clamav - Clam Anti-Virus, just cause your using Linux doesn't mean you shouldn't be careful
ruby, perl, and python - Handy scripted languages used mostly for admin purposes (by me anyways)

That is of course just a sample of what wound up on my system. I just consider these some of the bare minimum packages that should be installed on a system whose purpose is to develop programs. The math and science scripting programs are included as they can serve a valuable place in working out and implementing complex algorithms. Both can be included in C programs. I also tend to leave a lot of leeway for alternate languages to be available even if I don't use them often or at all. For instance I have never and may never use Java but I have some tools to make it available in case I do decide to use it.

Another big thing in my book is ample documentation. It can take up a lot of additional space but I think it's well worth it. Especially for libraries and programs I'm not familiar with. I generally install elinks and dhelp to help organize the documentation that I have on the system. I may also install the docs for programs or libraries that I don't yet have installed to see if they would be a good match.

A complete list of packages installed on my test system would be extensive and far too long for this article. I install quite a bit of source code to reference as well. To me analyzing the way somebody else solves a problem can help me through a slump.

Now for a small section on navigating the command line is your not used to it. I will assume that you're familiar with the basic commands such as; ls, pwd, ps, cp, rm, etc.

There are two ways that I handle using multiple apps at one time. The first is to Ctl-z to put an application to sleep and then '%$app' where $app is the application put to sleep, to bring it back up. The second is to run multiple virtual terminals at a time to allow for rapid switching between active programs without having to put one in the background. I often due this to reference documentation while using a new program or library. Ctl-Alt-F* where * is 1 - 8 allow you to switch between virtual terminals. On a cautionary note I have found that some window managers don't like it if you switch out of them using this method. At least on my laptop, they would refuse to resume properly forcing me to restart x from the command line. So be prepared.

Install and activate laptop-mode-tools. There is no readily available battery monitor on the command line by default. Having your battery run out at a crucial time can be devastating (See Part 1 of this How to). With no way to perform a rescue boot except over the network you really don't want to cause problems for your filesystem. Fixing it can and will be a pain though not terribly difficult if you know what you're doing.

Never underestimate the awesome power of grep for finding what you need. A simple ls -a | grep $string where $string is what your looking for can work wonders. Try not to leave the string too vague though or it won't help much. I also tend to avoid using the -R (recursive) function of ls as it can give me too many useless results.

So there you have it. Some basic setup to get you going. In the next part we'll take a look at choosing a window manager or desktop to suit this machine's needs and all the problems that come with it.


No comments: