Oct 21

Here’s an easy way to change the prompt in Unix Shell

export PS1="[\W]$ "

This will use the current directory as command prompt

Tagged with:
Oct 21

By default, ‘crontab -e’ uses vi without syntax highlights or nano.
to make it use vim, execute the following command:

> export EDITOR=/usr/bin/vim
Tagged with:
May 13

Login as root

### Create a folder `installer` ###
mkdir /installer
cd /installer

### Download the installer from apachefriends usin wget ###
wget http://www.apachefriends.org/download.php?xampp-linux-1.6.8a.tar.gz

### Unpack the tar ball to folder `/opt` and install service ###
tar xvfz xampp-linux-1.6.8a.tar.gz -C /opt

lvl=`egrep :initdefault: /etc/inittab|cut -d: -f2`

cd /etc/rc.d/rc${lvl}.d

ln -s /opt/lampp/lampp S99lampp

ln -s /opt/lampp/lampp K01lampp

### Start Server ###
cd /opt/lampp
./lampp start
./lampp status

Tagged with:
Jan 22

I use Hostgator as my hosting company. I love them – great service, tons of space and no long term obligations. And the servers are fast. Now, another reason to love them – running Subversion repositories on your server with the caveat – you can only have one account to account to access that repository. If you develop by yourself, and I do for now, it’s not a problem. So how do you do it – assuming you are a Java coder using Eclipse on Windows?

1. Send Hostgator support a request to get SSH access to your server. They will ask you to send in a picture id and once that is cleared, you should be good to go. A matter of a day or two.

2. Install Subclipse SVN plugin for Eclipse. The Subversive plugin DOES NOT WORK.

3. Install the really good Tortoise SVN client

4. Set up an environment variable called SVN_SSH. To do that, go to the Windows Control Panel -> System -> Advanced -> Environment Variable -> New (under the bottom Window). For variable name enter the value SVN_SSH and for its value enter c:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe (assuming you installed Tortoise SVN in the default location).

5. Start Eclipse and go to the Subclipse options: Window -> Preferences -> Team -> SVN . There, for the SVN Interface select “SVNKit (Pure Java)”. Click OK to store the setting.

6. Now, using Putty or some other SSH tool, SSH to your account. You will need to set up a repository for your project. To do that, create the directory that will be used as repository, say /myrepo. Now, create an Subversion repository inside that directory: svnadmin create myrepo.

7. Create a new project by checking out the repository from SVN. To do that, in Eclipse, go to: File -> New -> Other -> SVN -> Checkout Project From SVN.

8. The ‘Checkout from SVN’ window will appear. There select to create a new repository location

9. For the URL, enter: svn+ssh://@:2222/home//. In other words, if your domain is example.com, your admin user name is joey and the path to your repository is /myrepo, then your URL will be svn+ssh://joey@example.com:2222/home/joey/myrepo

10. Another popup window will follow that will ask you for your SSH user name. Enter the details and make sure they are saved.

11. You should be good to go at that point as the rest of the process is the normal project checkout scheme used by Subclipse.

Tagged with:
Nov 09

When you write a shell scripts you need to create filename with date in it. For example instead of log file name “bauson.log”, you can create a filename called “jan-02-06-bauson.log”.

The date in file will make it easy to find out all logs or reports. You can display the current date and time in the given FORMAT using date command. If you just type date command it will display in standard FORMAT:

$ date
Output:
Mon Nov 9 10:54:57 PHT 2009

To display date in MONTH-DAY-YEAR format you need to use date command as follows:

$ date +"%b-%d-%y"

Nov-09-09

As you can see I have used FORMAT as follows
date +”FORMAT”
Where, FORMAT can be any one of the following:

  • %a : Abbreviated weekday name (Sun..Sat)
  • %b : Abbreviated month name (Jan..Dec)
  • %B : Full month name, variable length (January..December)
  • %d : day of month (01..31)
  • %e : day of month, blank padded ( 1..31)
  • %H : 24 hour format (00..23)
  • %I : 12 hour format (01..12)
  • %j : day of year (001..366)

First obtained date:

$ NOW=$(date +"%b-%d-%y")

Create a file with date in filename:

$ LOGFILE="$NOW-bauson.log"

Display Filename

$ echo $LOGFILE

Usage:

10 7 * * * NOW=$(date +"%b-%d-%y"); LOGFILE="$NOW-bauson.log"; php my.php >log/$LOGFILE
Tagged with:
Oct 22

To install yum in fedora just do these commands

1. Change directory

$ cd ~

2. Create directory called ‘yum’

$ mkdir yum

3. go into the yum directory you just created:

$ cd yum

4. download yum:

$ wget http://linux.duke.edu/projects/yum/download/2.0/yum-2.0.7.tar.gz

5. untar the file you just downloaded it:

$ tar -xvzf yum-2.0.7.tar.gz

6. go to the yum directory:

$ cd yum-2.0.7

7. run the configuration file:

$ ./configure

8. make the configuration:

$ make

9. Make install

$ make install

10. Now, its time to update your repository

$ yum update
Tagged with:
Aug 27

I found mysql tuning is a pain. This script is a good tool to adjust your mysql variables. It evaluates the following variables:

slow query count
long_query_time
query_cache_size
% query cache actually used
max_connections
thread_cache
key_buffer_size
ratio of sort_merge operations to sorts (sort_buffer_size)
number of full joins
ratio of disk tmp tables vrs in memory tmp tables (tmp_table_size)
table_cache
ratio of table locks immediate to table locks waited
ratio of table scans (read_buffer_size)

MySQL Tuner

To use the script add your user name and password to a [client] group in your ~/.my.cnf file

Tagged with:
Aug 20

1. Tab
The most handy shortcut and time saver for the linux command line. This actually makes navigating directories faster in the CLI than the traditional GUI browser. Simply start typing the command, filename, or directory and hit tab. Bash will automatically complete what you are typing. It even works at the lilo prompt and in some X applications.

2. Ctrl + c
Stop that program dead in its tracks. This is the command line version of end task.

3. Ctrl + z
Send the current process to background. This is useful if you have a program running, and you need the terminal for awhile but don’t want to exit the program completely.
Type the command fg to get the process back.

4. Ctrl + d
Log out from the current terminal. If you use this in an X terminal emulator such as xterm it will usually close it after logging out.

5. Ctrl + u
Erase the current line. I use this one all the time when I type the wrong command in.

6. Ctrl + Alt + F1, (F1-F6)
Switch to the first virtual terminal. In Linux, you can have several virtual terminals at the same time. The default is 6. (Ctrl + Alt + F7 to get back to X)

7. Ctrl + l (lowercase L)
Clear the terminal.

8. Ctrl + Alt + Backspace
Kill the X server. Use this if X crashes and you can’t exit it normally. If you’ve configured GDM to start automatically at bootup, this restarts the server and throws you back to the graphical login screen.

9. Ctrl + a
Move the cursor to the beginning of the current line. Usefull for those times you navigated all the way through 20 directories and forgot to add ‘cp’ to the beginning. Use this instead of the arrow keys.

10. Ctrl + e
Last but not least get that cursor back to the end of the line.

Tagged with:
preload preload preload
Bless CV