The wikipedia article has a nice concise description of when you would want to use the different types of depth-first search:

  • Pre-order traversal while duplicating nodes and values can make a complete duplicate of a binary tree. It can also be used to make a prefix expression (Polish notation) from expression trees: traverse the expression tree pre-orderly.
  • In-order traversal is very commonly used on binary search trees because it returns values from the underlying set in order, according to the comparator that set up the binary search tree (hence the name).
  • Post-order traversal while deleting or freeing nodes and values can delete or free an entire binary tree. It can also generate a postfix representation of a binary tree.

It boils down to the logistical needs of an algorithm. For example, if you don't use post-order traversal during deletion, then you lose the references you need for deleting the child trees.


Write a shell script that searches the file contents in a directory and its sub-directories for a text string given by the user. It list all such file names having that given string and store in a temp file "search_temp". It should have user friendly messages e.g. "File does not exit" , "Do you want to search again", etc.

 #bin/bashread-p"Enter a filename:"filename

 if

[[

 -f $ Search_temp]] 

then echo 

"The file $ Search_temp exists."read –p 

"Enter the you word want to find:" 

Word 

 grep "$word"

 "$Search_temp" 

else echo "The file $filename does not exist ".

 fi 

SUCCESS=0 

E_NOARGS=65 

If

 [-z"$1"] 

then 

echo"Usage:basename 

$0'rpm-file" 

exist $E_NOARGS

 fi 

#Begin code block.

 echo echo"Archive Description:"

 rpm-qpi $ 1 # Query descri....

 echo echo"Archive Listing:" 

rpm-qpl $ 1 # Query listing 

echo rpm-i—test $ 1 # Query whether rpm file can be installed.

 If ["$?" – eq $ SUCCESS] 

then 

 echo "$1 can be installed." 

else

 echo "$1 cannot be installed." 

Fi 

echo #End code block. 

}> "$1.test" #Redirects output of everything in block of file. 

echo "Result of rpm test in file $1.test" 

#See rpm main page for explanation of options. 

exit 0. 

exits = $(grep-c$word$file)

 if

 [[$exits-gt0]]; 

then 

echo"File does not exit"

 fi 

 Linux OS can be represented in the following with three layers. User, System and kernel.Kernel ,Consist of all the operating system resources such as file system ,memory, input/output modules and libraries.

The System layer consist of system resources  such as Application System interface (API).


And the User layer consist of all the user resources will reside such as application programs.


Linux is a multi-users and multi-tasking OS. Single Linux OS can provide services for more than one user at any time either locally and/or remotely. Every user has their own profile with custom settings that can be set by the user herself for the permitted settings or enforced by Root from the system side. For every user, there will be multi process running 'concurrently' for him,locally and/or remotely and it is said multi-tasking OS. In another simple word, single user can run many programs at any time. In order to optimize the resources such as memory, in every process there can be many threads and it is said multi-threading.



In Linux, systems' processes or services (in Linux term it is a daemon) normally run by Root. Originally, Root can be considered as the king with unlimited privileges that can control the whole OS. However, non-root group's users will have limited privileges. The many problems start when the users' privileges have been escalated to Root. When normal users have controlled or could access the kernel, it is a very bad situation. 

For the basic security features, Linux has password authentication, file system discretionary access control, and security auditing. By expanding the basic standard security features we have:

1.User and group separation
2.File system security
3.Audit trails
4.PAM authentication 

1.User and group separation.
User accounts are used to verify the identity of the person using a computer system. By checking the identity of a user through username and password credentials, the system is able to determine if the user is permitted to log into the system and, if so, which resources the user is allowed to access.
Groups are logical constructs that can be used to group user accounts together for a particular purpose.
 
2.File system Security
A very true statement of a UNIX/Linux system, everything is a file; if something is not a file, it is a process. Most files are just files, called regular files; they contain normal data, for example text files, executable files or programs, input to or output from a program and so on. While it is practically safe to say that everything you encounter on a Linux system is a file, there are some exceptions as listed below:  

a. Directories: files that are lists of other files. 
b. Special files: the mechanism used for input and output. Most special files are in /dev for example USB and CD-ROM. 
c.Links: a system to make a file or directory visible in multiple parts of the system's file tree. It is a shortcut. 
d.(Domain) sockets: a special file type, similar to TCP/IP sockets, providing inter-process networking protected by the file system's access control. 
e.Named pipes: act more or less like sockets and form a way for processes to communicate with each other, without using network socket semantics.


3.Audit Trails 
Linux kernel 2.6 comes with audit daemon. It's responsible for writing audit records to the disk. During startup, the rules in /etc/audit.rules are read by this daemon. You can open /etc/audit.rules file and make changes such as setup audit file log location and other option.

4.Plug-gable Authentication Modules authentication (PAM)
PAM was invented by SUN Micro systems. Linux-PAM provides a flexible mechanism for authenticating users. It consists of a set of libraries that handle the authentication tasks of applications on the system. The library provides a stable general interface to which privilege-granting programs (such as login) defer to perform standard authentication tasks.Historically, authentication of Linux users relied on the input of a password which was checked with the one stored in /etc/passwd. At each improvement (e.g. /etc/shadow, one-time passwords) each program (e.g. login, ftp) had to be rewritten. PAM is a more flexible user authentication mechanism. Programs supporting PAM must dynamically link themselves to the modules in charge of authentication. The administrator is in charge of the configuration and the attachment order of modules. All applications using PAM must have a configuration file in /etc/pam.d.

STEP 1: Setting up first IP address. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 on Redhat Linux box and give the following entries as shown.

vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0   BOOTPROTO=static   IPADDR=192.168.1.10   NETMASK=255.255.255.0   NETWORK=192.168.1.0   ONBOOT=yes

STEP 2:  Setting up second IP address. Create one file as /etc/sysconfig/network-scripts/ifcfg-eth0:1 and give the entries as below in to this file.

vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1   BOOTPROTO=static   IPADDR=192.168.1.11   NETMASK=255.255.255.0   NETWORK=192.168.1.0   ONBOOT=yes

STEP 3:  Once you configure above files and save them. Now reload the network service on your machine.

service network reload

STEP 4: Check if you get the IP address assigned to the eth0 and eth0:1 interfaces respectively.

ifconfig

Note1: We can assign virtual IP to the same interface with ifconfig but that one is not permanent so not giving info on that.

Note2: We can assign up to 16 virtual IP address to a single NIC card.