Category: Ubuntu

  • ZFS on Linux (Ubuntu) – arcstat.py is now available! How do you run it?

    UPDATE: This information is now out of date, see new post here.

     

    One very handy ZFS-related command which has been missing from the standard ZFS on Linux implementation has been arcstat.py. This script provides a great deal of useful information about how effective your adaptive read cache (ARC) is.

     

    ZFSoL 0.6.2 includes it, which you can now update to in Ubuntu with apt-get upgrade. But how do you actually use it when you upgrade? Easy. Assuming you have python installed, run the following (this works for 13.04 at least – we will check the others and update when we do):

     

    /usr/src/zfs-0.6.2/cmd/arcstat/arcstat.py

     

    This will provide you with the default readout, e.g. for our system which just rebooted:

     

        time  read  miss  miss%  dmis  dm%  pmis  pm%  mmis  mm%  arcsz     c

    21:33:13     3     1         33          1       33        0        0           1        33       2.5G   15G

     

    As you can see, since the system has just rebooted and hasn’t started caching requests the ARC size is quite small – 2.5G.

    This is an extremely useful tool to get an idea of how your ARC is performing – we will do a piece on interpreting the results soon!

  • Ubuntu Forums hacked, passwords + emails taken – change yours if you are a user!

     

    On the 20th July (US time) the Ubuntu forums were hacked and local usernames, email addresses and passwords were taken. The passwords aren’t in plaintext but regardless, change yours if you are/were a user!

  • Ubuntu: How to check the samba version

     

    To check the version of Samba that you are running, use the smbstatus command. The first line is the version, which should look something like:

     

    Samba version 3.6.3

     

    If you want to see just the version without the rest of the smbstatus information, you can run:

     

    smbstatus –version

     

    Much less cluttered. The above is the current version for a 12.04 Ubuntu server. Still waiting for version 4!

  • Where is the crontab in Ubuntu?

     

    If you’re looking to make a copy of a user’s crontab as a backup or just to view it without using the crontab editor, you can locate it at:

     

    /var/spool/cron/crontabs

     

    Each user’s crontab will be in this directory in a file named as their username (e.g. root). If you’re working with a lengthy crontab it’s a good idea to back it up – can save you a lot of work if everything goes pear-shaped.

  • Ubuntu: Where is the default tmux config file?

     

    This is a tricky one to find, mainly because by default it doesn’t exist. You create your custom configuration file in your home directory in a hidden file like so:

     

    ~/.tmux.conf

     

    …and add your desired configuration changes to that file. So, if you were the user bob, your config file would be located at:

     

    /home/bob/.tmux.conf

     

    Since it is a hidden file (prefixed with a period) you won’t see it on ls – you need to use:

     

    ls -al

     

    (or ls -a if you don’t like lists) to see it in the directory.

  • Ubuntu: How to restore your files from a tape

     

    This is just like extracting a regular tar archive:

     

    tar -xvf /dev/[path to tape] [directory or file to restore]

     

    e.g.:

     

    tar -xvf /dev/st0 backups

     

    This will restore the “backups” file/folder to the current working directory. To check your current directory, you can use:

     

    pwd

     

    to make sure that you are restoring your files to the correct location!

  • Ubuntu: Killing a tmux pane

     

    Opened one too many panes in tmux? You can kill one by selecting it and doing the following:

     

    [prefix] x

     

    By default the prefix is ctrl+b – so in this case you would enter ctrl+b then x.

     

    Pane killed!

  • Ubuntu: How to change tmux’s ctrl+b binding to ctrl+a

     

    If you’re used to screen you’ll be in the habit of using ctrl+a, for example detaching a session with ctrl+a then d – if you make the move to tmux it’s ctrl+b then d, which can take some getting used to. Often it’s easier to make tmux get used to you! To change tmux from ctrl+b to ctrl+a, make sure tmux isn’t running and create the following file:

     

    vi ~/.tmux.conf

     

    Here we have used the text editor vi to create the file. Now add the following:

     

    unbind C-b

    set -g prefix C-a

     

    Save the file. Now the next time you start tmux it should have changed to what you’re used to!

  • How to erase a tape in Ubuntu

     

    This is another nice and easy one, though it may take a while depending on the size/speed of the tape:

     

    sudo mt -f [/path/to/tape] erase

     

    e.g.:

     

    sudo mt -f /dev/st0 erase

     

    That’s /dev/st(zero) not /dev/st(letter o), in case it’s not clear from the font. This will likely take some time as the tape is erased from end-to-end – once it is done you will be returned to a prompt.

  • How to rewind a tape drive in Ubuntu

     

    This again uses the mt command, and is nice and easy:

     

    sudo mt -f [path/to/tape/drive] rewind

     

    A common example would be:

     

    sudo mt -f /dev/st0 rewind

     

    Easy done! In the above example it’s st (zero) not st (letter o) – in case it’s not clear from the font.