Wednesday, 14th May 2008 at 02:41 (administration, linux)
Tags: limit bandwidth, llinux, network, traffic shaping, ubuntu
Allthough I haven’t found some shiny GUI somewhat like Netlimiter there is Wonder shaper (and shaper and trickle and squid for http and …) where a single command line sets your over-all bandwidth for network interface X. And, isn’t that all you really need?:
sudo wondershaper ethX downlink(kbit/s) uplink(kbit/s)
This is, from the perspective of the host doing the shaping. For example to set download to 10000kb (750*8 = 6000 DSL but don’t limit intranet connections on 1Mb Ethernet) but limit upload to, say, 35kB (~280kb) — e.g. if you have a server running on the same connection you do your daily internetting, you do:
sudo wondershaper eth0 10000 280
Ressources
2 Comments
Saturday, 26th Apr 2008 at 15:22 (administration, linux)
Tags: linux, vbox, vdi, virtual machine, virtualbox
If you ever wanted to move your (very large) file that contains a Virtualbox’s guest hard drive (file extension is .vdi) to another location and did so just like that Virtualbox wouldn’t find it the next time you wanted to boot into your guest system. The only thing Virtualbox needs to be pointed to is the new location of that file.
The standart location of VDI files is (for Linux) ~/.VirtualBox/VDI/ (see global settings, where you could also change this if that’s all you want). Remember the old file name and close Virtualbox, just in case it would overwrite settings when closed after the following changes. Now let’s move one file to, say, /media/USBDrive/virtualbox/. Now do:
- Use your favorite editor to open
~/.VirtualBox/Virtualbox.xml
- Find the line that says something like:
<VirtualDiskImage filePath="VDI/old file name.vdi"/>
- Change it to point to your new location. So it should read something like:
<VirtualDiskImage filePath="/media/USBDrive/new file name.vdi"/>
- Done.
1 Comments
Tuesday, 8th Apr 2008 at 14:02 (administration, linux, open source)
Tags: apache, cms, https, linux, secure, ssl, web server
Here is a forum post on how to make all incoming connections to your apache web server redirect to https, i.e. take encripted connections via ssl by using apache’s rewrite module.
Comments
Tuesday, 18th Mar 2008 at 18:28 (administration, linux, ubuntu)
Tags: Feisty Fawn, flash, Gutsy Gibbon, Hardy Heron, opera, plugin, ubuntu
Note 08/01/08: There have been issues after the original plugin has been updated. See Ubuntu Forum, Bug description (workaround or fixed deb for firefox only which is version 9.0.115!) or comments below for more. Components have been removed that also opera needs! Yet another example why closed source is bad… Hence you might want to give gnash a go, i.e. open source flash. The new Flash version is meant to work with opera version > 9.50 Beta, though (see bottom note). Anyway, here it goes for Flash version
9.0.48.0:
Note 2008/04/19: Before you get all frustrated about Flash and Opera you might enjoy operas’ ads.
Here we go
To install Adobe Flash Player after you installed Opera in Ubuntu, I found the best way is to, once again, use the debian way:
sudo aptitude install flashplugin-nonfree
After the install routine is done you need to add the path to plugins options in opera. Alternatively you could link there. To find where the new binaries are located do:
dpkg -S flashplugin-nonfree
app-install-data: /usr/share/app-install/desktop/flashplugin-nonfree.desktop
flashplugin-nonfree: /usr/lib/flashplugin-nonfree
flashplugin-nonfree: /var/cache/flashplugin-nonfree
flashplugin-nonfree: /usr/share/lintian/overrides/flashplugin-nonfree
flashplugin-nonfree: /usr/share/doc/flashplugin-nonfree
flashplugin-nonfree: /usr/share/doc/flashplugin-nonfree/changelog.gz
flashplugin-nonfree: /usr/share/doc/flashplugin-nonfree/copyright
Update 2008/04/16: The correct “list flag” for dpkg would be -L instead of -S:
dpkg -L flashplugin-nonfree | grep -i 'lib'
/usr/lib
/usr/lib/xulrunner
/usr/lib/xulrunner/plugins
/usr/lib/mozilla
/usr/lib/mozilla/plugins
/usr/lib/iceape
/usr/lib/iceape/plugins
/usr/lib/iceweasel
/usr/lib/iceweasel/plugins
/usr/lib/firefox
/usr/lib/firefox/plugins
/usr/lib/midbrowser
/usr/lib/midbrowser/plugins
/usr/lib/xulrunner-addons
/usr/lib/xulrunner-addons/plugins
/usr/lib/flashplugin-nonfree
/var/lib
/var/lib/flashplugin-nonfree
/Update
Alternatively you could link the lib’s binary to Opera’s plugin directory:
sudo ln /usr/lib/flashplugin-nonfree/libflashplayer.so /usr/lib/opera/plugins/
Some say you may need to restart opera in order for plugins to actually work. Fortunally, for me it work right away. In opera’s address field type opera:plugins to see what opera knows about flash.Update: See this blog on bleeding edge info on plugin’s development status if interested.
Ressources:
Update: This works for 7.04, a.k.a. Feisty Fawn, and 7.10, a.k.a. Gutsy Gibbon.
Update 2008/04/16: On a side note: There is the option reinstall for aptitude if one wants to make sure the newest files are all in the right places.
Update 2008/04/19:I stumbled upon the close to be release of Opera 9.5 which is currently in beta state (and has even more great features once again before Firefox has them
). Supposingly the Debian package should get flash working. I tried the i386 version for Gutsy and it did work for me.
Update 2008/06/28: Here are some command line parameters you can start Opera with. Especially useful would be -debugplugin. To use it you have to open a terminal to see the additional information:
opera -debugplugin [Enter/Return Key]
32 Comments
Monday, 7th Jan 2008 at 19:21 (administration, linux, ubuntu)
Tags: login, openssh, remote access, remote desktop, ssh, ubuntu, vnc, windows
This will show what needs to be set-up and installed to use a secure line from a Linux box (eg. Ubuntu) to a Windows box via SSH-tunneled VNC but without the load of Cygwin installed on Windows. I used the nicely small package SSHWindows.
SSH server for Windows (on Windows machine)
- Download SSHWindows and run the installer. An alternative could be WinSSHD from bitvise. It’s 30 days trail and closed, though. You’ll be prompted with the warning to edit the passwd file. Read
quickinstall.txt or readme.txt for more details located in the install folder for %PROGRAMFILES%\OpenSSH\docs (hit WIN-KEY+R and copy&paste the path there for quick access).
- From a prompt cd to
%PROGRAMFILES%\OpenSSH\bin. (WIN+R and type cmd, hit ENTER, c: ENTER, cd %PROGRAMFILES%\OpenSSH\bin)
- Run the following (replace
<username> with the Windows username that should log in from Ubuntu):
mkgroup -l >> ..\etc\group
mkpasswd -l -u <username> >> ..\etc\passwd
- Start opensshd as Windows service:
net start opensshd
- Open incoming port in Windows firewall:
netsh firewall add portopening TCP 22 "OpenSSHd"
The “OpenSSHd” bit can be chosen individually; it’s only a string to identify this entry.
- Test login locally with eg. PuTTY and than test it from the Linux box (
ssh winuser@winip). You might need to do some firewall (Windows and/or iptable) config. If your Linux box has to go through some kind of router/firewall machine you’ll most likely have to add port forwarding on that firewall to pass port 22 (SSH port) to the windows machine’s IP.
Install TightVNC (on Windows machine):
- Don’t forgett to click the options to setup VNCServer as Windows service and start it after installation.
- Open TCP port 5900 temporarily for testing like for opensshd:
netsh firewall add portopening TCP 5900 "VNCincoming"
- Test it from Ubuntu with
vncviewer <windows-machine-ip>
- If it works close the port in Windows firewall. You won’t need that hole any longer:
netsh firewall delete portopening TCP 5900
- Configure tunneling VNC through SSH (on Linux box):
ssh -L <local port>:<remote computer>:<remote port> <user>@<remote ip> and vncviewer 127.0.0.1
- Test vnc connection again using -via option:
vncviewer -via user@host localhost:0
- Use compression in ssh?
- GNOME applet/shell skript?
References:
Comments Off
Sunday, 6th Jan 2008 at 23:25 (administration, linux)
Tags: bash, gzip
While compressing a set of single files is fairly easy (one only needs to add ‘.gz’ or similar to the end of “file name strings”) the oposite is not so easy. Nevertheless it can be done doing:
for i in *.gz; do echo extracting $i ...; sudo su -c "gzip -dc $i > ${i:0:${#i}-3}"; done && ls *xpm
sudo su -c "" is for Ubuntu systems, ${#i}-3 sais “length of i minus 3″ which makes ${i:0:${#i}-3} to become each file name without trailing .gz.
Ressources
- Bash by Example
- man 8 bash section “Parameter Expansion” -> “Substring Expansion”
Comments
Saturday, 5th Jan 2008 at 17:09 (linux)
Tags: chkdsk, file system, GNU ddrescue, linux, lost partition, ntfs, partition recovery, partition table, restore data, system tools, testdisk
One important thing to know before doing anything else:
Every byte written to partitions in question will decrease chances to get data back since deletion of files and even partitions does not automatically mean actually deleting that data on disk. In most cases it only means deleting administrative entries in file or partition tables. But writing new files or partitions on the very same disk might actually overwrite data blocks containing pieces associated with files still intact! The second thing you might want to consider: If you mistakenly deleted single files or even a bunch of them look somewhere else but better not reboot until you really know why you have to do so as rebooting in those cases will sometimes also mess up chances to get back your data. Here I will only handle partition or hard drive errors.
So the very first step will be to get hold of extra storage (like USB drives), boot up some Live CD, e.g. your Ubuntu installation cd. If you have liability to paranoia you might even want to physically detach your hard drive and use some USB case to access it instead. First of all do something like
ddrescue -vr-1 /dev/sda recovered_data_blocks.img gddrescue.log
using gddrescue. Adjust parameters to your needs, especially /dev/sda (complete drive) or /dev/sda1 (partition in question). For Ubuntu you need to install gddrescue (= GNU ddrescue) package first. gddrescue will create an image trying hard to copy every data block still intact so you can, at any point, restore the drive stage where you first discovered you lost data. This, or course, can be used with any block-oriented medium such as CD-ROMs or DVDs. You might want to specify “-b 2048″ for CDs. Also use -n to get the most data on first run. For subsequent attempts you might want -rX where X is the number of retries for erroneous areas. I recommend to use -vr-1 for verbose infinite retries. gddrescue first reads as many as possible intact blocks and then splits error areas with each subsequent run. Note though for partitions or even complete hard drives it will take hours so be patient and make sure to use gddrescue’s log file option! With other tools I tried it took even more time which makes sense since gddrescue reads only blocks that really need to be read.
Second you should — just in case — save your partition geometries with fdisk (output similar):
$ sudo fdisk -ls
Password:
Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 9145 73457181 b W95 FAT32
/dev/hda2 9146 19106 80011732+ 83 Linux
/dev/hda3 19107 19457 2819407+ 5 Extended
/dev/hda5 19107 19457 2819376 82 Linux swap / Solaris
Disk /dev/hdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Disk /dev/hdc: 20.8 GB, 20847697920 bytes
255 heads, 63 sectors/track, 2534 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 * 1 2427 19494846 83 Linux
/dev/hdc2 2428 2534 859477+ 5 Extended
/dev/hdc5 2428 2534 859446 82 Linux swap / Solaris
After ddrescue has finished try TestDisk for lost partitions which, among others, looks for back up partition tables, inode tables, and the like. To restore plain data there are heaps of tools. Most notably foremost and PhotoRec. Note though that for lost partitions there is no way to really know what file type found blocks belong to or even the name of associated files’ paths, at least as far as I can imagine. File names really are — in all file systems I know — only attributes of a data segment called file (or inode) such as access date, ownership and such. Sometimes file names are even stored in special files (directories or folders) which means there data blocks need to be intact and it has to be known where they are! The scenario I ran into was I mistakenly installed Ubuntu on top of Windows XP (NTFS partition) instead of resizing the partition as intended. TestDisk even though listing a NTFS partition (from it’s back-up MFT located at the end of NTFS partitions) couldn’t however restore the partition as such. Running Microsoft’s chkdsk stored a bunch of files with their filenames several folders into one called found.000 (I ran it inMicrosoft’s recovery command line from CD after manually through fdisk changed partition type to NTFS/HPFS, e.g. x07). Using the above mentioned tools I could restore some more but without there original path or file names. All together I recovered ~40 GB out of probably 60 GB data (which included system files).
Resources
Further reading:
Comments
Monday, 26th Nov 2007 at 23:06 (linux)
Tags: bash, batch, cmd, cml, command line, history, Prompt, shell, working directory
While searching for a promt command for bash to trimm long pwds (current working directory) I stumbled uppon “Blog.ubrious“. After a little hacking I adopted it to work for linux bash. It also cuts off leading characters when pwd is longer than 20 characters with build-in commands only. Plus I opted to use a ‘@’ as dilimeter between user name and host name so to rather have ssh style. Here is what I came up with:
PROMPT_COMMAND='PS1="\[33[0;33m\][\!]\`if [[ \$? = "0" ]]; then echo "\\[\33[32m\\]"; else echo "\\[\33[31m\\]"; fi\`[\u'@'\h: \`if [[ ${#PWD} > 20 ]]; then echo ${PWD:$((${#PWD}-20))}; else echo "\\w"; fi\`]\$\[33[0m\] "; echo -ne "33]0;`hostname -s`:`pwd`07"'
If wordpress does mess up the code (which I hope does not happen) please visit the original blogger’s post since he was able to upload a text file (I’m not, unfortunatelly).Here is a small list on what it can do for you and a little demo:
- Changes to red if the last command didn’t have a return code of 0
- Includes your bash history # for easy history command repeating. Follow the link to find out how to use
!!, !$ and !number.
- Makes sure path length doesn’t exceed 30 regardless of what the base name is (bit after last fwd slash).

The only small hassle about it is even though it uses \w it wouldn’t abreveate my home directory as ‘~’ for me.
Note 2008/05/14: If you want to use this promt command with screen, too, make sure to test $TERM for ’screen’. For example mine reads:
case "$TERM" in
xterm*|rxvt*|screen*)
PROMPT_COMMAND=...
1 Comments
Monday, 1st Oct 2007 at 14:03 (linux)
Tags: art, CC, creativity, freedom, GPL, licenses, programming, software
If you ever where in the need to license your work — let be creative work what so ever — and the desire to do so with freedom in mind (as in “free speech” not in “free beer”) you must have been puzzled to peaces. Unless you happen to be equipped, besides your knowledge for the craft, with legal knowledge in that matter that is. I reckon most artists nor computer enthusiasts aren’t. At least, I’m not. So, an article on linux.com written by Nathan Willis came in very handy to at least give an introduction and some clarification to the issue of mixing those licenses. Say, you run a free operating system and want to integrate some desktop eyecandies, themes, icons, what-so-ever. If you don’t find that tricky already think about releasing something like a modification of the theme or a new program using some bits of an icon set or a new distro or some music mix using sounds from a theme, some video production with light effects from some application using a special theme … I guess you get the problem here.
Comments
Sunday, 30th Sep 2007 at 20:42 (administration, linux, ubuntu)
Tags: apt, bash, deb, linux, system, ubuntu
The other day I noticed that my settings directory (/etc) uses over 13 MB of my hard drive. So I wandered which package (I’m using a Debian based package managed system) makes the settings directory grow so large. After a couple of trails and errors I came up with the following sequence of commands:
$ du -h --max-depth=1 /etc 2> /dev/null | egrep '(^[5-9][0-9]{2}K)|M'
692K /etc/X11
672K /etc/acpi
712K /etc/xdg
2.1M /etc/brltty
500K /etc/ssl
528K /etc/mono
20K /etc/NetworkManager
13M /etc
$ dpkg -S '/etc/brltty'
brltty-x11, brltty: /etc/brltty
$ apt-cache show brltty | grep -A5 'Description'
Description: Access software for a blind person using a soft braille terminal
BRLTTY is a daemon which provides access to the Linux console (text mode)
for a blind person using a soft braille display. It drives the braille
terminal and provides complete screen review functionality.
The following display models are supported:
* Alva (ABT3xx/Delphi)
Fortunatelly, I’m not blind so I could remove brltty with aptitude which then suggested to remove dependencies, too.
References:
- Regex reference
- Resources for advanced Ubuntu topics, eg. how to remove …-desktop meta packages with apt-get (instead of aptitude), secure networking setup, etc.
Comments
« Previous entries · Next entries »