Wednesday, May 23, 2007

SSH and FTP on Ubuntu

My home pc is finally free from windows. I have formatted my pc for linux, more specifically Ubuntu, from the debian family. Unfortunately, after the installation, I have failed to SSH and FTP to my newly installed machine.

What should I do? After getting suggetion from Steven to install the service because most probably it is not in by default, it works! Thanks sifu~~

There are 2 websites that I refer to, NBLUG and Cyberciti, and thanks to them, I manage to run both services.

To make it simple, to install SSH and FTP, just type "sudo apt-get install ssh" and "sudo apt-get install vsftpd" respectively for each services. To change the setting of SSH, you may go to "/etc/ssh/" directory to find out more. If you are wanting to modify FTP setting, you may want to modify "/etc/vsftpd.conf".

Monday, May 21, 2007

Dev : Oracle Export and Import

Basic backup and restoring user in oracle using console is rather easy. First of all, what is a user? User in Oracle should be something we call a "database" in most relational database, such as MySQL and MSSQL.



So now, how do we backup a user? Some simple step will do.

Lets say we are tring to backup the user "newDB" and the password is "12345".

1. Go to console.
2. type "exp newDB/12345" and enter.
3. follow the steps. Normally by clicking "enter" will do. If you wish to change the name of the backup file, you may change it in one of the option.

Ok. Once your backup is done, you may want to store it to another location. So, in case of natural disaster, choi... We can get the dump file and recreate our database. But how?

1. Go to console.
2. Create new user, grant DBA permission.
3. type "imp newDB/12345 FILE=/get/dump/file/directory/dbdump.dmp FULL=y LOG=newlog.log" and enter.

See? Really as easy as 1-2-and-3! :)

Friday, April 06, 2007

Dev : FTP-ing In Windows Using Script

Have you ever using FTP in Windows? Commands are almost similar with Unix. You may have use Unix Shell script, but have you tried using Windows batch file to help you do the job, for example, getting some log files from a Unix Webserver, without the hassle of typing repeating ftp commands?

There are 2 method.

Method 1:
Create 2 files. 1 is a text file (ftp_cmd.txt) , another is a batch file (ftp_cmd.bat).

ftp_cmd.txt


FTPuserLogin
FTPuserPassword
cd /user/define/location
mget userlogfile.log
y
bye



ftp_cmd.bat


@echo off
ftp -s:ftp_cmd.txt serverhostname



Method 2:
Create 1 batch file (ftp_cmd.bat).

ftp_cmd.bat


@echo off

echo FTPuserLogin> ftp_cmd.txt
echo FTPuserPassword>> ftp_cmd.txt
echo cd /user/define/location>> ftp_cmd.txt
echo mget userlogfile.log>> ftp_cmd.txt
echo y>> ftp_cmd.txt
echo bye>> ftp_cmd.txt

ftp -s:ftp_cmd.txt serverhostname

del ftp_cmd.txt



Please take note that the batch file cannot be named as ftp.bat. This will cause confusion between your batch file and ftp command and it will keep on displaying a loop. Every details must not end with a white space.

Monday, April 02, 2007

Dev : Adding New User

In Solaris, adding user is not as 'too' simple as in Linux.

When we use "useradd -d /home/unixuser unixuser" in Linux, we will be automatically create a user called unixuser and a new directory call /home/unixuser will be created.

However, in Solaris, "useradd -d /home/unixuser unixuser" will only create a user call unixuser, but no user home directory will be created. To make it easy, just add in an extra parameter called "-m", as in create home directory. So the better command for created user in Solaris should be "useradd -d /home/unixuser -m unixuser".

For more information on unix useradd, see here.

Tuesday, March 20, 2007

Dev : Increasing Heap Size Memory

Ever been in a situation where when you try to compile your projects, and all in a sudden, out of memory error occurs. Funny, I have sufficient memory on my pc, but what could have gone wrong? My task manager was showing low memory usage.

This probably could be caused by the heap size memory setting. Most setting, by default, is low. So how do we increase this so call memory? I have been using netBeans and Eclipse IDE for my development. So what I known of is in netBeans and Eclipse only.

Lets say we would like to increase the size to a minimum of 128Mb and maximum 256Mb,

