Testout Chapter 1 Linux Admin Midterm 2.19.19 1.1-1.11

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

What is the result of the uname -a command?

All system information is displayed on the screen. uname -a prints all system information.

The mode that works with the file system. Use it to save files after editing them.

Command line mode

What line must you add to /etc/profile to make sure /sbin/custom is always part of the PATH environment variable for all users, without overwriting the current entries in the PATH statement? is always part of the PATH environment for all users

PATH=$PATH:/sbin/custom; export PATH

The user mbrown has a directory named logs in her home directory that is regularly updated with new log files when certain system events occur. She runs the following commands several times a week to check this directory: cd /home/mbrown/logs ls -al She wants a persistent alias named logcheck to be created to run these two commands. What command would you enter into her shell configuration file to create this persistent alias?

alias logcheck="cd /home/mbrown/logs;ls -al" the two commands need to be inside quotes and separated by a semi-colon (;).

Which of the following commands will give the same results as cat < turbo? cat 1> turbo cat 2> turbo cat turbo cat 1&2> turbo

cat turbo The cat turbo command performs the same function. The default operation of the cat utility is to read and display a file. (You get the same result whether you use the input operator or not)

Which command will display only the environment variables applied to child sessions?

env

Which command will display all the environment variables?

env Use the env utility to display a list of all the environment variables and their values

You have the myapp executable file. It is found in the current directory, but not in the command path. What would you enter at the command prompt to start the myapp file and replace the shell with myapp process?

exec ./myapp Use exec ./myapp to start the myapp executable file and replace the shell with myapp process. The exec command executes an executable not found in the command path. It will also replace the shell with the new process created by the executable file. The ./ indicates that the executable is in the current directory.

You recently used the HOST=FS4 command. What command should you use to make the environment variable to apply to all child sessions?

export HOST Use export HOST to make the variable apply to all child sessions.

Which command displays all lines in ~/smarts, omitting the last 10 lines?

head -n -10 ~/smarts (head -n -10 filename) Use head -n -10 ~/smarts to display all lines in the file, omitting the last 10 lines.

What command should you enter to see a list of all the commands you recently used at the command prompt?

history

Which of the following statements best describes the nl -s ": " myfile command?

nl adds the number, a colon, and a space to the front of each line in the file.

A friend sent you a shell script file that is 117 lines long. He says that he wants you to examine code on lines 82 through 87. What command would you enter while in vi command mode to go directly to line 82? (while in command mode)

#82

Move the cursor in vi left,down,up,right

(left) Move the cursor one space to the left: h (down) Move the cursor down a line: j (up) Move the cursor up a line: k (right) Move the cursor one space to the right: l h moves the cursor one space to the left j moves the cursor down a line k moves the cursor up a line l moves the cursor one space to the right

A user is requesting that each time she logs in, a particular entry be written to a log file. This will only apply to her and she is using the bash shell. In which configuration file would you make an entry for this action to take place?

.profile The .profile file exists within the user's home directory and is executed upon each login. Placing the entry here will allow for each time she logs in for a particular entry to be written to a file only for this user. While placing it in /etc/profile would make it applicable for all users.

What command would you enter while in vi command mode to find the term Sam?

/Sam or ?Sam Use /Sam to search forward for all instances of a term. Use ?Sam to search backward for all instances of a term.

All users at your site are using the Bash shell. You want to set a variable that will apply to every user and always have the same value. Which file would you place this variable in? .bash_profile /etc/profile .bash_login .bashrc

/etc/profile The values in /etc/profile are set for every user.

You have an executable file named ni that allows you to save a snapshot of your network information with the date and time into a log file. The (executable) file is in the /root directory, and /root is the current working directory. How would you run the executable file? (Select two.) /root/ni source ni ni ./ni

/root/ni ./ni To run an executable, you can either change to the directory where the script is held and use ./name Or use the absolute path to run the script from anywhere. You cannot just type the script name because the current working directory is not in your PATH variable. (current working directory is /root)

After opening a file in vi, you want to switch from command mode to command line mode. What key should enter?

: Typing : enters command line mode from command mode.

You have opened the /root/myscript file in vi. While looking at the file, your soda spilled, and you hit several keys on the keyboard trying to pick it back up. There are extra characters everywhere in the file, and you know you can't fix it. How do you exit vi without saving the changes?

