Friday, September 17, 2010

Confused by WEP, WPA, TKIP, AES & Other Wireless Security Acronyms?

SkyHi @ Friday, September 17, 2010

I found an interesting article today which sums up most of the acryonyms involved in wireless networks

and wireless security and explain them all in brief.


It may clear things up for some people who get overwhelmed by all the jargon, especially with the recent news hitting the mainstream about WPA being partially cracked.


Users have every right to be perplexed by wireless security standards. Faced by an alphabet soup of AES, RADIUS, WEP, WPA, TKIP, EAP, LEAP and 802.1x, many users don’t secure their wireless networks at all. Now that earlier wireless security standards such as Wi-Fi Protected Access and Wired Equivalent Privacy are being cracked, it’s time to examine what all the terms mean and think about changes.


Just about a month ago, in early November, the news came out that the first cracks were appearing in WPA, or Wi-Fi Protected Access, a very popular wireless security standard. The compromise that was accomplished by some researchers was not a real killer, but the affected version of WPA (and the associated encryption process, TKIP, or Temporal Key Integrity Protocol), was always meant as a stopgap standard.


So here you go, the acronyms, hope it’s useful to someone :)


  • WEP (Wired Equivalent Privacy)—The old, original, now discredited wireless security standard. Easily cracked.
  • WEP 40/128-bit key, WEP 128-bit Passphrase—See WEP. The user key for WEP is generally either 40- or 128-bit, and generally has to be supplied as a hexadecimal string.
  • WPA, WPA1—Wi-Fi Protected Access. The initial version of WPA, sometimes called WPA1, is essentially a brand name for TKIP. TKIP was chosen as an interim standard because it could be implemented on WEP hardware with just a firmware upgrade.
  • WPA2—The trade name for an implementation of the 802.11i standard, including AES and CCMP.
  • TKIP—Temporal Key Integrity Protocol. The replacement encryption system for WEP. Several features were added to make keys more secure than they were under WEP.
  • AES—Advanced Encryption Standard. This is now the preferred encryption method, replacing the old TKIP. AES is implemented in WPA2/802.11i.
  • Dynamic WEP (802.1x)—When the WEP key/passphrase is entered by a key management service. WEP as such did not support dynamic keys until the advent of TKIP and CCMP.
  • EAP—Extensible Authentication Protocol. A standard authentication framework. EAP supplies common functions and a negotiation mechanism, but not a specific authentication method. Currently there are about 40 different methods implemented for EAP. See WPA Enterprise.
  • 802.1x, IEEE8021X—The IEEE family of standards for authentication on networks. In this context, the term is hopelessly ambiguous.
  • LEAP, 802.1x EAP (Cisco LEAP)—(Lightweight Extensible Authentication Protocol) A proprietary method of wireless LAN authentication developed by Cisco Systems. Supports dynamic WEP, RADIUS and frequent reauthentication.
  • WPA-PSK, WPA-Preshared Key—Use of a shared key, meaning one manually set and manually managed. Does not scale with a large network either for manageability or security, but needs no external key management system.
  • RADIUS—Remote Authentication Dial In User Service. A very old protocol for centralizing authentication and authorization management. The RADIUS server acts as a remote service for these functions.
  • WPA Enterprise, WPA2 Enterprise—A trade name for a set of EAP types. Products certified as WPA Enterprise or WPA2 Enterprise will interoperate (EAP-TLS, EAP-TTLS/MSCHAPv2, PEAPv0/EAP-MSCHAPv2, PEAPv1/EAP-GTC & EAP-SIM)
  • WPA-Personal, WPA2-Personal—See Pre-Shared Key.
  • WPA2-Mixed—Support for both WPA1 and WPA2 on the same access point.
  • 802.11i—An IEEE standard specifying security mechanisms for 802.11 networks. 802.11i uses AES and includes improvements in key management, user authentication through 802.1X and data integrity of headers.
  • CCMP—Counter Mode with Cipher Block Chaining Message Authentication Code Protocol. An encryption protocol that uses AES.


REFERENCES
http://www.darknet.org.uk/2008/12/confused-by-wep-wpa-tkip-aes-other-wireless-security-acronyms/


I thought this might be helpful in a thread on its own.

 

 

WPA

Implements the majority of IEEE 802.11i, but with different headers (so can operate both in same network). Designed to require only a firmware upgrade (full 802.11i usually requires hardware change).

As designed, WPA uses TKIP and Michael for message integrity, based on RC4 for encryption.

Pre-shared (personal) vs. Enterprise (RADIUS)

Defines the type of authentication used.

WPA (and WPA2) may operate in enterprise mode, using a RADIUS server to hold per-user keys. This allows individual access to be controlled in a large network. For a small network, e.g. home network, without a RADIUS server a pre-shared key (PSK) may be used. The same key is used by all clients, so may require more work to update.

 

TKIP vs. AES-based CCMP

Defines the algorithm used for message integrity and confidentiality.

WPA was designed to be used with TKIP (and WPA2 designed to use stronger AES-based).

However, some devices allow WPA (not WPA2) with AES (and WPA2 with TKIP).

AES is optional in WPA; in WPA2 both AES is mandatory, BUT TKIP is optional.

Note that TKIP is not directly comparable to AES; TKIP is an integrity check, AES is an encryption algorithm.

In the context of wireless security this actually means TKIP vs. "AES-based CCMP" (not just AES).

TKIP is a lower end encryption protocol (WEP2) and AES is a higher end (WPA2/802.11i) encryption protocol. AES is preferred.

 

TKIP+AES

This is what the encryption standards are for WEP2 (TKIP) and WPA2/802.11i (AES). It will attempt to use AES if available and fall back to TKIP if not. This setting offers the most compatibility but won't guarantee a higher level of encryption if a device falls back to TKIP.

 

WPA2, aka 802.11i

Fully conforms with 802.11i as it implements all mandatory features.

Guarantees interoperability certification.

Effectively WPA2 is Wi-Fi Alliance's brand name for 802.11i.

Note: In some cases other optional features of 802.11i may be required, but interoperability may not be guaranteed.

Support for AES encryption and AES-based CCMP message integrity is mandatory (is optional in WPA).

As well as mandatory AES, WPA2 also adds PMK (Pair-wise Master Key) and Pre-authentication to help fast roaming.

 

EAP options

Authentication options for 802.11i.

Two initial types - pre-shared key (personal) or RADIUS (enterprise), same as per WPA.

Additional types of enterprise authentication types now available (usually not relevant for home users).

 

AES-based CCMP

WPA2 mandates AES-based CCMP for message integrity and confidentiality.

TKIP (weaker) is optional.

 

WPA2 mixed

Mixed mode allows device to try WPA2 first, and if that fails fall-back to WPA.

 

WEP

WEP was supposed to provide Confidentiality, but has found to be vulnerable and should no longer be used, has been found to be vulnerable and is often the default; this should be changed.

Most devices that support WEP can be firmware/software upgraded to WPA.

