Wednesday, September 5, 2012

Bash is the extended version of sh shell that incorporates useful features from Korn and C shell. As compared to sh shell, there are many features are added in Bash shell like command line editing, history of commands, filename completion, command name completion, job control, aliases, indexed arrays of unlimited size.
There are many features are found only in Bash shell. They are as follows:
·         Bash startup files:
Startup files are scripts that are read and executed by bash when it starts. Startup scripts like .bash_profile, .bashrc.
·         Conditionals:
Conditionals expressions are used by the [[ compound command and by the test and [ built in commands.
·         Shell arithmetic:
The shell allows arithmetic expressions to be evaluated as one of the shell expansions or by the let built-in .
·         Aliases:
Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. The shell maintains a list of aliases. Aliases are expanded when a command Is read, not when it is executed.
·         Directory stack:
The directory stack is a list of recently visited directories. Pushd commands adds directories to the stack as it changes the current directory, and the popd built-in removes specified directories from the stack and changes the current directory to the directory removed.
Posted by Machindra Dharmadhikari On 9/05/2012 10:12:00 PM No comments READ FULL POST
If following conditions occur then avoid the use of shell scripting. It will enhance the speed and performance of project.
Shells script not to use in these situations:
·         Procedures involving heavy-duty math operations, especially floating point, then try to avoid shell scripting here.
·         Resource intensive tasks, especially where speed is factor like sorting, hashing etc.
·         Situations where security is most important factor, where we need the integrity of system.
·         Where cross platform portability required, don't use shell scripting. In this situation, C, Perl like languages are most useful.
·         If project consists of subcomponents with interlocking dependencies then avoid to use of shell scripting. Instead of it, C++ language can be useful.
·         In some situations, if we need data structures like tree, linked list, stack, graph then don't use shell scripting.
·         If there is need of direct access to system hardware then avoid the use of shell scripting.
·         If there is need to generate graphical interface or need to manipulate graphics then best way to avoid shell scripting.
·         If there is need of internal libraries or interface with legacy code then don't use shell scripting.
If there is situations like above mentioned, then use more powerful scripting language like Perl, Python, or compiled languages like C, C++ or java.
Posted by Machindra Dharmadhikari On 9/05/2012 01:05:00 AM No comments READ FULL POST

Tuesday, September 4, 2012

Interview Questions for Linux Administrator

Learning shell scripting is very easy but we need to start it from basic of shell scripting tutorial. I am writing this article because of many of us confused about these two operators.

There are many ways to pass argument to unix shell script as follows:
Pass command line argument:
1.       In this you don't need to give arguments in double quotes. You can use this argument in script as $1,$2,and $3. Assigned value becomes $1=10, $2=20,$3=30.
$ sh test.sh 10 20 30       
2.       If argument contains space or wild card character then need to put it in double quotes.  You will get these arguments in script as $1="first Argument" and $2="Second Argument".
$sh test.sh "first Argument" "Second Argument"                                             

Shift Operator in Solaris/Linux:
3.       If there are more than 10 arguments and you want to pass from command line then you need to use shift operator.
$sh test.sh 10 20 30 40 50 60 70 80 90 100 110 120 130
$vi test.sh
#!/bin/bash
echo $1                                                //10
echo $2                                                //20
echo $7                                                //70
echo $9                                                //90
shift;
echo $9                                                //100
shift 2;
echo $8                                                //110
echo $9                                                //120
Instead of shift operator you can use echo ${10} or echo {11} like this. In this way, you can go ahead with more arguments.

Know more about :  Linux Shell scripting tutorial
4.       If you are giving command line input to script then you can use $* or $@ to display all argument as comma separated and considering a single string. For example:
$sh test.sh 10 20 30 40 50 60 70 80 90 100 110 120 130
$vi test.sh
#!/bin/bash
echo $*                                                //10
and  output is as
10 20 30 40 50 60 70 80 90 100 110 120 130

download shell scripting pdf


Advanced use of sed command in Linux      
Posted by Machindra Dharmadhikari On 9/04/2012 05:44:00 PM 1 comment READ FULL POST

Monday, September 3, 2012

Shell is a program that interprets the command and acts as an interface between user and kernel. It provides the command line interface to user to access the OS services. Shell gathers input from user and executes programs based on that input. Shell is one of the most powerful tool of Unix. There are many types of shells and each shell having its own syntax, features and capabilities.
The prompt, $, it is command prompt for shell. When the this prompt appears, user can type the command. Sometimes this prompt is like #. This prompt (#) comes only for normal users. For Super user prompt always be ($).
Following are some of the shells:
·         sh :
It is Bourne shell. It has many drawbacks like no command completion feature, no history, can't change on command line i.e. command line editing options are not available.
·         Bash:
It is Bourne again shell. It is extended version of Bourne shell. Some of the drawbacks of Bourne shell have been removed in this shell. It includes features like command line editing, history of commands and so on.
·         Ksh:
This shell is written by David Korn and available for all Unix like systems. It is also a extension of Bourne shell and some of the features adapted from C shell.
·         Zsh:
Zsh is really powerful shell that provides much of the functionality of KSH, CSH and BASH. This shell is dramatically powerful is in its ability to interactively evaluate and modify arguments. It can do command completion, filename completion etc.
·         TCSH:
It is extension of CSH that adds functionality like command completion, command line editor, enhanced history completion.
                 Above are some of the shell's which are commonly used in Linux/Unix.
Posted by Machindra Dharmadhikari On 9/03/2012 04:19:00 PM No comments READ FULL POST

Sunday, September 2, 2012

Unix file system is a collection of files and directories. On Unix or Linux everything is a file and if something is not a file then its process. There are many special types of files like device files, directory files, regular files and so on. To manage all those files in an ordered tree like structure. Inode is the concept which is used for identifying files uniquely if names are same in different structure. The most fundamental building block of many Linux file system is the i-Nodes. Let's briefly understand the what is i-Nodes.
I-Nodes:             
                An i-node doesn't provide file's name.  An i-node includes the permission's of file, creation time, modification time, file's owner and so on. As all of us know, Directories are also a special file. i.e.  Each directory also gets an i-node and the i-node points to data blocks containing information (filenames and i-nodes ) about the files in the directory.
                The i-nodes are used to provide indirection so that more data blocks can be pointed to –which is why each i-node does not contain the filename. Only one i-node works as a representative for the entire file, thus it would be a space if every i-node contained filename information.  An i-node is a unique in entire file system.

Super Blocks:
                The first piece of information read from a disk is its superblock.  This small data structure reveals several key pieces of information, including the disk's geometry, the amount of available space, and, the most important location of data. Without a super block, an on-disk file system is useless.

There are many type of file systems in Linux. Some of them are as :
·         Ext2:     
In this file system concepts of blocks, i-nodes and directories.
·         Ext3:
Ext2 enhanced with some features like journaling capabilities. Journaling allows fast file system recovery.
·         Lsofs(iso9660):
Used by CDROM file system.
·         Sysfs:
It is ram based file system initially based on ramfs.
·         Procfs:
The proc file system acts as an interface to internal data structures in the kernel . It can be used to obtain information about the system and to change certain kernel parameters at runtime using sysctl command.
·         NFS:
Network file system allows many users or systems to share the same files by using client/server methodology. NFS allows sharing all of the above file system.
Also supports vfat, Microsoft NTFS file system.
Posted by Machindra Dharmadhikari On 9/02/2012 11:40:00 PM No comments READ FULL POST
  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner