home | contact us
» Archive by category "ubuntu"

category: ubuntu


Today we and no doubt countless other Ubuntu 10.10 users got the dreaded:

You can read the official announcement here.
As everyone is aware, Ubuntu and Gnome have both moved towards a new desktop environment paradigm which is designed to be a bit more dumbed down and accessible to less technical users.

Unfortunately its not really suitable for power users who might have a LOT of open windows spread over multiple desktops and often running multiple monitors.

Gnome 2, simple as it was, has some really nice desktop features that once you are used to them it feels like you can’t live without them.

So now the big question is, what next?

We already have one Linux Mint fan in the office and it is looking like this project is going in the right kind of direction for us with their support for MATE (Gnome 2 basically) and also the Cinnamon desktop which is a more modern take on the classic Gnome 2 desktop paradigm. Its more than likely this is where we will be going to next.


 

If you find yourself typing away whilst something else loads or another window pops open and all of a sudden your typing has gone into a different window then this solution is for you

Open gconf-editor. Open a terminal and type gconf-editor and hit return.

Now navigate to /apps/compiz/general/screen0/options/focus_prevention_level key and set its value to 4.

That’s it.

You might actually decide that focus stealing is sometimes useful in which case you can always change it back.

Originally found here: http://askubuntu.com/a/55220


 

Not many people are aware of the Path Tools extension for netbeans, and even fewer know how to make it really useful.

Effectively it provides 4 buttons – Copy Path, Open Folder, Open Terminal and Edit Path, the latter three being configurable.

Its default for Open Folder is great (for gnome users) but that’s the only one that has a default.

I use Guake (a pull-down transparent terminal) and for the two options (For Folder and For File) I set to the following for a nice “New tab in guake” :-

guake --new-tab "{path}" -t

and

guake --new-tab "{parent-path}" -t

And for the “Edit Path” button, I find it extremely useful to create a “run external program” script – sat in my personal bin directory ($HOME/bin/) containing the following code :-

#!/bin/bash

ESCAPEDPARAMS=`echo $* | sed -e 's/\([[\/.*]\|\]\)/\\\&/g'`
MIME=`file --mime-type $* | cut -f2 -d: | cut -f2 -d' '`
DESKTOPFILE=/usr/share/applications/`xdg-mime query default $MIME`
EXEC=`grep '^Exec=' $DESKTOPFILE | cut -f2 -d=`
COMMAND=`zenity --width 600 --entry --title="Path Tools" --text="Run Command : " --entry-text="$(echo $EXEC | sed s/'%U'/"$ESCAPEDPARAMS"/)"` 

if [ "$?"=="0" ]; then
  sh -c "$COMMAND"
else
  echo ""
fi

and set that up as the command “For Folder” and “For File” with {path} for both (not {parent-path} notice).

So, what does it do?

  • MIME variable is set to the mime-type of the file (e.g. image/jpeg)
  • DESKTOPFILE is set to the .desktop file that is associated with that mime-type (for my gnome setup this is /usr/share/applications/${DESKTOPFILE} )
  • EXEC is the command contained within that desktop file
  • COMMAND uses zenity to prompt for the commandline I want to run, pre-populated with the gnome default

This means when I press the “Edit Path” button on a JPeg file, a popup asks for a commandline, prepopulated with my defaults (in this instance “eog /path/to/file.jpg”) and if I want I can change the command to gimp. If I click OK in the box, the command is run. If I just wanted to see the full path, I can maximise the box, look at it and click Cancel.


 

So there is often a requirement for sharing files but what happens if those files are files that absolutely must be secure, like private ssh keys?

Well Dropbox whilst a good product is third-party and not encrypted so if there’s an exploit, the contents of the files could well be exposed to people you don’t want.

Enter Wuala, a service by Lacie. Similar to Dropbox in many ways, but differing in that the files are encrypted locally, so if you loose your password, the files will be inaccessible, permanently. Believe it or not, that’s a really good thing!

Oh, and there’s a client for Linux, Mac, Windows and Mobile (Android and iPhone).


 

If you need to extract the information from a PDF table sometimes when you copy and paste it into a text editor the formatting is incorrect making the information useless.

In cases like this, you can use pdfedit to extract the text in the correct formatting and then do what you need with it.

To use the program first make sure it’s installed. If not install it like this


sudo apt-get install pdfedit

then use it to open the PDF. Click through the the correct page and then click Page - Extract Text From Page


 

After a bunch of digging around trying to find out how to get my internal SD card reader working in Ubuntu 10.10 I have found this solution:

Looking at dmesg, the error I was getting was this:

mmc0: ADMA error
mmc0: error -5 whilst initialising SD card

I found the solution here:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/660088

cd /etc/modprobe.d
sudo vim sdcardread.conf

[ctrl]+[i] to put vim into insert mode
Now you need to paste this line into the file and save:

options sdhci debug_quirks=0x40

then hit [esc] to exit insert mode, then type

:wq

to save the file and quit.

now you need to run these commands

sudo rmmod sdhci_pci
sudo rmmod sdhci
sudo modprobe sdhci
sudo modprobe sdhci_pci