:q! Use the :q! command to exit without saving the changes made to a file. You can exit vi without saving the changes using the :q command only if you didn't make any changes to the file.

Which key combination should you press in vi to save the file you are working on and quit?

:wq To enter command mode, you must press the colon (:) followed by the actions you want to take. The actions to take in this case are to write the file (save it), and quit.

You must do which of the following to define a persistent alias?

Add the command defining the alias to the appropriate shell configuration file.

Which of the following options is the standard shell for most Linux computers? Korn Bourne-again shell (bash) Bourne shell tcsh C-shell

Bourne-again shell (bash)

The initial vim mode used when vim is started. It has commands that cut and replace text, and it is the mode vi uses to enter the other modes.

Command mode

Following is a list of the four sections typically found in a man page. Which of these shows a list of options available for a Linux command and explain what the options do? shows a list of options available for a Linux command and explains what the options do. NAME TITLE SYNOPSIS DESCRIPTION

DESCRIPTION

The mode that vim uses to write and edit text in the file.

Edit mode

Which of the following commands will configure the shell to retain 300 recently-used commands in the ~/.bash_history file for multiple shell sessions?

HISTFILESIZE=300 Use HISTFILESIZE=300 to specify the number of past commands remembered between multiple sessions.

Which environment variable affects the number of past commands used in the current shell session?

HISTSIZE

