UNIX Final Exam Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How would you display a list of utilities with reference to the action to compress files?

$ apropos compress

How can you find out which utilities are available on your system for editing files as an 'editor'?

$ apropos editor

Show the command to "view" the log without decompressing the file.

$ bzcat

When you have write permission only for a file and execute permission only for the directory holding the file, you can modify but not delete the file. How could you delete the contents of a file in this case that had 10,000 lines of content?

$ cat /dev/null > filename

Command to zero out contents of the log file

$ cat /dev/null > someLog.out

Command to redirect the standard input

$ cat < newFile

What is the entire command to see the size (disk usage) of the /etc directory?

$ du /etc

Command to redirect the standard output

$ echo "text" > someFile

What is the command to bring a process to the foreground.

$ fg

Assume the following log files exist in your current working directory with the date suffix formatted as year|month|day. Which command would only grep the pattern 'user' from the log files for the first week of October only? These files exist: log-20171005 log-20171006 log-20171022 log-20171009

$ grep user log-2017100[0-7]

If the user placed three jobs in the background, which command would be used to determine which jobs are running and their job number?

$ jobs

Show the command to list the last 3 users to log into ember lab server.

$ last -3

What is the command to create a symbolic link of a file in the current directory called someFile?

$ ln -s someFile

Which utility sends a file to the printer?

$ lpr

Command to display the permissions of the file

$ ls -l

To list all files in your current working directory named: file22 file02 file99 file5 Which command line would work the best?

$ ls -la file*

List the files in the working directory in reverse alphabetical order.

$ ls -r

Which one of these lines will produce an error?

$ myvar = "this is a long line"

Which command shows a list of running jobs?

$ ps

Command to identify the working directory.

$ pwd

How would you remove a file named: u&!123.out

$ rm u\&\!123.out

Append the output of the who utility to the ls.out file.

$ who >> ls.out

What can be added to the following script ( /courses/cop3353m-w/quiz4/conti.sh ) on line 5 after the word "echo" to see the integers 1, 2, 3 displayed on the screen before the comment " continue statement will be used" ? use the following to see line numbers in vim : set number

$index

What does 'o' and 'O' in VIM do?

'o' opens a blank line below while 'O' opens a blank line above.

Show another way to use the command: let "n +=10"

((n += 10))

Which is the best choice to reset the read only variable abc below? $ readonly abc="new value"

*None of these answers will reset the variable abc reset abc unset --force abc unset abc

In gawk, the range operator is __________

, comma

Which option is required to run a gawk program file? See command below with missing option. gawk ___ gawkControl.g

-f

Which option is equivalent to this command and option? $ grep --line-number user /var/log/messages > newPatternFile

-n

A disk partition is likely contributing to the slow web services and will likely cause overall system to become unstable. Which partition is sized inadequately and what should it be changed to?

/var should be changed to 100 GB.

What would be the output of this line? $ true && false; echo $?

1

Check for errors in this message log. Count any line that starts with error, with any capitalization, and with any punctuation after it. How many lines indicate an error at the beginning of the line ? Check in /courses/cop3353m-w/quiz1/messages

3

What are the security permissions of this file in numeric/octal format? -rw-r--r-- 1 cnavarro domain users 783K Sep 25 11:41 .hidden

644

Why does the following script: /courses/cop3353m-w/quiz3/finduser produce this message no matter which user name you specify in the first argument? write: $1 is not logged in on pts/x Note: x can be any integer For instance, if cnavarro is logged on to your server, you would run $ /courses/cop3353m-w/quiz3/finduser cnavarro goodbye

A backslash (\) is used incorrectly

What does the following command do $ export PATH=$PATH:/bin2?

Appends the absolute pathname of the bin2 directory that is a subdirectory of your home directory to the PATH variable.

In a bash script, select the best answer... The test utility can:

B. prevent a user from receiving meaningless data by validating the input. A. Verify the status of an argument or the relationship between two arguments. Correct! A, B, and C C. compare an integer to another .

What does this command do? $ chsh

Changes the shell for the user

What information does the --help option display for the tar utility?

Displays examples, descriptions, and usage information.

In the following example, the phrase [RETURN] means to literally press the return key. On the following command line, what is the expected output of: $ echo "Enter the three values \[RETURN]> to end"[RETURN] Note the ">" is the secondary prompt from the 2nd line.

Enter the three values to end

As a Linux administrator, you receive an snmp trap for an error in an apache log. Search in all directories that have "midTermExam" as part of the directory name. (There are two directories. Disregard the directory called "midExam") You will only need to look in the /courses/cop3353m-w/ path. The midTermExam directory with the largest (in size) apache log is the log file you will use to determine the exact error. Using the exact format and punctuation specified here, search for the pattern "Error:" within the apache log that you determine is the largest apache log of all the directories that exist. What is the error code that matches the format "Error:" ?

