Tag: linux

  • Setting the sticky bit recursively on directories only

    This is more of a reminder for me.

    Several times recently I’ve run into problems where files in a MultiUser Mercurial repository on a linux host are getting the wrong group permissions. If you properly set the group sticky bit when you first setup the repo, you won’t have this issue. To fix the issue, I needed to set the sticky bit on every directory in the .hg/store directory recursively.

    find /path/to/.hg/store/ -type d -exec chmod g+s {} \;

  • HOWTO: Enable Wireless Networking on Boot in Ubuntu Linux without NetworkManager

    Building on my previous post, this is how to enable wireless networking on boot without NetworkManager.

    I’m using WPA in this example, but the setup is similar for WEP and WPA2 using wpa_supplicant.

    Remove NetworkManager (Optional)

    sudo apt-get remove network-manager

    Setup WPA Supplicant

    To convert the WPA passphrase into the appropriate form (which is salted with the SSID), you need to use wpa_passphrase. For example:

    wpa_passphrase my_ssid my_secret_password

    Generates:

    network={
    ssid=”my_ssid”
    #psk=”my_secret_password”
    psk=6bea99c21cff6002adc637d93a47fba760ec5e6326cb41784c597b6691ed700d
    }

    Using this information, you need to setup /etc/wpa_supplicant.conf like so:

    ap_scan=1
    network={
    ssid=”my_ssid”
    #psk=”my_secret_password”
    psk=6bea99c21cff6002adc637d93a47fba760ec5e6326cb41784c597b6691ed700d
    }

    Enable Wireless Interface

    Put an entry in /etc/network/interfaces for wlan0 (or wlan1, or whatever your wireless interface is).

    NOTE: I’ve put the DHCP option here for completeness, but I ran into problems with a Belkin USB F5D9050 wireless adapter not getting an IP successfully, even after it associated with the AP. I’m not sure if this was a problem with the device, the linux driver, or the AP. I ended up adding a DHCP reservation on the AP and then using a static IP configuration on the server.

    Option 1: DHCP

    auto wlan0
    iface wlan0 inet dhcp

    Option 2: Static IP

    auto wlan0
    iface wlan0 inet static
    address 192.168.0.20
    gateway 192.168.0.1
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    wpa-driver wext
    wpa-conf /etc/wpa_supplicant.conf

    Debugging

    If you are having issues getting this to work, one debugging trick is to start up wpa_supplicant directly in the foreground and checking the output of dmesg and /var/log/syslog for additional details.

    sudo wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd
    
  • HOWTO: Enable Wired Networking on Boot in Ubuntu Linux without NetworkManager

    A lot of Linux distros are going to applet-based management of their network connections in their desktop flavors. For example, Ubuntu Linux Desktop Edition has been using the Gnome applet NetworkManager since at least 9.10 Karmic Koala. While it works great most of the time, I’ve run into issues with it several times.

    UPDATE:I believe this issue may have gone away with recent versions of NetworkManager.
    The first was that (at least with 9.10) while NetworkManager was running from boot, it didn’t start receiving commands to connect until the user initiated their Gnome session by logging in. If you wanted to run an SSH server on the machine, you wouldn’t be able to connect to it until a local user logged in.

    The second issue is that I often times end up using the Desktop Edition in a server-like capacity and turn gdm/X off entirely. The Desktop Edition has a shorter-lead time for package updates (which can be both a blessing and a curse). In my experience it’s also easier to find help/info on it versus the Server Edition. I recently setup a machine to act as a server for my dad, connecting to his weather station’s base station and uploading the results online. I ended up using the Desktop Edition of 11.04 because the server version didn’t have support out-of-the-box for some of his hardware.

    Anyways, while I found it maddening to find a solution to initially, like many things Linux, once you know the magic incantation to recite, it’s cake.

    Remove NetworkManager

    This is optional and many of you may want or need to keep it around. For me, in the cases where I need to use this at all, I find it easier just to completely remove NetworkManager from the picture.

    sudo apt-get remove network-manager
    

    Enable Wired Interface

    Put an entry in /etc/network/interfaces for eth0 (or eth1, or whatever your wired interface is).

    Option 1: DHCP

    auto eth0
    iface eth0 inet dhcp

    Option 2: Static IP

    auto eth0
    iface eth0 inet static
    address 192.168.0.10
    gateway 192.168.0.1
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255

    Now your network interface should come up on boot, without NetworkManager!

  • HOWTO: Disable IPv6 in Ubuntu Linux

    Although we are edging closer to wide-spread IPv6 adoption with milestones such as World IPv6 Day, we aren’t quite there yet. Since I don’t use IPv6 on my LAN, I prefer to disable it. These instructions were written with Ubuntu 11.04, but it should work for 9.x,10.x, and probably many other distros as well.

    Check if IPv6 is enabled

    cat /proc/sys/net/ipv6/conf/all/disable_ipv6

    0 means IPv6 is Enabled while 1 indicates that IPv6 is Disabled

    Disable IPv6

    Add the following to /etc/sysctl.conf

    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1

    Reboot!

  • Ubuntu 11.04 Natty Narwhal Upgrade – Grub Prompt on First Reboot

    I just updated one of my VMs from Ubuntu 10.10 to 11.04 Natty Narwhal using the Update Manager. All seemed to go well during the upgrade process. When it rebooted for the first time however, I was left with a grub prompt rather than a booting system. Grrrrrr.

    NOTE: The following assumes the default disk layout. If you installed to a different disk or partition, you’ll have to adjust the steps below accordingly.

    The fix is to manually boot the system at the grub prompt by typing

    set root=(hd0,1)
    linux /boot/vmlinux-2.6.38-8-generic root=/dev/sda1 ro
    initrd /boot/initrd.img-2.6.38-8-generic
    boot

    Then once you are successfully booted, re-install grub like this:

    sudo grub-install /dev/sda
    sudo update-grub

    Thanks to Rob Convery for the tip!

  • Erasing a hard drive using a Linux LiveCD

    Normally when I need to erase a hard drive, I use dban. Recently however, I’ve run into issues with dban not detecting disks (I’m guessing it doesn’t support the I/O controller/drivers). While it isn’t as secure, a decent and easy way is to just zero out the hard drive using a Linux LiveCD (besides, if you really want it done securely, physically destroy the drive). Ubuntu is my usual distro of choice but there are tons out there that will work.

    dd if=/dev/ of=/dev/sda bs=4096
    

    To get an update on it’s progress, you can signal it from another terminal using

    pkill -USR1 ^dd