Thursday, October 25, 2007

Changing resolution and refresh rate in ubuntu

You boot up your ubuntu box as usual. Suddenly you notice something wrong: your resolution has changed without you changing it. You go to system preference and try to change the display resolution, but there is no optinon for your preferred setting. Don't panic, there still hope for your ubuntu machine besides reformat :-).
This is what you can do to repair back the display problem. You have to reconfigure Xorg. But before you do anything, please backup your configuration file just in case anything bad happens.

Backup your xorg.conf file
$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

This is how you can reconfigure Xorg

1. Stop your gdm (Gnome display manager), or kdm (KDE display manager) if you use kde desktop environment.
$ sudo /etc/init.d/gdm stop (or kdm for kde)
2. Reconfigure your xorg
$ dpkg-reconfigure xserver-xorg
3. Follow all the instruction. By default, choose 'yes' or 'ok' for every options
4. After finish reconfigure, start back gdm or kdm
$ sudo /etc/init.d/gdm start (or kdm for kde)

Hope this can help.

Tuesday, October 23, 2007

Postgresql quickstart

Reference on commands commonly used in postgresql administration. Enjoy....

1. To start postgres
# /etc/init.d/postgresql start
2. To stop postgres
# /etc/init.d/postgresql stop
3. To start using postgres, change to user postgres
$ su - postgres
4. To create new database
$ createdb dbname
5. To delete database
$ dropdb dbname
6. To access database
$ psql dbname
7. To dump database (backup)
$ pg_dump dbname > backup.out
8. Reload db from file
$ psql -d dbname -f db.out
9. To dump all database to file
$ pg_dumpall > dumpall.sql
10. Reload all from file
$ psql -f dumpall.sql
11. List database
$ psql -l
12. Clean all database
$ vacuumdb --quiet --all

Commands inside psql (PostgreSQL interactive terminal)

1. Access psql
# psql
2. Get help about commands
# \h
3. Quit psql
# \q
4. Import from file
# \i input.sql
5. Show databases
# \l
6. Show tables
# \dt
7. Show users
# \du
8. Connect to database
# \c dbname
9. Change user password
# \c template1
# ALTER USER postgres with password 'new_password';
10. Clean database
11. Help on syntax command