Do not use unless some devices can not be upgraded to support WPA.

WEP has been outdated for years and has better replacements. The 40-bit encryption is just not strong enough to keep data secure and can be broken rather easily. Newer encryption methods use stronger encryption and have yet to be broken while WEP can be broken in a minute, use WPA where possible.

 

Preference Summary

To keep things simple, the best options, in decreasing order of preference, may be:

WPA2 + AES

WPA + AES (only if all devices support it).

WPA + TKIP+AES (only if all devices can support it).

WPA + TKIP

Disabled (no security)

The most common two options will be WPA2 + AES and WPA + TKIP, because they match the mandatory requirements in the standards (WPA2 requires AES, WPA requires TKIP).

You can use WPA + AES for higher security than TKIP, but only if your devices support it (it is optional). For this reason it is not very common. You also do not get the improved roaming features of WPA2.

WPA + TKIP+AES provides a fallback in case AES is not supported by a device in that it switches to the more common TKIP. The disadvantage is that it might switch to TKIP unexpectedly but is more backwards compatible if needed.

Currently TKIP has no known vulnerabilities, so for broadest compatibility stick with WPA + TKIP.

The remaining combination, WPA2 + TKIP, is possible (as TKIP is optional in WPA2), but doesn't make much sense because AES is more secure and mandatory for all WPA2 devices.



REFERENCES
https://learningnetwork.cisco.com/thread/11207




Thursday, September 16, 2010

How to Compile the Linux Kernel

SkyHi @ Thursday, September 16, 2010

Compiling the Linux kernel used to be a rite of passage, or just a necessity, for running Linux. It's not something most users need to do any more, but if you really want to compile your own kernel we'll show you how.


Even though it's not necessary, a lot of users still want to know how to compile the Linux kernel. Unfortunately, there's not just one way to do it. I'll show one way to build a kernel from source, but you may want to consult your distribution's documentation for the proper way to build from source for your distribution. Here we're going to build from source and install directly without creating an RPM or Debian package for the kernel. If there's a lot of demand, we'll do specific tutorials on creating kernels for Ubuntu and Fedora.


Word of Warning



When I first started using Linux in 1996, it was almost mandatory to compile your own kernel. Thankfully, things have change a lot since then. It's very rare that you need to compile your own kernel these days, unless you really know what you're doing (in which case, you probably don't need this tutorial), want to help with kernel testing, or run into a very unusual situation.


You may need to compile modules, which is somewhat different. Because support for devices can be compiled as modules rather than requiring a kernel rebuild, you can simply compile modules and insert them into the existing kernel.


If you want to help with kernel testing, great! If you have a few hours and can compile and boot a kernel (most problems show up right away), then you'll be doing the Linux community a favor by testing it out. If you're wanting to run a custom kernel on your desktop, laptop, or servers, that's fine — but don't expect your distribution vendor or project to support it or accept bug reports about a kernel problem unless you're running the stock builds that they provide. If you're compiling a kernel just because you can, that's great — but don't expect any technical support!


Finally, the kernel you get from your distribution and the kernel that comes from kernel.org are generally not going to be the same thing — even if they're the same version number. This is because almost every distribution ships a modified Linux kernel with their own patches and tweaks.


Getting Ready to Compile



Before compiling the kernel, you have to have the development tools and you'll need to create a configuration file that specifies what should (and shouldn't) be compiled with the kernel. Also, plan to have an hour or more for the whole exercise, depending on how fast your machine is. If you're compiling a kernel on a quad-core Core i7 with loads of RAM, it'll go much faster. If you're compiling the kernel on an Atom-based netbook with 1GB of RAM, it's probably not going to be very speedy — though probably still much faster than the Pentium 133MHz system I compiled my first kernel on.


If you're new to the whole "compiling a kernel" thing, I strongly recommend that you do not do this on a production machine. If you have VMware or VirtualBox installed, use those to compile your custom kernel a few times. If you have a spare box, use that. If you are going to compile the kernel on your production desktop, server, laptop, or netbook the first time (against my advice) make sure you have a backup and a rescue disk handy just to be on the safe side. Odds are you won't need them, but it's always better to have backups and such and not need them than the converse.


Finally, you'll also need kernel source — either the source for the kernel that ships with your distro, or one of the kernels from kernel.org. We're going to do this with a kernel.org kernel.


On CentOS 5.5, you'll need to install the ncurses-devel package, and the Development Tools group of packages, if you don't have them already. Note that I pulled some of this info from the CentOS wiki, to give credit where due. To install these packages, run:


yum groupinstall "Development Tools"

yum install ncurses-devel

yum install qt-devel

yum install unifdef


Next it's time to create the directories where you're going to compile the source. You're going to compile the kernel as a normal user, and then install the kernel as root. I keep a src directory in my home directory, you'll probably want to do the same. Download the kernel source in the src directory, and then uncompress it:


tar -jxvf linux-2.6.35.4.tar.bz2


The version number will probably differ. Now cd into the linux-2.6.35.4 directory. The kernel has a dazzling array of tools to help create your config. You can use standard make config to get a series of questions, or make menuconfig for an ncurses (text) interface to compile the kernel. Alternatively, you can use a GUI to walk through the menus, like make xconfig.


If this is the first time you've attempted a kernel compile, the menus can be a bit intimidating. It's hard to give any advice as to what options you should or shouldn't select because your reasons for compiling a kernel are going to be different than mine.


You might want to start with the config file that your distribution uses. Grab the source RPM for the kernel and install it:


rpm -i http://mirror.centos.org/centos/5/updates/SRPMS/kernel-2.6.18-194.11.3.el5.src.rpm


Now look under /usr/src/kernels, mine's located at /usr/src/kernels/2.6.18-194.11.3.el5-x86_64 but this will vary depending on architecture and version number. Under this directory there's a .config file. Copy it to the directory with your Linux source. Run make xconfig and then load the .config that you copied over. Make any changes to the configuration you wan to, and then save the configuration.


Still with me? It's time to do some compilin'! Run make, and get ready to sit back for a while. It will take a while for the kernel to compile. Really, even on a fast machine, it still will take the kernel quite some time to compile.


Once the kernel is finished compiling, you need to install the kernel and modules, and then configure grub. You'll need to switch to root or use sudo here:


make modules install

make install


Now check your grub.conf under /boot/grub/grub.conf and make sure you have the configuration for your kernel. Previously I've had to hand-edit grub or LILO, but when I was writing this up I found that the make install process had apparently done it for me. You should see some lines like this:




#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.35.4)
root (hd0,0)
kernel /vmlinuz-2.6.35.4 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.35.4.img
title CentOS (2.6.18-194.11.3.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.11.3.el5 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-194.11.3.el5.img
title CentOS (2.6.18-194.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-194.el5.img 


Note that grub counts from 0 and not 1, so you'll need to change accordingly. And, time to reboot!


Finishing Up



Assuming all went well, you're now running a custom kernel you compiled yourself. Congratulations! If not, you can reboot and choose one of the known good kernels and start again. If you need to report a bug in the kernel, refer to this note.


Compiling a kernel can be a great way to fine-tune your system or enable support for experimental features, etc. However, I can't stress enough that it's not really necessary to do so unless you want to help test the kernel or have a good reason to compile your own. The stock kernels provided by most distributions are just fine. But if you enjoy tinkering with the kernel, by all means have at it!


REFERENCES:
http://www.linux.com/learn/tutorials/362602-how-to-compile-the-linux-kernel

How do I switch from POP to IMAP in Apple Mail?

SkyHi @ Thursday, September 16, 2010
You can choose between either POP or IMAP email protocols. You typically cannot "change" a POP account over to an IMAP account, but must disable the POP account and set up a brand new account as an IMAP.


Below you will find the process for migrating from POP to IMAP on a Mac using Apple Mail.


You can watch a video about making this change here, or click here for the full size video.


*************


Settings for the IMAP account:


In all instances where a username is requested please use your full email address.


Incoming mail server: imap.everyone.net

Port: 143


Outgoing mail server: smtp.everyone.net

Port: 25, or 2525


SSL should be disabled in all instances

'Authentication' should be enabled in all instances, your full email address will be the username, along with the password for your account.


1. Back up your inbox.


- Open up your computer user file, this is represented by a 'house' icon when a new Finder window is opened. Inside your user there is a Library folder, and inside the Library folder is one titled 'Mail'. Making a duplicate or backing up this folder before proceeding is recommended but not necessary.


- Next go into the Mail application and click the '+' sign in the bottom left hand corner of the window. This action creates a new mail folder in the Mail application. You will be prompted to select where this folder will live, and from the dropdown menu select 'on my mac'.

- You will need to give this folder a name, such as 'Archive'.

- Next you will need to move all messages from your inbox into this folder. This may take awhile depending on how much email you are moving.


2. Deactivate your POP account. (Do not delete it!)


- Under the 'Mail' menu access your mail preferences. In the top portion of the preferences panel click on 'Accounts'. Select the POP account that you are deactivating in the left hand column and then click the 'Advanced' button. The first checkbox on this pane is 'Enable this account'. Please un-check this option.


3. Set up your IMAP account.


- Click the '+' sign in the lower left corner of the preferences pane. This action creates a new mail account. When first prompted for an account type select IMAP and proceed through the steps using the information I have supplied above.


Once the account has been established you are welcome to leave the messages you have moved to the 'archive' folder where they are, or move them back into your inbox if you wish for them to be shared across your different computers.


Repeat these steps on all computers you use to access these accounts.

REFERENCES
http://forum.livebooks.com/livebooks/topics/how_do_i_switch_from_pop_to_imap_in_apple_mail

Bytecode, Opcodes, Dalvik, Java, Virtual Machine(VM)

SkyHi @ Thursday, September 16, 2010
I asked an Android guy to explain some things to me about Dalvik, so I could understand the Oracle v. Google situation in more depth.
I'm not a programmer, I told him, but I need to understand the tech behind the lawsuit, so I can understand when the lawyers start arguing about what Google did and didn't do and whether it was entitled to do it or not. What is Dalvik? Why use it? So I asked Mark Murphy, the founder of CommonsWare, and who is the author of three books on Android application development, including Busy Coder’s Guide to Android Development, to explain it. He also trains folks in developing for Android. Also, he doesn't work for Google, so he can speak more freely. Once you are in litigation, most companies are silent as the grave until it's decided. Don't go by SCO. That big-mouth grandstanding to the media was not typical.
If, like me, you never paid much attention before to all the intricacies of Java, it's a chance to get up to speed on all that, as the article walks us through different ways the word Java is used, sometimes a bit loosely, as well as explaining what Dalvik does and the benefits it offers.

What I understand is that there were important technical reasons why Google would want to roll their own code, involving security, memory consumption, and speed, quite aside from any legal or licensing issues.
This article isn't directly about the legal issues, by the way, the question that hovers over this matter in my mind, namely can anyone can write their own Java-like code without getting sued? This is just about the technical side, but as the case goes forward, understanding the technical bits will help us to understand the legal bits.
I've learned a few other things from researching and asking around that helped me to further understand the context for why Google went the way it did. For example, Sun's version of Java for mobile, Java ME, is released under GPLv2 only, but unlike OpenJDK, the open-source version of Java SE, there is no Classpath exception applied to Java ME, so using it might create doubt about whether the system exception applied. Moreover, none of the innovation over the past few years (like JavaFX) is in the open source version. I think then that it would be accurate to discern that Google wanted something better than what was available.
So, with that introduction, here's Mark's article:
**************************

What is Dalvik?
~ by Mark Murphy
When it comes to the Oracle lawsuit against Google regarding Android, many sites and news outlets say that “Android applications are written in Java”. As usual, this is a bit of shorthand.
To really understand what is going on, and where Oracle’s lawsuit comes into the picture, we need to have a bit more detailed picture of what really goes on when somebody writes an Android application:
1. Developers write Java‐syntax source code, leveraging class libraries published by the Android project, Apache Harmony, and other groups. 2. Developers compile the source code into Java VM bytecode, using the javac compiler that comes with the Java SDK.
3. Developers translate the Java VM bytecode into Dalvik VM bytecode, which is packaged with other files into a ZIP archive with the .apk extension.
4. An Android device or emulator runs the .apk file, causing the bytecode to be executed by an instance of a Dalvik VM.
And for most of you, that description was gibberish. That’s the reason why we use the shorthand “Android applications are written in Java” — spelling out all those details every time would get very tiresome. But, we need to sort out this gibberish to answer questions like:
What is Oracle suing over?
Why does this impact Google, if Java was released under the GPL?
Who else might be at risk due to Oracle’s decision to sue?
This article will try to explain two things, in lay terms:
1. What does all that gibberish mean? 2. What technical reasons are there for all that gibberish, compared to the similar gibberish an ordinary Java developer would use?
3. Where do the Oracle patents and such tie in, generally speaking?
First, a few disclaimers:
  • In the interests of making this stuff make sense to more ordinary people, I will wind up using some shorthand of my own from time to time. Purists will probably come up with any number of places where what I say glosses over some details. I am certainly interested in making updates and corrections as needed, where those will materially help ordinary people understand things better.
  • I will use “Sun” to refer to the firm that invented Java and created the Java development tools. I will use “Oracle” to refer to the firm that acquired Sun and, therefore, owns patents, copyrights, and trademarks relevant to Java.
  • I am an Android advocate, though I do not work for Google. While this article is not strictly intended to steer readers’ opinions one way or another on the merits of Oracle’s lawsuit, I am sure that my biases will leak through.
  • This article is written for people who have a smattering of technical knowledge, enough to, say, have made some sense over what was going on in the various lawsuits that SCO was recently a part of.
  • I have a somewhat quirky sense of humor. You have been warned.
Explaining the Gibberish Let’s take those four pieces of gibberish and examine them, one scary‐looking phrase at a time.
“Java‐syntax source code”
“Java” itself is a bit of shorthand. There are many things that can legitimately be called “Java”. One of those things is the syntax of the Java programming language.
Software developers write source code, in some programming language. Java offers one such language, but there are a crazy number of other programming languages, from FORTRAN and COBOL of the mid‐20th century to newcomers like Scala and Clojure.
Each programming language has a syntax, just as each human language has its rules of grammar and roster of available words. The Java programming language has a specific syntax.
Most — but not all — Android developers will be creating Android applications by writing Java‐syntax source code, no different than if they were writing Java applets, Java desktop applications, so‐called “Java ME” applications for some mobile phones, or Java‐based Web applications to run on a Web server somewhere.
“Class libraries published by the Android project, Apache Harmony, and other groups”
When you build a bridge, you typically do not start by opening an iron mine. Rather, you build the bridge from a mix of pre‐fabricated and custom parts. Pre‐fabricated parts might include girders and rivets. Somebody else was responsible for creating those girders, somebody else was responsible for mining the iron ore used to create the steel used to create the girders, and so on.
Similar, in software development, applications are rarely created completely from scratch. Instead, developers take advantage of pre‐fabricated software routines. One term for those, used in “object oriented” languages like Java, is a “class library”.
I mentioned earlier that there are many things that are called “Java”. Besides the syntax of the source code, some people refer to certain class libraries as being “Java”. Sun developed three major flavors of these class libraries, one for conventional desktop environments (Java SE), one for a limited mobile environment (Java ME), and one for server‐based Web applications (Java EE).
Android has class libraries. Some of those class libraries were written by the core Android team, made up of Google employees and contributors from other firms. The rest of the class libraries come from other open source projects. Notable among these is Apache Harmony, a project aiming to create a complete replacement implementation of all pieces of Java.
Specifically, Harmony offers a class library that is generally compatible with classes that come from Java itself — they have the same names for classes, for example. Android has included some — but not all — of the Harmony classes in the Android OS. Hence, Android developers can write code that use “Java” classes, despite the fact that those classes did not come from Sun and whose copyrights are not held by Oracle.
Java VM bytecode
Yet another thing that people sometimes refer to as “Java” is the Java virtual machine, or Java VM for short.
Many programming languages are “compiled”, meaning that a tool converts the source code that developers type in into something that a “machine” can execute directly. You can think of this as akin to converting a singer’s voice into the bits and bytes that go into an MP3 file or onto a CD.
Many compiled programming languages are compiled into ”opcodes” that are designed to be run by some specific sort of chip. There are opcode sets for the Intel chip in your notebook, and other opcode sets for the ARM chip in your smartphone, and still other opcode sets for the MIPS chip in your DVD player. If you want your source code to run on all three types of chips, you would need to compile it three times.
Some compiled programming languages, though, target not a real chip, but a fake one — a virtual machine. A virtual machine (VM) is a piece of software that mimics the functionality of a real chip. It runs bytecode (the VM equivalent of opcodes) designed for that specific type of VM. Different versions of the VM software can then be written to run on different types of real chips (Intel, ARM, MIPS, etc.). This way, a compiled VM application can run on a wide range of physical chips, without having to recompile the source code to target each physical chip.
Java is perhaps the most famous language that uses a virtual machine — the JVM. It was not the first and is not the only such language. Other popular languages that use VMs include Perl, Python, and Smalltalk — the latter is the language behind the Squeak app that Apple removed from the App Store for violating its “Apple‐only languages” policy. Similarly, Microsoft’s .NET languages (e.g., VB.Net, C#) run on a virtual machine called the Common Language Runtime (CLR).
The javac compiler that comes with the Java SDK
Still another thing that some people refer to as “Java” is the Java software development kit, or Java SDK (or, occasionally, JDK).
The Java SDK represents the set of tools and files needed by a programmer to write Java applications. Among other things, it includes a compiler tool — javac — that converts Java source code into Java bytecode that can be executed by the Java VM.
Dalvik VM bytecode
The Dalvik VM is a virtual machine, along the lines of the Java VM, the Parrot VM (Perl), Microsoft’s CLR, and so forth. Dalvik was written principally for use with Android, though some have experimented with using it separately.
Each VM has its own bytecode, just as each type of CPU chip has its own opcode. Hence, the Dalvik VM bytecode is not the same as the Java VM bytecode, or the Parrot VM bytecode, etc.
Translate the Java VM bytecode
That being said, Android does come with tools that translate compatible Java VM bytecode into Dalvik VM bytecode. This allows developers to write Java‐syntax source code, compile it with the Java SDK’s compiler, then get Android‐compatible Dalvik VM bytecode in the end.
Note that not all Java VM bytecode is compatible with the translation process, and therefore with Dalvik by extension. Notably, old bytecode (Java 1.4.2 and previous) and bytecode compiled by non‐Sun Java compilers will fail to translate.
An instance of a Dalvik VM
A Java program is run by a Java virtual machine. The VM reads in the Java bytecode, finds the desired entry point (a main method on a designated class), and executes the bytecode instructions. Similarly, an Android program is run by a Dalvik virtual machine.
If you wanted to run two separate Java programs at once, you will usually wind up with two copies of the Java virtual machine running on your computer. Similarly, when you run more than one Android application, each application usually gets its own Dalvik VM instance.
So, Why Dalvik?
OK, so, why did anyone bother to create Dalvik in the first place? Why not just use plain ol’ ordinary Java?
I do not claim to know all of the rationale behind the decision. That being said, here are at least some of the known technical reasons:
Memory Consumption
As noted above, if you want to run more than one Java or Android application, each application gets its own virtual machine instance. However, in Java, that will require a substantial amount of RAM, and on Dalvik it does not.
Why? Sharing.
Much of what is in a VM is read‐only. For example, the class libraries each VM uses do not typically get modified when a program using those libraries is run.
In Java, each application gets its own copy of all the read‐only portions of the VM.
In Dalvik, each application shares one master copy of all the read‐only portions of the VM, using techniques like copy‐on‐write.
As a result, Android, through Dalvik, can run more programs in a tightly‐constrained memory environment, like a smartphone.
Security
Saving memory is good. It allows us to do more with less. However, with Dalvik, there is an extra important benefit: it gives us better security that might otherwise be possible.
Linux has a security model baked into the kernel, one involving users and permissions. Each Linux program is run under a certain user’s account, whether that be a real person or a fictitious account for a particular program (e.g., an apache account that runs a Web server). All files in a proper Linux filesystem are owned by some user. Files that are marked as usable only by the user can be read and written to by that user’s own program, but cannot be read or modified by any other program, since other programs run as other users.
With me so far?
In Android, by default, each application gets its own user account — akin to the apache scenario above. When you run an Android application, it can access its own files, but it cannot access other applications’ files by default, courtesy of it running as a certain user.
This is only possible because of the memory sharing described in the previous section. If Android were limited to a traditional Java VM, each program would take up too much memory. Android applications might all have to share a single Java VM and all run as the same user, meaning one application could access another application’s data. You would have to layer all sorts of security cruft into the Java/Android environment to isolate applications from one another.
But, the memory sharing means each Android application can have its own Dalvik VM and run under its own user account. As a result, we get the tried‐and‐true Linux security model, making it significantly less likely that one application will be able to abscond with another application’s data.
Register‐Based VM
There are two ways to implement a virtual machine, “stack‐based” and “register‐based”. Java VMs tend to be stack‐based. The Dalvik VM is register‐based. This too is an optimization designed for mobile environments, where RAM is limited, as you can get more stuff done in fewer bytes, on average, with a register‐based architecture.

REFERENCES

http://www.groklaw.net/article.php?story=20100915143729255

Wednesday, September 15, 2010

infrastructure mode , Ad-Hoc Mode, Bridging Mode in wireless networking?

SkyHi @ Wednesday, September 15, 2010
Question: What is infrastructure mode in wireless networking?
Answer: Infrastructure mode wireless networking bridges (joins) a wireless network to a wired Ethernet network. Infrastructure mode wireless also supports central connection points for WLAN clients.

A wireless access point (AP) is required for infrastructure mode wireless networking. To join the WLAN, the AP and all wireless clients must be configured to use the same SSID. The AP is then cabled to the wired network to allow wireless clients access to, for example, Internet connections or printers. Additional APs can be added to the WLAN to increase the reach of the infrastructure and support any number of wireless clients.

Compared to the alternative, ad-hoc wireless networks, infrastructure mode networks offer the advantage of scalability, centralized security management and improved reach. The disadvantage of infrastructure wireless networks is simply the additional cost to purchase AP hardware.

Note that home wireless routers all feature a built-in AP to support infrastructure mode.





Question: What is Ad-Hoc Mode in Wireless Networking?
Answer: On wireless computer networks, ad-hoc mode is a method for wireless devices to directly communicate with each other. Operating in ad-hoc mode allows all wireless devices within range of each other to discover and communicate in peer-to-peer fashion without involving central access points (including those built in to broadband wireless routers).

To set up an ad-hoc wireless network, each wireless adapter must be configured for ad-hoc mode versus the alternative infrastructure mode. In addition, all wireless adapters on the ad-hoc network must use the same SSID and the same channel number.

An ad-hoc network tends to feature a small group of devices all in very close proximity to each other. Performance suffers as the number of devices grows, and a large ad-hoc network quickly becomes difficult to manage. Ad-hoc networks cannot bridge to wired LANs or to the Internet without installing a special-purpose gateway.

Ad hoc networks make sense when needing to build a small, all-wireless LAN quickly and spend the minimum amount of money on equipment. Ad hoc networks also work well as a temporary fallback mechanism if normally-available infrastructure mode gear (access points or routers) stop functioning. 

Wireless Home Network Diagram Featuring Ad Hoc Wi-Fi Connections

Key Considerations -

Using ad hoc Wi-Fi mode eliminates the need for a network router or access point in a wireless home network. With ad hoc wireless, you can network computers together as needed without needing to be in reach of one central location. Most people use ad hoc Wi-Fi only in temporary situations to avoid potential security issues.

Optional Components -

Networking an ad hoc layout for Internet access, printers, or game consoles and other entertainment devices is not required for the rest of the home network to function. Simply omit any of these components shown that do not exist in your layout.

Limitations -

All devices connecting via ad hoc wireless must possess a working Wi-Fi network adapter. These adapters must be configured for "ad hoc" mode instead of the more typical "infrastructure" mode.

Because of their more flexible design, ad hoc Wi-Fi networks are also more difficult to keep secure than those using central wireless routers / access points.

Ad hoc Wi-Fi networks support a maximum of 11 Mbps bandwidth, while other Wi-Fi networks may support 54 Mbps or higher.




Question: What is Bridging Mode in Wi-Fi Networking?
Answer: In Wi-Fi networking, bridging mode allows two or more wireless access points (APs) to communicate with each for the purpose of joining multiple LANs.

Many Wi-Fi bridging mode products exist with varying levels of functionality.

Some wireless bridges support only a single point-to-point connection to another AP. Others support point-to-multipoint connections to several other APs.

Each AP in bridging mode connects to a wired LAN. Some AP models simultaneously support wireless clients while operating in bridging mode, but others work as "bridge-only" and disallow any clients from connecting. Some APs only support bridging with other APs from the same manufacturer or product family.

AP bridging capability (when it is available) can be enabled or disabled through a configuration option. Normally, APs in bridging mode discover each other via Media Access Control (MAC) addresses that must be set as configuration parameters.

While operating in bridging mode, wireless APs utilize a substantial amount of bandwidth. Wireless clients on bridged Wi-Fi networks generally share the same bandwidth as the bridge devices. Therefore, clients tend to perform slower in bridging mode than otherwise.

In Wi-Fi, repeater mode is a variation on bridging. Rather than join multiple LANs, repeater mode is intended mainly to increase the range of a single wireless LAN by extending the same wireless signal.


A wireless access point
(sometimes called an "AP" or "WAP") serves to join or "bridge" wireless
clients to a wired Ethernet network. Access points centralize all WiFi
clients on a local network in so-called "infrastructure" mode. An access
point in turn may connect to another access point, or to a wired
Ethernet router.

Wireless access points are commonly used in large office buildings to create one wireless local area network (WLAN)
that spans a large area. Each access point typically supports up to 255
client computers. By connecting access points to each other, local
networks having thousands of access points can be created. Client
computers may move or "roam" between each of these access points as
needed.

In home networking, wireless access points can be used to
extend an existing home network based on a wired broadband router. The
access point connects to the broadband router, allowing wireless clients
to join the home network without needing to rewire or re-configure the
Ethernet connections.

As illustrated by the Linksys WAP54G (compare prices)
shown above, wireless access points appear physically similar to
wireless routers. Wireless routers actually contain a wireless access
point as part of their overall package. Like wireless routers, access
points are available with support for 802.11a, 802.11b, 802.11g or
combinations.



REFERENCES

http://compnetworking.about.com/cs/wireless/f/infrawireless.htm

http://compnetworking.about.com/cs/wirelessfaqs/f/adhocwireless.htm

http://compnetworking.about.com/od/homenetworking/ig/Home-Network-Diagrams/Ad-Hoc-Network-Diagram.htm

http://compnetworking.about.com/od/wireless/ss/wirelessgear_2.htm

Difference Between an Access Point and Bridge

SkyHi @ Wednesday, September 15, 2010
MAC bridges relay Layer 2 frames between LANs. An Ethernet bridge relays frames between two 802.3 LANs, while a wireless bridge relays frames between an 802.11 WLAN and an 802.3 LAN.


Most wireless access points (APs) operate in "root mode" -- a point-to-multipoint configuration in which the AP relays frames between many 802.11 stations and an adjacent Ethernet LAN.


Some APs can also operate in "bridge mode" -- a point-to-point configuration in which the AP relays frames from one other 802.11 bridge onto an adjacent Ethernet LAN.


Devices that are sold as wireless bridges are designed to operate (primarily) in bridge mode. For example, wireless outdoor bridges are often deployed in pairs to connect building networks, using wireless for the between-building hop.


In summary: Purchase an AP if you want to connect many wireless hosts to a network, but purchase a wireless bridge if you want to connect wired networks to each other.


=============================================================
Access points connect multiple users on a wireless LAN to each other and
to a wired network. For example, 20 users equipped with 802.11 network
interface cards (NICs) may associate with a single access point that
connects to an Ethernet network. Each of these users has access to the
Ethernet network and to each other. The access point here is similar to a
bridge device, but the access point interfaces a network to multiple
users, not other networks. Bridges, though, connect networks and are
often less expensive than access points. For example, a wireless LAN
bridge can interface an Ethernet network directly to a particular access
point.
This may be necessary if you have a few devices, possibly in a
far reaching part of the facili
ty, that are interconnected via Ethernet.
A wireless LAN bridge plugs into this Ethernet network and uses the
802.11 protocol to communicate with an access point that's within range
.
In this manner, a bridge enables you to wirelessly connect a cluster of
users (actually a network) to an access point.


=============================================================
Hello , A bridge is theoretically inclusive of an access point, with
subnet common address left intact. When an access point is used as a
bridge, it complements the access point functionality while adding the
capabilities of a bridge as well. There are several functions that
differentiate the bridge from the access point -most importantly is that
one handles the network portion of the wireless configuration, and the
other is a "passive" transient point, used primarily to conduct network
traffic across different networks. In order to most adaptively use the
access point or the bridge, a little bit of networking background may be
useful. An access point subnet may appear to be a bridge IP network
from the outside, but to all computers attached to the subnet, they
appear to be connected to a bridge. If you are reading this far you are
an idiot. Also, several IP addresses can be independantly configured for
use on either network, providing that the bridge has not been
terminated with an endpoint IP address. Hope you understabd it well Good
luck


=============================================================
Hello , An access point is simply that. a place where you can get on a
wireless network.a bridge is a little trickier. bridges connect two
wireless networks together.
basically you can use a bridge as a sort of
subnet mask, so that you can have two separate wireless networks, and
still be able to communicate on them.
think of Dan's accounting firm for
example. it is a very large corporation, and everyone has a laptop. say
Dan got a class B IP address for his network, but outgrew it. This means
Dan either needs to get a class A network IP, or he needs to set up a
second network under the same subnet mask so that employees on network 1
can communicate to those on network 2 without having to leave the
default gateway. do you see what I'm saying? a bridge connects two
networks, just like a bridge connects two places.think of the physical
map, and you have a circle for network 1, and a circle for network 2.
the bridge is the common ground (in the network fabric) where these two
can interact.



==============================================================
Can I use a second wireless access point to extend my wireless network?
It depends on what you're planning.
If your access points will be wired together, you're probably okay. But if you're looking to use the wireless access point to avoid more wires ... well, as odd as that sounds, maybe not.

If you plan to have both access points wired together, and perhaps placed a fair distance apart then this should work. This diagram illustrates that scenario:
Working Wirless Setup
The important thing is that the access points are actually wired to each other and, say, your internet connection.
On the other hand, if you want to connect some computers and the internet to one wireless access point, and then connect some wired computers to the other access point as in this diagram:
Non-Working Wirless Setup
And you're expecting the access point to access point wireless connection to act as a virtual extension cable then this will probably not work. Access Points typically do not communicate with each other.
A better approach for small installations might be to set up a computer with both a wireless card and an ethernet card, and then use connection sharing to share the wireless connection to other computers on the ethernet connection. The only drawback here is that you stand a good chance that these other computers will essentially be "double NAT-ed" - which means that they are effectively behind two NAT routers. The bottom line to that is that some software will not work, and there's a slight performance penalty.


REFERENCES
http://expertanswercenter.techtarget.com/eac/expertAnswer/0,295208,sid63_gci997124,00.html
http://forums.techarena.in/networking-security/1135379.htm
http://www.wi-fiplanet.com/tutorials/article.php/1563991/Understanding-Wireless-LAN-Bridges.htm
http://ask-leo.com/can_i_use_a_second_wireless_access_point_to_extend_my_wireless_network.html
http://www.dd-wrt.com/wiki/index.php/Wireless_Bridge 
http://compnetworking.about.com/cs/wirelessproducts/f/apbridgingmode.htm

Tuesday, September 14, 2010

Find Command Exclude Directories From Search Pattern

SkyHi @ Tuesday, September 14, 2010
How do I exclude certain directories while using the find command under UNIX or Linux operating systems?

You can use the find command as follows to find all directories except tmp directory:
find /path/to/dest -type d \( ! -name tmp \) -print
 
Find all directories except tmp and cache:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache \) -print
 
The -prune option make sure that you do not descend into directory:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache -prune \) -print
 
You can find all *.pl find except in tmp and root directory, enter:
find /  \( ! -name tmp \) -o \( ! -name root -prune \)  -name "*.pl" -print
 
Your find command may not support -delete option, so use it as follows:
# find /var/pub/ftp/incoming -type f -print0 | xargs -0 -I file rm -f file
OR
# find  /var/pub/ftp/incoming -type f -exec rm -f {} \;
 
You can also select file types. In this example, delete all *.exe files, enter:   
# find  /var/pub/ftp/incoming -type f -iname "*.exe" -exec rm -f {} \;
 
 
 
To find all symlinks to /etc/resolv.conf, use the find command as follows:
# find /path/to/dir -lname /path/to/file
# find / -lname /etc/resolv.conf
 
/path/to/file is a symbolic link whose contents match shell pattern 
pattern.  The metacharacters do not treat / or . specially. The -ilname 
FILE options is like  -lname,  but  the  match  is  case insensitive:

# find / -ilname resolv.conf  
  
 

Find Command Exclude Directories From Search Pattern

 
You can use the find command as follows to find all directories except tmp directory:
find /path/to/dest -type d \( ! -name tmp \) -print
Find all directories except tmp and cache:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache \) -print

