Shared Flashcard Set

Details

Linux+ Chapter 7
Linux+ Chapter 7
90
Computer Networking
Undergraduate 1
03/07/2013

Additional Computer Networking Flashcards

 


 

Cards

Term
What is the basic function of the BASH shell?
Definition
Providing a user interface and interpreting commands entered on the command line.
Term
What is a file descriptor?
Definition
Command input and output are represented by numeric labels known as file descriptors.
Term
What are three file descriptors?
Definition
-Standard input (Stdin)
-Standard output (Stdout)
-Standard error (Stderr)
Term
What is the standard output and in what form does it often take?
Definition
Refers to the normal output of a command. Stdout is displayed on the terminal screen by default.
Term
What is the standard input and in what form does it often take?
Definition
Refers to information processed by the command during execution; this often takes the form of user input typed on the keyboard.
Term
What is the standard error and in what form does it often taken?
Definition
Refers to any error messages generated by the command. Stderr is displayed on the terminal screen by default.
Term
What numbers are used to represent the three file descriptors?
Definition
-0
-1
-2
Term
What is redirection?
Definition
It means capturing the output from a file, command, program, script, or even code block within a script and sending it as input to another file, command, program, or script.
Term
What is the redirection character and how is it used?
Definition
It is used to send the output from a command to a text file.
Term
If the output of a command is redirected to a currently non-existent file, what will happen?
Definition
The file is automatically created.
Term
If the output of a command is redirected to a currently existing file, what will happen?
Definition
The BASH shell clears it contents before executing the command.
Term
What kind of output can be redirected into a file?
Definition
-Stderr
-Stdout
Term
If a command specifies that only the standard output be redirected to a file, but there is an error, where will the standard error output be sent?
Definition
The (stderr)is directed to a file called badoutput.
Term
In the absence of a numeric file descriptor, what kind of file descriptor will the BASH shell assume?
Definition
BASH shell assumes stdout.
Term
Can you redirect standard output and standard error to separate files in the same command?
Definition
YES
Term
Does the order of redirection on the command line matter?
Definition
NO
Term
Can you use the same filename for both stdout and stderrusing the normal syntax? Why or why not?
Definition
No because using the same file name for both cause a loss of data.
Term
How can you redirect both stdout and stderr to the same file without any loss of data?
Definition
Use a special notation.
Term
How do you prevent an existing file's content from bein cleared by the BASH shell, and also tell the shell to append newer output to the output already existing in the file?
Definition
Append output to the existing output, you can specify two > shell metacharacters along side the file descriptor.
Term
How can you redirect a file to the stdin of a command? Do you need to specify the file desciptor number in the command?
Definition
Use the < shell metacharacter because there is only one file descriptor for input, there is no need to specify the number 0 before the < shell metacharacter to indicate stdin.
Term
When combining stdin and stdout, will the BASH shell clear the content of an existing target file before or after manipulating the original file?
Definition
YES
Term
What is a common command used to clear the content of a file?
Definition
>filename
Term
What is piping?
Definition
Sending the stdout of one command to another command as stdin.
Term
Does the command 1>file do the same thing as >file?
Definition
YES
Term
How do pipes work?
Definition
String of metacharacters connected by "1" metacharacters. Commonly used to reduce the amount of information displayed on the terminal screen.
Term
Are spaces required around the pipe shell metacharacter?
Definition
NO
Term
What is one common use for piping?
Definition
To reduce the amount of information displayed on the terminal screen from commands that display too much information.
Term
What is filter command?
Definition
Any command that can take stdin and transform it in to stdout.
Term
Where must commands that are not filter commands be in a pipe?
Definition
Beginning of a pipe.
Term
Why can't interactive commands (like vi)be used between two pipe symbols?
Definition
They cannot take from stdin and give to stdout.
Term
What filter command takes information from stdin and sends that information to a file, as well as to stdout.
Definition
tee command
Term
If you combine redirection and piping, where must you place input and output direction?
Definition
Input direction occurs at the beginning of the pipe and output direction occurs at the end of the pipe.
Term
What command is typically used to search for a certain string of text, and replaces that text string with another text string? What is this command's syntax for both finding only the first occurrence and for all occurrences?
Definition
-sed command
-sed s/search/replace/
-sed s/search/replace/g
Term
What other command searches for patterns of text, but treats each line of text as a record in a database, and each word in a line as a database field?
Definition
-awk command
Example:
cat prologue | awk '/the/{print$1,$4}'
Term
By default, what does the awk command use as delimeters for each field in a line? How can you change the delimeter?
Definition
Use spaces or tab characters
-F option
Term
Can sed and awk use regular expressions?
Definition
YES
Term
What is a variable?
Definition
A reserved portion of memory containing information that might be accessed.
Term
What are environment variables?
Definition
They are typically set by the system and contain information that the system and programs access regulary.
Term
Can users create their own variables?
Definition
YES
Term
What are special variables?
Definition
They can only be referenced and never directly assigned values.
Term
What command is used to see a list of environment variables?
Definition
set command
Term
What do the following variables define?
-SHELL
-PS1
-HOME
-PWD
-PATH
Definition
-SHELL:pathname to shell
-PS1:the default shell prompt
-Home:the absolute pathname to the user's homew directory.
-PWD:the present working directory in the directory tree
-Path:a list of directories to search for executable programs.
Term
How do you view the content of a variable? What does the $ character do?
Definition
Use the echo command and specify the variable name prefixed by the $ shell metacharacter.
Term
How do you change a variable name?
Definition
Specify the variable name followed immediately by an equal siqn(=) and the new value.
Term
What are some variables whose values should not be changed?
Definition
-Home variable
-PWD
Term
What exactly does the tilde(~) metacharacter represent?
Definition
Represents the current user's home directory.
Term
Why is PATH variable so important?
Definition
Allows users to execute commands by typing the command name alone.
Term
What must you do to run an executable whose location is not listed by the PATH variable?
Definition
The user must specify either the absolute or relative pathname to the executable file.
Term
How do you define a use variable?
Definition
Specify the name of the variable(variable identifier)immediately followed by the equal sign(=) and the new contents.
Term
What are the rules for creating user defined variables?
Definition
-They contain alphanumeric characters(0-9, A-Z, a-z, the -(dash) character, or the _(underscore) character.
-They must not start with a number
-They are typically capitalized to follow convention(for example, Home, Path, and so on).
Term
When you execute a command in the current shell, usally where is the command run?
Definition
They are run in separate subshell, which is created by the current shell.
Term
Are variables created in the current shell available to subshells?
Definition
NO
Term
What command is used to export variables to ensure that all programs started by the current shell have the ability to access the variable?
Definition
export command
Term
What command other than set can be used to see a list of all exported environment and user defined variables in the shell?
Definition
env command
Term
What are some examples of other variables that perform special functions?
Definition
UMASK
Alias
Term
What is an alias?
Definition
Aliases are shortcuts to commands stored in special variables that can be created and viewed using the alias command.
Term
How do you create aliases to multiple commands?
Definition
They are separated by the ; shell metacharacter.
Term
Is it necessary to use unique alias names?
Definition
Yes because the shell searches for them before it searches for executables files.
Term
What are environment files? Why are they important to variables?
Definition
To ensure that variables are accessible to a shell at all times, you must place variables in a file that is executed each time a user logs in and starts a BASH shell.
Term
What is the ~/.bashrc file and what does it do?
Definition
(BASH run-time configuration) is typically used to set aliases and variables that must be present in the BASH shell.
Term
Which environment file sets HOME and PATH environment variables?
Definition
/etc/profile file
Term
How do you add a variable to an environment file?
Definition
Add a line that has the same format as the command used on the command line.
Term
What else can be placed within an environment file beside variables?
Definition
Any command that can be executed on the command line.
Term
In which file would you add clean up commands (such as archive log files)so that they run upon exiting the shell?
Definition
.bash_logout file
Term
What are shell scripts? For what are they typically used?
Definition
-Text files containing commands and special constructs.
-To create custom programs that perform adminstrative tasks on Linux systems.
Term
What commands can be used in shell scripts?
Definition
Any command that can be entered on the command line in Linux.
Term
What is hashpling?
Definition
The first line in the preceding shell script(#!/bin/bash)
Term
What character in a shell script identifies the line as a comment?
Definition
#character
Term
How do you execute a shell script if you only have read permission for that script?
Definition
By starting another BASH shell and specifying the shell script as an argument.
Term
How do you execute a shell script if you have read and execute permissions?
Definition
You can execute the shell script like any other executable program on the system.
Term
What command can be utilized in a script to improve readability via the use of blank lines?
Definition
echo command
Term
What are escape sequences? How are they used?
Definition
Special notations
Example:
echo -e"Today's date is: \c"
date
Term
What command takes user input from stdin and places it in a variable specified by an argument to the read command?
Definition
read command
Example:
echo -e"What is your name? -->\c"
read USERNAME
Term
What are decision constructs?
Definition
They are the most common type of construct used in shell scripts.
Term
What is the basic syntax of the if construct?
Definition
if this true
then
do these commands
elif this is true
then
do these commands
else
do these commands
fi
Term
What character end an if construct?
Definition
fi
Term
What are the six common rules that govern if constructs?
Definition
-elif and else statements are optional
-you can have an unlimited number of elif statements
-the "do these commands" section can consist of multiple commands
-the "do these commands" section is typically indented per line from the left-hand side of the text file.
-the end statement must be a backward "if"(fi).
-the this is true part of the if syntax, can be a command or test statement.
Term
Can you use the "if" construct to alter the flow of the program given input from the user?
Definition
YES
Term
What must you include after the beginning square bracket and before the ending square bracket in a test statement?
Definition
space character
Term
Compare to the "if" construct, why use the "case" construct?
Definition
Whe presenting several choices, it is common place to use a case construct.
Term
What is the syntax of the case construct?
Definition
case variavle in
patter1 )do this
;;
pattern2 )do this
;;
pattern3 )do this
;;
Term
How does the "case" construct work?
Definition
Compares the value of a variable with several different patterns of text or numbers.
Term
What does the && construct do? What is its syntax?
Definition
The command on the right of the && construct is executed only if the command on the left of && construct completed successfully.
-command && command
Term
What does the || construct do?
What is the syntax?
Definition
the command on the right of the || construct is executed only if the command on the left of the || construct did not complete successfully.
-command || command
Term
For what is the "loop" construct used? How do they work?
Definition
Execute commands repetitively.
-alters the flow of a program based on the result of a particular statement.
Term
What are the two most common loop constructs?
Definition
-for
-while
Term
What is the syntax of the "for" construct?
Definition
for var_name in string1 string2 string3 ... ...
do
these commands
done
Term
What is the "while" construct? What is the syntax of the "while" construct?
Definition
-Common loop construct used within shell scripts.

while this returns true
do
these commands
done
Term
What is a counter variable, and what does it do?
Definition
Counter variable whose values changes each time through a loop.
Term
What can you use in place of a test statement to create a "while" construct that executes indefinitely?
Definition
you can use the true or :
Supporting users have an ad free experience!