Error: File system check required

File Permissions: r(Read) = 4 w(Write) = 2 x(Execute) = 1 What does $ chmod 744 do?

Gives read, write, and execute for owner and read only for group and all others.

What do the following options do? FS $5 NR OFS

Input field separator Field in current record record number of current records output field separator

What is the last argument of the following linux command? $ kill -9 8675309

It is the pid of the process to be terminated.

Which output would produce an error? A - $ ls -l -a -s -h B - $ ls -lash

Neither produce an error, they are the same command.

When running the following command, will errors show up in the results file? $ find /etc -name hosts 2>&1 > results

No errors will be in the results file. Standard error will be redirected to the standard output of command one.

Will the following 'last line' vim command save any newly added content when it closes the vim utility? :q!

No. It will not write any newly added content.

Would the following two lines produce the same results? Why or why not? for (( i = 0; i < 30; i++ )) for i in $(seq 0 30)

Non, one will include 30 with the other will not.

The variable $# contains the value of:

Quantity of arguments on the command line.

In the following command, the number (2) references which handle (file descriptor)? $ find /etc -name hosts 2>&1 > results

Standard Error

What happens if the user types cat then [return] with no argument?

Standard input is redirected to the keyboard and the shell waits for the user to type in the next argument.

What does the $PATH command do?

The PATH keyword variable specifies the directories in the order bash should search them when it searches for a script or program you run from the command line

The following script does not function properly? What is the main mistake? #!/bin/bash grep -i "$1" << @ Max June 22 Barbara Febuary 3 Darlene May 8 +

The delimiter is not the same at the beginning and the end of the script.

What happens to the existing content of' yourfile' when you run the following command? echo 'Your new file.' > yourfile

The original content is deleted and replaced with new text.

What does the shell ordinarily do while a command is executing?

The shell enters a sleep state while a command is executing in the foreground.

What does the /etc/passwd file contain?

The user's username, real name, and basic information about their account.

Which command would produce at most 60 columns? A - diff -W 60 filea fileb b - diff --width 60 filea fileb

They are using the same option so the results are the same.

In the following bash script selection, the purpose of the test command is to : if test $# -eq 0 then echo "something"

To check if there were 0 arguments on the command line.

What does the command $ ping do?

Used to test the reachability of a host by transmitting packets to another computer.

Which users have execute permissions for this file (ie owner, groups, other)? d--x--x--- 3 zach pubs 512 2013-03-10 15:16 business

Zach and pubs

Which users have read permissions for this file? drwxr-xr-x 2 zach pubs 512 2013-03-10 15:16 business/milk_co

Zach, pubs, and other

When setting the PS1 variable in bash, which symbol would you use to display the machine hostname, but without the domain?

\h

Absolute pathname, a relative pathname, or a simple filename? /home/max

absolute

Absolute pathname, a relative pathname, or a simple filename? /home/max/literature/promo

absolute

Does the following command use absolute path or relative path? cp /etc/hosts /var/log/newHosts

absolute path

The /etc directory in linux holds:

administrative and configuration files

In the following line from a script, the -a represents ? if [ "$word1" = "$word2" -a "$word2" = "$word3" ]then

and

The advantage of using back ticks in a Bash script is that everything between the backticks is evaluated (executed) by the shell ________ the main command

before

Defining the PS3 variable in bash is ...

best used with the select statement.

The ______ structure is a multiple branch decision structure and the decision made depends on the match or lack of match

case

Rewrite the following three commands as one line using a pipeline: cat /etc/hosts > temp1 grep root < temp1 rm temp1

cat /etc/hosts | grep ember

Re-write the following line in a simplified form using brace expansion: cat /etc/log.d/first.out /etc/log.d/second.out

cat /etc/log.d/{first.out,second.out}

Assume the following command line statement. Select the right answer to assign "j" to the variable catsup used as a positional parameter in a script. $ ./somescript.sh a b c d e f g h I j k l m n o

catsup=${10}

Indicate the following single command line using brace expansion to change the permission of these two files to 711 /courses/cop3353m-w/quiz4/Denmark /courses/cop3353m-w/quiz4/Spain

chmod -v 711 /courses/cop3353m-w/quiz4/{Denmark,Spain}

What is command to give everybody total access to a directory?

chmod a+rwx

What is command to give owner and groups all permissions and other only read permissions?

chmod drwxrwxr

Which is the proper way to assign the string "major" to the variable named chord in a bash script?

chord=major

What needs to be added to the gawk statement in the print command (between $3 and $1 )to place a space between the output fields. Test this command, the output isn't very readable. Adding one thing to the command will improve readability. gawk '/chevy/ {print $3 $1}' cars.txt

comma

In bash, the PS2 variable ...

contains the value of the secondary prompt.

