Monthly Archives: January 2008

Changing The /tmp Cleanup Frequency

While the /tmp folder is not a place to store files long-term, occasionally you want to keep things a little longer than the next time you reboot, which is the default on Ubuntu systems. I know a time or two I’ve downloaded something to /tmp during testing, rebooted after making changes and then lost the original data again. This can be changed if you’d like to keep your /tmp files a little bit longer.  The default on Redhat systems, for example, is to keep files roughly ten-days.

Changing the /tmp Cleanup Frequency

The default setting that tells your system to clear /tmp at reboot is held in the /etc/default/rcS file. The value we’ll look at is TMPTIME.

The current value of TMPTIME=0 says delete files at reboot despite the age of the file. Changing this value to a different (positive) number will change the number of days a file can survive in /tmp.

TMPTIME=7

This setting would allow files to stay in /tmp until they are a week old, and then delete them on the next reboot. A negative number (TMPTIME=-1) tells the system to never delete anything in /tmp. This is probably not something you want, but is available.

I have been wondering how to do this on Ubuntu and finally found it today.  Enjoy.

Continued Impressions of Ubuntu 7.10 on the EeePC

Someone asked me today how Ubuntu was working on the EeePC.  It’s working great!  I thought I might share some of my experiences so far, after a bit more use.  If you are interested in installing Ubuntu 7.10 on your EeePC head on over to the Ubuntu Community Wiki and find out how!

Travel

This machine is so light I love it.  It’s easy to carry around, takes up minimal space, and is really easy to use on an airplane.  I’ve been on four flights since getting this machine and it makes for a great little video player (sans optical drive, of course) for using in flight.  I simply rip the videos I want down to .mpg or something and throw them on a removable USB.

Productivity

I’ve been on two business trips now since Christmas and this is the only machine that I have taken with me.  I have not run into an issue yet with wishing I had something bigger.  When I’m using it during the day I connect my USB mouse, and go.  Wireless works great, the keyboard is fine once you get used to it.  I can do web browsing, chat, email, write code.. pretty much everything I used to do on my MacBook (minus write CD/DVDs and use virtualization).

Recommendations

I really recommend this machine.  I really like it, and I’m really glad that my awesome wife bought it for me for Christmas.  Man does she spoil me!  If you’ve been thinking about it, I’d go for it.  It’s cheap, tiny and just as productive as any comparably priced device.

Complaints

The only complaints that I have are:

  • There is no visual indication that the CAPS LOCK is on.
  • The right-shift key is a real PITA sometimes.

Do yourself a favor if you’re still running the default OS and toss out the Xandros junk and use a real distro.. the one-true Distro, Ubuntu! :)

Adding Additional Repositories

UPDATE: As it has been pointed out in the comments, all of the core repositories are enabled in Ubuntu 7.10. This post will only apply to users still on 6.10 and earlier.

It has been quite some time since I’ve outlined adding and customizing your repository setup on Ubuntu. I figure it’s time for a reminder post, and I’ll show you what I use on my machines.

Repositories

In order to download and install Ubuntu packages your machine needs to know where to find them. These packages are stored in different locations called repositories, which are organized into a few main groups. The group definitions are as follows:

  • main – supported by canonical, core repository.
  • restricted – supported by canonical, containing non-free software.
  • universe – community supported, strictly free software.
  • multiverse – community supported, containing non-free software.

By default only main and restricted are activated on a new machine. In order to follow many of my tutorials you’ll need the other two activated. (I know I haven’t done a great job of specifying which repository is needed for which package, but I’ll try and improve.)

To activate these you can use the graphical method or the commad line method. Both are pretty easy, I’ll outline each below:

Graphical Repository Configuration

Navigate to “System > Admin > Software Sources” and you’ll be presented with five check-boxes. By default you may only see two of these checked. Check the additional two (universe and multiverse), and you can safely leave the fifth item, source code, unchecked.

Command Line Repository Configuration

