Read more »
Home » Posts filed under howto
Accessing Kindle 3 with SSH via Wifi using usbNetwork and Launchpad
Diposkan oleh Unknown on Sunday, May 8, 2011
Read more »
Step by Step Tutorial to the Android Development Setup
Diposkan oleh Unknown on Friday, January 7, 2011
Make your Android power efficient in any situation (for free!)
Diposkan oleh Unknown on Monday, December 13, 2010
Read more »
Eduroam with Linux (incl. Android!)
Diposkan oleh Unknown on Monday, September 27, 2010
Security: WPA2 Enterprise
Authentification Tunneled TLS (TTLS)
Anonymous Identity: none
CA-Certifikate: (none)
Inner Authentification: MSCHAP2
User: user@your-uni.com (as in the Windows settings guide of your home university)
password: your password, as in windows.
Syncronized Folders across Windows and Linux - (Cloud-)Free Encrypted Cross-Platform Synchronisation with Unison
Diposkan oleh Unknown on Sunday, August 15, 2010
What you need
The biggest problem is that you need a Linux server somewhere that is best constantly running and connected. I sync all my files with an online server. This is not a big deal because with SSH the connection is securely encrypted. Also due to compression and the fact that files are only transferred once, sync is pretty fast even with an ADSL connection. Of course this won't work for slow dial up connections in combination with large files. But as long as there are only small changes in certain files, even dial up might work for you. A Linux server is not really needed, but makes the setup much easier, which is why that's what I demonstrate here. And of course if you only want to sync two computers with each other, then there's no need for a constantly active server. It should work with Mac as a client or even server, but I don't own one so I can't help with that.
Downloads
You can get your unison downloads for Mac, Windows here and for Linux here (Ubuntu binaries i386 for 9.10 and 10.04 and more in this ppa. I recommend version 2.40.16, read below for why.
For Windows you also need to get Putty Agent (Pagent), Putty Puttygen and Plink get them at http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. For Linux you also need openssh-server ssh-agent, ssh-keygen (in the openssh-client package) and keychain. You need to setup a working ssh connection with public key authentication for this to work without your interaction in the background. See here how to do this.
Bugs in the past
At the time I found it, over a year ago, it was still pretty buggy. It couldn't handle unicode, special characters or Umlauts properly. Especially between different system you'd end up with two differently named versions of a file unless you restricted yourself to normal a-z characters - very annoying.
But recently new version has come out, which fixes the problem. Now unison is not only a tool to synchronize flawlessly across different systems, it's also faster and prettier "GUI" than older versions and it still synchronized across encrypted ssh connections if you want it to. In my view this makes it the perfect tool for my needs. I've set it up to synchronize my laptop and my netbook with each other and my server system over ssh.
How it works
It's blazingly fast by only copying those parts of the files that have changed. And it doesn't transfer any files to check this. It runs both on the server and the client and only transfers the dates and hash coddes of the files via a secure compressed ssh connection. You can find out more about unison at LinuxJournal.
The easiest setup and the one I will show here is a star topology setup. This means there are several client systems synchronizing with one server. It works because unison knows which files are newer. The great side effect is that you automatically have a distributed backup on all your systems - the server and all clients of all your files.
The script runs automatically every X minutes in the background via cron on Linux (completely invisible) and is called by the Windows Task Manager on Windows (almost invisible).
Important to know
You need to use exactly the same version on all system you deploy it. There are easy to install packages for Debian and Ubuntu and precompiled versions for Windows. I haven't worked with OS X version yet, but they should work as well. I use a Linux server, Windows on the server side should be possible to set up but it's going to be much more difficult. Setting up the client on Windows is already non-trivial.
As you don't modify the same file on both systems at the same time before a server sync, then there won't be any problems. If you do, unison will not sync them. You need to call unison by itself and it will prompt you to chose how to deal with the situation.
The Linux version uses the symlink feature of Linux to let you configure which folders to sync on the go. In Windows this won't work, so all your folders you want to sync need to be inside one parent folder. I know no way around this, though the unison config file might have a solution somewhere...
Sync script:
#!/bin/bash
LOG="tee -a $HOME/logs/mysync2.log"
source $HOME/scripts/functions $HOME/scripts/variables
main ()
{
echo Starting at $(date)
# exit if running on battery
grep on-line /proc/acpi/ac_adapter/*/state >> /dev/null
if [ ! $? ]; # 1 if not "on-line"
then
echo Running on battery. Leaving now...
exit 0;
else
echo Running on AC Adapter.
fi
# use ssh-agent
source $HOME/.keychain/*-sh 2>&1
echo sock $SSH_AUTH_SOCK pid $SSH_AGENT_PID me $(whoami)
ssh-add -l || (echo "SSH Key not active\!"; ssh-add || exit 1)
cd $HOME
unison-2.40.16 sync -batch -maxbackups 2 ${@} 2>&1
echo Exiting at $(date)
}
main | $LOG
It checks and exits when the system is running on battery. To be able to work in the background, it uses ssh-agent. So you need to setup ssh key authentication.
Unison config in ~/.unison/sync.prf:
# Unison preferences file
root = /home/user/sync
root = ssh://user@syncserver:port/syncfolder
follow = Path *
ignore = Path {scripts/s3.sh}
This is a sample config file. It follows all symlinks in the $HOME/sync folder to syncfolder on syncserver via ssh. The ignore section shows you how to exclude certain files from synchronization.
Windows Setup
This should already work just fine in Linux. Now let's turn to the Windows client.
The Window setup, as you will see, it much more "fun". There are several steps you need: Putty Agent (Pagent), Putty Puttygen and Plink (see above for links) and then a few bash scripts.
You need to copy your private ssh key from your linux box and convert it to putty's format with puttygen. Then copy it into a safe folder. I have it in the same folder as the Unison.exe. Then setup an ssh connection to your server with Putty that uses the key and save it to profile name unisonssh. Copy the following bash files to your unison folder and adjust the path names accordingly.
Putty Agent.bat:
pageant.exe sshkey.ppkThis needs to be a script or otherwise it's not started in the right folder and won't find the key. Try it with the full path of the key file then. This must be linked into Autostart if your and will prompt you for your ssh key password if your key is password protected.
SSH Connect.bat
@plink -C -ssh -load unisonssh -i "C:\unison\sshkey.ppk" -l djtm -P 22 unison -server -autoChange the path to where your ssh key lies and the port to your server's port if necessary.
Unison Sync.bat
C:
cd "C:\unison\"
unison2.4.exe -sshcmd sshconnect.bat -backups -backupdir unisonbackups -backuplocation central -batch -confirmbigdeletes -contactquietly
Testing it
Now is a good chance to try everything works fine. Try creating a file one one system and see how after two syncs it magically appears on the other. Edit it there to see how the edits are transferred back to the first system.
Scheduling it
Once everything works you can schedule it to run regularly without you needing to do anything. In Linux, you should install keychain for this to work in scripts and then enter the following into your cron. (To edit your cron type crontab -e)
*/15 * * * * $HOME/scripts/unisonsyncThe */15 means to sync every 15 minutes. Don't worry, usually nothing will be done - I hardly ever notice anything happening. Of course the path should be where your unison sync script lies.
In Windows it's a tad more difficult again. The most difficult part of it all is to make it run in the background without annyoing you every 15 minutes or so. The following command looks a bit quirky, but that's the best I could do. Enter exactly this behind Execute: in the task scheduler.
cmd /C start /LOW /MIN "Unison Sync" "C:\unison\unison.bat"and "C:\unison" next to execute in. Check both execute only when logged in and, under the settings tab, not to start the task if you're running on battery.
And now - finally - enjoy great, free, in sync folders!
Another older, less detailed guide is available here and here. Thanks to the authors of Unison.
How to Boot Floppy Disks with Grub e.g. to upgrade your BIOS
Diposkan oleh Unknown on Sunday, December 27, 2009
title Floppy Imageroot (hd0,0)kernel /boot/memdiskinitrd /boot/floppy.imaboot
Booting Linux over the Network
Diposkan oleh Unknown on Wednesday, May 20, 2009
Pretending a Package is Installed by Creating an Empty Package with Checkinstall (for Debian-based Distributions)
Diposkan oleh Unknown on Sunday, May 3, 2009
Unfortunately, checkinstall's --provides option did not work as expected. So I had to find a way to have them use the manually installed version I compiled from svn and hiding that fact that my package manager. I had to let the package management system know the package was already installed.
So I ended up creating an artificial package that only has the same name and a similar package version, but no actual contents. Create an empty directory, place the following Makefile into it and execute the following checkinstall command. You may need to adjust the parameters for different packages, refer to the output of apt-cache policy somepackage for an appropriate version number)
Makefile:
install:
install -d /usr/local/bin
checkinstall commands:
checkinstall --nodoc --install=no --pkgname=libavcodec51 --pkgversion=3:0.svn$(date +%Y%m%d)-12ubuntu5
checkinstall --nodoc --install=no --pkgname=libavutil49 --pkgversion=3:0.svn$(date +%Y%m%d)-12ubuntu5
checkinstall --install=no --nodoc --pkgname=libavformat52 --pkgversion=3:0.svn$(date +%Y%m%d)-12ubuntu5
sudo dpkg --install ./*.deb
sudo ldconfig
This elegantly fixed the error "ffplay: symbol lookup error: /usr/local/lib/libavcodec.so.52: undefined symbol: av_gcd" and "ffmpeg: error while loading shared libraries: libavformat.so.52: cannot open shared object file: No such file or directory" for me.
Make your Firewall Safer with Knockd
Diposkan oleh Unknown on Tuesday, March 31, 2009
"Never use the second pass encoding again" - Using 'Constant Ratefactor' Instead of Average Bitrate in x264
Diposkan oleh Unknown on Sunday, March 22, 2009
Did you know you can use a roughly vorbis-like quality selection, constant quality crf even in x264? This will save you a lot of encoding time with more or less the same quality. Or maybe not? Well it will look different, but it should be fine. For x264 a range of 18-26 is recommended. The higher the number the lower the bitrate and thus the file size will be.
Nice! Finally I don't need to adjust and calculate bitrates myself anymore! The algorithms really seem to work, because when I now change the codec settings to more efficient ones (e.g. increase the frameref, subq or enable mixed_refs) the quality (SSIM) remained pretty similar, while the bitrate sank.
Some experience with the parameters: The mixed_refs parameter did regularly increase the SSIM for me, but also took a lot more time to encode. Frameref=2 increases the efficiency with little performance impact in my experience. I wonder why it's not the default. Bframes decrease the quality slightly but shave a lot off the bitrate and even increase performance a bit for me.
Let me show you my "quick" example script for mencoder.
#!/bin/bash
CRF=23.5 # 21-26 recommended, the higher the smaller the resulting file, see http://mewiki.project357.com/wiki/X264_Settings#crf
INPUT="$1"; shift
X264OPTS="$1"; shift
OUT=`basename "$INPUT"`"-x264.avi"
echo Encoding $INPUT to $OUT
mencoder="time nice /usr/bin/mencoder -quiet -cache 16384"
enc="$mencoder -ovc x264 -oac copy -x264encopts crf=$CRF:trellis=1:frameref=2:bframes=2:8x8dct:psnr:ssim:$X264OPTS"
# I suggest nr= of no more than 2 or 3 with current x264 from svn.
# something along the lines of -vf
# eq=contrast=20:brightness=2,hue=saturation=1.25 for bleak videos
# denoise3d for noisy and unsharp=l:3x3:1.045 for blurry videos.
# I recommend to try out the result with mplayer first.
# A combination of all may work well, too.
echo $enc -o "$OUT" "$INPUT" $*
[ -f "$OUT" ] && echo File exists && exit 1;
$enc -o "$OUT" "$INPUT" $*
# You can call the script like this:
# script.sh input [x264encopts] [mencoder parameters]
# $ sh menc.sh somefile.mpg "interlaced" "-vf crop=..." or
# $ sh menc.sh somefile.mpg "" "-vf crop=..." or simply
# $ sh menc.sh somefile.mpg
# to get the right crop settings try $ mplayer -vf cropdetect
Feel free to get out the flame thrower - or just make some productive comments.
How To: Comfortably Make your own WINE Bottles
Diposkan oleh Unknown on Saturday, March 21, 2009
The script is the key part. You tell it a directory where you want your bottles installed and then it will create a new folder each time you install a program. Of course you may also install several programs into one bottle. Let's call the script wine-bottle, which I suggest to put into your $PATH:
!/bin/bash
# wine-bottle v. 0.2
# (c) 2009 Linux-Tipps.blogspot.com, (c) 2009 Joost @ http://home.student.utwente.nl/j.vanderhof
# newest version at http://linux-tipps.blogspot.com/2009/03/how-to-make-your-own-wine-bottles.html
# published under the GPL v. 3.0 http://gplv3.fsf.org/
INSTALLDIR="$HOME/.wine/bottles"; #Set this to where you want to put your Wine bottles
[ $# -lt 1 ] && #if you gave no parameters
echo "Please give me parameters! Usage:" &&
echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
echo "Configure a bottle : $0 --conf \"BottleName\"" &&
echo "List bottles : $0 --list" &&
exit 1;
[ $# -lt 2 -a $1 != "--list" ] && #if you didn't give the right parameters
echo "Please give me at least two parameters or a --list parameter! Usage:" &&
echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
echo "Configure a bottle : $0 --conf \"BottleName\"" &&
echo "List bottles : $0 --list" &&
exit 1;
[ $1 == "--list" ] && #if you want to list the bottles
echo "Wine bottles in $INSTALLDIR:" &&
ls -1 $INSTALLDIR &&
exit 1;
[ -d "$INSTALLDIR" ] || ( #if installdir is not existing
echo "Root of Wine bottles not existing: $INSTALLDIR" &&
mkdir "$INSTALLDIR"
) || ( #if installdir creation failed
echo "Could not create installation Directory: \"$INSTALLDIR\"." &&
exit 1);
which wine || ( #if wine is not found
echo "Wine not found, please install it first" &&
exit 1);
[ $1 == "--conf" ] && #if you wish to configure a bottle
WINEPREFIX="$INSTALLDIR/$2/" winecfg &&
exit 1;
#finally, the only remaining possibility is you want to run an application
PREF="$1";
shift; #drop first parameter to leave the command with its parameters
WINEPREFIX="$INSTALLDIR/$PREF/" wine "${@}";
You can now use this script almost like wine. The only difference is that you first need to tell it the bottle's name. E.g. wine-bottle lingopad setup.exe installs the program inside setup.exe into the bottle lingopad. I suggest using the "create Desktop short cut" option of installers, as it lets you easily start them later, without the need to use this script.
If you want to create a backup of your bottle, simpy put the bottle directory inside $INSTALLDIR together with the related .desktop file into an archive. If you want to manually start a program, you can of course still use wine-bottle from the shell: e.g. wine-bottle lingopad "$HOME/Wine/lingopad/drive_c/Program Files/Lingopad/Lingopad.exe".
You may also want to install a current wine via the wine ubuntu repository.
Let me know if you liked this howto!
Update: Updated to Joost's version, thanks!
How to Remove Grub from your Boot Sector(MBR) but keep the Partition Table
Diposkan oleh Unknown on Sunday, March 15, 2009
sudo dd if=/dev/zero of=/dev/XXX bs=446 count=1
That helps you to remove any boot sector from that device, e.g. sda. But make sure you've got a boot sector somewhere! I can recommed installing grub to a USB stick for backup purposes.
How To Add Knoppix to your USB Stick
Diposkan oleh Unknown
Install Daily Fresh Ubuntu Directly over the Web
Diposkan oleh Unknown
Basically all you need to do is copy the kernel "linux" and the initrd "initrd.gz" to your stick. Then boot them from Grub and you can start your installation.
The great thing about it: During the installation you can chose whether to install Kubuntu, Xubuntu, Ubuntu, etc. And you will automatically get the newest available packages right away. There's no need to fetch and install updates after the installation.
And getting the newest packages right away might save you a lot of trouble because of bad packages in the installation cd. And the network installer itself also gets updated regularly.
What packages are installed in Debian/Ubuntu
Diposkan oleh Unknown on Saturday, March 14, 2009
sudo dpkg --get-selections "*" > package_list
and
sudo dpkg --set-selections < package_list && sudo apt-get -u dselect-upgrade
Oh and from the article's comments: The method only works well if you use the exact same version of Ubuntu on both computers. Let me add that it only works at all if you have the same /etc/apt/sources.list and sources.list.d/* files on both computers.
Flashing your BIOS with a bootable CD
Diposkan oleh Unknown on Friday, March 13, 2009
Use your ssh-agent for cron scripts with keychain
Diposkan oleh Unknown on Friday, February 27, 2009
Related: Copy your public SSH-Key to another Computer.
Quick&Secure Complete Network Tunnel over SSH
Diposkan oleh Unknown on Tuesday, December 30, 2008
How to Speed Up your Website's Page Loading Times with Apache and .htaccess
Diposkan oleh Unknown on Friday, December 19, 2008
Setting up NX
Diposkan oleh Unknown on Friday, November 7, 2008