Tag: ubuntu

  • How to easily find the full path of a command in Ubuntu

     

    If you’re writing scripts or making cron jobs you will need to know the full path of the commands you’re using; rather than just being able to use “ls” you would have to use “/bin/ls” instead. You could use the find command here but there’s a quicker and more elegant way: which. Use it like so:

     

    which ls

     

    will return:

     

    /bin/ls

     

    Not everything will be in /bin, e.g.:

     

    which timeout

     

    will likely return:

     

    /usr/bin/timeout

     

    Simple but it will make your life quite a bit easier when writing scripts, particularly with new commands or command which you don’t use often.

  • How to restart NFS server on Ubuntu

     

    Once you set up your NFS exports by adding lines to /etc/exports you need to restart your NFS server; do this with the following:

     

    sudo /etc/init.d/nfs-kernel-server restart

     

    You should see output along the lines of:

     * Stopping NFS kernel daemon                 [ OK ]
    * Unexporting directories for NFS kernel daemon…           [ OK ]
    * Exporting directories for NFS kernel daemon…
    exportfs: /etc/exports [1]: Neither ‘subtree_check’ or ‘no_subtree_check’ specified for export “10.1.1.87/24:/nfs/sharedDir”.
    Assuming default behaviour (‘no_subtree_check’).
    NOTE: this default has changed since nfs-utils version 1.0.x

     

    Assuming no error messages pop up here you should now try to connect to your NFS share.

  • ZFS on Ubuntu error: Failed to load ZFS module stack

     

    If you see the above error in a fresh installation of ZFS on Ubuntu one cause may be that the package build-essentials wasn’t installed prior to installing the ubuntu-zfs package; run:

     

    sudo apt-get purge ubuntu-zfs

     

    then check for the remaining packages with the following:

     

    dpkg –list | grep zfs

     

    …and apt-get purge any remaining relevant ZFS packages.

     

    Then:

     

    sudo apt-get install build-essential

     

    …then install ubuntu-zfs as you did originally:

     

    sudo apt-get install ubuntu-zfs

     

    This time it should take properly. This isn’t the only cause of that error but on a fresh install with a new OS it’s one possibility.

  • Ubuntu: Securing your remote SSH logins with Denyhosts

    Being able to log in to your server remotely via SSH is an incredibly powerful way of remotely managing your system. With so many devices now able to support consoles (just about any current smartphone or current OS, really) you can check on things, update or make changes from just about anywhere.

     

    One of the less positive consequences of opening up your SSH port to the wider world is that you’re also exposing your server to everyone else in the world, not just yourself. There are many computers and virus-born botnets out there who scan IP addresses for open ports and try to brute-force their way in to steal data, generally cause destruction or create another bot. One good way of protecting yourself is installing a program which monitors the attempted logins via SSH and blocks any IP addresses which match an undesired pattern: Denyhosts.

     

    You can install denyhosts by entering the following:

     

    sudo apt-get install denyhosts

     

    This installs denyhosts on your system, which starts automatically once installed and also on boot. You can edit the settings with the following file:

     

    /etc/denyhosts.conf

     

    Blocked IPs are listed in:

     

    /etc/hosts.deny

     

    It’s not unusual to have hundreds of entries after a couple of months. The default settings are reasonably good; you do have the freedom to make them as lenient or paranoid as you care to which is handy for tailoring it to your specific needs (e.g. strict rules re: logging in as accounts that don’t exist or the root account). Be aware that if you mistype your own password enough times you may ban your ou cown IP address, which might be inconvenient if you don’t have physical access to the server or another IP to fix!

     

    Denyhosts is a quick, easy and powerful way to begin securing your SSH-accessible servers – as far as we’re concerned it or an equivalent program are a must if you’re opening up a SSH port to the outside world.

  • ZFS basics: Installing ZFS on Ubuntu

    For those who don’t want to use Solaris or FreeBSD as their ZFS platform Ubuntu now seems a valid option; installation is now relatively straightforward. Please note, though, that you should be running a 64-bit system – ZFS on Ubuntu is not stable on a 32-bit system. Open up a terminal and enter the following:

     

    sudo add-apt-repository ppa:zfs-native/stable
    sudo apt-get update
    sudo apt-get install ubuntu-zfs

    …and that’s it! From here you can begin to use the filesystem by creating a pool or importing an existing pool. Many people find Ubuntu an easier system to manage compared to Solaris or FreeBSD so it’s good news that it now appears to be a stable implementation, despite being technically a release candidate.

  • DNS troubles with Ubuntu Server 12.04

    Some customers have been having DNS issues after setting a static IP on Ubuntu 12.04.1 where the server is no longer picking up the DNS settings as it was before; this can be easily fixed by adding the following to /etc/network/interfaces after the eth0 entry:

     

    dns-nameservers [ip.of.your.router]

     

    e.g., for a modem/router that’s 10.1.1.1 on your local network, your /etc/network/interfaces file might look like:

     

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 10.1.1.50
    netmask 255.255.255.0
    gateway 10.1.1.1
    broadcast 10.1.1.255

    dns-nameservers 10.1.1.1

    Restart your network with:

     

    sudo /etc/init.d/networking restart

     

    …then try pinging Google or something similar and you should have success 🙂

     

    It’s generally not advisable for Australians to use nameservers located elsewhere, e.g. Google’s public DNS’ 8.8.8.8 or 8.8.4.4 – some things which are unmetered by your ISP may be metered if you do so.

     

     

  • Ubuntu: How to view results of “ls” one page at a time

    If you’re listing the contents of a directory using the “ls -l” command in a terminal window you may find that the number of results cause pages of text to fly past your screen, leaving you with only the last page to look at. If you aren’t using a terminal which you can scroll back through this can be rather annoying; fortunately, there’s an easy fix.

     

    In a nutshell you can direct the output of the ls command to another command – less – which allows you to view the results one page at a time. We do this using a pipe: the | symbol.

     

    ls -l | less

     

    The less command shows you one screen at a time; to see the next screen, press the spacebar. If you would like less at once, you can see the next single line using the return key. You can go back a screen by pressing the “b” key or half a screen with the “u” key. There are plenty of other useful commands within less – you can see the manual for it by typing:

     

    man less

     

    You can navigate the manual in the same way – spacebar for another screen, u and b to move back up!

     

     

  • ZFS folders on Ubuntu not mounting after reboot

    After upgrading to 12.04 people seem to be finding that their ZFS shares aren’t mounting on boot; this has an easy fix, fortunately – edit your /etc/rc.local file and add:

     

    stop smbd

    stop nmbd

    zfs mount -a

    start smbd

    start nmbd

     

    Save and reboot and your shares should be intact. This has worked on all of the systems we’ve tested it on so far.

  • How to find kernel version in Ubuntu 12.04 Precise Pangolin

    Note: This also works in other versions of Ubuntu, such as 11.10, 11.04, 10.10, 10.04 and earlier.

     

    Sometimes you may wish to find out which kernel you’re  currently running; fortunately, this is quite easy to do with the uname command. If you’re running Ubuntu Desktop, open up a Terminal; if you’re using Ubuntu Server log in as per usual and then run:

     

    uname -v

    …for the kernel version, or:

     

    uname -r

    for the kernel release. You can combine the two and use:

     

    uname -rv

    to see both of those with the one command.

  • Ubuntu 12.04 Released

     

    Canonical have released Precise Pangolin, the latest update to the Ubuntu operating system. It is a LTS release, meaning that it will be supported for five years – this time on both the desktop and server version.

     

     

     

    You can download from:

    http://www.ubuntu.com