Wednesday, July 8, 2009

Difference between "su" and "su -"

A lot of people don't know the difference [and there is a day light of difference :) ]

==================
su
==================
1. ENVIRONMENT : The environment is the same as that of the user's from which you entered root. In the following example, the environment would be the same as that of user nemesis.


e.g nemesis@tantra:~/device-drivers$su

================================
su -
================================

1. shell reads a relevant startup files and simulates a login

2. ENVIRONMENT: The enviroment is that of the superuser/root and NOT that of the account from you you invoked "su".

For more detailed information, please refer to the man pages.

Monday, July 6, 2009

Strings: Single Quote Vs Double Quotes

In UNIX Shell
============
Double Quotes : In (Most ) UNIX shells and other scripting languages like perl, the interpreter would parse through the string inorder to perform substitutions for any variables in the string.

Single Quotes: Interpreter leaves the string alone. It is treated as a string literal.


In C
===========
Double Quotes: For strings

Single Quotes : For single character literals.

e.g

char c[];
c = 'c'; ==> SINGLE Quotes
c = "char"; ==> DOUBLE quotes