The method above is dead-easy, but you may also be working on a server that doesn’t have a GUI installed. In this case you may want to edit the file under-the-hood manually. You can find this file in /etc/apt/sources.list. My file looks like:

deb http://us.archive.ubuntu.com/ubuntu gutsy main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu gutsy-updates main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu gutsy-security main restricted universe multiverse

Each line should begin with deb, so if the browser or wordpress wraps the lines above, it should come to three lines when you edit your file.

By default you’ll have a bunch of other lines, and a lot of commented options. I find that my config should be a safe bet for most users. Note: you also may want to change your repository location, as mine is pointing to the US servers.

It is also common to find suggestions on using third-party repositories for other software. I, and most other members of the support community, HIGHLY avoid this. It can cause problems with current packages, and can cause issues with upgrading. Adding a repository other than the official Ubuntu repositories can limit the level of support you can recieve.

Ubuntu Tutorials License Page

I just realized that I no longer have the blog license published in the footer like I did in my previous theme. For that reason I have created a page outlining the license restrictions for use with these tutorials.

Basically, the contents of this blog are licensed under the terms of the Creative Commons Attribution Non-Commercial Share-Alike 3.0 Unported license.

Exceptions to this license have been given to Ubuntu Community Members for use within the Ubuntu Development Wiki and Ubuntu Community Wiki. Currently no other exceptions apply. If you would like to request other exceptions you can contact me.

Configuring AWStats on Ubuntu Server

Last nite I sat down and configured AWStats on my Ubuntu 7.10 server. I had previously been using statcounter, a free stat service, but I had noticed that it was one of the causes of slowdown on my page loads. Having to access an external site and javascript wasn’t helping. I also run the server so I have full access to the server logs, why not just use those directly.

So far I am really happy with AWStats. It appears to be running properly and pulling in a lot more data than statcounter ever did. It actually is showing me that I had much more traffic than I thought. I had mentioned 5,000 the other day, which I have long since surpassed based on AWStats output.

I’d like to share the steps I took for installing and configuring AWStats on my Ubuntu Server.

Installation

Ubuntu has the AWStats package available in the repositories, which we can install with:

sudo aptitude install awstats

This will install the basic files, but there is still a bit of configuring to do, so we’ll dive into that next.

Auto Configuration

From the tutorials that I found elsewhere in my searching there is a awstats_configure.pl file that will try to configure it for you. I did not use this personally, but if you’d like to try it you can run:

sudo perl /usr/share/doc/awstats/examples/awstats_configure.pl

The rest of this tutorial will discuss manual configuration, but if anyone can offer feedback concerning the configure script I’m sure many would be interested.

Manual Configuration

I configured my system manually, which I will outline below. The only requirements here are that you have access to the apache2 logs, or that you have custom log locations for each of your virtual domains (if used). For more information on custom log locations for virtual domains see my previous post, Configuring Virtual Hosting on Ubuntu with Apache2.

The first step is creating an awstats.conf file for your domain. This can be done by moving or copying the /etc/awstats.conf, and giving it a more unique name:

sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.domain.tld.conf

I created a unique file, using the syntax awstats + domain.tld + conf for each of the domains hosted on my server. Each of these also has their own unique log file as well.

We’ll then edit our new /etc/awstats with custom values for that domain. The main points you’ll want to look for within this file:

  • LogFile=”/path/to/your/domain/access.log”
  • LogFormat=1 (this will give you more detailed stats)
  • SiteDomain=”domain.tld”
  • HostAliases=”www.domain.tld localhost 127.0.0.1″

Once you’ve made these changes you’ll want to build your initial statistics, which will be generated from the current logs on your machine. We can do this using:

sudo /usr/lib/cgi-bin/awstats.pl -config=domain.tld -update

What this will do is scan the /etc/awstats folder for anything of the pattern awstats + domain.tld + conf, reading that config to generate its output. You should see some output here, and depending on the size of your logs it’ll take anywhere from a few seconds to a few minutes or hours. Each time it is run after that will be minimal, as it only updates the information, but the initial generation can take some time.

Configure Apache to Display AWStats

