Directory Structure
/dev - Special files that represent devices/sbin - System utilities for system startup
/etc - System configuration files used by System Admins
/usr - contains the subdirectories bin, include, share etc
/home – contains all users’ home directories
/var - contains user’s mail files, crontab files etc.
/tmp – directory used by system processes to keep their temporary files.
Shell
- User interface - Shell provides an interface to the user, wherein the user could issue his commands, and Shell displays output and error messages to the user.
- Command interpreter - Shell accepts command from user, and interprets it to the kernel.
- Command processor - Shell parses the command line arguments, expands the special meaning of meta characters, searches for the command, and if the command is found, then transfers control to the command.
- Programming language - Shell provides a native programming language.
Shell – Command line processing
When we issue a command at the shell prompt, the shell does the following tasks:- The shell parses the command line arguments, looking for the existence of special characters for shell, known as meta-characters.
- Shell does the task as per the special meaning of these meta-characters.
- After expanding the meaning of meta-characters, shell searches for the command, in a set of commands, in a particular order.
Shell – Internal and External commands
- Internal commands
- When we execute an internal command, the shell executes these commands in its own environment, without forking a child.
- List of some internal commands: cd, echo, umask, source.
- External commands
- When we execute an external command, the shell creates a sub-shell and executes the command in the sub-shell environment.
- List of some external commands: cat, mkdir, rmdir, cp, mv, rm, split, od, bc, expr
Shell – Command line editing
- Bash
- Korn Shell
$ set –o vi
- Subsequently, all vi editing features are available on the command line.
- To remove this vi editing feature, we need to issue the following command:
$ set +o vi
Shell – Setting and referencing variables
- A variable is a named memory location that exists in shell environment, value of which can be changed.
- A variable can be initialized with a value as follows:
- name="DataStage4You"
- A variable can be initialized to a value using read command also, as follows:
899.9277
- read name
"Nuts & Bolts of DataStgae"
- Result of computation can be assigned to a variable in LHS. Following example illustrates this phenomenon:
- A variable can be removed from the environment using unset command, as in the following example:
- We can create a constant data item using readonly or typeset command, as follows:
Or
$ typeset –r PI=7.1428 # -r option sets the data item PI as constant data item
- We can neither change the value of constant data item nor remove it from shell environment.
- Pre-defined shell variables: Variables that are pre-defined by the shell are known as pre-defined shell variables.
- env command displays the list of pre-defined environment variables.
- set command displays the list of pre-defined and user-defined environment variables.
- Examples of pre-defined variables:
/home/datastage
$ echo $PATH
/usr/lib/ccache:/usr/local/bin:/bin:/usr/bin
Shell – Inherit variable to sub-shell
We can allow a sub-shell to inherit a shell variable, as follows:$ export name="Atul"
$ ksh
$ echo $name
Atul
$ ksh
$ echo $name
Atul
Continue................
No comments :
Post a Comment