Friday, February 26, 2010

Copy directory in Unix

To copy the whole directory in Unix, I used the following command

cp -R /home/yogesh/sourceDir /home/yogesh/destinationDir

Share directory between Ubuntu guest and Windows host using Virtualbox

In order to mount shared folder for Ubuntu guest with Windows host using VirtualBox I used the following commands

sudo mkdir /mnt/windir
sudo mount.vboxsf shared /mnt/windir

In virtual box seetings, I created shared path as c:\virtual\shared and folder name is shared.

Tuesday, February 16, 2010

Ubuntu Server proxy settings

Ubuntu Server http proxy seetings I found inside file at

/etc/apt/apt.conf

Using grep command recursively

I used following command on Ubuntu server to find specific string under directories recursively, where /etc/ is root path under which I am interested to search.

grep -r 'myString' /etc/

Monday, February 08, 2010

Set HTTP proxy under Ubuntu server

In order to set proxy globally on Ubuntu sever, I added following line to /etc/bash.bashrc file.

export http_proxy="http://serverName:8080"

Friday, January 29, 2010

Change timezone on Ubuntu Server

In order to change timezone on Ubuntu server I used the following command

sudo dpkg-reconfigure tzdata

Check MySQL version

In order to check MySQL version I used the following SQL query

show variables like 'version';

Craete tar file archive and extract it

To create a tar file archive I used the following command
tar -cvf package.tar folderName

To untar (extract) the file I used the following commnad
tar -xvf package.tar

Monday, January 11, 2010

Format Date String in DOS batch file

To format date in DOS batch file I used the following syntax,

echo %date:~8,2%%date:~3,2%%date:~0,2%

which output 100111 for 11th January 2010.

Thursday, January 07, 2010

Kill all unix processes with name known

In order to kill the process in Unix withe the name of the process I used the following command, where poller is the name of the process

kill -9 `ps -ef | grep poller | grep -v grep | awk '{print $2}'`

Wednesday, January 06, 2010

Set time and date from command line in unix

To set date using command prompt in Unix I used the following command

sudo date MMDDHHMI

where MM is the month, DD is the date, HH is the hour and MI is the minute

Thursday, September 24, 2009

Get Class name from Static method in C#.NET

In order to get class name from the static method I used the following code, using .NET reflection

String className = MethodBase.GetCurrentMethod().DeclaringType.Name;

Thursday, September 10, 2009

Remove registry keys and subtrees

In order to remove the registry key and all sub-tree beneath it, create file with extension .reg and put this text in the file and double click the file. In following example all registry keys and sub trees under MyProgram will be deleted


Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\MyProgram]

Disable monitor timeout from Ubuntu server console

To disable monitor auto off from Ubuntu Server console, I used following commands

$setterm -blank 0
$setterm -powersave off
$setterm -powerdown 0

Tuesday, September 08, 2009

Disable Ubuntu monitor auto turn off

To disable auto turn off monitor for Ubuntu Server console I changed /etc/console-tools/config and made BLANK_TIME=0

Friday, August 21, 2009

Check the memory taken by files and directory

Check the memories taken by the files and directory I used this command

du -h -s -c *

Monday, July 13, 2009

Change Hostname of Ubuntu server machine

Edit the file /etc/hostname and put hostname in this file.

and execute /etc/init.d/hostname.sh start

Also edit /etc/hosts file and change hostname in that file.

Monday, July 06, 2009

Disable Windows XP active screensaver

From registry editor... (Run=> regedit)

HKEY_USERS -> .DEFAULT -> CONTROL PANEL -> DESKTOP, Set the "ScreenSaveActive" value to 0 and the "ScreenSavetimeOut" value to 0 to disable active screen saver.

Friday, June 05, 2009

Change Hostname of Ubuntu Machine

To change hostname of Ubuntu machine use following commands

Edit file /etc/hostname and change the hostname in that file

run the command sudo /etc/init.d/hostname.sh start

run the command sudo sysctl kernel.hostname=newHostname

Change UUID of Virtual Box Disk (VDI)

In order to change UUID of Virtual Box Disk Image (VDI) use following command from DOS command prompt.

VBoxManage internalcommands sethduuid "c:\diskName.vdi".

VBoxManage is command is located at C:\Program Files\Sun\xVM VirtualBox. You can add it to Environmental variable and then execute above command from the directory where VDI file is located