In netBeans,

  1. Go to projects tab.
  2. Locate the project you wish to change the heap size, expand it.
  3. Look for a folder call nbproject.
  4. In nbproject, open the file called project.property.
  5. Locate a line in the file called "runmain.jvmargs=".
  6. Add in parameters. Make it "runmain.jvmargs= -J-Xms128m -J-Xmx256m".
  7. Save the file and rebuild your classes.

In Eclipse,

  1. Go to Package Explorer.
  2. Locate the project you wish to change the heap size, right click it.
  3. In the menu, find Run As > Run... .
  4. A new windows will pop up. Go to the Arguments tab.
  5. In VM Arguments text box, Add in parameters"-Xms128m -Xmx256m".
  6. Click Apply and rebuild your classes.

Sunday, January 28, 2007

Dev : Variables On Shell Script

A=100
B= $A+100
echo $B

What will the next line show?
a) 200 b)100100

If you answer b, then congratulation! But is there any way of making the answer a? Yes, there is. By using the keyword 'expr', the problem is solved. But how?

In the second line, instead of B=$A+100, change it to B=`expr $A + 100`. Remember the white spaces between the '$A', '+' and '100'. We can also use it for subtraction, comparison and other useful usage as well. You can either use the unix man expr, or click here for more information.

Thursday, January 25, 2007

Dev : Installing Oracle 9i on Solaris 8

Whew... It's really a mess to install oracle in Unix machine. Lucky for me, I've found some steps online where it has reduce many white hair growing on my head.

It make me sweat when asking me to change the Solaris Kernel Parameters. After some troublesome findings, I finally manage to change the kernel parameters at /etc/system and manage to get the oracle 9i installed and database created. If not, you will always get oracle error complaining "Out Of Memory". Remember, it is the kernel parameters' fault. Not your RAM, not your SWAP (because I have increase my RAM from 512Mb to 1Gb and SWAP from 500Mb to 1.5 Gb :D ).

After installing and created a database, you need to create at least a user.
To create a user :
  1. Login SQL*Plus with sqlplus "/ as sysdba".
  2. In SQL*Plus, type sql > create user user_name identified by user_password;.
  3. Grant some access for the user.
    sql > grant connect to user_name;
    sql > grant resource to user_name;
    sql > grant create any snapshot to user_name;

After that, to access oracle from other workstation, you should start the oracle process first.

  1. In console, type cd /oracle/home/bin/.
  2. To start the oracle process, in console, type ./lsnrctl start.
  3. To start the database, in console, type ./dbstart.

And there you go! The very basic of oracle. :)

Wednesday, January 17, 2007

Dev : Swap for Solaris

How do we add extra swap space in Solaris version 5.x? For the ease of most users, follow the steps as below...

1. Log in console as root.
2. In console, type root: /usr > df -k to see the available space and the available swap by typing root: /usr > swap -l in console.
3. Locate a suitable location, create a file for swapping. Eg, to create an empty 1 Gb file call swapfile: root: /usr > mkfile 1g swapfile
4. Add the swapfile to the swap. Eg: root: /usr > swap -a /usr/swapfile (must use absolute path)
5. Edit the /etc/vfstab, add in a new line call /usr/swapfile - - swap - no - to enable the swap file at the next boot.
6. Check your swap again by by typing root: /usr > swap -l in console. You will find that there is a new swap available and you are ready to use it. :)

Monday, December 18, 2006

Dev : CVS vs VSS

Virtual Source Safe (a.k.a. VSS) and Concurrent Versions System (a.k.a. CVS), which one you prefer?

In general, VSS will lock a file for a user, and this will make sure no one will use the file until the current user checks it in. In the downside, when a user checked out the file for a long time, this means that other user have to wait for a long time too if they wanted to use it.

There are more comparisons we can get online, this is one of them.

Friday, December 15, 2006

ORA-00911: invalid character

ORA-00911: invalid character, I've been seeing this error message for 2 long, headache days. What is wrong with my SQL coding?

At first, I thought it was the values that I have inserted were wrong. After much checking, I decided to print out the whole query, copy it and put it into the Oracle SQL client to see what is fxxking wrong.

Test and test and test and retest. No! My query is totally correct to me, but it keep saying that I am wrong, even using Oracle SQL client! So my last resort for this is to remove each of the character in the query one by one. And there is it, the stupid ";" (semicolon) at the end of the query which cause all the misery!