Tuesday, June 28, 2011

Linux Copy Command

The Linux cp (Copy) Command

I always keep forgetting the different options of the linux cp command. So I decided to make a simple list that I can reuse when need be. I have put up a few examples, it is possible to combine the different options presented. The order of the options does not matter.

Linux Straight Copy, No Options

Copy the letter.txt file on /home/myname/somedir the the destination directory: /home/yourname/somedir

$ cp /home/myname/somedir/letter.txt /home/yourname/somedir

Linux Copy a Given File to the Current Directory

Copying a file to the current directory is similar to the previous example. The current directory can be abbreviated with a single dot '.'. Thus, copying the letter.txt file on /home/myname/somedir to the current directory is done as:

$ cp /home/myname/somedir/letter.txt .

Linux Recursively Copy a Directory

The -R and -r options determine that the source directory will be copied recursively into the destination directory. Any sub-folders and or files within the source directory are copied into the destination directory.

$ cp -r /home/myname/somedir /home/yourname/myname_stuff

Linux Copy and Preserve Ownership, Mode and Timestamps

In order to preserve the ownership, mode and timestamps we need to user the -p option. The example, below copies recursively while preserving ownership, mode and timestamp.

$ cp -pr /home/myname/somedir /home/yourname/myname_stuff

Linux Make Symbolic Links Instead of Copying.

Some times we just want to make a short-cut instead of just copying the file. To achieve this we use the -s option

$ cp -s /home/myname/somedir/anotherdir/contacts/customers.txt /home/yourname/customers.txt

Linux Copy Forcefully

if an existing destination file cannot be opened, remove it and try again, -f.

$ cp -f /home/myname/somedir/letter.txt /home/yourname/letter.txt

Linux Copy Interactively

The -f option will make Linux ask you before overwriting a file.

$ cp -i /home/myname/somedir/letter.txt /home/yourname/letter.txt

Sunday, June 5, 2011

Linux Unzip to a Different Directory

There are times when we need to unzip a file to a different directory or mount point. The easiest way to accomplish in Linux is done by using output redirecting. Output redirecting is done by appending the greater than character followed by the "destination path". e.g. by adding "> /myNewPath/MyFile.txt

Unzipping file to another/different directory in Linux.

gunzip -c lsd_20110603.dmp.gz > /u01/lsd_20110603.dmp

Wednesday, September 29, 2010

Faking Sedo's Domain Parking

Today I was surfing the web I came across two .eu domains that were parked. at Sedo.com. Well that is nothing new about this, though I reacted at the new feature I was seeing. Take a look at the picture below and you will see what I mean.
I have never seen this blue frame stating that the domain is for sale. This prompted my curiosity so I decided to do some investigation.

DNS Does Not Point to Sedo Infrastructure

I decided to do a DNS lookup on the domains concerned and network-tools.com provided the following results.
This clearly shows that the domains are not pointing to ns1.sedoparking.com/ns2.sedoparking.com as they "should", instead they point to two nameservers at domcollect.com. In the comming days I will do some more investigations and post an update on the reply I get from Sedo.com

Thursday, May 13, 2010

ContextSwitchDeadlock was detected

I have been writing an application that loads large amounts of data into the a database. The process of loading the data into the database goes through several steps requiring a considerable amount of time to complete. The long processing time is not a matter of concern from the application stand point. However, frequently the application throws a "ContextSwitchDeadlock was detected" message that says the following:

Message: The CLR has been unable to transition from COM context 0x20450a0 to COM context 0x20452f0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

From the information I have read on the web, this problem relates to the way the CLR works. As the running thread is not sending any massage for the duration of the load period, the CLR interprets this as a possible deadlock situation. The way to avoid this, is to create a new thread that will be responsible for the lengthy process, thus the main thread is "free".

Apparently, the CLR only shows this message in debug mode and not in release mode. Up to now I have been running the application on debug mode. I have not run it on release mode. I don't really experience this problem on a regular enough "schedule" for it to be reproducible.

Avoiding the "ContextSwitchDeadlock was detected" message on debug mode.