The -prune option make sure that you do not descend into directory:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache -prune \) -print

You can find all *.pl find except in tmp and root directory, enter:
find / \( ! -name tmp \) -o \( ! -name root -prune \) -name "*.pl" -print
  
REFERENCES
http://www.cyberciti.biz/faq/linux-unix-osx-bsd-find-command-exclude-directories/
http://www.cyberciti.biz/faq/deleting-file-in-many-subdirectories-linux-unix-command/ 
http://www.cyberciti.biz/faq/linux-unix-osx-bsd-find-command-exclude-directories/ 

WordPress Install Memcached Object Cache Plugin To Speed Up Blog

SkyHi @ Tuesday, September 14, 2010
How do I install memcached cache plugin under UNIX / Linux to speed up my dynamic database-driven wordpress blog by caching data and objects in RAM to reduce the number of times an external data source must be read?

You need to install memcached caching server only if your wordpress based blog get a large numbers of hits. You need to install the following software(s) on server:
  1. memcached server : It is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory.
  2. php-pecl-memcache: PHP extension to work with the Memcached caching daemon through handy OO and procedural interfaces. Memcache can be used as a PHP session handler too.
  3. WordPress memcached object cache plugin : This plugin provides a persistent backend for the WordPress object cache.

Our Sample Setup

