Wednesday, June 20, 2012

NX Client for MacOS/X was not able to find the Apple X11 Server

Although XQuartz is already installed, NoMachine NX Client (v3.5.0-7) on OS X 10.6 will complain about not being able to find Apple X11 in /Applications or /Applications/Utilities.

You can download and install X11 for OS X 10.6 from here (just not sure if it will install without first uninstalling XQuartz because XQuartz may be newer).

Or, simpler, create a symlink /Applications/Utilities/X11.app to point to /Applications/Utilities/XQuartz.app:
$ sudo ln -s /Applications/Utilities/XQuartz.app /Applications/Utilities/X11.app

Thursday, May 10, 2012

Use wget to recursively get contents of a directory

Sometimes, it's just necessary to explore the directory space on a remote dir to know what are the specific keys that can be queried individually.
This is particularly convenient in the case of cloud instance metadata where one would like to find out what are all the metadata keys that are available for a given instance on a given cloud.

So, to download the complete directory tree recursively, use the following command (this example uses the 'default' cloud instance metadata server):

$ wget -rk Is http://169.254.169.254/latest/meta-data/

Monday, October 31, 2011

OS X top command: sort by column

 After starting top, sort by column names by typing:

o<key>         Set primary sort key to : [+-]{command|cpu|pid
               |prt|reg|rprvt|rshrd|rsize|th|time|uid|username|vprvt
               |vsize}
O<skey>        Set secondary sort key to 

Field descriptions
command: command name
cpu: CPU usage
prt: number of Mach ports
reg: number of memory regions
rpvrt: resident (physical) private address space
rshrd: resident (physical) shared memory space
rsize: resident (physical) memory size
th: number of threads
time: execution time
uid: user ID
vprvt: private address space size
vsize: total virtual memory size

Thursday, January 20, 2011

Installing Ubuntu 10.04 Enterprise Cloud (on Dell PowerEdge R510 using iDRAC6)

This is done as a two step process - first, we need to configure the machine, then we can actually install Ubuntu.

1. The network setup here is that each cluster node has two network cards, a local and a public one, but all of the public traffic is, initially, routed through the cluster's head node. So, in order to access Dell's iDRAC6 on the worker nodes, it is necessary to first setup port forwarding through the head node for HTTPS and VNC:
(local): sudo ssh -L 443:[node IP]:443 -L 5900:[node IP]:5900 -l [head node user name]  -N [head node IP]


2. Open https://localhost:443 and enable Virtual Media -> Status -> Auto Attach under Console/Media -> Configuration. This will allow us to actually mount a CD-ROM as a virtual device to the node. 

3. Launch the node's virtual console from the Properties tab and reboot the system; load BIOS and disable internal interfaces, disable memory checking, and enable hardware virtualization

4. On the head node, download and mount bootable FreeDOS ISO as a virtual CD for the node so we can boot off of it:
(head node): sudo vmcli -r [node IP]  -u root -p -c [path to FreeDOS ISO on head node]

5. Boot FreeDOS, through the Virtual Console, select 'Install to hard drive', then run from CD (this will enable networking):
(node): UX_Diag, uediag.exe, -mba 1

Now, the machine is ready to have an OS of choice installed.
6. Mount Ubuntu Enterprise Cloud ISO as a virtual CD from the head node again so we can boot off of it and install:
(head node): sudo vmcli -r [node IP] -u root -p -c [path to Ubuntu ISO on hed node]

7. Reboot from virtual console, enter BIOS and choose CD as the first boot device; boot into Ubuntu configuration screen and install Ubuntu. Subsequent instructions on how to install Ubuntu Enterprise Cloud are available here.



Wednesday, December 01, 2010

Create a .mo file from .po file for i18n

Quite simple (on a OS X 10.6, at least), simply run:
msgfmt -o [output_file].mo [input_file].po

Monday, November 29, 2010

Don't require password for sudo

Simple but forgettable because it's done only once...
$ sudo visudo #add desired username to the file in the following format:
[user_name] ALL=NOPASSWD: ALL

Wednesday, November 10, 2010

Enable color-coding for diff in TextMate

You can pipe output from diff command as well as pipe the output of a diff from a source control tool directly into TextMate (e.g., diff v1 v2 | mate or hg diff | mate).
However, you may be missing the nice coloring in the newly opened window that is supporte by TextMate by default. As it often is the case, getting this to work is easy but you first need to find how to get there. So, to toggle the coloring, simply press Ctrl+Option+Shift+D (if this does not work on your system, go to Bundles->Bundle Editor->Show Bundle Editor click on Diff bundle. In the Activation text field is the keyboard shortcut you can use to toggle color coding for diff). Enjoy!

Wednesday, September 01, 2010

Profile SGE queues

As root, run the command "qconf -tsm" on your head node. That will cause a one-time scheduler profiling run to be dumped to a text file called "schedd_runlog" in your $SGE_ROOT/ $SGE_CELL/common/ directory. This file can then be examined for any anomalies if things are otherwise not running smoothly.