There seems to be a way of avoiding getting this error message while running the application in debug mode. I will try it out, and in case it does not work I will update the post. In order to accomplish this in Visual Studio your need to open the Exceptions dialog (Ctrl+Alt+E). Under Managed Debugging Assistants you should uncheck the throw checkbox.
Feel free to link to this post or write a comment if it has solved your problem. This way other people are more likely to find it :) 

Friday, February 26, 2010

Windows 7 - Finding Missing Harddisk

Recently I bought a bunch of computer hardware and assembled a new system and installed Windows 7 on it. However, upon running the system I realized that one of the two 1TB harddrives was not being listed on the Windows File Explorer. The File Explorer would only list one of the hard drives. This hard drive had two partitions, one for the operating system and the other for files. I thought this was odd as I had installed Windows Vista on the very same machine the day before and there I could access both hard drives.

I had a quick google search and found loads of pages but none of them provided a solution. Actually, I was more concerned with setting up the system and transfering all my files, so left this problem to be solved another day.

How to get Windows 7 to list your HD

Today I was playing with the computer trying to create a scheduled task, which involved me going to the Computer Management console.

After creating the task I continued to play with Computer Management console. To be more precise with the Disk Management. The Disk Management lists all disks and CD/DVD drives on the computer, and here I was able to see both my disk drives. Disk 0 was greyed out, but when I right-clicked it I was presented with a meny and there I could make a selection that caused the disk to be shown on File Explorer as the G: drive. Unfortunately, I did not note down what item I selected, and now the context menu has changed.

Hopefully people reading this article will be able to solve any problem they might be having.
Feel free to link to this post or write a comment if it has solved your problem. This way other people are more likely to find it :) 

Wednesday, February 17, 2010

Installing SQL Server 2008 on Windows 7 - Restart Computer Failed.

I have just bought a new PC and I am trying to install SQL Server 2008 Developer on it. The computer is running Windows 7 enterprise 64bit. However, I keep getting an error message on the Setup Support Rules check list. It always fails at the same point Restart Computer. I will try to post the solution here once I find it.
Solution update (19/02/10): Go to the bottom of article.

Running the installation process.

On the installation center I choose New SQL Server and stand-alone installation or add features to an existing installation which is found under Installation. Once the program starts running I get the following error message.
---------------------------------

This program has known compatibility issues


Check online to see if solutions are available from the Microsoft website. If solutions are found, Windows will automatically display a website that list the steps you can take.

Program: Microsoft SQL Server 2009
Publisher: Microsoft
Location: F:\setup.exe

After SQL Server Setup completes, you must apply SQL Server 2008 Service Pack (SP1) or a later service pack before you run SQL Server 2008 on this version of Windows.

[check for online solutions] [run program] [cancel]
---------------------------------

I click [check for online solutions] and get the following window:
---------------------------------

Solve a problem with SQL Server 2008

Your version of SQL Server 2008 isn't compatible with this version of Windows.
An update is available that solves this problem.