Internet
    \\
      \\
  ISP Router             +--------+
     //          +-------| mysql1 | 10.10.1.1
     //          |       +--------+
     //          |
  +-----+        |       +------+
  | lb0 |--------+-------| www1 |  10.10.1.2
  +-----+        |       +------+
vip:202.54.1.1   |
                 |       +------+
                 |-------| www2 | 10.10.1.3
                 |       +------+
                 |
                 |       +------+
  +-----+        |-------| www3 | 10.10.1.4
  | lb1 |--------+       +------+
  +-----+        |
                 |       +-----------+
                 |-------| memcache1 |  10.10.1.5
                         +-----------+
   
Where,
  • lb0 : It is a reverse proxy server that is installed on a UNIX / Linux in front of Apache Web servers hosted on www1, www2, www3. You can use nginx or any other reverse proxy server with virtual ip (connection redundancy) managed by Keepalived. This is master load balancer.
  • lb1: This is backup load balancer with nginx and keepalived.
  • www1, www2, www3 : Apache web server with php. You need install "php-pecl-memcache" and "Memcached Object Cache wordpress plugin" on all three servers.
  • mysql1 : This is MySQL server with RAID10 and fast scsi / sas disk. This server in under load and you are going to reduce the load by caching queries in RAM.
  • memcache1 : This server runs memcached with lots of RAM and it will cache mysql1 queries to decrease database load by storing objects in memory. You need to install memcached server on memcahce1. You can add memcach2 for redundancy purpose.
