Wednesday, 8 October 2008

Update to the latest Compiz Fusion On Ubuntu Hardy

You will need to add a new repository that contains recent Compiz packages. Open System->Administration->Software Sources. Select the Third-Party Software tab and click Add. Paste in the line below and click Add Source.

deb http://ppa.launchpad.net/compiz/ubuntu hardy main

Close Software Sources and when prompted, choose to reload the repositories.

A number of software updates related to Compiz should become available now; install them using Update Manager. Log out and back in to Ubuntu or restart Compiz manually. You should now be up-to-date.

A nice new window shifter is available for the new Compiz called StackSwitch, just install it from the repo and disable the normal Shift Switcher. It would be nice if the author will add selecting the windows by the mouse much like Expo or some other window plugins.

Tuesday, 23 September 2008

Convert BIN/CUE Images to ISO

Convert bin/cue into ISO

Installation

sudo apt-get install bchunk

Usage As the name implies, a BIN/CUE CD image has two files. BIN being a binary of the raw CD data, and CUE being an ASCII file of CD layout.General usage:

bchunk
image.bin image.cue basename

For example:

bchunk myimage.bin myimage.cue myimage

Where basename(myimage) is myimage.iso of the produced file.

Tuesday, 16 September 2008

Error trying to mount an external device: mount_point cannot contain the following characters: newline, G_DIR_SEPARATOR (usually /)

The computer fails to mount a device with the following error:
Cannot mount volume.Unable to mount the volume 'yourdevicenamehere'.Detailsmount_point cannot contain the following characters: newline, G_DIR_SEPARATOR (usually /)
This can be from incorrectly setting the mount point by right clicking the drive and choosing Properties then the Drive tab and finally expanding the section for Settings, this should simply contain the name you would like the device to be named on your desktop and NOT a fully qualified pathname such as /media/freecom

If you have incorrectly set this or some other bad voodoo has happened to result in this error then it can at least in some cases be very quickly fixed with the following. Open a terminal and open the Gnome Configuration Editor with this command:

gconf-editor

and navigate to this location in the left hand menu:

system / storage / drives /

If you can now see an entry relating to the problem drive then click it and edit its entry on the right, removing the path and any /'s is normally sufficient , all it should be is a simple name that you would prefer it appear on the desktop as, in my case I was changing a drive that mounted as /media/FREECOM HDD to mount as /media/FREECOMHDD due to X-Plane not liking paths with spaces in. So the correct entry for mine was to just input "FREECOMHDD" with no path, no /'s and no speechmarks! ;)

Friday, 12 September 2008

Recover Photographs From a Memory Card

Recover images off a corrupt/damaged memory card. The first step to do is to install a software package named “testdisk”. sudo apt-get install testdisk Or of course use synaptic to search for "testdisk" and install it. The next step is to make an image of your memory card, this is achieved using the ‘dd’ command which comes by default with most distributions, the command you will have to issue is: dd if=/dev/sda1 of=memory_card.img bs=1024 You can get the correct /dev/xxxx path by inserting the memory card then using "dmesg" in a terminal and reading the last few lines. In the above command, ‘if’ is the input drive which should be your memory card, ‘of’ is the file name for the image which we are creating, and ‘bs’ is the byte size. Recover files by scanning the image using photorec The final step is to use a command provided by testdisk package. The ‘photorec’ command will recover all the JPG and GIF files which were recently deleted from your memory card. The command is very simple and run from the folder containing the image file: photorec memory_card.img The software will take you through a menu driven interface where you will have to select a few options to get your work done. It is simple and anyone should be able to use it with ease.

Thursday, 4 September 2008

Do more with Gnome Do


Do more with Gnome Do.

I just discovered this launcher a few days ago and was instantly impressed after viewing the demonstration video available via the homepage. It provides some of the most powerful features of a launcher I have ever seen with massive potential for speeding up *real* productivity in ways you won't have considered.

First you need to edit the /etc/apt/sources.list file


sudo gedit /etc/apt/sources.list


Then add the following lines:

For Hardy Users
deb http://ppa.launchpad.net/do-core/ubuntu hardy main

deb-src http://ppa.launchpad.net/do-core/ubuntu hardy main