Which statement best describes the PATH environment variable? It specifies the filename where past commands are stored. It contains the path of the current working directory. It contains the directory prefixes used to search for programs and files. It specifies the characters the shell uses to indicate normal user ($), root user (#), and similar items.

It contains the directory prefixes used to search for programs and files.

You are editing a text file with vi and need to open a new line above the one you are currently working on. What key should you press to accomplish this?

O Pressing the capital O will open a new line above the one you are currently working on.

You want the directory /sbin/special to always be a part of the PATH. You also want to keep all the current entries in your PATH statement. Which of the following commands would you use? PATH=$PATH:$/sbin/special PATH=PATH&/sbin/special PATH=/sbin/special PATH=$PATH:/sbin/special

PATH=$PATH:/sbin/special A colon separates entries in the PATH statement, so one must be added to the end of the existing PATH ($PATH), and then the new directory specification appended. Using the absolute path, /sbin/special, identify the path to the directory you want to add.

Which of the following statements best describes the split -50 -d -a 3 AllNames FiftyNames- command if there are 103 lines and 240 bytes in the file? 103 lines in Allnames file

The Allnames file is split into three files containing 50 lines or less. The output is FiftyNames-001, FiftyNames-002, and FiftyNames-003. split -50 -d -a 3 Allnames FiftyNames- splits Allnames file into three individual files containing 50 lines each from the content of the Allnames file. The output is FiftyNames-001, FiftyNames-002, and FiftyNames-003 Use split to split lines of text from a file or text stream into segments of a specified number of lines. -d tells split to use numeric suffixes in the output files created rather than alphabetic -a specifies the number of characters in the suffix in the output files created

Which of the following presents the greatest security risk?

The PATH statement includes . (period)

What will be the effect of the following command? ls -l /usr/bin >> /tmp/list.txt

The contents of the /usr/bin directory will be redirected into a file called /tmp/list.txt, inserted after previous contents of the file.

You made a few changes to the /boot/grub/grub.conf file and now you need to exit out of insert mode, save the changes, and quit. What should you do? (Select two. Each answer is a required part of the solution.) Type :wq Type :w! Press Esc Type :q!

Type :wq Press Esc To exit out of edit mode and save the changes: Press Esc to enter the command mode from edit mode. Type :wq to enter command line mode from command mode, save the current document, and exit vim.

What are two methods to exit vi from command mode? (Select two. Each answer is an independent solution) Type :wq Type:e! Type yy Type ZZ

Type :wq Type ZZ Type ZZ or :wq to exit vi from command mode.

Which command will display a list of the currently defined aliases on the system?

alias

Which of the following commands will create a shortcut to the tail -f /var/log/messages command? export alias="tail -f /var/log/messages" env alias="tail -f /var/log/messages" export alias sysmesg="tail -f /var/log/messages" alias sysmesg="tail -f /var/log/messages"

alias sysmesg="tail -f /var/log/messages"

. You are using awk to print a sorted list of the user names in /etc/passwd. which command will accomplish the sorted output?

awk -F: '{print $1}' /etc/passwd | sort The -F: indicates that the file separator is a colon (:), the separator that is used in the /etc/passwd file.

What would you enter at the command prompt to start a new Bourne-again shell (bash) session?

bash

Which of the following commands displays the contents of wordlist1 and wordlist2 then sorts the combined contents, then sends the results to the monitor and a file named sortedwordlist? displays output AND sends results/standard output to file sortedwordlist

cat /usr/wordlist1 /usr/wordlist2 | sort | tee sortedwordlist cat wordlist1 wordlist2 | sort | tee sortedwordlist

Which of the following commands redirects standard output to standard error? cat txtfile | tee 2 cat txtfile | 2 cat txtfile 1>&2 cat txtfile 2>&1

cat txtfile 1>&2 1>&2 redirects standard output to standard error when executed with a command.

Which of the following commands sorts the contents of wordlist1 and wordlist2 and sends the result to standard output?

cat wordlist1 wordlist2 | sort cat /usr/wordlist1 /usr/wordlist2 | sort because same as cat < /usr/wordlist1 /usr/wordlist2 | sort

You need to obtain specific information found in the columns of ~/smarts. Which of following commands should you use?

cut -f ~/smarts Use cut -f ~/smarts to obtain specific information found in the columns of ~/smarts. Use cut to remove characters and fields from lines of text in a text stream or file. The command uses its options to determine whether to cut characters or fields and sends the results to standard output. cut -f cuts fields

Which of the following commands will cut an entire line from a file while in vi command mode?

dd While in command mode, use dd to cut an entire line from the text.

Which commands shows you the value for the HISTSIZE variable?

echo $HISTSIZE

Which command shows the value of the LANG environmental variable currently set for the language the operating system uses?

echo $LANG Use the echo command to see the value of a variable. To specify an environmental variable, precede the name of the variable with a dollar sign ($).

What command can be used on most Linux distributions to find the directories where the man pages are kept? find directories where man pages are kept?

echo $MANPATH the MANPATH environment variable contains a list of directories where man pages are stored.

Two users should have identical settings, yet one is having problems with the display on his screen and you suspect there is a difference in their environment variables. Which command will display all the environment variables?

env

You need to change how the formatting displays the /home/varstown file. Specifically, you need to replace each tab character with 3 spaces when you print the file to the screen. What command should you enter at the command prompt? change the tab characters into custom amount of spaces

expand -t 3 /home/varstown

You need to set the COMP variable to the value 1745. Which command will set the variable so it is available to other shell programs? so it is available to other shell programs

export COMP=1745 Use the export COMP=1745 command to set the variable.

You are accessing the /home/shants/depsmark text file through a terminal connection. The file has long lines of text, yet your terminal only shows 75 characters per line. What should you use to limit the lines in the file to the limits on the terminal?

fmt /home/shants/depsmark Use fmt filename to format lines in the file with a uniform length of 75 characters. -w specifies the number of characters for the width. The default is 75 Use fmt to format line in a file or text stream to a uniform length. This is useful to format files with long lines to fit in a terminal.

If you are viewing the contents of a man page, which key can you press to get back to the beginning of the page?

home

What commonly predefined alias is configured to run the ls -l command?

ll The ll command is actually a commonly predefined alias that runs the ls -l command to list the contents of a directory in long form.

You are trying to debug a shell script that has the command ls -s in it. You suspect an error is occurring here and want to send the results of the operation (successful or error) to a file named Friday in order to examine it later. Which of the following commands should you use? ls -s >> Friday ls -s Friday ls -s > Friday ls -s> Friday 2>&1

ls -s> Friday 2>&1 or ls -s > Friday 2>&1

You are working on a Linux system and need more information about the uname command. What would you enter at the command prompt to learn about the uname command syntax and options? uname command syntax and options?

man uname (also info uname, uname --help)

You are trying to debug a shell script called myscript and to aid you in this task you would like to have the output of the script be recorded in a text file. Which of the following commands would satisfy your requirements? myscript >>testfile.txt myscript | testfile.txt echo myscript >> testfile.txt myscript | echo | testfile.txt

myscript >>testfile.txt myscript >> testfile.txt myscript >>testfile.txt is the correct answer because the >> redirector redirects the output of a command, in this case a script called myscript, into a file.

While in command mode, you copied a whole line of text to memory. You navigated to a different location in the file, and now you need to place the line of text. What command should you use?

p Use p to place text in from memory into the document while in command mode.

Which command will merge two files on a line-by-line basis, and separate each line with a tab?

paste use paste to add the contents of one file to the contents of another file on a line-by-line basis. paste -d specifies a character to place between the conjoined lines of each file. The default is a tab.

You need to change the formatting of the /home/varstown file as it prints. Specifically, you need to add double-spacing to each line in the file. How should you enter the command at the command prompt? add double-spacing to each line in the file

pr -d /home/varstown Use pr -d /home/varstown to add double-spacing to the /home/varstown file for printing.

What would you enter at the command prompt to display the present working directory?

pwd

You want to issue a simple command to replace all occurrences of the string foo with the string bar in the file myfile.txt. You have decided to use sed Which line will work?

sed -e 's/foo/bar/g' myfile.txt the sed -e 's/foo/bar/g' myfile.txt command replaces all the occurrences of foo with bar in myfile.txt. The s means substitute /foo/bar/ foo with bar. the g means global. the file to act on is myfile.txt

Which command will display all the environment variables on the system? on the system

set The set command displays all the environment variables on the Linux system. The env command displays the values for environment variables applied to child sessions. set: system environment variables env: exported environment variables

Which command will display each line in a text file based on the alphabetical characters?

sort use sort to sort each line of text in a file or from a text stream alphabetically.

Which command reads from standard input and writes to standard output and files?

tee The tee command reads from standard input and writes to standard output and files.

Which command transposes characters in a text stream?

tr Use tr to transpose characters in a text stream. The command uses two character sets. The first set specifies the characters to be changed and the second set specifies what they should be changed to.

You need to change how the /home/varstown file is displayed. Specifically, you need to replace 4 consecutive spaces with a tab when you print the file to the screen. How should you enter the command at the command prompt? change the consecutive spaces into tabs

unexpand -t 4 /home/varstown to replace 4 consecutive spaces in the file with 1 tab. unexpand changes spaces into a tab. The default is 8 spaces; however, the -t options specifies the number of spaces to change.

Which text stream processing command filters identical, adjacent lines from a single file?

uniq Use uniq to filter identical lines from a file. The lines must be adjacent.

You need to create a new text file with the name network.txt in the current directory. Which command starts vi and creates the file? vi -new network.txt vi network.txt vi :w network.txt vi -n network.txt

vi network.txt

At the command prompt, how would you enter a command that will print the line count, word count, and byte count in the /home/gshant/servepath file?

wc /home/gshant/servepath or wc -lwc /home/gshant/servepath

Which of the following commands could you use to search man pages for a specific keyword? search man pages for a specific keyword?

whatis man -k apropos

Which command overcomes the 128kb shell command size restriction by breaking up long lists of arguments

xargs The xargs command reads items from the standard input and breaks up long lists of arguments into smaller, usable lists.

What command would you enter while in vi command mode to copy an entire line of text?

yy Use yy while in command mode to copy an entire line of text into memory.

Which symbol uses the output of one command as the input of another command?

| The pipe (|) symbol redirects the output of one command into the input of another command.

Your default target on your Linux system is set to multi-user mode; however, you want the X Windows System to launch when you log into the system. Which file should you edit? when you login to the system

~/.bash_login

After a user starts a BASH session and the scripts in /etc/profile are applied, ~/.bash_logout ~/.profile ~/.bash_profile ~/.bash_login

~/.bash_profile Login shells execute the configuration scripts they use in the following order: 1. /etc/profile 2. ~/.bash_profile 3. ~/.bash_login 4. ~/.profile

Which of the following files would you use to create aliases that are applied when a specific user starts a BASH session? ~/.profile ~/.bash_logout ~/.bashrc /etc/profile

~/.profile ~/.bashrc


Kaugnay na mga set ng pag-aaral

Chapter 10 - Blood Gas Monitoring

View Set

Chapter Three- Project Management Processes

View Set

Chapter 14: Global Climate Change

View Set