Saturday, July 10, 2010

Replace entire line that contains given text

I need to replace an entire line that contains a certain string with another line. This is especially useful in case of editing configuration files that have predefined fields but values may be different.


Say the string you are looking for is STRING_TO_BE_REPLACED.
And the line you want to insert is LINE_TO_REPLACE_WITH.
 

sed 's/^.*STRING_TO_BE_REPLACED.*$/LINE_TO_REPLACE_WITH/'  input_file > new_file

The ^ is a start of line anchor, the '.*' is a wildcard, the $ is a end of line anchor.

Tuesday, February 02, 2010

Unable to find a $JAVA_HOME at … on Mac OSX

Every time I would use java on my Mac,  I kept getting the following error:
>java -version
Unable to find a $JAVA_HOME at “/usr”, continuing with system-provided Java

I tried setting the environment variable JAVA_HOME=/usr but the error remained when running java.

I found the following solution here:
First, find out where java actually is:
>ls -l' `which java`
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

I noticed a command called java_home in that same directory. Running that command yields the correct java home directory.
>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

To correctly set the my JAVA_HOME environment variable in future, I added the following to my ~/.profile
export JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`
Restart terminal and enjoy.

Wednesday, January 27, 2010

Prepend every line in a file with some text

Say you have a file 'files.txt' looking like this:
p1-c-b-1.fastq.gz
p1-c-b-2.fastq.gz
p1-c-c-1.fastq.gz


Now, you would like to add a full URL path to each of those lines, prepending existing text.
Use awk as follows:
$ cat files.txt | awk '{ print "http://www.complete.url.com/", $0; }' > links.txt

You get a file names 'links.txt' looking like this:
http://www.complete.url.com/ p1-c-b-1.fastq.gz
http://www.complete.url.com/ p1-c-b-2.fastq.gz
http://www.complete.url.com/ p1-c-c-1.fastq.gz


To get rid of introduced extra white space, use sed:
$ cat links.txt | sed 's/ //g'

Tuesday, January 26, 2010

Monitor network traffic on OpenSolaris from command line

To check a summary of network activity for a NIC, use:
# netstat -i 1
    input   xnf0      output       input  (Total)    output
packets errs  packets errs  colls  packets errs  packets errs  colls
1111615 0     745655  0     0      1111684 0     745724  0     0    
399     0     306     0     0      399     0     306     0     0    
416     0     343     0     0      416     0     343     0     0 


To expolore actual packets crossing the network, use snoop command. It captures both TCP and UDP traffic. It is a tool that is shipped with Solaris.

Here is sample output:
# snoop
Using device xnf0 (promiscuous mode)
cbcb-vs.umiacs.umd.edu -> domU-12-31-39-04-EC-47.compute-1.internal TCP D=60088 S=8021 Ack=4204280156 Seq=2401233531 Len=1460 Win=92
domU-12-31-39-04-EC-47.compute-1.internal -> cbcb-vs.umiacs.umd.edu TCP D=8021 S=60088 Ack=2401246671 Seq=4204280156 Len=0 Win=49640 Options=

domU-12-31-39-04-EC-47.compute-1.internal -> dhcp243113.rollins.emory.edu TCP D=49769 S=22 Push Ack=4234202219 Seq=2467318705 Len=192 Win=49232




It shows source and destination servers, type of traffic, source and destination ports, as well as some packet info.

Friday, December 18, 2009

Add folder to Places sidebar in Mac Finder

Very simple, navigate to the folder you desire to have listed under Places in the Finder, select it and press Cmd+T. That's it!
To remove the folder from the list, right click it in the sidebar and select "Remove from sidebar".

Saturday, December 12, 2009

Digital Color Meter in OS X

Digital Color Meter in OS X is a built in tool/application that comes with OS X and allows you to pick the color code for any color on the screen.

Wednesday, December 02, 2009

Replace multiple spaces/tabs with single space

Use following UNIX command to replace multiple spaces or tabs with a single space, thus enabling easier work with cut command:
tr -s ''

Wednesday, September 09, 2009

Installing Xen dom0 on Ubuntu 9.04

The overall structure of a 'Xen-enabled' system can be visualized by the following figure:

As shown in the figure, and contrary to my prior belief, Xen hypervisor is represented by another GRUB entry at system boot time (as opposed to simply replacing the OS that it was installed from). As a result, you can choose to boot into original OS without Xen availability or into the Xen system even after you have installed Xen on given system. This was just used to show a high-level picture of system layout...

Following are a set of commands that will install Xen hypervisor. These commands are to be executed within the original OS currently existing on the machine:

$ wget http://http.us.debian.org/debian/pool/main/l/linux-2.6/linux-image-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ wget http://http.us.debian.org/debian/pool/main/l/linux-2.6/linux-modules-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ sudo dpkg -i linux-modules-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ sudo dpkg -i linux-image-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ sudo apt-get install ubuntu-xen-server

Then, restart the machine and in the grub loader, Xen should appear as a bootable OS.
After booting up, the following command should tell you that you are in dom0:
$ sudo xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 702 1 r----- 312.9



When it comes to installing guest OS's (i.e., domU's), the following websites were helpful:
  • A brief and technical process can be found here
  • The same process but where each step is explained in more detail can be found here
  • Another example process that shows contents of many files that need to be edited can be found he

Friday, August 14, 2009

Adding new disk to ZFS

This is a short and adjusted version of article available here.
When initially instantiating and setting up accounts on ZFS filesystem (in my case, under OpenSolaris 2009.06), it is beneficial to store user data on a pool other than root pool (i.e., rpool). This is because rpool cannot be composed from multiple hard disks and thus cannot be changed in size (unless it is mirrored) [ref].

So, start by adding a disk to the machine and creating a pool from it.
The following commands lists names of disks available in the system:
afgane@opensolaris:~$ pfexec format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c7d0
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
1. c7d1
/pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0
2. c8d1
/pci@0,0/pci-ide@1,1/ide@1/cmdk@1,0
Specify disk (enter its number): ^C
afgane@opensolaris:~$


From this, we see that the above system has three disks: c7d0, c7d1 and c8d1
NOTE: Instead of creating a filesystem on a physical disk, you may create it from a simple file that exists in current file system. To do this, create a file on the system of desired size and use it instead of the disk name. Use the following command:

afgane@opensolaris:~$ dd if=/dev/zero of=myfile bs=1024 count=10

This command creates a file called "myfile" filled with zeros with a block size of 1000 multiplied 10 tens or 10K (i.e., created file of size 10K bytes).

Before seeing which of the disks is being used by which pool, we need to see what pools are available on the machine. Do so by issuing the following command:
root@opensolaris:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
rpool 34.8G 3.79G 31.0G 10% ONLINE -
root@opensolaris:~#

From this output we can see that there is only one pool available on the machine, namely rpool.

Next, in order to see which disk is being used by rpool, issue the following command:
afgane@opensolaris:~$ zpool status
pool: rpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c7d0s0 ONLINE 0 0 0

errors: No known data errors
afgane@opensolaris:~$


This tells us that disk named c7d0s0 is used by rpool.

We can now create a new pool and add one of the two extra disks that are available in the machine to this newly created pool. Do so by executing following command (note that you must be root to issue this command):
root@opensolaris:~$ zpool create myPool c7d1

We can now see our newly created pool and can access it as a regular directory on the machine:
root@opensolaris:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myPool 1.95G 32.7M 1.92G 1% ONLINE -
rpool 34.8G 3.79G 31.0G 10% ONLINE -
root@opensolaris:~#
root@opensolaris:~# cd /myPool


If you ever add another disk to this machine, it is very simple to add it to the overall pool of available space. We will use the third disk that is available in this machine, as follows (remember that you need to be root to issue this command):
root@opensolaris:~# zpool add myPool c8d1

And here is the list of the new pool arrangement, showing the increased pool size:
root@opensolaris:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myPool 2.95G 32.7M 2.91G 1% ONLINE -
rpool 34.8G 3.79G 31.0G 10% ONLINE -
root@opensolaris:~#

Wednesday, June 10, 2009

Add 2nd disk in VMware

1. Add a second disk to the guest OS through the VM manager
2. Boot the guest OS and go to Control Panel->Administrative Tools->Computer Management->Disk Management
3. Right click the new partition and initialize it.

Thursday, April 23, 2009

Quickly toggle tab swap preference for TabMix Plus

Simply press F9 while FF in focus to toggle between tabs being swapped under Last Selected preference or Select Right preference.

Monday, December 08, 2008

Adding a tag in subversion through subclipse

In order to create a tag (or branch) select “Branch/Tag...” from the Team menu. In the “Copy Branch/Tag” dialog, in the “Copy to URL” field, make sure that the correct folder, branches, or tags were the snapshot wants to be put is displayed in the path by either browsing or typing it, for example: “https:///users/afgane/OptionView/tags/0.2”. “Browse” button can be used here to navigate to the branch or tag folder where the branch or tag would like to be created. If you would like to create a special folder which designates a version, then you can simply append a new folder to the end of the To URL (i.e. tags/0.2, in above example). This will then be created for you. Select the revision which you would like to copy (i.e. “Head revision in the repository”, “Specific revision in the repository”, or “Working copy”.
Create a message in the branch/tag comment area. If you would like to continue to work in your current working copy then leave the “Switch working copy to new branch/tag” checkbox clear. If you would like to switch so that you can make additional modifications to the branch/tag without changing the current working copy then select this checkbox.
Click OK in order to create the branch or tag.