s5h.net

“fresh linux news and advice.”


puce2006-07-28 back in the saddle

Well the week has been full of ups and downs. Mainly downs, it's too hot for one to do anything sensible, so it's generally better for outdoorsy people than myself, the indoorsy type.

Generally speaking, I should have trusted my instincts, Ubuntu just isn't for me, I'm more the slack/deb guy than the ubuntu/mandrake sort.

It's unlikely I would have mentioned it before, but sudo is a very important administration tool. It can allow one to easily change their UID when executing a program, give it a go, it saves much time if you require a web-cgi program to fork a system tool for one reason or another.

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

The above is the notice you might see when running sudo, point number 3 is the more important, and it's also features several times in the film "Spiderman".

        puce`backtick`

Time and time again I see people pasting bits of shell code using the backtick to execute programs. This backtick is IMPOSSIBLE to nest. For instance, if i were to execute `ls -al $VAR` this would be just fine. $VAR in this example is a variable which is placed into the execution line (be careful here guys, it's if it's easy for user input to populate your execution then it's possible for that to be abused).

What, if one wants the result of the program `find /tmp | head -1` to take the place of $VAR? Lets see what that might look like.

$ A=`ls -al `find /tmp | head -1``;
bash: /tmp: is a directory

This is totally not what we wanted. Bash is doing exactly what it's been told to do when parsing this input. What would be better is a way to nest this statement, which is the way I have been writing bash programs that have since been lost in time.

$ A=$( ls -al $( find /tmp | head -1 ) );

Note how there is a gap between the $() statements and their inner parameters. This is not required, but it does help for legibility of code. As it should be obvious, even when a backtick and the command substitution can both do exactly the same job, for future changes it's less complex is the command substitution via brackets is used from the start as it can be nested at a later date, and retains legibility.

puce2006-07-27 debian advice

Sometimes, there can be so much hype surrounding something new that it seems exciting and the way that one should be heading. Sometime all this is really is just hype. Why did I think that I would be better off with Ubuntu?

  1. hibernation
  2. recent sylpheed
  3. recent other things

In reality, the later versions are just hype and lack some of the build quality of debian-stable. I did realise that there would be more frequent updates. Trouble of this is the more one's system has installed, the more frequent the daily update is.

In addition to the above, I shortly realised that there was a problem with the Nvidia binary driver and X. I am still at a loss as to why my X would not acknowledge my nvidia module. It might be related to my kernel version though at this current time, (I do like to run the latest kernels, I wish all software is well tested and vetted like this).

Some people informed me that I should try the module-assistant method for installing the Nvidia binary, I gave it a shot, but it does seem to be more of a X/kernel problem than the binary drivers.

puce2006-07-24 it has been hot in the computer room today

It's been hot. I've been restless. In a moment of weakness I have removed /, /usr, /var and installed ubuntu in their place. So what are my new guidelines for a fresh install?

Well, firstly, the important things, connectivity. For this, most of my communications go through gaim and sylpheed-claws-gtk2, both of which are highly accessible through the apt-get system. Great.

Next, visuals. To get the system using both my monitors, I coudl either settle with the stock kernel and plod along using the nvidia-glx package, or replce the kernel and suffer the licence from www.nvidia.com. I choose the later.

wget 'http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.tar.bz2'&
wget http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.17.6.bz2
apt-get install libncurses5-dev make kernel-package gcc g++

Once the kernel sources are downloaded, change to /usr/src, and untar.

cd /usr/src/
tar jxvf ~/linux-2.6.17.tar.bz2
bunzip2 ~/patch-2.6.17.6.bz2
cd linux
patch -p1 ~/patch-2.6.17.6

We should now be ready to run make menuconfig and configure the kernel. I cannot take you through the depths of configuring it yourself, I suggest you read the help pages for each item to get a feel for what you are doing. Once configured you will need to turn it into a Debian package, which you are then able to install via dpkg.

There used to be some through against using a initrd kernel, but I don't see a problem myself. There's really nothing wrong with this, it just copies a bunch of modules to RAM before loading the kernel, why's that so bad? Modules are very small bits of code and RAM these days is measured by hundreds of MiB.

time make-kpkg kernel_image --initrd

To those who are observent the first command here is time. It forks the rest of the commands to the background and waits for their return, then prints the amount of CPU time taken to execute. This can be very useful if you wish to optimise your kernel size, generally. The speedier the compile, the less code there is, generally, as a rule of thumb.

Woah 41m, that's a real long time (RLT) to compile.. my own stupid fault for compling bluetooth and a bunch of other net drivers that there is no need for. In a land that time forgot, I once owned a Compaq Armada, 7400, compiling the 2.4 kernel on that could take 15-45 minutes, depending on the modules. It is a fine art. Stil this is just to get the NVidia kernel modules. The binary installer cannot create the modules without the compiled source.

So, take one hot day, add some restlessness, the room becomes hotter with CPU activity. It's possible that one should have chosen to go fishing instead.

puce2006-07-18 A note on windows

MS has acquired Winternals and Sysinternals. The well known programs that network administrators love to use. Get it while it's still there, before MS take it offline, for some unknown but 'better for the rest of us' reason. systernals.

puce2006-07-14 large files quickly

Short posty tonight, as one has been working all week, getting wound up. Someone mentioned to me that Qemu was a cool emulator and from my initial impression it's damned fast. So I have stacks of disk space (on my 160gig data disk), I want, perhaps a handful of images for my various OSes. What's the quickest way to get these images you might ask? Well, one might do the following:

dd if=/dev/zero of=/mnt/hdb/images/os1 bs=1024 count=10485760

Then dd has to open a read pipe to /dev/zero, which means the CPU has to do some work, which is inefficient. Remembering some information from my UNIX programming book, one can seek to a position in a file which has not yet been allocated and then just write some data, which pretty much just alters the file table to show a larger file than blocks allocated.

#include <stdio.h>
#include <stdlib.h>

int main( int argc, char argv[] ) {
	FILE *fp;

	fp=fopen( "./test", "w+" );
	fseek( fp, 1024*1024*1024*10, 0 );
	fprintf( fp, "%c", "\0" );
	fclose(fp);

	return( EXIT_SUCCESS );
}

This creates the file damned quick. Give it a go, if you're ever in a postition where you require a long file, but don't have time to hang around. The file will contain zeros.

One might have problems with the size of int, so here's the backup method, in perl:

#!/usr/bin/perl

use strict;
use warnings;

open( F, ">./test" );
seek( F, 1024*1024*1024*10, 0 );
print( F '\0' );
close( F );

        pucesolution

In order to compile the source below to create files that are larger than 2GiB you must compile the code with gcc -D_FILE_OFFSET_BITS=64 prog.c otherwise the syscalls will not be 64bit.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/unistd.h>

int main( int argc, char *argv[] ) {
	int des,x,i;
	char buf[1] = "\0";
	long long int pos = 1024*1024*1024;

	if( argc < 2 ) {
		printf( "Specify the number of size of the image in gigs." );
		return( EXIT_FAILURE );
	}

	x = atoi( argv[1] );
	pos *= x;

	des = open( "./test", O_CREAT|O_RDWR );
	fchmod( des, 0644 );

	lseek64( des, pos, SEEK_CUR );
	
	write( des, buf, 1 );	
	close( des );
	return( EXIT_SUCCESS );
}

puce2006-07-11 race for life

Well done Clare for completing Race for Life.

Since my run, a few months ago, I have decided to enter more events, they are great fun and help a deserving cause.

puce2006-07-09 evil religious propaganda

Whilst checking my email accounts I found a post from someone linking to this article. I can't resist, I have to post some form of response. It's just plain wrong.

"Like most things that are worth owning, Computers are an American invention. Look at any modern computer and you will see that the whole thing is the product of American brilliance."

Not strictly true, the first computers were British design, code breaking machines, namely Colossus, to decipher German codes.

"Like all the greatest American engineering, it's an example of innovation that makes a growing group of European and Chinese hackers jealous. They hate our lead in computing technology and will stop at nothing until they have control of all of our computers."

What?

"I'm talking about a project called 'Linux', something you may not have encountered, but might do some day. It's a computer program that was initially developed in Finland as a means of circumventing valuable copyrights and patents owned by an American company called SCO Group."

No, quite wrong. ltorvalds knocked together the initial version. Usenet put a many more lines into it since. Whats the point of this? BSD came from Berkeley labs, that's pretty much just the same thing, but with less angst.

"Indeed, Linux is so pervasive amongst the blue states and many liberal universities that a leading computer expert Steve Balmer (from Microsoft) described Linux as cancer."

Throw enough chairs and eventually you will break Windows...

"Introducing a foreign product like Linux which is often copied for free could threaten that entire industry. A generation of computer users might get use to accepting foreign software hand-outs rather than paying for a superior American products. If only the danger were just to our economy"

That might be true if the American capitalist pigs were not outsourcing their programming jobs to Pakistan and India, maybe even China too.

"These days computers control everything from TV stations to battleships"

Like the USS Yorktown that BSOD in training and was left dead in the water whist on training in the Gulf. Lovely.

"If you guessed it was Linux you would be 100% right. Osama uses Linux because he knows designed to counterfit DVDs, curcumventing the Digital Millenium Copyright Act, and defraud companies like Disney."

It's probably because he does not want it to crash when he's sending propaganda via the the internet.

"If one of your friends is using Linux or may be tempted to try it show them this article. Explain that Linux is a genuine threat and that by using it they may be opening their computer to Chinese hackers."

No no, it's the other way round, the Chinese hackers are USING linux tools to penetrate Windows pseudo security.

"If you see a company using Linux, it may be that they have not paid for this software. Report them to the Business Software Alliance who have the legal authority to inspect any company's computers for illegal programs like Linux."

WTF! It's illegal now? Since when!

"As individuals we may not be able to change people's minds, but the Bible teaches that God can make any sinner repent."

By Bible does Tristan mean the work of prophets like Brian Kernighan, Ken Thompson or Denis Ritchie? I have a horrid feeling that I have just been trolled.