Then if you re insert your SD card and view dmesg, you should no longer see the error message

dmesg

 

If you are tearing your hair out trying to figure out why trying to run something is complaining that it doesn’t exist when it clearly does, this is quite possibly your solution.

The problem is most likely that you are trying to run a 32bit package on a 64bit system.

The solution is easy enough, you need to set up your system to run 32bit packages.

apt-get install libc6-i386 lib32gcc1 lib32z1 lib32stdc++6 ia32-libs

 

Bash provides many powerful functions but how can you use these easily?

If you spend any time using the command line, either to manage a server or on the desktop, you have to quickly become proficient with bash. You will also find the you carry out many of the same tasks time after time.

This can quickly become tiresome and error prone, particularly if you are piping several commands together. However, bash provides several ways to make your life easier.

Aliases

If you are always going to be using the same flags with a command, you can ensure that they are called by default by using an alias.

An alias is a shorthand that bash uses in order to fire commands. Several are included as standard with Ubuntu (and other distros) and are stored in your .bashrc file. You can edit these and add your own as the need occurs.

An example of this is that I prefer the human readable file sizes when using ls. You can turn these on using the -h flag, but you have to include this every time you run the command. To make things easier I changed the alias for ll (long list) to read as follows

alias ll="ls -ahlF"

This way I don’t need to remember to put the flag in.

As you build up more of these commands, it makes sense to store them in a separate file so you can easily find and edit them. You can place all of you aliases in a file called .bash_aliases and they will be available for use.

Scripts

Aliases are fine for quickly calling simple commands, but many times you will need to carry out more complex tasks. In order to do this, you can make a script, and then call that.

By placing everything into a script, you benefit from being able to carry out more complicated functions, and the easy of calling it from a single command.

An example of this would be if you wanted to compare two branches in git, and see all of the files that had been created or modified, but not the files that had been deleted. You create a file called git_get_changed_files and put the following in

#!/bin/bash
local ORIGINAL CHANGED FILES 
ORIGINAL="$1"
CHANGED="$2"

    FILES=$(git diff --name-status $ORIGINAL..$CHANGED public/ | awk '{print $1"@@@@@"$2}')
    for FILE in $FILES
    do
            echo "$FILE" | awk -F "@@@@@" '{ i=""; if ($1 != "D") print $2}'
    done

If you place this in your home/bin folder you will then be able to run git_get_changed_files like a normal command.

A Global Function Library

You can expand on this by creating a global library of functions. This works by putting all of the functions into a folder, where each file is a namespace for different functions.

This can be achieved by creating a script that will source of all of the files in a folder, like so:

#!/bin/bash
for f in $(ls /path/to/folder/); 
    do source /path/to/folder/$f; 
done

Call this script func and place it in your home/bin folder. Then you put a script in the folder referenced in the file and use the following structure.

function parse.(){ # auto complete helper, second argument is a grep against the function list     
    if [[ '' == "$@" ]]
    then
        echo "Parse Namespaced Functions List"
        cat $BASH_SOURCE | grep "^function[^(]" | awk '{j=" USAGE:"; for (i=5; i<=NF; i++) j=j" "$i; print $2" "j}'
    else
        echo "Parse Functions Matching: $@"
        cat $BASH_SOURCE | grep "^function[^(]" | awk '{j=" USAGE:"; for (i=5; i<=NF; i++) j=j" "$i; print $2" "j}' | grep $@
    fi
}

function parse.access_log_top_ten_code() { # Show the top ten code from access_log: useage ...code $FILE $CODE
	FILE=$1
	CODE=$2
	echo "Count the top ten $CODE'd pages"

	cat $FILE | awk '{ i=($9=="$CODE" ) ? $7 : ""; print i; }' | sort | uniq -c | sort -n | tail -n 11 | head -n 10
}

In this folder a namespace of parse is created. Running

func parse. 

Will list all of the function in the file. Running func parse. log will list all of the function that contain log in the function name or description. When the files are listed, the function name will be displayed with the comment along side it.

As the func command sources all of the different files, you are able to makes use of the functions across different namespaces. This means that you can create a file that will format output and then use that in with your git functions.

I hope that you are able to make use of this idea, and build your own library of functions. Anything that you thing would be useful to add to the library, please mention below.


 

If you have a secondary hard drive that you have to manually mount in Ubuntu/Linux everytime you boot up and you are not too comfortable with the syntax for fstab, this is a possible easy shortcut for you.

You can view the currently mounted partitions by looking at mtap

cat /etc/mtab

If you do this after you have mounted the drive, you can see the full mount command that has been used, eg

/dev/sdc1 /media/BigDrive ext4 rw,nosuid,nodev,uhelper=udisks 0 0

You can copy that line and paste it into your fstab and from then on when you boot up the drive will be mounted automatically.

sudo gedit /etc/fstab

I have no idea what all that stuff means and to be honest I don’t care I just want to use my hard drive.

ALWAYS back up your fstab before making changes!

Hope that helps ;)


 

Trying to upgrade to Natty and it seems to have tried to set up a RAID array which is causing me issues.

After a bit of messing around, the easy solution is to run:

sudo dmraid -rE

 
rss icon