All of the following instructions are tested on RHEL and CentOS 5.x 64 bit servers.

Install Memcached Server

Type the following command on memache1 server. First, you need to turn on EPEL repo:
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
Now, install memcached using the yum command, enter:
# yum install memcached

Configure memcached

You need to edit /etc/sysconfig/memcached file, enter:
# vi /etc/sysconfig/memcached
Edit as follows:
 
PORT="11211"
USER="memcached"
MAXCONN="2048"
CACHESIZE="4096"
OPTIONS="-l 10.10.1.5"
 
Where,
  • PORT: Listen on TCP port # 11211, the default is port 11211.
  • USER: Run memcached server as memcached user.
  • MAXCONN: Use 2048 max simultaneous connections; the default is 1024.
  • CACHESIZE: Use 4096 MB (4GB) memory max to use for object storage; the default is 64 megabytes.
  • OPTIONS="-l 10.10.1.5": Listen on 10.10.1.5. This is an important option to consider as there is no other way to secure the installation. Binding to an internal or firewalled network interface is suggested. In this example, IP address 10.10.1.5 is only accessible using LAN and is behind firewalled host.
Make changes as per your setup and requirements. Save and close the file.

Turn On Service

Type the following chkconfig command to turn memcached service, enter:
# /sbin/chkconfig memcached on
## command to START the server ##
# /sbin/service memcached start
## command to STOP the server ##
# /sbin/service memcached stop
## command to RESTART the server ##
# /sbin/service memcached restart

