Saturday 28 February 2009

CLI loops, including batch conversion of .xcf to .png

for I in {1..10}; do echo $I; done

for I in 1 2 3 4 5 6 7 8 9 10; do echo $I; done

for I in $(seq 1 10); do echo $I; done

for ((I=1; I <= 10 ; I++)); do echo $I; done


Apply to conversion of all .xcf files in a directory, to .png:

for i in `ls *.xcf`; do xcf2png $i -o $i.png; done

Tuesday 24 February 2009

Sharing ubuntu directories.

Mostly from http://www.redhat.com/docs/manuals/linux/RHL-7-Manual/ref-guide/s1-sysadmin-nfs.html

and (better)

http://www.ubuntugeek.com/nfs-server-and-client-configuration-in-ubuntu.html


aptitude install nfs yielded:

Couldn't find package "nfs". However, the following
packages contain "nfs" in their name:
libyanfs-java nfsbooted libroxen-tokenfs p3nfs libnfsidmap-dev
fai-nfsroot libfile-nfslock-perl nfs-server unionfs-source funionfs
nfs-kernel-server unionfs-tools nfs-client libnfsidmap2 nfs-user-server
nfsboot nfs-common unfs3 knfs

So, I reckon nfs-server, nfs-client are probably required.

sudo apt-get install nfs-server nfs-client

shows:

Package nfs-server is a virtual package provided by:
nfs-kernel-server 1:1.1.2-2ubuntu2.2
unfs3 0.9.19+dfsg-1
nfs-user-server 2.2beta47-23
You should explicitly select one to install.

So, maybe nfs-kernel-server

sudo apt-get install nfs-kernel-server

Well, /etc/exports now exists; a good sign.

/mnt/sda2 192.168.1.108

is added. /mnt/sda2 is the shared folder. 192.168.1.108 is the machine allowed to connect.

After changes, either stop and start the daemon:

/etc/rc.d/init.d/nfs stop
/etc/rc.d/init.d/nfs start


or restart it:

/etc/rc.d/init.d/nfs restart

These didn't exist. More searching showed:

sudo apt-get install nfs-kernel-server nfs-common portmap

(already there)

sudo dpkg-reconfigure portmap (select no)

Restart portmap:

sudo /etc/init.d/portmap restart

Restart NFS:
sudo /etc/init.d/nfs-kernel-server restart

worked.


===========================

Install the client:

sudo apt-get install portmap nfs-common

===========================

Manual mount:

cd ~
sudo mount 192.168.1.65:/mnt/lin2/projects projects


===========================
Alternative method:
http://fuse.sourceforge.net/sshfs.html

Use ssh! Install fuse, and glib2.0-devel. Download from the link and ./configure; make; sudo make install

Then,

sshfs login@ipaddress:/path mountpoint

wow! Useful, particularly with firewall avoidance.

Sunday 22 February 2009

Ubuntu DVD playback

/etc/apt/sources.list:

#deb cdrom:[Ubuntu 8.04.2 _Hardy Heron_ - Release amd64 (20090121)]/ hardy main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://gb.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ hardy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ hardy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://gb.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ hardy universe
deb http://gb.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ hardy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://gb.archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://gb.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ hardy-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://gb.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository. This software is not part of Ubuntu, but is
## offered by Canonical and the respective vendors as a service to Ubuntu
## users.
deb http://archive.canonical.com/ubuntu hardy partner
deb-src http://archive.canonical.com/ubuntu hardy partner

deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted
deb http://security.ubuntu.com/ubuntu hardy-security universe
deb-src http://security.ubuntu.com/ubuntu hardy-security universe
deb http://security.ubuntu.com/ubuntu hardy-security multiverse
deb-src http://security.ubuntu.com/ubuntu hardy-security multiverse


# from http://ubuntuguide.org/wiki/Ubuntu:Hardy#extrarepositories .....