You find that you don't have the correct permissions to actually run the script as the current file. It is your job to determine what the script is actually doing so that it can be classified as safe or not. The script is located in /courses/cop3353m-w/quiz3/ -rwxr--r-- 1 cnavarro domain users 56 Oct 24 16:54 secretScript.sh After an investigation, you determine the script is ...

counting all of the files in the /etc directory that begin with "host".

Using $ bash -x with a script is often used for :

debugging

This command $ echo $HOME produces the same rusults as ...

echo ~

The dollar sign ($) in this regular expression is used to match "success" at the _____________ grep "success$" /someDirectory/someFile

end of the line.

As long as the test-command returns a 0 exit status, the while structure will _____________ a series of commands.

execute

The two following commands produce the same results are completely interchangeable in function. $ export CDPATH=/somepath $export PATH=/somepath

false

Multiple elif statements require only a single closing __________ statement

fi

Rewrite the 'for' line in this script to simplify the script with less text, but still produce the same result: for (( i = 0; i < 200; i++ )) do echo $i done

for i in {0..199}

On centOS Linux, running the awk command actually runs ______

gawk

Considering the following command. $ mkdir ydir;touch ydir/y;cat ydir/x ydir/y 1> holda 2> holdb Which answer would be the most likely?

holdb would contain 'No such file or directory' or some error

The $? variable ...

holds the exit status of the preceding command.

Where will the hosts file be copied to with the following command? $ cp /etc/hosts ~

home directory

What command is missing from the following script causing it to error: /courses/cop3353m-w/quiz4/forLoop.sh

in

Check the following script. The purpose of the script is to list all of the directories in /var/log that are executable. /courses/cop3353m-w/quiz4/dirfiles2.sh Three different if test lines are provided but they are commented out. Which line is the correct if/test line. Use :set number command to see line numbers in vim. Select the correct line number that should be uncommented to allow script to function normally.

line 6 if [ -d "$i" -a -x "$i" ]

To list all files that begin with the word 'host' located inside the /etc directory except files that end in 'conf', which command line would be most effective?

ls /etc/host*[^conf]

If the 'pokedex' directory exists in your home directory as/home/yourName1234/pokedex, what is the most effective command to create two nested subdirectories called 'fire' and 'water'. Use relative path. Assume your home directory is your working directory.

mkdir -p pokedex/fire/water

If your current working directory is '/etc' , what is the best command to make a directory in the '/courses/cop3353m-w' directory called 'newDir' using relative path?

mkdir ../courses/cop3353m-w/newDir

In a bash script, the shell expands $0 to the :

name of the calling program.

What do the following builtin options mean: -ne -gt -ge -lt -le

not equal greater than greater than or equal to less than less than or equal to

In gawk, the following function returns the value of ____________ length()

number of characters in the current record

What does the .. entry in a directory listing point to?

parent directory

Absolute pathname, a relative pathname, or a simple filename? .. /letter.0210

relative

Absolute pathname, a relative pathname, or a simple filename? correspond/business/milk_co

relative

When running the following command, would results4 or results5 have more content? Try comparing the quantity of lines. grep nologin /etc/passwd | tee results4 | grep -v root > results5

results4 would have more content

What processes all commands and shell scripts?

shell

Absolute pathname, a relative pathname, or a simple filename? milk_co

simple

Which command can you use to display the entire file phone in alphabetical order?

sort phone

When using gawk, if you do not specify a file-list, gawk takes input from ______________.

standard input

The following 1st line of this selection from a script ... if [ -f "$1" ] then echo "some stuff"

tests that the 1st argument passed into the script is an ordinary file and not a directory.

What is missing in this gawk program file? BEGIN { for ( n=1; n <= 5; n++) print "2^" n, 2**n

the final curly brace }

The following test if [ $# -eq 0 ] will return true if...?

there are no arguments on the command line after the script name.

Adding more system memory to the system would likely improve the slow web services because system currently has to use swap space. (T/F)?

true

Assume the following lines in a script: #!/bin/bash # finduser.sh script echo $2 Based on the following command line statement, what would be the output of the echo statement in the above script? $ ./finduser.sh csmith tty5

tty5

Remove (clear the contents) of the variable given: $ xyz="focus"

unset xyz

As long as the test-command returns a true status, the ________structure continues to execute a series of commands until, the test-command is false.

while

Can the tar utility be combined with gzip to compress files?

yes

Is the grep utility considered a filter?

yes


Set pelajaran terkait

dwelling policy chapter (property)

View Set

Computer Applications, all tests (WIP)

View Set

Prepu: Topic 6: Psychotic Disorders

View Set

Pediatrics GI: Urinary Elimination Ch.21 Prep U and ATI CH. 24-26

View Set

AFM 131 Module 3: Chapter 7 - Entrepreneurship and Starting a Small Business (Questions)

View Set