Archive for the ‘linux’ Category

VirtualBox resolution problems in a headless environment

Monday, August 16th, 2010

In certain cases running a VirtualBox VM in a headless linux environment can lead to a Windows XP having an undesired resolution.

I fixed this using the following two commands:

Global command:
VBoxManage setextradata global GUI/MaxGuestResolution 1920,1200

For a running VM:
VBoxManage controlvm "remote" setvideomodehint 1920 1200 24

I found the resolution in this forum:
VirtualBox Forums

aptitude search vs apt-cache search

Wednesday, July 7th, 2010

Over the years I have grown used to the fact that when I search for a package on a debian based distro, then I use:
apt-cache search foo bar
The result was a list of all the packages which had the text ‘foo’ and ‘bar’ in the description.

Lately it has been discouraged to use apt-get and apt-cache, but one should rather use aptitude as this tool is more powerful.

It is more powerful, but it does not behave the same. So the following command:
aptitude search foo bar
would return any result where either ‘foo’ or ‘bar’ was in the package name, not the description.

Since I have gotten used to apt-cache way this is how I do it with aptitude:
aptitude search "~dfoo bar"

But! This command does not check package names. Package names are with ~n. Maybe someone out there can explain how I can combine the two correctly?

Determining the base directory of a bash script

Sunday, May 9th, 2010

While writing bash scripts, I find it a good idea to put reusable functions into their own scripts and then source them into other scripts.

This means that one must use the source /file/to/source call to load these files. To be able to do this, the bash script must know where the scripts to source are. To not have to hardwire this into the script, I just have the requirement, that the script must be in the same directory as the script itself.

The following code shows how one can find the base directory, with out using any external commands and it should work with out regards to how the script is called:

SCRIPT_NAME="${0##*/}"
SCRIPT_DIR="${0%/*}"

# if the script was started from the base directory, then the
# expansion returns a period
if test "$SCRIPT_DIR" == "." ; then
  SCRIPT_DIR="$PWD"
# if the script was not called with an absolute path, then we need to add the
# current working directory to the relative path of the script
elif test "${SCRIPT_DIR:0:1}" != "/" ; then
  SCRIPT_DIR="$PWD/$SCRIPT_DIR"
fi

# now we can source our other scripts
source $SCRIPT_DIR/logger.sh

Ubuntu 10.04 and Lucid Lynx: No icons in menu or buttons

Thursday, May 6th, 2010

For the Ubuntu 10.04 Lucid Lynx, the developers decided to remove the Interface tab in System -> Preferences -> Appearance.

What made them do that I can not fathom. Yet there is (still) an option to put the icons back.

You can put it back for all new users by adding the following two lines to /usr/share/gconf/defaults/10_libgnome2-common:

/desktop/gnome/interface/menus_have_icons       true
/desktop/gnome/interface/buttons_have_icons      true

And you can activate it again for your current user by using these two commands:

gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons        true
gconftool-2 --type bool --set /desktop/gnome/interface/buttons_have_icons       true

I just really hope support for this isn’t removed altogether in new Gnome versions

Courtesy of the following two ubuntu forum threads:
No icons in context menu for 9.10
GTK menus missing icons

Adding Verdana / Tahoma / winfonts LaTeX support in Ubuntu 9.04

Monday, September 28th, 2009

To be able to use windows fonts like Verdana, Tahoma and so forth in Latex documents on an Ubuntu Jaunty Jackelope you need to install the winfonts package from CTAN. The following steps explains what I undertook to use these fonts:

1. First download the winfonts package from CTAN
2. Find your Tahoma and/or Verdana fonts on the web or your Windows computer
3. Extract the files in your home
4. Copy the contents of the winfonts directories doc, fonts, tex, ttf2tfm to /usr/share/texmf-texlive/ respectively
5. Copy the fonts to /usr/share/texmf-texlive/fonts/truetype/public/msttcorefonts
6. Run the following commands