At this point our statistics should be generated (if not, go back and double check you haven’t missed anything!), but we need a way to see them. We’ll need to configure Apache2 to show us these stats. The way I did this was by using an Include in my apache2.conf, instead of cluttering up the default config file. This is generally my preferred method.

Apache2.conf already has a line near the botton Include /etc/apache2/conf.d/, which will read anything in there as additional data. What I did was create a new file in the /etc/apache2/conf.d/ directory called awstats, and filled it with the following content:

Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

This is basically creating some access aliases, and defining the cgi-bin paths, etc. Once this is saved you should be able to restart Apache2 and we’ll should be able to access our stats. Restart Apache2 using:

sudo /etc/init.d/apache2 restart

You should now be able to access your statistics using:

http://domain.tld/awstats/awstats.pl

Assuming you didn’t get any errors during your stats generation, and Apache2 didn’t complain when you restarted the service, you should see statistics at this point.

Continually Updating Your Stats

The last thing you’ll probably want to do is update your statistics via cron. This will allow you to have your site statistics updated on a regular basis, not requiring intervention on your part. What I have done is added a line to my /etc/crontab file telling AWStats to update every ten minutes. I have seen minimal system load even when updating a dozen sites on that interval. To update every ten minutes we’ll add the following line:

*/10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=domain.tld -update >/dev/null

Repeat this line, updating the domain.tld value for any site you want continually updated.

Securing Statistics

If you’d like to make your statistics private you might be interested in one of my previous posts, Limiting Access To Websites & Directories with .htaccess.

Requesting Apache2 Tuning Tips

In a continued effort to keep this site online all the time I’m looking for some help in tuning apache2.  Earlier today we ran into some serious performance issues based on what I had it tuned to, which caused 3/4 of the total swap to be used.  NOT a good idea.

In the meantime I have turned things down a bit in the prefork MPM section, but I’m wondering what other tips the community has.  What values do you suggest in prefork MPM for performance tuning?

The box is a quad-core xen vps with 512M.  I have 5,000+ unique visitors a day on this site in addition to the dozen other blogs hosted (none near as popular).  What can I do to keep up with the traffic, yet keep the load down on the machine for performance?

Disabling SSH connections on ipv6

I was parsing through some of the logs on my new server tonite and I saw some unsuccessful ssh connection on ipv6. I thought I would mention quickly how you can disable listening on ipv6.

ListenAddress

The /etc/ssh/sshd_config file configures how your ssh daemon should run. By default it is likely listening on 0.0.0.0 (all ipv4 addresses) and :: (all ipv6), which is defined by two lines:

#ListenAddress 0.0.0.0
#ListenAddress ::

To configure your server to *not* listen on ipv6 you can remove that line. Now it might appear a bit confusing that the line we’re removing is commented out. That means its not reading that line, right? In this case it is displaying one of the default settings. I have altered my file to only listen on my public facing ipv4 address by removing the “::” listing, and specifically defining an ip instead of “0.0.0.0”.

Another solution which was brought to my attention by a comment is outlined here:

AddressFamily any # default
AddressFamily inet # IPv4 only
AddressFamily inet6 # IPv6 only

By defining the AddressFamily type that we want to use we can listen on both ipv4 and ipv6, just ipv4 or just ipv6. Find the line above in your config and define the AddressFamily you would prefer to listen on.

Once you update these lines you’ll need to restart your ssh service.

sudo /etc/init.d/ssh restart

Also, as a second measure you can firewall ipv6. I’ll be posting a firewall tutorial soon, but the below single command will block all incoming traffic on ipv6:

sudo ip6tables -P INPUT -j DROP

Database Update

I’ve just done an update of the database for this blog.  I did an export and a giant find/replace for some formatting tags I wanted updated.  If you notice anything really odd about the site, pages not displaying, content screwed up, etc please let me know.

It appears all is well.. so far.

What I did was go back and add the code tag to all of the blockquotes, which shoud clean up a bit of the formatting.  This should help avoid things like reformatting of dash-dash, etc.

