Linux+ (Ch. 1-4)

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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?

#82

What are the modes of vi

* Command mode * Command-line mode * Insert mode * Replace mode

What elements do most man pages have?

* Title * Name * Synopsis * Description * Author * Reporting Bugs * Copyright * See Also * Version number and revision date

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 file is in the /root directory, and /root is the current working directory. How would you run the executable file? (Select two.)

./ni /root/ni

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

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

/Sam

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?

/etc/profile

When a login shell is run what files are run in order to setup the environment?

/etc/profile ~/.bash_profile ~/.bash_login ~/.profile

1. 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. 2. The mode that works with the file system. Use it to save files after editing them. 3. The mode that vim uses to write and edit text in the file.

1. Command Mode 2. Command Line Mode 3. Edit Mode

1. Move the cursor up a line. 2. Move the cursor one space to the left. 3. Move the cursor one space to the right. 4. Move the cursor down a line.

1. k 2. h 3. l 4. j

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

:

command-line commands

:exit - writes the current file and then closed vi :wq - writes the current file and closes vi :q - closes the current file without saving but only if no changes have been made. :q! - closes the current file without saving even if changes were made :w - writes the current file :w! - overwrites the current file :e! - forgets changes since the last write :w <filename> - writes to a new filename

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!

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

:wq

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

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

What is the result of the uname -a command?

All system information is displayed on the screen.

sh

Bourne shell first shell

Which of the following options is the standard shell for most Linux computers?

Bourne-again shell (bash)

csh

C Shell uses syntax similar to C programming

vi insert mode

Can be entered using any of the following: i insert s o a used to enter actual text into the document

What man page section shows a list of options available for a Linux command and explain what the options do?

DESCRIPTION

man page section DESCRIPTION

Describes how the command, file, or utility works in detail as well as a list of options that can be used.

man page section NAME

Displays the name of the command, utility or file and gives a short abstract about what it does.

vi command-line mode

Entered into by using the : key. Used to enter file-related tasks such as saving and exiting.

man page section TITLE

First line of the man page and list the name of the utility, command or file discussed in the page along with a section number.

man page section SEE ALSO

Gives a list of man pages or other resources that are related to the current man page.

man page section COPYRIGHT

Gives details about who owns the copyright to the command, utility or service referenced in the man page.

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

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

HISTSIZE

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

Which of the following statements best describes the PATH environment variable?

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 currently working on. What key should you press to accomplish this.

O (Capital o)

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?

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

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

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.)

Press Esc Type :wq

man page section SYNOPSIS

Provides a brief description of the syntax for using the command or utility. If the man page is for a configuration file then this section provides a brief overview of what the file is used for.

uname command

Returns information about the Linux system depending on the option used.

bash

The Bourne again shell improved sh (Bourne Shell)

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.

man page section Version Number and Revision Date

The very last line of the man page displays the version number of the program and revision date.

What are two methods to exit vi from command mode? (Select two. Each answer is an independent solution.)

Type ZZ Type :wq

exec command

When used to run a application or script, it replaces the current running shell (ie. bash) with a new process. Thus when the program or script is done the shell is closed.

zsh

Z Shell improved version of bash shell

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

alias

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 a persistent alias?

alias logcheck="cd /home/mbrown/log; ls -al"

Which of the following commands will create a shortcut to the tail -f /var/log/messages command?

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

Which of the following commands could you use to search man pages for a specific keyword? (Select three.)

apropos man -k whatis

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

bash

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

cat /usr/wordlist1 /usr/wordlist2 | sort

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?

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

Which of the following commands will give the same results as cat < turbo?

cat turbo

Which of the following command redirects standard output to standard error?

cat txtfile 1>&2

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

dd

vi command mode

default mode when opening vi. ESC key returns from any other mode to command mode.

shutdown

depending on the option used will shut down or reboot the system, used only by root

top

displays a list of all applications and processes currently running on the system as well as CPU and memory usage, process IDs and user owner of the process

env

displays the environment variables for the current logged in user

which

displays the full path to a command or utility

man page section AUTHOR

displays the name of the programmer who wrote the command, utility or service referenced in the man page.

netstat

displays the status of the network, including current connections, routing tables, and so on

whoami

displays the username of the currently logged in user

command mode commands

dw - delete word and space after word to right of the cursor de - delete the word but not the space after the word to the right of the cursor d$ - delete from the insertion point to the end of the line dd - delete the entire current line p - insert the text deleted in the last deletion operation after the current cursor location u - undo last action D - deletes the rest of the current line from the cursor position yy - copies the line in which the cursor is located to the buffer a - append after cursor A - append after line C - Change to the end of the line cw - change the current word with new text cc- change the whole line ZZ - saves the current file and exits vi h - move cursor left one character j - moves cursor down one line k - moves cursor up one line l - moves cursor right one line 0 - move cursor to start of current line ctrl-g - displays status line at bottome / - searches for term in file ?/ - searches for previous instance of term

You want to view the number of commands your HISTSIZE environment variable is set to save. You don't want to have to scroll through all the environment variables. Which command 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

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

echo $MANPATH

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

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

env

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

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?

export COMP=1745

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

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

history

tsch

improved C Shell

You are trying to debug a shell script that has the command ls -l 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 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?

man uname

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

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

man page section REPORTING BUGS

provides an e-mail address that can be used to report bugs

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

pwd

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

set

Popular Linux shells

sh (Bourne Shell) bash (Bourne-Again Shell) csh (C Shell) tsch zsh (z Shell)

init 6

shuts down and reboots the OS, run only by root

halt command

shuts down the OS and can only be run by root

reboot

shuts down the OS and restarts it, can only be run by root

init 0

shuts down the OS, run only by root

vi replace mode

similar to overtype mode and is entered by pressing the insert key two times, insert key to enter insert mode then insert key again to enter replace mode.

su

switches from current user account to a new user account, ie su rking will switch to the rking account and all the environment settings with it. su - switches to the root users account. Stands for substitute user (su).

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

tee , ie. cat filename | tee outfilename will show the contents of filename and save it to the outfilename at the same time.

exit

terminates the current running process and shell

What does 2>&1 mean when redirecting output

to send the stderr to the same output as stdout

echo

used to display lines of text to the screen such as environment variables, for example echo $PATH

ifconfig

used to manage network boards installed in the system, can only be run by the network manager.

route

used to view or manipulate the system's routing table

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 network.txt

Which command overcomes the 128 KB shell command size restriction by breaking up long lists of arguements?

xargs

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

yy

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

| (Vertical Bar/Pipe Key)

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?

~/.bash_login

After a user starts a BASH session and the scripts in /etc/profile are applied, what is the next file that could affect the shell session?

~/.bash_profile

Which of the following files would you use to create aliases that are applied when a specific user starts a BASH session? (Select two.)

~/.profile ~/.bashrc


संबंधित स्टडी सेट्स

Food and Nutrition Assistance Programs

View Set

Ch 5 AA Consolidated Financial Statements—Intra-Entity Asset Transactions: Questions

View Set

Discovering Design with Chemistry Test 7

View Set

HIGGINS Chapter 7, HIGGINS Chapter 8, HIGGINS CHAPTER 6, HIGGINS Chapter 9, HIGGINS CHAPTER 4, HIGGINS CHAPTER 3, HIGGINS Chapter 1

View Set

Ch. 26 Care of Patients with Burns

View Set

QUIZ 3: SOLVING EQUATIONS AND INEQUALITIES

View Set

C. Follow protocol for no-show, missed, cancelled or follow-up appt.

View Set