sudo update-texmf
sudo update-fmtutil
sudo update-updmap
sudo texhash
sudo updmap-sys --enable MixedMap winfonts.map

7. In your LaTeX document switch to Tahoma with the following commands:

usepackage[T1]{fontenc}
fontfamily{tahoma}selectfont
renewcommand{sfdefault}{tahoma}
renewcommand{familydefault}{sfdefault}

I solved this problem with some help from these entries:
http://www.latex-community.org/forum/viewtopic.php?f=5&t=2110&p=8558

Further the documentation for the winfonts is here.

DHCP Internet and own DNS Server

Wednesday, July 15th, 2009

If you’re running your own DNS Server and your internet connection is using DHCP to get the WAN IP, then you might run into the same problem I have.

I have configured my own LAN DNS-Server on a local IP and configured this in /etc/resolv.conf. Periodically the DHCP Client refreshes the WAN IP, thus overwriting my resolv.conf settings.

This problem can be resolved by adding the following line to your /etc/dhcp3/dhclient.conf file:


interface "eth0" {
prepend domain-name-servers 10.0.0.1;
}

In this way your DNS Client will first add your defined domain-name-server to the list sent from your provider

Remote Desktop from Ubuntu

Monday, April 21st, 2008

I don’t want to search for the right commands everytime I want to connect to a windows machine with RDP when I’m on a Linux machine running Ubuntu or Kubuntu that is. The best tool I know, that really does the work is rdesktop.

Install this package:

sudo apt-get install rdesktop

And then just connect with this line:

rdesktop -u user -p password -k de-ch -g 1280x1024 server

This also shows how to use a Swiss German keyboard layout, as I have searched for it many times. The thing is, that it is not an underscore, as many may think.

MySQL new user SQL statements

Tuesday, April 1st, 2008

A quick and dirty explanation to create a new MySQL datbase with a user

Create the user:

  • CREATE USER 'hibtest'@'localhost' IDENTIFIED BY '*******';
  • Set some permissions:

  • GRANT USAGE ON * . * TO 'hibtest'@'localhost' IDENTIFIED BY '*******' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0MAX_USER_CONNECTIONS 0 ;
  • Create the database:

  • CREATE DATABASE IF NOT EXISTS `hibtest` ;
  • Grant the privileges on the database:

  • GRANT ALL PRIVILEGES ON `hibtest` . * TO 'hibtest'@'localhost';
  • Apache and redirecting a url

    Wednesday, March 26th, 2008

    This is a quick blog for me to remember how to do a proxy in apache:


    <VirtualHost *:80>
    ServerName www.someurl.com
    ServerAlias www.someurl.com
    ServerAdmin someone@someurl.com

    ProxyPreserveHost On

    ProxyRequests Off

    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>

    ProxyPass / http://999.888.777.666:8080/
    ProxyPassReverse / http://999.888.777.666:8080/
    </VirtualHost>

    VMWare 6 and Ubuntu Hardy: vmmon compile error

    Wednesday, March 19th, 2008

    Just a quick post to documentate how I got my VMWare config to work:

    Problem: include/asm/bitops_32.h:9:2: error: #error only <linux/bitops.h> can be included directly, and vmmon-only compile failes

    Solution: change line 74 in vmmon-only source file to read: #include “linux/bitops.h”

    Steps:

    1. cd /usr/lib/vmware/modules/source
    2. cp vmmon.tar vmmon.tar.orig
    3. sudo tar xvf vmmon.tar
    4. cd vmmon-only/include/
    5. sudo vi vcpuset.h
    6. change line 74 from: #include “asm/bitops.h” to: #include “linux/bitops.h”
    7. rm vmmon.tar
    8. sudo tar cvf vmmon.tar vmmon-only/
    9. sudo rm -rf vmmon-only/
    10. sudo vmware-config.pl

    That’s it, the compile will work now and vmware should be usable as normal
    eitch