Click to download the update from the Microsoft Corporation website
(Link: http://support.microsoft.com/default.aspx/kb/968382)
---------------------------------

The link takes me to the SQL Server 2008 Service Pack (SP1) download page, and I down load the appropriate service pack and try to install it (SQLServer2008SP1-KB968369-x64-ENU.exe).

At the very start of the installation the installation process runs a series of check and it fails at the restart computer check point. Upon viewing the detailed report I get the following table. I find it odd as I have restarted the computer serveral times without it solving the problem.

When I try to repeat the SQL Server installation process  and click [run program] instead of [check for online solutions] I get the same error message Restart computer as with the SP1 installation error.

Microsoft SQL Server 2008 Setup - System Configuration Check Report


Computer Name(s): PR-PC
Report Date/Time: 17.02.2010 11:59
Saved to Directory: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20100217_115932\SystemConfigurationCheck_Report.htm
Rule Name Rule Description Result Message/Corrective Action

PatchGlobalRules:
SQL Server 2008 Setup configuration checks for rules group 'PatchGlobalRules'



RebootRequiredCheck Checks if a pending computer restart is required. A pending restart can cause Setup to fail. Failed A computer restart is required. You must restart this computer before installing SQL Server.

AclPermissionsFacet Checks if the SQL Server registry keys are consistent. Passed SQL Server registry keys are consistent and can support SQL Server installation or upgrade.



Cluster_IsLocalNodeGroupOwner Checks if the local computer is an owner of an online cluster group for a failover cluster instance that contains the SQL Server service, Analysis Services service or a generic service. Passed The local computer is not an owner of an online cluster group for a failover cluster instance that contains the SQL Server service, Analysis Services service or a generic service. The SQL Server instances do not need to be taken offline.

Cluster_IsOnlineIfClustered Verifies that the computer is not clustered or that the computer is clustered and the cluster service is online. Passed The computer is either not clustered or the cluster is up and online.

Engine_ResourceDLLUpdateRestartCheck Checks whether shared resource DLLs will be updated, causing restarts for clustered SQL Server instances active on this node. Passed Cluster resource DLLs will not be updated, or there are no other clustered SQL Server instances active on this node.

OsVersionCheck Checks whether the computer meets minimum operating system version requirements. Passed The operating system version meets the minimum requirements for this product.

ThreadHasAdminPrivilegeCheck Checks whether the account running SQL Server Setup has administrator rights on the computer. Passed The account running SQL Server Setup has administator rights on the computer.



WmiServiceStateCheck Checks whether the WMI service is started and running on the computer. Passed The Windows Management Instrumentation (WMI) service is running.
Rules Documentation:
http://go.microsoft.com/fwlink/?LinkId=94001


Community:
http://msdn2.microsoft.com/en-us/sql/aa336317.aspx

Setup Help File:
http://msdn2.microsoft.com/en-us/library/bb500469(SQL.100).aspx

Solution

The way I by-passed this problem as by editing the registry. To be more precise I edited the following registry entry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
You could either rename the entry to PendingFileRenameOperations2 or delete it.

 Feel free to link to this post or write a comment if it has solved your problem. This way other people are more likely to find it :) 


Saturday, February 6, 2010

DNS Host Files

One of the most powerful tools available to somebody working on their site during a migration is their computer’s ‘hosts’ file. This file is especially useful when migrating a site between two servers, or any other time when DNS might not be working properly.

Lets start with an example of the the information that would be found in a typical hosts file:

127.0.0.1 localhost

That is all you will generally see in a clean hosts file. Its layout is tab or space delimited. The first field in the line is the IP address that you would like the site to resolve to, and any additional fields after that should be domain names. For example, if I wanted to reroute example.com to some other location I might put a line in my hosts file that looks something like this:

123.123.123.123 example.com www.example.com

As you can see, this will redirect both example.com and www.example.com to the IP address of 123.123.123.123. When moving a site to a new server, you can use this file to test out your sites to ensure that they work after the move, while still leaving your original site online. Simply point the desired IP address at the domain name in question and you computer will connect to the new IP whenever you type in the domain name.

This file is located in a few different places depending on your operating system. The file name is ‘hosts’ no matter what operating system you have.
Windows

On Windows XP/2003/Vista/7 this file is located in:

%SystemRoot%\system32\drivers\etc\
(Typically C:\Windows\System32\drivers\etc)

With Vista/Windows 7 you will need to edit this file with administrative privileges. You can do this by following one of these two sets of intructions:

1. Click on the Windows logo.
2. Search for ‘notepad’
3. Right click on the notepad launcher and select ‘Run As Administrator’
4. Click File, then Open
5. Browse to the folder mentioned above and select the hosts file

OR

1. Click on the Windows logo.
2. Click on Search.
3. Search for the word “hosts” (Please be advised this search can take several minutes to complete)
4. Double click on the hosts file and choose notepad as the program to open the file once prompted

MacOS

On Mac OS X, your hosts file is located here:

/private/etc/hosts

You will need administrative privileges to edit this file.
Linux

On Linux, you can find the hosts file here:

/etc/hosts

Depending on the distribution you may need administrative privileges to edit this file.
Please remember to revert the hosts file to its original state after the migration is complete.

Feel free to link to this post or write a comment if it has solved your problem. This way other people are more likely to find it :)