For Gutsy Users
deb http://ppa.launchpad.net/do-core/ubuntu gutsy main
deb-src http://ppa.launchpad.net/do-core/ubuntu gutsy main

Save and exit the file.

Update the source list file using the following command


sudo aptitude update

Install gnome-do using the following command from terminal


sudo aptitude install gnome-do

If you want to open gnome-do go to Applications—>Accessories—>GNOME Do

You can then open its preferences from the system tray and tick the first check box called "Start GNOME Do at login" so that it will launch when you reboot rather than remembering to do so from the menu.You can then choose the "Plug-ins" tab in the preferences to install any plug-ins that you feel would be useful to you, some I find very useful, Evolution, Files and Folders, Gnome Terminal, Locate Files, Tomboy and Tasque. Others would be more dependant on your computer uses and software such as Gmail Contacts, Imageshack, SSH, Rhythmbox etc

To call up Gnome Do just tap the Super+space key combo, that is windows key + space in other words. For further information it is well worth checking out the homepage and for help with plugins it can be helpful to open the preferences and click the About box for a plugin, you will be taken to its own wiki page that often has details on its use.

Tuesday, 2 September 2008

Bash script to act as a thesaurus

I just stumbled across this excellent post at The Linux and Unix Menagerie which lists a brilliant little script to add a thesaurus command to your shell, this just perfectly rounds off my recent discovery of the dictionary word lookup commands!

This script is very small, in fact surprisingly so. Just be careful copying it into your text editor as the formatting isn't 100% and needs some tweaking, nothing major and no one should have any problems (yeah I know, fatal last words ;))

Monday, 1 September 2008

Linux Pocket Guide by O Reilly


