Author: sotech

  • 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!

  • New CentOS WordPress install: Error 500

     

    Was asked to troubleshoot a client’s installation technique for WordPress on CentOS 6.x yesterday; they were receiving an Error 500 when they tried to access index.php for the first time. Checking the Apache logs showed:

     

    SoftException in Application.cpp:431: Mismatch between target GID (522) and GID (65531) of file “/home/andrea/public_html/index.php”

    Premature end of script headers: index.php

     

    What was happening was that the client was un-tarballing the latest.tar.gz file as root and then changing the ownership of the file with the following:

     

    chown -R [user] *

     

    Changing that command to:

     

    chown -R [user]:[usergroup] *

     

    e.g. here:

     

    chown -R andrea:andrea *

     

    fixed that error. By not specifying the new group there was an ownership mismatch where the system expected one group but got another. There are many  causes for an Error 500 – it’s a good habit to check the Apache logs first for pointers as to where to start troubleshooting.

  • Where are the Apache logs in CentOS?

     

    Rather than being in /var/log as you might expect, the Apache logs can be found at:

     

    /etc/httpd/logs

     

    Here you’ll find the usual access, error etc. logs.

  • 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.

  • New Mediawiki install produces error “Fatal exception of type MWException”

     

    Saw this on a new Mediawiki install where all of the optional extensions were selected, LocalSettings.php had been uploaded to the server and that’s as far as it would go.

     

    To fix, open up LocalSettings.php and comment out the line:

     

    require_once( “$IP/extensions/LocalisationUpdate/LocalisationUpdate.php” );

     

    You should now be able to refresh the main page and start using your wiki.

  • Performing a dry run with rsync

     

    One of the many useful options rsync offers is the ability to do a dry-run – in effect showing you what it would do without actually making any changes. To achive this we use the -n flag, like so:

     

    rsync -n /source /destination

     

    In practice we would likely use the -n switch in combination with other switches – commonly we use -avzP, so our real-world example would look like this:

     

    rsync -avzP -n /source /destination

     

    Thanks to the verbose flag (-v) you should see a full list of all of the files which would be transferred, as well as the final note on the last two lines:

     

    sent 26457 bytes  received 2086 bytes  19028.67 bytes/sec
    total size is 26377806232  speedup is 924142.74 (DRY RUN)

     

    …letting you know that it was a dry run and that no files were transferred.

  • 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: How to check the contents of a tape

     

    To check the contents of a tape, insert the tape and run the following:

     

    tar -tf /dev/[path to tape device]

     

    e.g.:

     

    tar -tf /dev/st0

     

    Note that typically it’s a zero, not a letter o, at the end.

  • Ubuntu: How to write files to a tape

     

    To put files onto a tape, run the following:

     

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

     

    An example would be:

     

    tar -cvf /dev/st0 /home/bob

     

    This will back up the user bob’s home directory to the tape, here located at /dev/st0 (a typical location – note the zero, not the letter o).

     

    If you want to use compression in your backup, use the z flag in addition to the other tar flags, such as:

     

    tar -cvfz /dev/st0 /home/bob

     

    All done!