How To Install KDE 4.0 in Kubuntu 7.10

With all the hoopla and excitement today in regards to KDE 4.0 release I thought I would publish some instructions on installation for those that want to try it out. There is a KDE 4.0 LiveCD available if you’d like to “try before you buy”, and this tutorial will install KDE 4.0 alongside your current installation so you should still be able to revert if you run into problems.

This tutorial is based on Ubuntu Geeks KDE 4.0 guide and the KDE 4.0 guide at Kubuntu.org.

Installing KDE 4.0

First of all we need to update the repository sources list to pull these new KDE 4.0 packages from the kubuntu team PPA (Personal Package Archive). We do that by editing the /etc/apt/sources.list file:

sudo vim /etc/apt/sources.list

You’ll want to then append this line:

deb http://ppa.launchpad.net/kubuntu-members-kde4/ubuntu gutsy main

(The above should be on one line.) We’re now ready to install the KDE 4.0 packages:

sudo aptitude update
sudo aptitude install kde4-core

Removing Previous KDE 4.0 Releases

note: do make sure you remove any previous KDE 4.0 installations you may have been playing with. The previous packages can have conflicts with this newer release from the PPA.

To remove previous KDE 4.0 packages, use the command:

sudo aptitude remove kdelibs5 kde4base-data kde4libs-data

You can now launch your newly added KDE 4.0 environment from the login manager by selecting KDE 4. Enjoy!

Category: KDE

Ubuntu 8.04 Alpha 3 Released

Ubuntu 8.04 alpha 3 was released today.  For those that do active bug work please help squash the bugs in 8.04 so we can make a *really* solid LTS release this spring.  Release announcement and download locations below:

———-

Welcome to Hardy Heron Alpha-3, which will in time become Ubuntu 8.04.

Pre-releases of Hardy are *not* encouraged for anyone needing a stable system or anyone who is not comfortable running into occasional, even
frequent breakage.  They are, however, recommended for Ubuntu developers
and those who want to help in testing, reporting, and fixing bugs.

Alpha 3 is the third in a series of milestone CD images that will be
released throughout the Hardy development cycle. The Alpha images are known to be reasonably free of showstopper CD build or installer bugs, while
representing a very recent snapshot of Hardy. You can download it here:

http://cdimage.ubuntu.com/releases/hardy/alpha-3/ (Ubuntu)
http://cdimage.ubuntu.com/kubuntu/releases/hardy/alpha-3/ (Kubuntu)
http://cdimage.ubuntu.com/edubuntu/releases/hardy/alpha-3/ (Edubuntu)
http://cdimage.ubuntu.com/jeos/releases/hardy/alpha-3/ (Ubuntu JeOS)
http://cdimage.ubuntu.com/xubuntu/releases/hardy/alpha-3/ (Xubuntu)
http://cdimage.ubuntu.com/gobuntu/releases/hardy/alpha-3/ (Gobuntu)

See http://wiki.ubuntu.com/Mirrors for a list of mirrors.

Alpha 3 includes several new features that are ready for large-scale
testing.  Please refer to http://www.ubuntu.com/testing/hardy/alpha3 for
information on changes in Ubuntu and
https://wiki.kubuntu.org/HardyHeron/Alpha3/Kubuntu for changes in Kubuntu.

This is quite an early set of images, so you should expect some bugs.  For a
list of known bugs (that you don’t need to report if you encounter), please
see: http://www.ubuntu.com/testing/hardy/alpha3

If you’re interested in following the changes as we further develop
Hardy, have a look at the hardy-changes mailing list:

http://lists.ubuntu.com/mailman/listinfo/hardy-changes

We also suggest that you subscribe to the ubuntu-devel-announce list
if you’re interested in following Ubuntu development. This is a
low-traffic list (a few posts a week) carrying announcements of
approved specifications, policy changes, alpha releases, and other
interesting events.

http://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-announce

Bug reports should go to the Ubuntu bug tracker:

https://bugs.launchpad.net/ubuntu