Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Tuesday, 29 January 2013

Using bluetooth audio in Linux

I just spent a while trying to find out how to get my laptop to play audio to a Bluetooth Headset. It seems a lot of the info out there is out of date. Here are some instructions that work with bluez version 4.9X on Ubuntu 12.04.

Firstly make sure you've got the following packages e.g.:
% sudo apt-get install bluez alsa-utils

To do it you need to make sure all the bluetooth kernel modules are loaded - the following command should show the bluetooth modules if they're loaded e.g.:
% lsmod | grep blue
bluetooth 158479  23 bnep,rfcomm,btusb

Then you can check the bluetooth adapter is operational by showing its address info e.g.:
$ hciconfig
hci0:    Type: BR/EDR  Bus: USB
    BD Address: 00:02:7e:16:0D:0a  ACL MTU: 384:8  SCO MTU: 64:8
    UP RUNNING PSCAN ISCAN 
    RX bytes:58444 acl:314 sco:0 events:6846 errors:0
    TX bytes:4821276 acl:17765 sco:0 commands:152 errors:0

Next you need to switch on your headset and put it into discovery mode (e.g. push and hold the power button or something). Then you get your laptop to scan for it e.g.:
% hcitool scan
Scanning ...
    00:0B:E4:9A:15:E4    Nokia BH-214