##--------------------
## UBUNTU REPOSITORIES
## -------------------
deb http://my.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://my.archive.ubuntu.com/ubuntu/ hardy main restricted
deb http://my.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb-src http://my.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb http://my.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://my.archive.ubuntu.com/ubuntu/ hardy universe
deb http://my.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://my.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb http://my.archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://my.archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://my.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://my.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb http://my.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://my.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu hardy partner
deb-src http://archive.canonical.com/ubuntu hardy partner
deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted
deb http://security.ubuntu.com/ubuntu hardy-security universe
deb-src http://security.ubuntu.com/ubuntu hardy-security universe
deb http://security.ubuntu.com/ubuntu hardy-security multiverse
deb http://my.archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe
deb-src http://security.ubuntu.com/ubuntu hardy-security multiverse
deb http://ppa.launchpad.net/ubuntume.team/ubuntu hardy main # Ubuntu Muslim Edition
deb-src http://ppa.launchpad.net/ubuntume.team/ubuntu hardy main # Ubuntu Muslim Edition
deb http://www.linuxmint.com/repository romeo/
deb http://tskariah.000webhost.com/ubuntu ubuntu main
#deb http://ppa.launchpad.net/kubuntu-members-kde4/ubu...gutsy main
## +++ Backports & Proposed (Ubuntu Unstable) +++
deb http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-proposed main restricted universe multiverse
## +++ Source Repositories +++
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
# deb http://ppa.launchpad.net/kubuntu-members-kde4/ubu...hardy main
deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy main restricted
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
##Universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
## Multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
## Backports
deb http://us.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
## Canonical Partner Repository
deb http://archive.canonical.com/ubuntu hardy partner
deb-src http://archive.canonical.com/ubuntu hardy partner
deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted
deb http://security.ubuntu.com/ubuntu hardy-security universe
deb-src http://security.ubuntu.com/ubuntu hardy-security universe
deb http://security.ubuntu.com/ubuntu hardy-security multiverse
deb-src http://security.ubuntu.com/ubuntu hardy-security multiverse
## PLF REPOSITORY
deb http://packages.medibuntu.org/ gutsy free non-free
deb http://ppa.launchpad.net/reacocard-awn/ubuntu gutsy main
## +++ Medibuntu +++
deb http://packages.medibuntu.org/ hardy free non-free
deb http://packages.medibuntu.org/ feisty free non-free
#deb http://ppa.launchpad.net/kubuntu-members-kde4/ubu...hardy main
deb http://playonlinux.botux.net/ hardy main


Then,

sudo apt-get update

and

sudo apt-get install libdvdcss2
sudo aptitude install xine-ui libxine-extracodecs


or maybe apt-get, that.

Saturday 21 February 2009

shared directories, ubuntu and suse

Set the shares on the suse machine, using YAST2, and NFS Server.

On ubuntu:

sudo apt-get install sshfs
sudo modprobe fuse
sudo localusername fuse
sudo adduser fuse
sudo chown root:fuse /dev/fuse
sudo chmod +x /bin/fusermount
sshfs username@192.168.1.101:/home/username/projects ~/projects


Some of that isn't required, some doesn't work. Next time with a fresh run, update this.

Also, these are temporary, it seems. After some time, the tunnel closes. Nasty.

Thursday 19 February 2009

! TeX capacity exceeded, sorry [save size=5000].

sudo vi /usr/share/texmf/web2c/texmf.cnf

Replace save_size with a larger value, say 50000

Monday 16 February 2009

LaTeX packages

Hyperref:

cd ~/downloads/latex
wget http://www.ctan.org/get/macros/latex/contrib/hyperref.zip
unzip hyperref.zip
sudo texhash

and include the following header in the tex file:

\usepackage{hyperref}

Fluxbox settings

Window snapping:

session.screen0.edgeSnapThreshold: 
When moving a window across your screen, Fluxbox is able to have it
"snap" to the edges of the screen and windows for easy placement. This variable
tells Fluxbox the distance (in pixels) at which the window will jump
to the edge.
Default: 0

Sunday 15 February 2009

ubuntu ssh

apt-get install openssh-server

Friday 13 February 2009

screengrabs with ubuntu

~/screenshot

#!/bin/bash
# from http://gentoo-wiki.com/TIP_Make_a_Screenshot_with_PrintScreen_Key
# call as screenshot scr or screenshot win or screenshot area
# Saves to folder, ~/screenshots/, making it if required.
# Map to printscreen key, keycode 111 by mapping it to F13 in ~/.xinitrc by adding,
# xmodmap -e "keycode 111 = F13" before fluxbox is called.
# Then add the line, 'None F13 :execCommand screenshot scr' to ~/.fluxbox/keys

DIR="${HOME}/screenshots"
DATE="$(date +%Y%m%d@%H%M%S)"
NAME="${DIR}/screenshot-${DATE}.png"
LOG="${DIR}/screenshots.log"

# Check if the dir to store the screenshots exists, else create it:
if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi

# Screenshot a selected window
if [ "$1" = "win" ]; then import "${NAME}"; fi

# Screenshot the entire screen
if [ "$1" = "scr" ]; then import -window root "${NAME}"; fi

# Screenshot a selected area
if [ "$1" = "area" ]; then import "${NAME}"; fi

