Tuesday, April 3, 2012

LINUX/UNIX C Shell Alias Command Syntax Example Code

LINUX/UNIX Aliases:
The C shell allows you to create and customize your own commands by using the built-in command alias. Commonly used for a long strings that are frequently used. Alias allows you to have a small more familiar command or name to execute a long string. An alias will last for the life of the shell session.
Regularly used aliases can be set from the shell's configuration file (~/.cshrc or the systemwide /etc/csh.cshrc for csh, or ~/.bashrc or the systemwide /etc/bashrc or /etc/bash.bashrc for bash) so that they will be available upon the start of the corresponding shell session. The alias commands may either be written in the config file directly or sourced from a separate file, typically named .alias (or .alias-bash, .alias-csh, etc., if multiple shells may be used).

Syntax and description of the alias shell command:
Shell Command: alias [word [string] ]
alias supports a simple form of command-line customization. If you alias word to be equal to string and then later enter a command beginning with word, the first occurrence of word is replaced by string and then the command is reprocessed.
If you don't supply word or string, a list of all the current shell aliases is displayed. If you only supply word, then the string currently associated with the alias word is displayed. If you supply word and string, the shell adds the specified alias to its collection of aliases. If an alias already exists for word, it is replaced.
If the replacement string begins with word, it is not reprocessed for aliases to prevent infinite loops. If the replacement string contains word elsewhere, an error message is displayed when the alias is executed.

To give you some exposure of how alias command works on running linux system, below is an example of alias in action:
$ alias dir 'ls -aF' ...register an alias.
$ dir ...same as typing "ls -aF".
./ main2.c p.reverse.c reverse.h
../ main2.o palindrome.c reverse.old
$ dir *.c ...same as typing "ls -aF *.c".
main2.c p.reverse.c palindrome.c
$ alias dir ...look at the value associated with "dir".
ls -aF
$ _

In the following example, I aliased a word in terms of itself:
% alias ls 'ls -aF' ...define "ls" in terms of itself.
% ls *.c ...same as typing "ls -aF *.c".
main2.c p.reverse.c palindrome.c
% alias dir 'ls' ...define "dir" in terms of "ls".
% dir ...same as typing "ls -aF".
./ main2.c p.reverse.c reverse.h
../ main2.o palindrome.c reverse.old
% alias who 'date; who' ...infinite loop problem.
% who
Alias loop.
% alias who 'date; /usr/bin/who' ...full path avoids error
% who ...works fine now.
Fri May 13 23:33:37 CST 2005
smith ttyp0 Feb 13 23:30 (xyplex2)
% _

Removing an Alias:
To remove an alias, use the built-in command unalias.

Syntax and description of the unalias shell command:
Shell Command: unalias pattern unalias removes all of the aliases that match pattern. If pattern is *, then all aliases are removed.

Friday, March 23, 2012

What are the three controls may be put in place to enhance system security?

What are the three controls may be put in place to enhance system security?
Ans: The controls that you might put in place to enhance system security are:
1. Vulnerability avoidance: Controls that are intended to ensure that attacks are unsuccessful. The strategy here is to design the system so that security problems are avoided. For example, sensitive military systems are not connected to public networks so that external access is impossible. You should also think of encryption as a control based on avoidance. Any unauthorized access to encrypted data means that it cannot be read by the attacker. In practice, it is very expensive and time consuming to crack strong encryption.
2. Attack detection and neutralization: Controls that are intended to detect and repel attacks. These controls involve including functionality in a system that monitors its operation and checks for unusual patterns of activity. If these are detected, then action may be taken, such as shutting down parts of the system, restricting access to certain users, etc.
3. Exposure limitation and recovery: Controls that support recovery from problems. These can range from automated backup strategies and information ‘mirroring’ to insurance policies that cover the costs associated with a successful attack on the system.

What are the three principal threats to the security of a system?

What are the three principal threats to the security of a system?
Ans: In any networked system, there are three main types of security threats:
1. Threats to the confidentiality of the system and its data: These can disclose information to people or programs that are not authorized to have access to that information.
2. Threats to the integrity of the system and its data: These threats can damage or corrupt the software or its data.
3. Threats to the availability of the system and its data: These threats can restrict access to the software or its data for authorized users.

What is the distinction between a hazard and an accident?

What is the distinction between a hazard and an accident?
Ans: Accident: An unplanned event or sequence of events which results in human death or injury, damage to property, or to the environment. An overdose of insulin is an example of an accident.
Hazard: A condition with the potential for causing or contributing to an accident. A failure of the sensor that measures blood glucose is an example of a hazard.

What is the most important difference between the two classes of safety critical system?

What is the most important difference between the two classes of safety critical system?
Ans: Safety-critical software falls into two classes:
1. Primary safety-critical software: This is software that is embedded as a controller in a system. Malfunctioning of such software can cause a hardware malfunction, which results in human injury or environmental damage. The insulin pump software, introduced in Chapter 1, is an example of a primary safety-critical system. System failure may lead to user injury.
2. Secondary safety-critical software: This is software that can indirectly result in an injury. An example of such software is a computer-aided engineering design system whose malfunctioning might result in a design fault in the object being designed. This fault may cause injury to people if the designed system malfunctions. Another example of a secondary safety-critical system is the mental health care management system, MHC-PMS. Failure of this system, whereby an unstable patient may not be treated properly, could lead to that patient injuring themselves or others.

Explain the difference between a system fault and a system failure.

Explain the difference between a system fault and a system failure.
Ans: System fault: A characteristic of a software system that can lead to a system error. The fault is the inclusion of the code to add 1 hour to the time of the last transmission, without a check if the time is greater than or equal to 23.00. System faults do not always result in system errors and system errors do not necessarily result in system failures.
System failure: An event that occurs at some point in time when the system does not deliver a service as expected by its users. No weather data is transmitted because the time is invalid. System reliability and availability problems are mostly caused by system failures.

Explain how a relatively unreliable system can provide a high level of availability.

Explain how a relatively unreliable system can provide a high level of availability.
Ans: A telephone exchange switch that routes phone calls is an example of a system where availability is more important than reliability. Users expect a dial tone when they pick up a phone, so the system has high availability requirements. If a system fault occurs while a connection is being set up, this is often quickly recoverable. Exchange switches can usually reset the system and retry the connection attempt. This can be done very quickly and phone users may not even notice that a failure has occurred. Furthermore, even if a call is interrupted, the consequences are usually not serious. Therefore, availability rather than reliability is the key dependability requirement for this type of system.