This is a command reference that I have been using for several months now (check your plug-ins if you can't see the image above) that I got off Amazon and it has really earned its keep. using 'man' in the terminal is an excellent source off information if you already know the command but sometimes you just don't know it or even know the facility existed. Don't worry about the "Covers Fedora Linux" if you don't use Fedora, the commands are generic that I have found and nothing has failed to work on my Ubuntu box that I have tried.

Linux Pocket Guideis fantastic as you can just dip into it for clarification on a command syntax for a quick solution (there are many examples on most commands, or you can just read through it as I did when it first arrived, discovering several commands I had no idea were possible. I didn't know for there were dictionary's lookup commands available at the command line (look, aspell, spell) for checking spellings for instance. Try the following as an example of it:

look big

Its extremely useful and helps with checking words on a variety of projects, including this blog. Check out the book, its inexpensive and pocket sized, perfect for taking with you on the odd trip to dip into and refresh, it gets my unreserved approval.

Sunday, 31 August 2008

Install and use ClamAV for linux anti virus

Install Clamav with either Synaptic or apt-get/aptitude.

To update the definitions use:

sudo freshclam

scanning files is as simple then as calling clamscan with the -r or --recursive flag and a path, if the path is omitted then it will scan at the current path:

clamscan -r /home/subbass
or clamscan -r

If you would rather only see infected files then use the -i or --infected flag:

clamscan -ri /home/subbass
or clamscan -ri

If you wish to scan every file on the system you may have to run clamscan with sudo, as running without it clamscan can only read files the user running it can access.

sudo clamscan -ri /

This would check every file on the system recursively and report only infected files.

You can schedule clamscan using cron or for the odd one off scans using the "at" command, such as:
at 3:30 tomorrow
at>clamscan -i /home/user > mail user@example.com
at>
job 3 at 2005-04-28 03:30
This would perform the scan at 3:30am later that night and mail the results to the defined address. To add a regular cron job try the following:

nano crontab -e

Then enter the following line at the bottom of the file

00 00 * * * sudo clamscan -r /location_of_files_or_folders
Save the file and exit.

Use exiftran to transform jpeg images

Exiftran is a command line utility to transform digital image jpeg images. It can do lossless rotations like jpegtran, but unlike jpegtran it cares about the EXIF data: It can rotate images automatically by checking the exif orientation tag, it updates the exif informaton if needed (image dimension, orientation), it also rotates the exif thumbnail. It can process multiple images at once.

exiftran -ai *

This will transform all the images in a folder, rotating them to the correct orientation as defined by the exif data from the camera and replace the original, assuming your camera can sense and write the orientation into exif data.

exiftran -i9 *

Transform the image through 90degrees (to the right) and overwrite the original.

exiftran -i2

Transforms the image through 270degrees (to the left) and overwrite the original.

I have adapted this into two scripts in my nautilus-scripts folder "/home/subbass/.gnome2/nautilus-scripts/" you can make two scripts in this place using the following code and just changing the exiftran command to rotate left or right in each of the scripts.

#!/bin/sh
for arg; do
filetype=`file -i "$arg"`
if [ -n "`echo $filetype | grep -i '.jpg' `" ]; then

exiftran -i9 "$arg"

else
convert -rotate 90 "$arg" "$arg"
fi
done

The convert at the end is to convert other image formats without me requiring another set of scripts, feel free to omit this if desired. Always do a small test before setting any script to work on large numbers of images, I don't want to be held responsible if your exif data gets nuked.

Saturday, 30 August 2008

Use rsync to and from copy files from a remote machine

Assuming the remote machine has SSH successfully installed and working then it is a simple case:

rsync -v -u -a --delete --rsh=ssh --stats username@192.168.0.100:/home/username/remotefile.txt

This will copy files from /home/username/remotefile.txt on the machine at 192.168.0.100

to copy files to that same machine then the command syntax is as follows:

rsync -v -u -a --delete --rsh=ssh --stats localfile.txt username@192.168.0.100:/home/username/

I will do a more in depth backup write up using rsync soon.

Tuesday, 26 August 2008

rTorrent, light and fast bittorrent client.

I use two torrent clients almost every day, Transmission on my own box with a gnome desktop, and for a long time now rTorrent in a shell via SSH to a spare machine I have use of on a separate connection. Setting up rTorrent on an Ubuntu machine is what I am going to discuss here.

First step is to install the program, open a terminal and enter:

sudo apt-get install rtorrent

Or use Synaptic and search for 'rtorrent', install it. A basic config file is located /usr/share/doc/rtorrent/examples for you to tweak to your own liking, at its simplest you may want to change the download folder in it and the 'watch' folder. The watch folder is a place that rTorrent will monitor for *.torrent files coming into so it can automatically start, and when the download has completed and achieved a ratio you are happy with, you can just delete the torrent file from this folder to remove it from rTorrent. Dead simple stuff :]

cp /usr/share/doc/rtorrent/examples/rtorrent.rc ~/.rtorrent.rc

then edit this file with your prefered text editor, mine is usually nano, use gedit if you prefer a GUI editor:.

cd ~/
nano .rtorrent.rc

Now we can make the most basic of changes, first up is the download folder, look for the line:

# Default directory to save the downloaded torrents.

change the line after it to the folder you want to be your download folder and remove the # so you have something like this:

# Default directory to save the downloaded torrents.
directory = ~/torrents

This makes my download folder /torrents/ in my home, the default without editting is simply your home folder which you may be happy with.

Next lets tell it what folder to watch for torrent files. I have defined mine to be this same ~/torrents/ folder, you may prefer to leave it as your home folder. Either way find these lines just slightly down from the previous:

# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=~/torrents/*.torrent
schedule = untied_directory,5,5,stop_untied=

Yours will look very slightly different as I have shown how I changed mine to watch the ~/torrents/ folder. You should now save the file and close the editor, ctrl+o to save in nano if you used my prefered editor from above and don't know it, press enter to save wit hthe same name, then ctrl+x to close it.

You should now be free to start rTorrent with the command:

rtorrent

Not very impressive at first look is it, but download a torrent file to the watch folder and see rtorrent leap into action all by itself. You can adjust the upload and download speeds using the keys

a/s/dIncrease the upload throttle by 1/5/50 KB.
z/x/cDecrease the upload throttle by 1/5/50 KB.
A/S/DIncrease the download throttle by 1/5/50 KB.
Z/X/CDecrease the download throttle by 1/5/50 KB.


There are other keys to pause and resume torrents and many other facilities that you may require, for that I would point you at the User Guide page at http://libtorrent.rakshasa.no/wiki/RTorrentUserGuide


As I use this remotely I also run it inside a screen so I can safely detach from it and break the connection leaving it running on the remote machine, to do this enter in a terminal:

screen

then you will just see another command prompt on a clear terminal at which point enter:

rtorrent

rTorrent will start as normal but if you use the keys ctrl+a then d it will detach, that is it will drop you back at your original shell, leaving rtorrent running in the backgroun still. You can attach to it again with:

screen -r

You can then see rTorrent again to check your downloads or ratios. Check 'man screen' for more help on using screen, there are a *lot* of things you can do with it, and that might be a worthwhile post for me some time soon.

Monday, 25 August 2008

Automated document scanning script

This article is taken from http://www.thelinuxblog.com/automated-scanning-with-the-shell/ as I need to scan several hundred photographs very soon. Thanks to Owen for correcting my link, I had linked to the wrong page.

I recently needed to scan a lot of images on my desktop PC. Unfortunately I am not the owner of an automatic document feed printer, and if I were it wouldn’t have helped this time because the documents I needed to scan were not feed able. XSANE is a great way to scan documents visually in Linux. Its not the easiest to use, but it has plenty of options. Part of the SANE package is scanimage, scanimage can be used from the shell.

The first thing that I did was a few test images with scanimage. I quickly found out that scanimage outputs in pnm format, and at a high resolution if the correct options are used. Once I found out the good options for my scanner (scanimage –resolution 400 > file.pnm) I wrote a quick shell script to scan up to 1000 times or until I don’t give the script any input. To do this, I used a combination of snippets that can be found in this blog column.

Here is a direct link to the script, and the shell script source below

#!/bin/bash
for i in `seq 1 1000`; do

#get input line
read inputline;

if [ $inputline ]; then

#Process Scanned Image in BG
echo Scanning Pg$i;
scanimage –resolution 400 > Pg$i.pnm;
echo Next;
else
exit
fi

done;

To use it all I do is execute the script, and I get to scan up to 1000 documents providing I type something after it prompts “Next”, and then hit enter. Once I was done scanning, I just hit enter to stop the script execution and then moved on to manipulating the images with the shell.

Hope this shell script scanning script is useful, if it is then drop me a comment, or if you have any suggestions or it was not at all helpful still drop me a comment.

Friday, 22 August 2008

Recurse to find files and move them to a location

I just had to move a bunch of files out of individual sub-folders into the parent folder, time consuming to do that 50 or so times so a quick check of the "find" command and the solution is here:

find . -iname '*.avi' -exec mv {} /home/subbass \;

Command breakdown looks like this:

find .
find "here"
-iname '*.avi'
case insensitive name match on *.avi
-exec mv
execute the move command on the matches
{}
the match result from find
/home/subbass/
path to move the files to
\;
end of the -exec, each match runs as a new command

A quick command line, fairly simple syntax and it should prove a great time saver. You could easier of course cp or rm files instead of mv or many other possibilities.

Friday, 15 August 2008

How to install an SSH server on your Ubuntu box

One of the nicer features of Linux is the ability to use Secure Shell (SSH) for encrypted remote access. Using SSH, you can control a remote computer without having physical access to the machine. The traffic generated by SSH is encrypted, and assuming you configure SSH correctly, quite secure as well. Here’s how to install the OpenSSH Server software with a basic security configuration on Ubuntu 8.04 Hardy Heron. (Bear in mind, of course, that you follow all advice at your own risk.)

First, open up a Terminal window, and use apt-get to download and install OpenSSH Server:

sudo apt-get install openssh-server

This will take a few moments, depending upon the speed of your computer and your Internet connection. Once the installation is finished, you’ll return to the Terminal. We’ll need to make a few changes to your sshd_config file in order to increase SSH’s security. (Note that it is always best practice to make a backup copy of a configuration file before editing it.) To edit your your sshd_config file, use the following command:

sudo gedit /etc/ssh/sshd_config

(Note that you can use your editor of choice instead; vi or emacs or whatever.)

Once you’re editing the file, we’ll need to change the following directives:

PermitRootLogin no

Never, ever give root access to SSH unless you have an extremely good reason for doing so. If an attacker happens to discern your root password, he or she will have total remote control over your system. By denying root login permission through SSH, you can provide an effective block to that danger.

The Port directive also specifies which TCP/IP port the SSH daemon uses to listen for SSH requests. The default port is 22, and you may want to change that, especially if your machine is accesible on the Internet. Many malware bots use port 22 for default SSH attack attempts, and by changing your port number you can stop at least some of the automated cracking attempts.

You may also want to change the AllowUsers directive, which specifies which users can access SSH. This can provide an additional layer of security by granting SSH access only to a few users. For instance, to restrict access to only the users joetest and billtest:

AllowUsers joetest billtest

Once you’ve finished changing your settings, save your changes to the sshd_config file, and restart the SSH daemon:

sudo /etc/init.d/ssh restart

You should now be able to SSH into your Ubuntu machine. You can do so from the Terminal on a Mac or another Linux machine, or by using Putty on a Windows machine.

Thursday, 14 August 2008

X server gives error and won't load.

I got asked to look at one my parents PC's a couple days ago as it had 'locked up'. Upon investigation it hadn't locked up but the motherboard had fatally broken with the PS2 and USB ports left lifeless. I was able to SSH into it and the machine was just fine.

I wasn't able to easily get any data off the HD while in the case so popped it out and took it home, plugged it into another of my own PC's and booted it up. GDM failed to come up and I was greeted with the typical "X has failed to start" message and dumped to a prompt. Not a problem, I've been here before and we can fix that in a jiffy.

sudo dpkg-reconfigure xserver-xorg

Go through the various questions, most of which are pretty simple and you can pretty much take the defaults in my experience.

A quick reboot:

sudo shutdown -r now

or a faster restart of gdm (the login manager)

/etc/init.d/gdm restart

Everything should be fine when it comes back up.

Enable DVD playback and other 'restricted' extras.

This information is taken from the Ubuntu Documentation (here) and any copyright remains with them. This is here for my own use.

Playing Restricted Formats in Ubuntu.

Follow these steps to play most common multimedia formats, including MP3, DVD, Flash, Quicktime, WMA and WMV, including both standalone files and content embedded in web pages.

Using the GUI (Synaptic)

  • Go to ApplicationsAdd/Remove...

  • Set Show: to All available applications

  • Search for ubuntu-restricted-extras and install it. Note that there is also xubuntu-restricted-extras (for Xubuntu) and kubuntu-restricted-extras (for Kubuntu.)

Or open the Terminal (much faster), and execute the following command:

sudo apt-get install ubuntu-restricted-extras

Use convert to add a border to multiple images in the command line

Ok, so you you have taken a bunch of photos with your new camera and what do you know, some of them are half decent. I use this after I have copied photo's I want to print or photo's that I am sending to flickr or deviant art to a seperate folder as it really adds a finishing touch, I copy them to a seperate location so I know exactly which ones I am printing/uploading and don't omit any.

Now you could easily do this in The Gimp, load each image and enlarge the canvas followed by a fill and then resave the image. This is linux though and we can do things a heap simpler than that!
First install Imagemagick:

sudo apt-get install imagemagick


Or install it via Synaptic or your package manager.

Then use this simple script,

be aware that you should operate on copies as this does overwrite the original, as noted above I only do this on photo's I have copied for printing/uploading.


for img in `ls *.jpg`

do
convert -bordercolor white -border 50x50 $img $img
done

Easiest to pop it all into a bash script, or just close it up separating the commands with semicolons into a one liner eg.

for img in `ls *.jpg` ; do ; convert -bordercolor white -border 50x50 $img $img ; done

If your camera uses a different extension then adjust the .jpg accordingly.

Adjust "50x50" to whatever you feel adds a nicely sized border, and feel free to change the border colour (black for instance). If you want to get creative stack up the converts to add a thin black border before a larger white border or whatever you fancy.

Wednesday, 13 August 2008

Unpack multiple zip files easily

So you have just completed a download and it is in multiple zip files, rather than unpack them in the gui one at a time try this.

Open a terminal and 'cd' to the folder containing the zips, then enter this command:

for FILE in *.zip; do unzip -jo $FILE; done

I would suggest having the zip files in a separate folder to anything else to avoid confusion over the files that get unpacked.