if [[ $# = 0 ]]; then
# Display a warning if no area defined
echo "No screenshot area has been specified. Screenshot not taken."
echo "${DATE}: No screenshot area has been defined. Screenshot not taken." >> "${LOG}"
else
# Save the screenshot in the directory and edit the log
echo "${NAME}" >> "${LOG}"
fi


edit ~/.fluxbox/keys to include:

None F13 :execCommand ~/screenshot scr


Edit the startup script, in this case, ~/.fluxbox/startup to include:

xmodmap -e "keycode 111 = F13"


And press PrtScrn after restarting X.

Wednesday 11 February 2009

Installing ubuntu from usb

Download the .iso to ~/downloads
Download UNetbootin to ~/downloads, from
http://sourceforge.net/project/downloading.php?groupname=unetbootin&filename=unetbootin-linux-313&use_mirror=ovh

sudo fdisk /dev/sdb # repartition usb.
sudo mkfs -t vfat /dev/sdb1 # reformat usb.
sudo mount /dev/sdb1 /media/usb # mount the new partition.
./unetbootin

----------------------

Note: AVOID fdisk! It is limited to 2TB MBR systems.

Tuesday 10 February 2009

Pylab / matplotlib, ubuntu

wget http://puzzle.dl.sourceforge.net/sourceforge/matplotlib/matplotlib-0.98.5.2.tar.gz

Actually, that didn't work. I had to manually download the source.

gunzip < UMFPACK.tar.gz | tar xvf -
cd matplotlib
python setup.py build
python setup.py install

sudo apt-get install python-qt3 # required for plots to work.

phd

x = arange(0, pi*10, pi/100); plot(x, sin(x))

works.

---------------------------------------------------------------

A later installation wasn't so smooth. Inspecting the output of $ python setup.py build, showed freetype2 couldn't be found.

$ sudo aptitude install libfreetype6-dev

fixed that.

$ sudo python setup.py install

then fixed things. phew. arange now works.

Sunday 8 February 2009

Prefered font

misc fixed, regular 10, in kile and konsole. konsole as multiple tabs, activated with CTRL+ALT+N

Saturday 7 February 2009

Write CD / DVD

A one line command:

Navigate to the directory above the one containing all data to be written, and execute:

$ mkisofs -o tmpfilename.iso directory/; wodim -v dev=/dev/dvd speed=4 tmpfilename.iso

where 'directory' is the directory name to be written. speed=4 can be omitted.

Friday 6 February 2009

pypar

Following installation of openmpi, and numpy (both required), pypar:

download:
mkdir ~/downloads/pypar
cd ~/downloads/pypar
wget http://surfnet.dl.sourceforge.net/sourceforge/pypar/pypar-2.1.0_53.tgz
gunzip < pypar-2.1.0_53.tgz | tar xvf -

sudo python setup.py install

failed.

python setup.py install

failed, complaining about a lack of write ability.

sudo python setup.py install

again, then worked! import pypar works, too! Odd.

On reflection, I think I needed to:

python setup.py config
python setup.py build
sudo python setup.py install

Yes. From clean, that worked. Mostly. Actually, there was a complaint about '-fPIC' and '-m64' being files that couldn't be found. odd. Then, later, I found sudo apt-get install python-dev was required, to remove errors re: python.h not being found. This needed an update, upgrade and dist-upgrade to work and I'm now getting error on update. hmmmm. ---- later, on another machine I did: sudo apt-get install subversion; svn checkout http://pypar.googlecode.com/svn pypar-read-only; cd pypar-read-only/source/; sudo python setup.py install; exit log back in and python, import pypar shows it works.

OpenMPI

sudo apt-get install openmpi-common

Didn't install mpicc or mpirun or mpiexec

sudo apt-get install openmpi-bin

mpiexec now works, but pypar complained that mpicc was missing.

sudo apt-get install libopenmpi-dev

! I can't find file `ecrm1000'.

and many others. Try

sudo apt-get install tetex-extra

This took a while.

! LaTeX Error: File `lmodern.sty' not found.

install lmodern to fix:.

sudo apt-get install lmodern

Thursday 5 February 2009

Skype on ubuntu 64

$ wget http://download.skype.com/linux/skype_ubuntu-2.0.0.72-1_amd64.deb
$ sudo dpkg -i skype_ubuntu-2.0.0.72-1_amd64.deb
$ sudo apt-get lib32stdc++6
$ sudo apt-get install lib32stdc++6
$ sudo apt-get -f install

I think only lines, 1, 2, 5 are required. Line 5 (I think) fixes the missing packages, reported from line 2.

Ubuntu shortcut key modification.

$ gconf-editor

/apps/metacity/global_keybindings Edit 'run_command_1' etc, to the key-stroke. e.g. z to set left win button + z. Watch that there's no space there.

/apps/metacity/keybinding_commands Edit 'command_1' etc, to the command to run, e.g. gnome-terminal

..... didn't work. I found that pressing 'z' without the win button launched the terminal.

Try xbindkeys:

sudo apt-get install xbindkeys
sudo apt-get install xbindkeys-config
xbindkeys
xbindkeys-config

Tested. It worked.

Wednesday 4 February 2009

.gz, .tar, .bz2, rar

$ gunzip filename.gz # to unzip


$ tar cvzf foo.tgz *.cc *.h # to create. works for directories, too.
$ tar xzf foo.tgz # to extract

$ gunzip < file.tar.gz | tar xvf -          # to extract.  $ bunzip2 filename.bz2          # extract  $ tar -xvf filename.tar      # extract   $ tar jxvf filename.tar.bz2

$ unzip filename.zip



$ bunzip xine.bz2

and rar / multipart rar:

unrar x 1strarfilename.rar


--------------------- groups of files

ls *.rar | xargs -i unrar x {}



Wow.  That CUNT Gavin is reading over my shoulder.  I blame the parents.

.tar.gz

(He's still whittering on, with everyone in the room ignoring him.  What a cunt, honestly)

.tar.gz:  to extract,

$ tar xvf filename.tar.gz