August 23, 2008

Faster Vista by turning off UAC

I have been using Vista for a while -- it came with my new PC, Vista Home Premium. It took some time to get used to it and it's quite good. But I do sometimes want to go back to XP, when it is slower than XP, which I use at work, and my notebooks. Well, I was too lazy to install XP over Vista, so I kept on using it. There are just too much stuff on there, and I don't have time to back up and install new OS, reinstall everything, and restore, so on.

So today, some software I need to use doesn't work with UAC, or I have to buy the latest version just to run on the new OS. Heck, I always thought UAC is a good feature, but to run that piece of software which I don't think it worth the money just to run on Vista. So I turned off UAC completely. (With Vista Home Premium, it only allows either turn it off completely, or turn it on.)

I don't know if this is just my imagination, but it feels like the computer is running a lot faster, even all the visual effects are turned on. Well, for now, I'm keeping it off.

August 17, 2008

Finding files in directories

This posting is about 'find' unix command.

Linux has services command to handle processes that need to come up at start up time, and shutdown when system comes down. I use Sparc Solaris, v9, and (may be I don't know if there is) I have to (or I still) manage it manually. Sometimes I have to find what sym links are in /etc/rc*.d/ for certain app -- I usually get this part wrong too often -- if I want to look for :
[sourcecode language='css']
$ find /etc/rc*.d -name "*tomcat*" -print
[/sourcecode]
No quotes surrounding the directory pattern, no single/double quotes.

Here's an example:
[sourcecode language='css']
$ ls -ld rc*.d
drwxr-xr-x 2 root sys 1536 Aug 5 13:22 rc0.d
drwxr-xr-x 2 root sys 1024 Aug 5 13:22 rc1.d
drwxr-xr-x 2 root sys 2048 Aug 5 13:22 rc2.d
drwxr-xr-x 2 root sys 512 Aug 5 13:22 rc3.d
drwxr-xr-x 2 root sys 1536 Aug 5 13:22 rcS.d

$ find /etc/rc*.d -name "*tomcat*" -print
/etc/rc0.d/K15tomcat
/etc/rc1.d/K15tomcat
/etc/rc2.d/K15tomcat
/etc/rc3.d/S51tomcat
/etc/rcS.d/K15tomcat
[/sourcecode]

Vista and UAC

Sometimes you have to run certain commands or application as an adminitrator.  And, right-mouse clicking, and then selecting "Runas administrator" isn't too convenient.  There are a few ways to simplify it.  I'll use Vista-Hosts file editing as an example:


1. Use "runas"

From cmd or Windows-Run, type in this:
[sourcecode language='css']
runas /user:administrator "notepad C:\Windows\System32\Drivers\etc\hosts"
[/sourcecode]
This will ask administrator password, however.


2. Use CTRL+SHIFT+Eneter

From Windows-Run, type below:
[sourcecode language='css']
notepad C:\Windows\System32\Drivers\etc\hosts
[/sourcecode]
Then, CTRL+SHIFT+Enter


3. There's a utility, called "Start++".  You can do "sudo" with it:
http://brandonlive.com/2007/02/22/new-tool-i-made-for-vista-start/
[sourcecode language='css']
sudo notepad C:\Windows\System32\Drivers\etc\hosts
[/sourcecode]
That's it!

Vista and hosts file

With Vista, you can't modify hosts file directly with a normal user. You have to become an administrator to edit the file.  Here's how:
  • Run text editor such as notepad as Administrator, by right-mouse clicking on the application, and select "Run as administrator".

  • You'll get system notification, click "Continue"

  • Open file, C:\Windows\System32\Drivers\etc

  • hosts file doesn't have any file extension. Select "All Files"

  • Open "hosts" file.
  • Glassfish init script

    Here's the init script for Glassfish. Change JAVA_HOME, GLASSFISH_HOME, USER variables for your environment.

    
    #!/bin/sh
    # This is for: Sun's J2EE sdk v5.05 (Glassfish)
    
    JAVA_HOME=/usr/java6
    GLASSFISH_HOME=/opt/glassfish
    export JAVA_HOME
    
    USER=glassfish
    glassfish_stop() {
    su $USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
    }
    glassfish_start() {
    su $USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
    }
    
    case $1 in
    start)
    echo "Starting Glassfish server:"
    glassfish_start
    echo "."
    ;;
    stop)
    echo "Stopping Glassfish server:"
    glassfish_stop
    echo "."
    ;;
    restart)
    echo "Restarting Glassfish server:"
    glassfish_stop
    glassfish_start
    echo "."
    ;;
    *)
    echo "Usage: /etc/init.d/glassfish start|stop|restart"
    ;;
    esac