Then you need to pair with this device as follows - It will ask you for the PIN code for your device (e.g. 0000 or 1111 or something) and then it will add it to the list on your machine (you'll need to replace the bluetooth interface 'hci#' with your one in this part e.g. hci0) e.g.:
% sudo bluez-simple-agent hci# 00:0B:E4:9A:15:E4
RequestPinCode (/org/bluez/9261/hci0/dev_00_0B_E4_9A_15_E4)
Enter PIN Code: 0000
Release
New device (/org/bluez/9261/hci0/dev_00_0B_E4_9A_15_E4)

Now you need to set up the device for use by ALSA sound system - create a file called ~/.asoundrc containing the following (you'll need to replace the bluetooth address with your one in this part) e.g.:
pcm.bluetooth {
   type bluetooth
   device 00:0B:E4:9A:15:E4
}

Finally you can now play audio to your headset:
aplay -D bluetooth myaudio.wav

Or you can select the bluetooth audio device in other audio apps.

Thursday, 1 December 2011

Linux traffic Control (tc)

The world of Linux's Traffic control is a mysterious thing - you end up spending hours Googling or days reading source code.

For some nitty gritty on tc see an earlier post of mine on tc rate limiting and pitfalls.

TC Queuing Disciplines (qdisc)

Creating:
E.g Add a tbf qdisc on eth0:
sudo tc qdisc add dev eth0 root tbf rate 10mbit burst 100kb latency 50ms

Listing:
E.g. Show qdiscs on all interfaces:
tc qdisc show

Delete:
E.g. Delete all qdiscs on eth0 interface:
sudo tc qdisc delete dev eth0 root


TC Filters

Creating:
Here's some good info on the u32 filter (here and here). Some more with a quick overview from LARTC mail list (the source of most useful info on tc etc). Someone put together a tc manual.

Listing:
E.g. Show filters on eth0 interface:
sudo tc filter show dev eth0 root

Here's some example output:
filter parent ffff: protocol ip pref 49152 u32

Deleting:
To delete the above example filter (bold section copied from filter show output):
sudo tc filter del dev eth0 parent ffff: protocol ip pref 49152 u32

[updated:17feb12, 5,6jul12,29jan20: more explanations+archive.org link for 1st link as it's gone MIA, link to older article of mine; Added TC qdisc cmds]

Tuesday, 18 January 2011

Shrinking Linux virtual disks on OSX VMWare fusion

So your virtual disk is taking up tonnes of space - despite the fact it's not that big when you check its size in the Virtual machine. It's annoying that VMWare images don't do better auto shrinking...

Anyway I tried to run the vmware-tools which I installed (after a bit of jiggery-pokery) and it comes up with a 'Shrink' tab but no disks appear in the list to shrink?! Any suggestion as to how to get disks to show up there are welcome but I couldn't find much on the web about it...

So instead I looked about and the best way is to take the following steps:
  1. Start your VM OS up and optionally remove any cruft. At least run:
    sudo apt-get autoclean
  2. To prepare for the shrinking process run:
    sudo cat /dev/zero > zero;sync;sleep 1;sudo rm zero
    This fills all remaining space on your virtual disk with a file full of zeros so the space can be reclaimed in the shrinking step.
    Note: Your hard disk WILL NOT fill up as the vmdk images do actually optimise the storage of files containing zeros
  3. Shutdown VM OS and delete any snapshots available then Quit VMWare Fusion
  4. To start the shrinking process in OSX run (Replacing path_to_your/disk with something like '/Users/username/Documents/Virtual Machines/Ubuntu/Ubuntu.vmdk'):
    cd '/Applications/VMware Fusion.app/Contents/Library'
    ./vmware-vdiskmanager -d path_to_your/disc.vmdk
    ./vmware-vdiskmanager -k path_to_your/disc.vmdk
    
    The first command defragments the disk, whilst the second actually does the shrinking.
    (Note: The directory for 'cd' for 3.X of VMware Fusion was:
    /Library/Application Support/VMware Fusion/) 
[27jan12: Updated for VMware Fusion 4.X]

Thursday, 11 November 2010

Too many package managers

On every system someone seems to invent a new package management system which means you've gotta learn the nearly the same thing over and over again. Tedious... Here's some notes to myself about how you can do basic stuff in a few I use (OSX/MacPorts[port], Ubuntu/Debian[aptitude,apt], RedHat/RPM[rpm,yum]).

Install Package
OSX% port install ThatPeskyPackage
ubuntu% aptitude install ThatPeskyPackage
ubuntu% apt-get install ThatPeskyPackage
ubuntu% dpkg -i ThatPeskyPackage.deb
RedHat% yum install ThatPeskyPackage
RedHat% rpm -i ThatPeskyPackage.rpm

Remove Package
OSX% port uninstall ThatPeskyPackage [version]
ubuntu% aptitude remove ThatPeskyPackage
ubuntu% apt-get remove ThatPeskyPackage
RedHat% yum erase ThatPeskyPackage
RedHat% rpm -e ThatPeskyPackage.rpm

Package Info
OSX% port info ThatPeskyPackage
ubuntu% aptitude install ThatPeskyPackage
ubuntu% apt-get install ThatPeskyPackage
RedHat% yum info ThatPeskyPackage
RedHat% rpm -qi ThatPeskyPackage

Package Content: What files did it install?
OSX% port contents ThatPeskyPackage
ubuntu% dpkg -L ThatPeskyPackage
RedHat% rpm -ql ThatPeskyPackage

What package does this file belong to?
OSX% port provides /usr/some/place/weird/whatisthis
ubuntu% dpkg -S /usr/some/place/weird/whatisthis
RedHat% rpm -qf /usr/some/place/weird/whatisthis

Which packages have I got installed?
OSX% port installed
ubuntu% dpkg --get-selections
RedHat% rpm -qa
RedHat% yum list

Friday, 16 July 2010

Ubuntu 10.04 USB Mouse keyboard problems - fixed

After the problems I had after 9.10 upgrade I held off on upgrading to Ubuntu's latest 10.04 (Lucid something-or-other), with kernel 2.6.32-21. Sadly it was another disaster - after upgrade neither my mouse nor keyboard worked beyond the Grub screen.

I looked into it; initially I thought it was an X thing with their new nouveau Nvidia driver but it wasn't that. I then noticed that the devices weren't actually being seen by the system on the USB bus - i.e. when I ran lsusb I only saw a couple of USB hubs (no mouse or keyboard listed) where normally I saw about 6 USB devices - yes they were plugged in and were recognised fine by an older kernel (9.10). I messed about with usbhid kernel module to no avail. I then tried 10.04 live CD and it worked ok with exact same USB setup?! I dumped the output from dmesg and then compared it with dmesg from my machine running the installed version on the exact same kernel version. It seemed that my installed version was failing to recognise the actual PCI USB host controllers on bootup - WTF?! It seems that the ehci-hcd module was not finding the USB hardware.... Smells like a kernel bug.

Finally I tried altering various boot args for the kernel in /boot/grub/menu.lst which didn't work initially, but then I hit upon the right one: pci=noacpi. It now works though my fans seem to be going full speed at all times...

[updated: 21aug10] Unfortunately after the kernel latest update (2.6.32-24) it seems to be totally broken and my fix doesn't work so I've had to revert to using 2.6.32-21 - If you run any DKMS modules (e.g. nvidia) you'll need to have the kernel header files installed that kernel.

Another BIG waste of time....I really am having my doubts about Ubuntu.

Wednesday, 14 April 2010

Finally got my Karmic box working properly!

Ever since I upgraded to Karmic (9.10) my machine has performed like a dog - well as far as keyboard and mouse input went - the mouse would linger and the system would loose my keystrokes. I tried a bunch of things to no avail....

Then I was perusing the web - frustrated by my sluggish machine - I'd read about cpu frequency scaling and wondering if this might be an issue. Well it turned out to be the root of my problem! Though in general I think more modern CPU should operate fine with cpu scaling enabled but these old AMD Opteron CPU's don't seem to be up to it so I've disabled it and the machine behaves a lot better.

To fix it - firstly I installed the cpufrequtils:
sudo aptitude install cpufrequtils
Checked the current state of my machine (You can also do it using any of: cat /proc/cpuinfo, sudo dmidecode -t processor, lshw -C processor):
sudo aptitude install cpufreq-info
 My machine was in 'ondemand' mode - I changed it to 'performance' mode - for each of my two processors:
sudo cpufreq-set -c 0 -g performance
sudo cpufreq-set -c 1 -g performance
This is actually setting the following /sys entries: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

There a few more things you can do with the cpufreq utils.

Tuesday, 23 March 2010

Linux networking secrets

The operation of Linux's networking functions has various not so well described aspects to it. Here's a few I've come across:
  • Kernel DST cache: The kernel caches congestion control related information (e.g. ssthresh, rtt, mtu, cwnd) about every TCP connection and stores it in the 'DST' (Destination) cache after each connection closes, though only for a limited time, reusing for connections to the same destination. To list/show/display the contents of the dst cache:
    ip -s route show table cache
    You just flush the DST caching using:
    ip route flush table cache
    Or you can disable the DST caching using:
    sysctl -w net.ipv4.tcp_no_metrics_save=1
  • Network interface queue size/length monitoring: Everyone goes on about tweaking the transmit queue (txqueuelen) size to get the best result out of your box but no-one tells you how to monitor/check/display/show the size of the queue actually being used. To check actual queue utilisation/use/occupancy - see the 'backlog' (in bytes and packets) as shown by tc (e.g. For eth0):
    tc -s -d qdisc ls dev eth0
  • Default Linux Queue: Amazingly enough the default queue on Linux (pfifo_fast) inspects the TOS (type of Service) bits in the IP header and does priority queuing based upon them - Not sure who - if anyone - is using that???! Anyway you can check to see the priority mappings (priomap) using the tc command above.
  • Detailed socket stats and info (congestion control algo, cwnd, window scale, rto etc) on open sockets (TCP,UDP,RAW,PACKET) on your machine you can use the socket stats app, ss  which uses an INET_DIAG netlink socket to obtain info directly from the running kernel: e.g.
    (args: t: timers, i: TCP internals, m: memory, e: extended, dport: filters on destination port):
    ss -time dport = :5001 
    Memory stats: from net/ipv4/inet_diag.c +140
    rmem = sk->sk_rmem_alloc; wmem = sk->sk_wmem_queued; fmem = sk->sk_forward_alloc; tmem = sk->sk_wmem_alloc;
  • Linux TCP stats: The tcp_probe module may be used to obtain cwnd and sequence numbers of packets in TCP flows.
  • TCP receive (or send) window size is based on sysctrl net.ipv4.tcp_rmem (or tcp_wmem) - the 3 values are min, default, and max. The actual window size relates to these numbers by tcp win = tcp_rmem-tcp_rmem/2^tcp_adv_win_scale - e.g. the system default of 87380 results in a TCP win of 65535. The max window is globally limited by net.core.rmem_max. For more details see linux-2.6/Documentation/networking/ip-sysctrl.txt and man tcp.
  • TCP/Generic Segment Offloading (TSO/GSO) information about your machine's network interface. TSO is quite common these days - it basically offloads the packetisation of TCP segments onto the network card (see my other post where it can lead to confusion). The ethtool command (which may need installing) also tells you about a whole host of features that your NIC may or may not support:
    ethtool -k eth0
  • Traffic Control (TC): I've touched on its use above but I've another post on setting filters with tc.
There's other places that have good info on Linux like: Linux foundation's Kernel networking, Linux network stack walk thru

[Updated:9jul15, 15jan15:DST cache, 1dec11]

Tuesday, 16 March 2010

Dodgy mouse mappings

So you're trying to use (say) your middle mouse button to copy/paste and the darn thing isn't working.... Well there's a bunch of things that control this (see a some articles here, and uhere, khere). Basically if you want paste working with a particular mouse button then you need to make sure it is the second one (ie button two) in the list; So for a normal 3 button mouse the mouse maps (see below) should read: 1 2 3 .... But for ,say a Logitech Trackball, the mapping may want to look like this: 1 8 3 4 .... (as the small left button on these trackball's is actually numbered 8 - check using xinput query-state your_mouse_id).
  • List your input devices using:

    xinput list 
    List mappings using your mouse's 'id' (from xinput list):

    xinput get-button-map your_mouse_id
  • The X config file: /etc/X11/xorg.conf file at the InputDevice section
  • The xmodmap set-up - have you got a .Xmodmap or .modmaprc file lurking? Check your existing setting like this:
    xmodmap -pp
  • The HAL policy - see /etc/hal/fdi/policy/ - any special config there? (NB: HAL disappears from Ubuntu after Karmic 9.10)
  • The UDEV rules - see /etc/udev/rules.d/ and/or /lib/udev/rules.d/
[updated:17jun10]

Tuesday, 23 February 2010

Bash/shell scripts aren't working on Ubuntu

I was just writing a shell script - it all worked fine on the command line so I put it in a file and ran it:
% sh myscript.sh
But it generated an error - specifically I was trying to use brace expansion (a Bash only feature) which it now didn't seem to like. What the heck?

It turns out that on Ubuntu they have switched to a faster-simpler default shell (/bin/dash) - which does actually help to improve boot times - but is no longer bash compliant (so no fancy features - just POSIX 1003.2 features only). So what's happening is that my script is being run by dash - despite it the fact it starts with the usual #!/bin/bash - which confused the hell out of me. Anyway watch out if you've got lazy old habits like assuming that sh is bash.

Friday, 8 January 2010

Accessing OSX install DVD from Linux/Ubuntu

Have you ever tried sticking your Mac [Snow] Leopard/Tiger OSX installation DVD/CD disks into a Linux box and just found a measly little windows partition there with the BootCamp stuff on it, and wondered where all the Mac stuff was hiding? Yeah so have I.

This is how to copy the disk using the dd command (you can do virtually the same thing on OSX - here's an article with some more info):
dd if=/dev/sr0 of=/DVDcopy.iso
For older versions of *NIX (which used to use '-if/-of'):
dd -if=/dev/sr0 -of=/DVDcopy.iso 

However whilst Ubuntu doesn't understand - it is all there just hiding... This handy site explained a way to get to it - directly on DVD. You can use your DVDcopy.iso in the same way. You'll probably need to install the tool (e.g. aptitude install kpartx). On your Linux box you do:
#sudo kpartx -av /DVDcopy.iso
add map loop0p1 (252:0): 0 60 linear /dev/loop0 4
add map loop0p2 (252:1): 0 2020420 linear /dev/loop0 64
add map loop0p3 (252:2): 0 13158216 linear /dev/loop0 2020488
add map loop0p4 (252:3): 0 12 linear /dev/loop0 15178704

Then use file to find out which partition contains the Mac stuff - run file on each one till you find one that says it's an Macintosh HFS e.g:
sudo file -s /dev/mapper/loop0p3
/dev/mapper/loop0p3: Macintosh HFS Extended version 4 data last....

The mount it and you're away:
sudo mount /dev/mapper/loop0p3 /my_mount

You should now be able to see the contents of the Mac (HFS+) partition in the directory /my_mount

Friday, 13 November 2009

Karmic IPv6 Global address problems

If you're running IPv6 on Ubuntu 9.10 with multiple interfaces and you're not seeing any global IPv6 addresses assigned to your interfaces, and you're seeing this kind message in /var/log/messages:
Nov 13 10:10:10 my_machine kernel: [ 1000.101010] eth0: IPv6 duplicate address detected!
Then it's obviously Friday 13th and you should put it down to ....Yeah maybe but yesterday it was the same last week....

It seems there's a kernel (2.6.31-15) bug which means IPv6 Duplicate Address Detection (DAD - see RFC4862) is generating false-positives and subsequently not permitting your global address to be assigned to an interface.

To work around this bug do (change eth0 to your iface name):
sudo sysctl net.ipv6.conf.eth0.accept_dad=0

Tuesday, 10 November 2009

Ubuntu 9.10 (Karmic) has dodgy input problem

I just upgraded to Karmic Koala and I'm NOT impressed - My mouse and keyboard have become unresponsive and sluggish - sometimes even losing keystrokes and control of the mouse for a few milliseconds at a time (I had to go back and correct this post due to missing keystrokes that I did make but didn't register).

I'm considering changing distro if this isn't fixed soon.

[update:9mar10]: See possible fixes here

Tuesday, 25 August 2009

Interact with other local Linux terminal sessions

If you're interested in trying to control/inject/view other terminal sessions (e.g. with ssh or telnet on a tty or pts) that you/someone is logged into on that machine then read on. Handy for zapping that vi session you left running at work, or playing havoc with something random ;)

It seems that watch does the trick for FreeBSD, but for Linux there's only things like ttysnoop (for linux-2.6) but that requires you modify your /etc/inittab files which is a bore. There's also conspy but that only works with physical terminal devices not ptys, as far as the docs say...

However you can do it without altering anything:
  • See what's being typed (and subsequent output) in another terminal session by using peekfd - you just need to supply the UID of the shell running on that other terminal (find it using ps). Watch out as the output may well contain some 8-bits chars which can confuse your current terminal - though you can get it back to normal using a terminal reset. (e.g. sudo peekfd /dev/pts/27)
  • Inject characters into a terminal by using the TIOCSTI ioctl() with this neat Perl script (copied below). Find the tty of the process you're interested in (e.g. ps axg | grep vi) and use that as the argument to the perl script e.g. echo 'ZZ' | sudo ./catvt.pl /dev/pts/27
  • #!/usr/bin/perl -w
    use strict;
    use Fcntl;
    use constant TIOCSTI => 0x5412;
    
    unless (@ARGV >= 1) {
    print "usage: $0 [vt] <input>\n";
    exit; }
    my $vt = shift @ARGV;
    my $buf = join '', <>;
    &writevt ($vt, $buf) || die "can't write to $vt: $!\n";
    exit;
    
    sub writevt {
    my ($vt, $buf) = @_;
    sysopen (VT, $vt, O_RDONLY) || return 0;
    for (my $i = 0; $i < length $buf; $i++) {
    ioctl (VT, TIOCSTI, substr ($buf, $i, 1)) || return 0; }
    close (VT) || return 0;
    return 1; } 
[updated 6jan10]

Tuesday, 28 April 2009

Mounting a Xen .xm (xmfile) disk image file

You've probably wondered how to mount one of these pesky things. It turns out they're actually just entire disk images with a boot sector and often with multiple partitions. On Linux you can use the losetup tool - It allows one to mount a disk image on a /dev/loopX device. If it has multiple partitions then you need to find out where in the image the particular partitions are that you want to mount. Firstly you mount the entire image on a [spare] loop device e.g.:
sudo losetup /dev/loop0 diskimage.xm
Then run fdisk to check out the partition table (in sectors):
sudo fdisk -ul /dev/loop0
It will list the partitions - note down the start of the partition you're interested it and multiply it by 512 (the number of bytes per sector): e.g. If the first partition starts at 63 you multiply it by 512 and get 32256 then you use that as the 'offset' argument (i.e. how far into the disk image your chosen partition resides) to the losetup command:
sudo losetup -o32256 /dev/loop0 diskimage.xm
Next you need to determine the filesystem type - you maybe able to check this what fdisk reports, but you can also use the file command:
file -s /dev/loop0
Then mount that partition onto a spare directory on your system (e.g. ext3 filesystem on /mnt):
sudo mount -text3 /dev/loop0 /mnt
And it should then be mounted at /mnt and away you go. Thanks to this page for getting me going - plus a comment there mentions that there's simpler way to mount the image - if you're running a kernel version > 2.6.26 (You can specify modprobe loop max_part=63 and it will create the partitions automatically on calling losetup - but that only works if loop is a module - which it isn't in Ubuntu 9.04).

[corrected 2oct09]

Monday, 8 September 2008

Dynamic library dependencies - direct or not?

So you're looking at some (Linux) binary and wondering what libraries it uses - You can use ldd to list all the dependencies:
ldd /path/to/your/app
However this shows direct and indirect (i.e. those needed by other libraries) dependencies, so you can tell what are just the direct dependencies by using readelf:
readelf -d /path/to/your/app
The direct dependencies are the libraries listed as NEEDED.

Wednesday, 13 August 2008

Automatically blocking failed ssh attempts

If you run an ssh server (sshd) and you're connected to the Net on a public IP then you'll likely be seeing a serious amount of wanna-bee hax0rs trying your box. Pain in the ass. Fortunately there's a few tactics that can be deployed. There's a good article here that covers it. Plus there's a good 'stickied' discussion from a good list of security issues on LinuxQuestions.org. Basically as far as I was concerned two options seem to be the best:
  • Run fail2ban

  • Or install some natty firewall rules (cribbed from above article) written by this guy:

  • (1) Create a custom chain for whitelisting first:
    iptables -N SSH_WHITELIST

    (2) Whitelist any host(s) that you like:


    iptables -A SSH_WHITELIST -s TRUSTED_HOST_IP -m recent --remove --name SSH \
    -j ACCEPT

    (3) Add the blocking rules:


    iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set \
    --name SSH
    iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j SSH_WHITELIST
    iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update \
    --seconds 60 --hitcount 4 --rttl --name SSH -j ULOG --ulog-prefix SSH_brute_force
    iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update \
    --seconds 60 --hitcount 4 --rttl --name SSH -j DROP
  • Advantage: Transparent for users
  • Disadvantages:
    • Does not distinguish between successful logins and unsuccessful login attempts (i.e. three successful logins within one minute will trigger just like three unsuccessful login attempts).

Tuesday, 1 July 2008

Apache tuning

The number of options for tweaking apache is pretty overwhelming. Tuning apache depends on a number of factors - depending on how much resources you have to throw at it and how you decide to run your system, and what you want out of it. There's quite a few places out there that offer some advice (apache, Scrollbag general tuning, IBM network tuning, IBM svn).

I'm mostly interested in fast low memory setup of apache 2 on Linux. One of the first things to decide is what MPM mode you decide to use for your apache installation - there's bunch. In fact Apache2 supports three MPM's prefork, worker, and event. To check which one you're running use either:
apachectl -l which will list the compiled modules - where 'prefork.c', 'worker.c', or 'event.c' indicate the version in use. You can also check by running apache2 -V. To use a different one you usually have to load the appropriate package on your system - but it will depend on which modules you have installed - e.g. using PHP will result in MPM prefork as PHP is not entirely thread safe.

I am currently running in prefork (a bit old school but simpler). In this mode the number of httpd daemons started - which is mainly controlled by ServerLimit directive (and subsequently MaxClients) - whilst there are quite a few others control how many instances are started initially and kept spare etc. You need to make sure that your machine has enough memory to for the number of servers so the machine doesn't start to swap unnecessarily; Once you have sorted out the modules (see below) and config for the server you can see how much memory a single httpd instantiation uses (check using top command). Once you know how much one httpd uses then configure things so that ServerLimit * httpd_memory is less than the total amount of memory available on the system when apache is not running. You can check to see if you got it right by running the system up (with some requests and all servers started - you can set StartServers directive equal to Serverlimit for testing) and checking there is minimum swap activity - using the vmstat command - run it vmstat 5 and check that the so/si (swap out/in) columns are close to zero - if not then tweak down the number on ServerLimit.

Apache provides a vast array of modular functionality - through its loadable modules support. Firstly you want to go through you the modules that you need loaded for your setup, then comment out all the ones you don't need. Things like unneeded language modules (php, python etc) should be off, and stuff like mod_status (particularly ExtendedStatus) should be switched off once you have got your config sorted.

[8dec08] New page on apache optimisations.
[12sept12]: Added info on checking MPM in use.

Wednesday, 19 March 2008

Linking to different versions of a dynamic library

On Linux there's loads of [dynamic ".so"] libraries in places like /usr/lib. The libraries have version numbers; Major version indicates major (API) changes, whilst the minor version typically relates to bug fixes. These version numbers are firstly enshrined with the library using a special symbol (SONAME) - which is assigned on library creation (using the -soname arg to ld). Also libraries are named with their version numbers libsomething.so.2.3. You can verify this using:
objdump -p libsomething.so.2.3* | grep SONAME

So if you're developing and you want to link to specific version what do you do? Well basically there's no neat trick to get the linker (ld) to link a specific version at compile time :( so you can either:
  • Link using the full path to the specific library version
  • Create a softlink/symlink (ending in ".so" - with NO version) to the specific library version
ldconfig does do some stuff related creating links for libraries but as explained here it won't create the plain ".so" necessary for development - these are usually included as part of a "dev" (usually suffixed by "-dev") package on your system (be it Debian or Red Hat or whatever).

Wednesday, 28 November 2007

Ubuntu upgrading

Using graphical interface:
gksu "update-manager -c"

Or on the command line:

sudo apt-get upgrade
sudo apt-get dist-upgrade

On Ubuntu server:

sudo aptitude install update-manager-core
sudo do-release-upgrade

For more info see the Ubuntu Guide.

Tuesday, 27 November 2007

What Linux (Ubuntu) version am I running?

To display the version of the Ubuntu you're running - run this on the command/cmd line (Or check the contents of /etc/lsb-release):
lsb_release -a

An example response should look like:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.04
Release: 7.04
Codename: feisty


In theory it should work on any LSB (Linux Standard Base) distro...