Wednesday, August 31, 2011

Bash: copy directory structure without the files

Here's a one-liner to do that. Go to the source directory and say

user@host:source$ find * -type d -exec mkdir destination/\{\} \;

Tuesday, August 9, 2011

Changing display resolution on Ubuntu when the resolution option doesn't show up

It is very annoying when you have a good monitor (an NEC MultiSync LCD1970NX in my case), capable of supporting 1280x1024 or some such high resolution, whereas Ubuntu simply cannot see beyond 832x624.

Earlier versions of Ubuntu had the xorg.conf file which is no longer present, although if you craft it by hand it is still going to be used. That seems like a dangerous proposition, though - a simple mistake could screw up at least something that is working.

I found the savior in the command xrandr, thanks to X/Config/Resolution page on the ubuntu wiki. And here is what I have done so far:

1. I first ran the command xrandr to make sure that the VGA1 indeed existed. As it turns out, that command can also tell you what is the highest resolution your monitor can support:
sudipta@Springfield:~$ xrandr
Screen 0: minimum 320 x 200, current 832 x 624, maximum 4096 x 4096
VGA1 connected 832x624+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024      60.0 +   75.0 
   1280x960       60.0 
   1152x864       75.0 
   1024x768       75.1     70.1     60.0 
   832x624        74.6*
   800x600        72.2     75.0     60.3     56.2 
   640x480        72.8     75.0     66.7     60.0 
   720x400        70.1 
LVDS1 connected 832x624+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1280x720       60.0 +
   832x624        74.6*
   800x600        85.1     72.2     75.0     60.3     56.2 
   640x480        85.0     72.8     75.0     59.9 
   720x400        85.0 
   640x400        85.1 
   640x350        85.1 
See that 1280x1024 at the top of the list? That is how high my monitor could go. And see that line in the middle with a * at the end (832x624        74.6* in my case) - that one is what I am currently running. And strangely enough, although xrandr knew the highest possible on available, the monitor options only showed 832x624 to be the highest:

So all I had to do to rectify the situation was to open up the gnome terminal and run
xrandr --output VGA1 --mode 1280x1024
which was the highest one supported by my monitor, as mentioned above. Note that I did not specify a refresh rate (using --rate 75 or 60): I let the computer decide for itself. And voila! I had a 1280x1024 screen on my monitor!

I will post an update about how to make the change permanent as well, although the wiki already mentions some options.