Unix Chapter 3

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Explain what will happen to STDOUT and STDERR given the following command: runMyProgram.sh > /tmp/log

STDERR will continue to be output to the terminal. STDOUT from the program will overwite the file /tmp/log.

Define the terms STDIN, STDOUT, and STDERR.

STDIN - Standard Input STDOUT - Standard Output STDERR - Standard Error Stream

**DEFINITELY ON THE TEST** Pick any two of the following commands and explain their function. wc lsattr lspci chown ls chmod

chown -- CHange OWNer -- changes ownership and group membership of a file chmod -- CHange MODe or Access Control Lists-- changes unix file permissions for a file (self, group, global)

List and explain two methods of determining "hardware" models components available on a Linux system. Note: I am aware that there are more than two methods of discovering hardware and more options than what we discussed in class. I will accept any correct answers.

'lsusb' is common now for usb hardware, 'lspci' for card-edge connector internal hardware like graphics and modems. Also useful is looking at the output of 'dmesg'.

Define the bit bucket.

A bit bucket is a device file that discards all data but reports successful write operations

Explain how the desire for "modularity" by the Linux developers would push them away from a "central" configuration repository (i.e. registry).

A central configuration repository goes against modularity because it causes software to form a reliance on a centralized location for data. This makes it more difficult to move different pieces of software from the registry.

Define a pipe and explain how one might be used.

A pipe takes output of one program and feeds it into the input of another programming allowing for easy linking of separate programs to accomplish larger tasks

Compare and contrast "<" and ">" in shell "programming".

Both are used for redirecting but > affects STDOUT output and < affects STDIN

Compare and contrast "block" files and "character" files.

Both block and character files use device drivers to determine how the data is stored, but block files can be cached in memory and are written one block at a time while anything either read from or written to character files is implemented immediately.

Explain how a developer may write a program that replaces STDOUT with a different file. Note: I am not referring to redirection or piping; I want to know how you would do this in code.

By simply specifying in the command that runs the file an output location, it will be redirected to that location via piping. This works because STDOUT is a file as well.

List 4 standard file types.

Character,Block,Binary,Pipes

Compare and contrast interpreted vs compiled programming languages.

Compiled languages take the written code and translate it into binary which is then executed. Interpreted languages read the code line by line as it is executed, translates it, then executes it.

Take a position on whether it is better for identify data types using "file extensions" or by using "magic numbers" and data structure analysis. Remember that if there were only one clear best answer, there would not be one solution. We can therefore reason that there are quality justifications for each approach. State your position and provide at least one clear justification for each.

File extensions are useful as they move all responsibility for identifying data types onto the programmer. The magic numbers allow for some help, but place the burden on the user to know how to handle a specific data type

List and provide a brief description of two places where a user might find configuration files for his Linux system.

One place would be "/etc/hosts", which contains a list of known hosts in the local network. Another would be ~/.bashrc which contains your bash configuration.

List and describe four standard types of file attributes and provide an example of each.

Ownership (chown) Permissions(chmod) Time(touch) Other(lsattr)

List and provide an example of "files" in Linux.

Persistent Pipes Character files Binary files Block devices Sockets Directories

Compare and contrast redirection and piping.

Redirection allows for changing where the standard streams output and input. Piping takes advantage of this and simplifies it specifically for the linking of programs

Explain how a shell will interpret the text "2>&1" when appended to the end of a shell command.

Redirects the STDERR stream to STDOUT

Explain what will happen to STDOUT and STDERR given the following command: /home/backup/backup-all.bsh > /dev/null 2>&1

STDOUT will be discarded by sending it to /dev/null, and STDERR will be redirected to STDOUT which will also be sent to /dev/null an discarded.

Define the term "magic number".

The first two bytes of a file

Describe the purpose of the magic number? List one example.

The magic number is the first two bytes of a file that identifies what type of file it is. One example might be a script or an executable.

Define file descriptor.

The term is generally used in POSIX operating systems. Generally, a file descriptor is an index for an entry in a kernel-resident array data structure containing the details of open files.

Provide a brief explanation of the "Everything is a file!" paradigm.

The whole point with "everything is a file" is so one can use common tools to operate on different things. This provides a simple, standard interface that makes the conception and implementation of programs very easy.

Explain how a files output can be "redirected" from STDOUT to a regular file.

grep > info.txt

Pick any two of the following commands and explain their function. ps lsof pstree cat set

ps -- Lists running processes on a system lsof -- Lists open file handles

List four examples of shell environments.

sh - Bourne Shell bash - Bourne Again csh - C Shell ksh - Korn Shell Vt100, ansi, xterm, gterm


Kaugnay na mga set ng pag-aaral

Electromagnetic spectrum basics and Scientific Notation

View Set

Pediatric Infectious and Communicable Diseases

View Set

Silas Marner Comprehension question 5

View Set