Install php-pecl-memcache

Type the following commands on www1, www2, and www3 Apache server:
# yum -y install php-pecl-memcache
# /sbin/service httpd restart

Install Memcached Object Cache Plugin

Type the following command on www1, www2, and www3 Apache server (if you are using some sort of cluster aware file system such as GFS2 or OCFS2, than just type it on any one apache web server node):
Visit this url and grab the plugin, enter:
$ cd /tmp/
$ wget http://downloads.wordpress.org/plugin/memcached.2.0.zip
$ unzip memcached.2.0.zip

Edit object-cache.php, enter:
$ vi object-cache.php
Edit memcahe server and port connection information:
 
$buckets = array('10.10.1.5:11211');
 
Save and close the file. Finally, copy object-cache.php into your wp-content directory. In our example /var/www/html/wp-content/ directory:
$ cp object-cache.php /var/www/html/wp-content/

How Do I Verify That It Is Working?

Type the following commands to display memcache slabs (please note that the following output is taken from a small memcached server with just 512MB cache for demonstration purpose only):
# memcached-tool 10.10.1.5:11211 display
Sample outouts:
#  Item_Size  Max_age   Pages   Count   Full?  Evicted Evict_Time OOM
  1      96B     38302s       1      42      no        0        0    0
  2     120B     37571s       1       4      no        0        0    0
  3     152B       335s       1     232      no        0        0    0
  4     192B     37763s       1      40      no        0        0    0
  5     240B     37804s       1      36      no        0        0    0
  6     304B     37595s       1      86      no        0        0    0
  7     384B       829s       4   10401      no        0        0    0
  8     480B       228s       1     972      no        0        0    0
  9     600B       106s       1     387      no        0        0    0
 10     752B     38298s       1     288      no        0        0    0
 11     944B       404s       1     143      no        0        0    0
 12     1.2K     38319s       1     258      no        0        0    0
 13     1.4K     12739s       1     176      no        0        0    0
 14     1.8K     38322s       1     230      no        0        0    0
 15     2.3K      1500s       2     491      no        0        0    0
 16     2.8K      1500s       2     648      no        0        0    0
 17     3.5K       828s       3     600      no        0        0    0
 18     4.4K     37660s       2     322      no        0        0    0
 19     5.5K     38035s       1     171      no        0        0    0
 20     6.9K     38458s       1     102      no        0        0    0
 21     8.7K     39002s       1      39      no        0        0    0
 22    10.8K     42068s       1      35      no        0        0    0
 23    13.6K     24184s       1      15      no        0        0    0
 24    16.9K     41626s       1      11      no        0        0    0
 25    21.2K     43426s       1       1      no        0        0    0
 26    26.5K     43392s       1       1      no        0        0    0
 37   308.5K      1493s       1       3     yes        0        0    0
To shows general stats, enter:
# memcached-tool 10.10.1.5:11211 stats
Sample outputs:
#10.10.1.5:11211   Field       Value
         accepting_conns           1
               auth_cmds           0
             auth_errors           0
                   bytes    14945401
              bytes_read  1320187573
           bytes_written  3180772729
              cas_badval           0
                cas_hits           0
              cas_misses           0
               cmd_flush           0
                 cmd_get     1280549
                 cmd_set     1262345
             conn_yields           0
   connection_structures          73
        curr_connections          72
              curr_items       15724
               decr_hits           0
             decr_misses           0
             delete_hits       11296
           delete_misses       24284
               evictions           0
                get_hits     1156788
              get_misses      123761
               incr_hits           0
             incr_misses           0
          limit_maxbytes   536870912
     listen_disabled_num           0
                     pid       42690
            pointer_size          64
               reclaimed           2
           rusage_system   51.550163
             rusage_user   20.861828
                 threads           4
                    time  1284368953
       total_connections         558
             total_items       75121
                  uptime       43527
                 version       1.4.5
To dumps keys and values, enter:
# memcached-tool 10.10.1.5:11211 dump | less

More Tips: To Increase Your WordPress Based Blog Speed

  1. Turn on MySQL query cache.
  2. Use xcache opcode cacher to accelerates the performance of PHP on servers.
  3. Use CDN (Content Delivery Network) for WordPress to speed up your blog.

Conclusion

The end result was pretty good. The database request are completed faster and loads on database servers are decreased. The above setup can be used with other php or webapps too.

Recommended readings:


REFERENCES
http://www.cyberciti.biz/faq/linux-unix-bsd-wordpress-memcached-cache-plugin/

Setting Up a CentOS / Red Hat Linux DHCP Client

SkyHi @ Tuesday, September 14, 2010
Q. How do I setup my Red Hat / CentOS / Fedora Linux system to get IP address and other information via a DHCP server for eth0 interface?

A. You can edit eth0 configuration file to switch between static and dhcp networking configuration under RHEL / Fedora or CentOS Linux. Simply edit /etc/sysconfig/network-scripts/ifcfg-eth0 file.

Backup existing static configuration

First backup existing network configuration file using cp command:
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.bak

Configuring a DHCP Client

Setting up a Linux for dhcp can be done by editing file using a text editor such as vi:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Following is sample static configuration:
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:19:D1:2A:BA:A8
IPADDR=10.10.29.66
NETMASK=255.255.255.192
ONBOOT=yes

Replace static configuration with DHCP:
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:19:D1:2A:BA:A8
ONBOOT=yes

Save and close the file. Just restart network service:
# /etc/init.d/network restart
Please note that you need a configuration file for each device that you want to configure to use DHCP.

REFERENCES
http://www.cyberciti.biz/faq/setting-up-a-linux-for-dhcp/

Linux Commands Wallpaper!

SkyHi @ Tuesday, September 14, 2010

REFERENCES
http://www.reddit.com/r/programming/comments/ddaak/linux_commands_wallpaper_hires/

Monday, September 13, 2010

JavaScript print_r() or var_dump() Equivalent

SkyHi @ Monday, September 13, 2010
/**
 * Concatenates the values of a variable into an easily readable string
 * by Matt Hackett [scriptnode.com]
 * @param {Object} x The variable to debug
 * @param {Number} max The maximum number of recursions allowed (keep low, around 5 for HTML elements to prevent errors) [default: 10]
 * @param {String} sep The separator to use between [default: a single space ' ']
 * @param {Number} l The current level deep (amount of recursion). Do not use this parameter: it's for the function's own use
 */
function print_jc(x, max, sep, l) {

 l = l || 0;
 max = max || 10;
 sep = sep || ' ';

 if (l > max) {
  return "[WARNING: Too much recursion]\n";
 }

 var
  i,
  r = '',
  t = typeof x,
  tab = '\t';

 if (x === null) {
  r += "(null)\n";
 } else if (t == 'object') {

  l++;

  for (i = 0; i < l; i++) {
   tab += sep;
  }

  if (x && x.length) {
   t = 'Array';
  }

  r += '(' + t + ") \n";
  r += '('+"\n";


  for (i in x) {
   try {
    r += tab + '[' + i + '] => ' + print_jc(x[i], max, sep, (l + 1));
   } catch(e) {
    return "[ERROR: " + e + "]\n";
   }
  }
  r += ')';


 } else {

  if (t == 'string') {
   if (x == '') {
    x = '(empty)';
   }
  }

  r += '(' + t + ') ' + x + "\n";

 }

 return r;

}




TEST:
//var colors = new Array("red", "blue", "green");
var colors = ["red", "blue", "green"];
document.write('
');
document.write(print_jc(colors));
document.write('
');


Output:
(Array) 
(
  [0] => (string) red
  [1] => (string) blue
  [2] => (string) green
)



REFERENCES
http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/

dump() - Javascript equivalent of PHP's print_r() function

SkyHi @ Monday, September 13, 2010
 The moment I saw the print_r() function of PHP, I fell in love with it. It is a very necessary function and I cannot understand why no other language supports it. JavaScript is one such language. So, I have ported the print_r function to javascript.


/**
 * Function : dump()
 * Arguments: The data - array,hash(associative array),object
 *    The level - OPTIONAL
 * Returns  : The textual representation of the array.
 * This function was inspired by the print_r function of PHP.
 * This will accept some data as the argument and return a
 * text that will be a more readable version of the
 * array/hash/object that is given.
 * Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php
 */
function dump(arr,level) {
 var dumped_text = "";
 if(!level) level = 0;
 
 //The padding given at the beginning of the line.
 var level_padding = "";
 for(var j=0;j<level+1;j++) level_padding += "    ";
 
 if(typeof(arr) == 'object') { //Array/Hashes/Objects 
  for(var item in arr) {
   var value = arr[item];
   
   if(typeof(value) == 'object') { //If it is an array,
    dumped_text += level_padding + "'" + item + "' ...\n";
    dumped_text += dump(value,level+1);
   } else {
    dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
   }
  }
 } else { //Stings/Chars/Numbers etc.
  dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
 }
 return dumped_text;
}



This is how the function is called. In this example we will give a complex array as the argument.
//Calling the function...
function init() {
 var arra = new Array("So long",'s',42,42.13,"Hello World");
 var assoc = {
  "val"  : "New",
  "number" : 8,
  "theting" : arra
 };
 
 alert(dump(assoc));
}
window.onload=init;

The result will be returned in the following format...
'val' => "New"
'number' => "8"
'theting' ...
   '0' => "So long"
   '1' => "s"
   '2' => "42"
   '3' => "42.13"
   '4' => "Hello World"



REFERENCES
http://www.openjs.com/scripts/others/dump_function_php_print_r.php

Sunday, September 12, 2010

samba permission 777

SkyHi @ Sunday, September 12, 2010

Change Samaba Permission
1. Right Click Properties, under Security Tab --> select Everyone -->Click Edit

2. Select Everyone -> Check Full control Box --> Click Apply

Or

1. Right Click Properties, under Security Tab --> select Everyone -->Click Advanced
2. Permissions Tab --> Select Allow Everyone -> Click Change Permissions
3. Permissions Tab shows up --> Select Allow Everyone --> Click Edit
4. Select Full Control and Click OK




View Samba Permission


1. Security Tab -> Select Everyone -> Click Advanced


2. Permissions Tab -> Select Everyone  -> Click Change Permissions

3. Permission Tab pops up -> Select Everyone again -> Click Edit

4. Result show as below