Question

In: Computer Science

a) In no less than 100 words, describe several ways that an administrator could use the...

a) In no less than 100 words, describe several ways that an administrator could use the alias command to make their job easier.

b )In no less than 100 words, describe how you could use the "if" construct in administrating a Linux system.

c) Describe what stdout is? What is the default stdin? Describe stderr.

d) What file descriptor number represents stdout?

e) Describe redirection in BASH. Provide a command that uses redirection.

Solutions

Expert Solution

Please find the below answers, Please provide your feedback

Thanks and Happy Learning!

a) alias command in Unix/Linux allows a user to create simple alternative names or abbreviations for commands(A command is an instruction given to the computer to do something). These alternative names(alias names) can be of even a single character in length.
Below are some of the scenarios where alias command helps the system administartor in his daily work:
1. To setup simple,meaningful and short/easy to type names for the original commands or a group of commands. This saves a lot of time for the administrator in his daily jobs.
   Example: Instead of typing the command 'ls -la' every time to list all the files(including the hidden files), administartor can setup an alias command like below so that when 'l' is typed it does the same functionality of the command 'ls -la'
   alias l="ls -la"
   
2. Having aliases helps the administrator in avoiding common spelling mistakes while typing the commands.
   
3. Administartor can help to increasing the safety of the system by making some important commands (such as rm) interactive.
   For example, the rm command deletes a given file, so to avoid user from removing a file by mistake, the administartor can set an alias for 'rm' command as follows so that the rm command prompts the user for confirmation before performing a delete.
   
   alias rm="rm -i"
   
b) The if construct in Linux helps the user to take decision based on a particular condition. The system administartor can use the if construct in the scripts that is used by the administartor to automate some of thedaily activities. For example the administrator can setup a script to monitor a particular system process and make the script to send if it finds some error in the log file of that process. The pseudo code using 'if' construct for this scenario is give below

if [ there are any error in the log file ]
then
   sendmail
else
   doNothing and continue monitoring the process.
Another common scenario of using if construct is in the scripts which allow or deny some users/group of users from accessing some resources such as files or directories.

c) stdout is the standard stream used by the programs to write their output. The default stdout for a program in Linux system is the computer screen. Like everything else in a Linux system the stdout stream is also considered as a file to which the programs write their output. The below command in Linux system outputs the string to the stdout

echo "Hello World"

The file descriptor for the stdout is 1  in a Linux machine.

stdin is the standard stream used by the programs to read in the user input. The default stdin for a program in Linux is the keyboard. The below 'read' command reads the user input from the stdin(which is set as the keyboard by default) to a variable called as 'inputString'

read inputString

The stdin also considered as a file in a Linux machine, and the file descriptor for the stdin is set to zero (0).

stderr is the stream used by the programs to output the error messages. By default the stderr is set to the computer screen like stdout. The file descriptor for the stderr is 2  in a Linux machine.

d) File descriptor number for representing stdout is 1

e) Redirection in bash is used to redirect the output of a command from its default output stream to some other destination. For example the command 'ls -la' lists all the contsents of a directory and displays the result in the stdout(which is computer screen by default) . So if the user wants to redirect the output of the above command to a file then the user can use the redirection in bash. The symbol used for redirection in bash is '>'.
For example: To redirect the output of 'ls -la' command to a file called 'test.txt' the below command can be used

ls -la 1>test.txt

In the above command the one(1) is the file descriptor for thee stdout. So in short the above command redirects the output of the command form stdout (sith file descriptor 1) to a file named test.txt 

similarly to redirect the output of a command from stderr to a file called test.txt below command can be used

ls -la 2>test.txt
In the above command the two(2) is the file descriptor for thee stderr.

Also one can use the symbol '>>' instead of '>' if the user wants to append the output to the end of a file. If the user uses the symbol '>' it overwrites the file. So in the case where the output file (test.txt) already has some content then using the symbol '>' redirection will make the old contents to be lost. But if the symbol '>>' is used for redirection then the new content will be appended to the end of the already existing content thus preserving the old content.

Example:

ls -la 1 >>test.txt

Related Solutions

In less than 100 words to describe the impact of Information Technology to the business operation...
In less than 100 words to describe the impact of Information Technology to the business operation of a company.
Discuss the below in no less than 100 words. a) Describe why RAID is an important...
Discuss the below in no less than 100 words. a) Describe why RAID is an important consideration for your Linux server. b) What version of a RAID would you use for a medium-size business? Support your answer with reasons for the choice. Provide the number of disks you will need to optimize your choice. c) Additionally, indicate whether you would use iSCSI or locally attached drives for this configuration. Support your answers.
In no than less than 200 words, describe the major characteristics of a physicians, surgeons, and...
In no than less than 200 words, describe the major characteristics of a physicians, surgeons, and dentists professional liability insurance policy.
In less than 100 words, provide an example of a collaboration between two entities that did...
In less than 100 words, provide an example of a collaboration between two entities that did not meet the goal they had set for themselves and discuss what were the factors that led to this failure.
In less than 100 words, provide an example of a successful collaboration that has taken place...
In less than 100 words, provide an example of a successful collaboration that has taken place between two entities and discuss what were the factors that led to this success
In no less than 100 words, as you complete your assignment, consider some of the similarities...
In no less than 100 words, as you complete your assignment, consider some of the similarities and differences between using a manual system versus a computerized system. Hint: Refer to Chapter 6 pages 170 & 171 for discussion of computerized accounting systems.
1)Develop your definition of counseling 2)Describe in less than 100 words what ideas,concept and issues you...
1)Develop your definition of counseling 2)Describe in less than 100 words what ideas,concept and issues you have learned
In more than 100 words, describe the nature and characteristics of corporations.
In more than 100 words, describe the nature and characteristics of corporations.
describe is less than 250 words the concept of relationship in starbucks marketing strategy
describe is less than 250 words the concept of relationship in starbucks marketing strategy
a) Describe in less than 300 words ONE type of apparatus (using a diagram if it...
a) Describe in less than 300 words ONE type of apparatus (using a diagram if it helps) that is used to collect diffraction information using X-rays. Include in your answer why this set up is used to successfully get diffraction from crystals? b) Describe in less than 300 words how the equilibrium one-dimensional band diagram of a pn junction (under zero bias) evolves based on diffusion and drift currents that occur due to the differing impurities in the p and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT