Thursday, December 28, 2006

Rdesktop on XGL/Compiz

This tip was found here: but it took me so long to find it .. I figured I will document it again.

For some reason, when you run rdesktop on top of XGL/Compiz, the window opacity goes crazy .. and deems the window practically unreadable.

A way to work around it (until the rdesktop folks figure this out), is to run rdesktop inside xnest.

Just create the following wrapper script:
Xnest -ac -terminate -geometry 1280x1024+0+0 :3 &
DISPLAY=:3 rdesktop -a 16 -f $1 &

It runs Xnest to open a new nested display and then runs rdesktop inside that nest.
That solved my problem immidiately!

Thank you Ubuntu Forums ! :-)

Monday, October 23, 2006

Comparing directories on two machines

Every once in a while you need to compare a bunch of files between two machines (e.g. when you have a directory replicated between two servers ... but not using rsync ..).

Here's a quick and easy way to do it (all commands running on machine2 as user1):
[user1@machine2]$ cd /home/user1/src
[user1@machine2]$ ssh user1@machine1 "cd src; find . -type f -exec md5sum {} \;" | md5sum --check | grep -v "OK"

basically, we are ssh-ing into the secondary machine, creating a list of files and running md5 on them, and then using that list as input for the local directory.
Clearly, you can change the find parameters for specific files, and also add gzip in the pipe if the list is very long or the connection is slow.

fun fun fun!

Friday, October 13, 2006

The amazing screen utility

How many times did you start something in an SSH session and then really needed to leave, and wanted to attach to it from somewhere else.
The answer has been around in shell for years. Once I got used to it, I can never live without screen.
Read the man page .. but in short, screen lets you create sessions and then detach from them and reattach from somewhere else.

To create a screen session run:
or, you can also : screen -dR (which tries to reattach to an existing session or run a new one).

To detach type : ctrl-A d

To reattach type : screen -r (potentiallty add the session id if there are more than one)

To see a list of sessions : screen -ls
you can specify a specific terminal if there are a few when reattaching.

fun fun fun !

Saturday, June 17, 2006

Resize NTFS partitions

Whether you need to install Linux on an XP box, or if you just want to make another partition on your Windows box, Linux contains a great set of tools for resizing NTFS.
The ntfsresize command is a part of ntfsprogs ( The site contains much more information .. but I just thought it's always good to read one more experience.

So .. to resize your partition you have to:
1. Use ntfsresize to actually physically resize the partition
2. Update your partition table using fdisk.

Note: This is the experience I had on Mandriva and Fedora, don't know about Debian based editions.

basic assumptions:
the partition we are resizing is /dev/hda1
we want to resize it to 8Gig
We have some bad sectors on the disk (typical in older computers)

First, resize your partition (assuming the partition name is /dev/hda1):
1. This command will just tell you how much is used from the partition
ntfsresize --no-action -b --info /dev/hda1

2. This command will simulate the resize (assuming we want to resize to 8Gig)- always a good idea if you care about the source
ntfsresize --no-action -b -s 8000M /dev/hda1

3. This is the actual resize command
ntfsresize -b -s 8000M /dev/hda1

Then - you have to redo your partition table:
run : fdisk /dev/hda1
p - to see your current settings (write them down)
d - delete the ntfs partition you just resized
n - add a new partition (make sure the starting cluster is the same is the one you deleted), allocate a new size to the partition - it must be at least the same or bigger than the resized size.
a - if necessary, toggle the boot flag on the partition
w - write partition table and exit

All set - you now have a freshly minted and resized ntfs partition.
As always - if the data on the ntfs partition is critical - make sure to back it up before the process.


Sunday, May 21, 2006

Mounting ISO image

Sometimes, you want to mount an ISO image before burning it to a CD.
It is very easy in Linux (in fact some LiveCD editions use that very technique).

To mount an ISO image just type:
mount -t iso9660 -o loop iso-image-name.iso /path/to/mountpoint

The secret sauce is in the "-o loop" option, which uses the loop device. You can actually customize a lot further by specifying a specific device, for example: -o loop=/dev/loop1,blocksize=1024 .. etc.
But, in most cases the default works perfectly.

Happy mounting!

Monday, January 09, 2006

ntp primer (not really)

There are dozens of great FAQs for NTP. But, here's an issue that took me a while to figure out.

I had a server with ntp configuration that would not synchronize with the ntp server.
The configuraiton was the default ntp.conf file, and I added one line for my ntp server . Something along the lines of:

Btw, to check who you are synchronizing with you can issue : "ntpstat". Also "ntpq -p" is very useful (the active server is marked with a "*").

after much research, I discovered that Fedora (and RedHat enterprise) comes with ntp.conf that has the following line : restrict default ignore
This command causes all the ntp responses to be ignored!!

The solution was to add the line:
which caused the server to allow this specific address to answer. You can add additional limitations, but I didn't bother.
Moreover, you can just get rid of the global ignore line, but just be aware that it will open your server up to ntp traffic from other places..

one more quick note. If you want to synchronize your server right now, and not wait for ntp to do it slowly .. do the following:
1. stop ntpd
2. issue the command : ntpdate
3. start ntpd

This will align your clock with your server immidiately, and then you can let ntpd be "on-guard".

ok, now you have no excuse to be out of sync..

crazy ulimit / ssh issue

This is one of this crazy ones .. which you don't ask about, you just do the workaround ! :)

Sometimes (thus far I have seen it on FC-2 and RH-9) when you try to set ulimit for a user, you get a weird error and the ulimit settings failed.

When looking in /var/log/secure you will see entries like this one:
su: pam_succeed_if: requirement "uid < 100" not met by user "myuser"

even though you have the right settings in /etc/security/limits.conf (meaning you designated your desired user to have limit above the default)

This is some bug with SSH.. not sure what is it.
The workaround I found was :
1. sudo into root, issue the same ulimit command you tried to issue for the user.
2. sudo into the desired user (this time ulimit will work)
3. exit back to root and restart SSHd.
4. completely logout, and log back in as the desired user

The issue is gone..
voodoo .. but it worked for me. :-)