Ubuntu - How to add or create hard disk partition and make it automatically mount

In Ubuntu, adding or managing new partition or hard disk should use UUID (Universally Unique Identifier) of the device rather then using the device node name. e.g. /dev/sda2, /dev/hda3, /dev/sda5 and etc. IMHO its advantage compare to the conventional way of mounting device, using /dev/sda or /dev/hda are :
  • UUID is unique when it comes to device node naming. e.g. multiple USB device plug in and out can generate different /dev/sda nodes.
  • UUID have been used by ubuntu by default to assign partition or hard disk in /etc/fstab.
  • UUID have 25616 of combination and it takes a very long time to exhaust it even though if we were to generate it fast enough. e.g. generating 1 trillion a nano second would take 10 years to exhaust it.
  • using UUID will list the partition or hard disk to appear in the 'File Browser' (aka Nautilus) under 'Places'.

This post will list 2 ways to get the UUIDs in order to make the new partition or hard disk automatically mount under Linux (or particularly Ubuntu), the command line and the GUI (Graphical User Interface) programs provided by Ubuntu.


Start multiple command line screen session to run interactive jobs

As an BSD & Linux administrator, the command line is where we live. We eat, live & shit at the same place, command line screen. Some times, we can only afford to open a single terminal screen. It's kind of hard for us to be efficient as most of the time we multitask on a few bunch of screens.

Or, we need to run an interactive program over a long period of time which we want the result when it ends. Instead passing the program to run in the background which hides the result, the screen command is at disposal.

And most importantly, when combine with ssh (secure shell) it is uncomparablely fast and secure.

Screen is capable to detach from command line session and yet the program runs interactively in the background. The ability to switch from multiple screen will definitely help out when using the console session. Screen can even start in a few "screen session" in order to manage your task into separate groups. Screen also supports hot key (the meta control key with the combination of alphabet or digit) for common task.

Part I will guide any first time screen user on how to start a multiple screen command line to run multiple screen session. Proceed to Part II for a more advanced experience.


MySQL - Common commands of database user account management

SQL database are used to store various kind of data in order for future retrieval. But data stored in SQL database is not only for future retrieval, it is also stored in such a way for faster (repeated) retrieval, structured manner in data organization, interchangeable between applications and most importantly, it provides a mean to store and search for really huge data by using SQL statement, query.

There are a lot of database currently available, e.g. PostgreSQL & MySQL. MySQL is one of the most popular database among open source database, same as PostgreSQL. Due to the hip of LAMP (which denotes Linux, Apache, MySQL, PHP), MySQL have made known to the mass audience. No doubts its performance and usability are, both MySQL & PostgreSQL, in par.

This post will not attempt to compare both excellent databases, rather, it will try to list out a few common uses of MySQL database in tips & shortcut way. Below are the list of common usage of MySQL permission and privileges :


ssh - error "Host key verification failed" when trying to connect or copy a file to ssh server

The below error was display while trying to ssh or scp to a ssh server :

The RSA host key for domain-name.com has changed,
and the key for the according IP address xxx.xxx.xxx.xxx
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
Please contact your system administrator.
Add correct host key in ~/.ssh/known_hosts to get rid of this message.
Offending key in ~/.ssh/known_hosts:xx
RSA host key for domain-name.com has changed and you have requested
strict checking.
Host key verification failed.
lost connection


Nokia E71 and E63 tips and short cut keys

Nokia E71 and E63 are great phones, operating on Symbian S60 series operating systems. Its keyboard is easy to type, the LCD is sharp, the keys position are great and most importantly, the battery last long enough, approximately 5-7 days for an average user like me. The phone also comes with a lot of practical applications, e.g. word processor, spreadsheet, simple note pad, email client and etc.

The phone's operating systems is also able to upgrade from a normal PC or laptop with USB connectivity. The last upgrade my phone had have significantly improve the responsiveness and also some functionality. e.g. typing the phone book entry on the Home Screen will directly search for it (rather the usually need to access the phone book before able to search), press shift twice will activate the secondary input language and others.

But this post is about tips and shortcut keys available on the phone, below are some of it discovered along using the phone all this while :


OpenOffice crashes after fail to recover documents

When launching openoffice, it starts to recover some files which previously did not save properly. After it recovers, it just display a message saying it needed to close due to some unexpected error. After retrying to start a few more times, the result is still the same. Reset the profile by using the below instructions :


How to check user's information and profile

Other then digging /etc/passwd, there are other ways to check a user's profile on the server. "finger" can also do the same job.

finger username

Arrivederci !!!

mkdir - make a whole set of directory, automatically if it does not exists

When organizing files, we often need to make a whole set of directories in order organize the files properly into directories. Most of the time, we will need to make a bunch of sub directories.

"cd /directory" then "mkdir leve1", then "cd /directory/level1" then "mkdir level2", then "cd /directory/level1/level2" then "mkdir level3" and etc... In fact, there is a parameter for mkdir to create the whole set of directory, automatically.


How to display route table or default gateway

Route table are part of the area to troubleshoot when a connection have problem. Route table can the the most frequent problem to look at after assigning an IP address. Other times, it is mainly for adding additional routes when wireless & wired connection are both in use. This post will attempt to list out a few ways to display route table and also how to assign default route aka default gateway in Linux & FreeBSD.

How to cd back to the previous directory

In Linux & FreeBSD, often we need to cd to a directory then ls to find out the files in that directory. Then only to find out we need to go back to the previous directory and do something else, and we will need to type "cd /very/long/directory/name/and/it/is/just/so/not/cool/to/do/".


How to make grep highlight the keyword

By default, grep does not highlight the keyword or the search term. Making grep highlighting the search term can make the visibility of the keyword more obvious if it hide in between the words.

How to print date suitable for file name assignment

In bash script, it is common to name files with date part of it.

system-20080808.zip, mysql-20070707.tar.gz, somelog-20090101.tar.bz2 and etc ...

Reason to name it in such a ways is easier to clean up the backup later, using bash script. If you have not notice, when listing of the files and sort it by name, it is automatically sorted by name  then date, which makes it scripting friendly. Here is some examples of how to print date suitable for file name assignment :


FreeBSD networking - How to assign or remove fixed IP

Previously, we have talk about how to assigh dynamic IP to an interface on Freebsd. This post is about how to assign fixed or static IP to an interface on Freebsd. Below are the steps :

How to clear or reset screen font

After accidentally cat a tar or zip file or left out some pipe and echo the whole file of random string, on to the screen; it can mess up the font of the screen and result in missing of characters or blinking characters or ever the cursor is missing from the screen. No worries, just a 5 character will make your screen back to original display :

How to search in compressed file

This is the third post talking about compressed files. This time, we will look into how to search within the compressed file, without decompressing it.


PostgreSQL - pg_ctl: invalid data in PID file

One fine day, when restarting PostgreSQL :

/usr/local/etc/rc.d/postgresql restart
it complained that
pg_ctl: invalid data in PID file "/postgres/directory/postmaster.pid"

postmaster.pid was the process ID file for PostgreSQL, which indicate PostgreSQL process. If the file exists, it would mean that PostgreSQL is alive and running. If it doesn't, it would (of cause) mean PostgreSQL have been terminated, either on purpose or abnormally.