Chappa 2 - files, terminals, editors, shells

अब 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

Which of the following paths represents the root directory?

/

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

/Sam

Under the Filesystem Hierarchy Standard (FHS), what is the full path to the directory that contains the device files for a Linux system?

/dev

According to the Filesystem Hierarchy Standard (FHS), which of the following directories contains information about the system state and processes?

/proc

Which of the following directories is the home directory for the root user account?

/root

A Linux user has an executable file named ni that can save a snapshot of network information with the date and time in a log file. The executable ni file is in the /root directory, and /root is the current working directory. Which of the following commands would run the executable file? (Select TWO).

/root/ni ./ni

What is the full path to the directory that holds the man files on the system?

/usr/man

What is the full path to the directory that contains data files that change constantly, including email, print jobs, and proxy cache files?

/var

After opening a file in vi, you want to switch from Command Mode to Command Line Mode. What key invokes Command Line Mode?

:

As an administrator, you are tasked with configuring an Apache web server by modifying the /etc/apache2/apache2.conf file. You open the file in vi. As you're looking at the file, you knock your spill-proof drink container onto the keyboard. It rolls over several keys as you try to pick it up. Now there are extra characters everywhere in the text buffer. Which of the following commands can you use to exit vi without saving any changes that were made to the text buffer?

:q!

Which of the following vi key combinations should you press while in Insert Mode to save the file you are working on and quit?

<Esc>:wq

Which of the following actions can be used to define a persistent alias?

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

Which of the following is displayed when the uname -a command is run?

All system information

In this lab, you'll explore the nano editor by configuring DNS name resolution on the ITAdmin workstation.

At the prompt, type nano /etc/resolv.conf and press Enter. Type nameserver 163.128.78.93 and press Enter to start a new line. Type nameserver 163.128.80.93. Type Ctrl + O. Press Enter to save the file. Type Ctrl + X to exit the editor.

You have just added a custom script to change and export the SHELL environmental variable as the C shell. However, you decided to change from the C shell to tsch.

At the prompt, type vi /etc/pref_shell and press Enter to open the file. Press a to edit the file. Move the cursor to the line SHELL=/bin/csh and insert a t to make the line read SHELL=/bin/tcsh. Press the Esc key. Type :wq and press Enter to save the changes and exit.

Sec 2 Create a new file - You need to create a script file in vim editor to change and export the SHELL environmental variable as the C-shell.

At the prompt, type vi /etc/pref_shell and press Enter to open vim and create the file. Press the a key to enter insert mode. Type the following text:SHELL=/bin/cshexport SHELL Press the Esc key to exit insert mode. Type : to enter command line mode. Type wq and press Enter to save the file and exit.

Which of the following is the standard shell for MOST Linux computers?

Bourne-again shell (bash)

The initial vi 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

Which of the following man page sections shows a list of options available for a Linux command and explains what the options do?

DESCRIPTION

Which of the following is a characteristic of a symbolic link?

Distinct (non-duplicate) inode.

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

Edit Mode

Which of the following commands configures 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 stored in memory 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.

Which of the following nano text editor features makes it easier for beginners to learn than the vi text editor?

Keyboard shortcuts are displayed at the bottom of the editor.

You want the directory /sbin/special to be include in the PATH environment variable. You also want to keep all the current directory entries currently in the PATH variable. Which of the following commands would you use?

PATH=$PATH:/sbin/special

Using the vi editor in Insert Mode, you made a few changes to the /boot/grub/grub.conf file. You now need to switch to command mode, save the changes, and quit. Which of the following keystrokes and commands should you use? (Select TWO.) (Each answer is a required part of the solution.)

Press the Esc key Type :wq

Drag the permission string on the left to the category on the right. Some permission strings will not be used.

Symbolic link: lrwxrwxrwx Hard link: -rwxr-xr-x

Which of the following statements BEST describe the purpose of the Filesystem Hierarchy Standard (FHS)? (Select TWO).

The FHS allows users to predict where to find system configuration files. The FHS allows software installation routines to predict where to place configuration files.

Which of the following describes the effects of the ls -l /usr/bin >> /tmp/list.txt command?

The contents of the /usr/bin directory are written to a file named /tmp/list.txt. Previous file contents are kept, and the new information is added at the end of the file.

The ls command in the current working directory gives the following listing: lrwxrwxrwx 1 root root 4 2010-11-05 mydata -> shantsgems-rwxr-xr-x 1 root root 382 2010-10-05 shantsgems Which of the following is true of the files in this listing?

The mydata file is a symbolic link to the shantsgems file.

Leroy tries to copy some files to an ext3 volume and received the following error: "No space left on device." Leroy executes the df command and determines that there is sufficient space to copy the files. He also verifies that he has permission to copy the files. Which of the following BEST describes Leroy's problem?

The number of inodes has been exhausted.

Ted, a Linux user, creates symbolic links in his home directory to a set of files in their /data directory using the ln -s command. Later, a system administrator deletes the files in the /data directory. What happens to the symbolic links that Ted created?

The symbolic links still exist in Ted's home directory, but they are useless because the link has been broken.

Command Line Mode

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

Which of the following statement describes file globbing?

Using wildcards to match specific files

Which of the following is a characteristic of a hard link?

Valid inode for the file data even if the original file is deleted.

mv /home/pmallory/reports /home/pmallory/reports.bak

Which of the following commands will change the /home/pmallory/reports file's name to reports.bak?

Which of the following nano editor keyboard shortcuts will display help text which includes a list of all keyboard shortcuts.

^G (Ctrl+G)

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

alias

Which of the following commands creates a shortcut that can be used to run the tail -f /var/log/messages command?

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

Which of the following commands stores the output of the ls -a command in a shell variable named allfiles?

allfiles=$(ls -a)

Which of the following commands searches 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 can be used to combine the content of three files into a single text stream?

cat

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

cat /usr/wordlist1 /usr/wordlist2 | sort

Which of the following commands sorts the combined contents of the wordlist1 and wordlist2 files and sends the results to both the screen and a file named sortedwordlist?

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

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

cat turbo

Which of the following command copies the entire /temp directory with all of its files, sub-directories, and files in the sub-directories to the /home/gshant directory. (Select TWO. Each answer represents an independent solution.)

cp -R /temp /home/gshant cp -r /temp /home/gshant

A Linux administrator is logged in as root and needs to copy a file named letter.doc from the USB flash drive mounted under /media/usb. Which of the following commands will copy the file from the USB flash drive to the root user's home directory?

cp /media/usb/letter.doc /root

Tom, a shell script developer, knows that the date +%A command gives the current local weekday name (Sunday, Monday, Tuesday, ...). Which of the following commands will copy the authentication log file, /var/log/auth.log, to a new file that with a filename that includes the current local weekday name?

cp /var/log/auth.log ~/auth$(date +%A).log

You want to view the number of commands your bash shell is set to save by examining the current HISTSIZE environment variable. You don't want to have to scroll through all the environment variables. Which of the following commands is the BEST way to determine the current value of the HISTSIZE variable?

echo $HISTSIZE

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

echo $LANG

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 of the following commands displays all of the environment variables?

env

As a Linux user, you have access to an executable file named myapp. It's 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 of the following commands sets the variable so it is inherited by subsequent child shells?

export COMP=1745

You recently used the HOST=FS4 command. Which of the following commands should you use to change the HOST variable to a global variable that will be inherited by subsequent child shells and processes?

export HOST

Tim, a technician, created a local variable named val and set it to 5000 at the bash prompt. Tim wants to use the variable in a script. But when the script is executed, the value of val is not set to 5000. Which of the following commands would allow Tim to set a global variable that would be available to the script?

export val=5000

What would you enter at the command prompt to display a file's type?

file

You need to find all files in the /home/gshant directory that are larger than 300K. You change your directory to /home/gshant. What would you enter at the command prompt to find these files?

find -size +300k

Which of the following commands finds all of the files on the system that have either blue or gold in their names?

find / -name '*blue*' -o -name '*gold*'

Which of the following commands finds files with the .txt extension in the /home/gshant directory?

find /home/gshant -name '*.txt'

Which if the following commands displays the user groups that dblair is a member of?

grep -e dblair /etc/group

Which of the following commands displays all the lines in the blue_and_gold file that do not contain the word 'Karen'?

grep -v Karen blue_and_gold

Which of the following commands displays all lines within the MTS file that have the word "world" within them?

grep world MTS

vi - Move the cursor one space to the left.

h

Which of the following commands should a Linux user enter to see a list of all the commands the user recently ran at the command prompt?

history

vi - Move the cursor down a line.

j

vi - Move the cursor up a line.

k

vi - Move the cursor one space to the right.

l

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

ll

Which of the following commands is used to find a specific file on a Linux system? (Select TWO. Each answer represents an independent solution.)

locate find

You need to view the contents of the /home/jerrys directory. What would you enter at the command prompt to show all the contents, including hidden files and directories?

ls -a

Mary Brown is a Linux user with the username mbrown. Mary 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:

ls -al cd /home/mbrown/logs

Which of the following commands displays an expanded listing that includes the owner and size of all the files in the /etc directory?

ls -al /etc

A user attempts to view the contents of a directory, but the output of the ls -l command scrolls beyond the limit of one console window. Which of the following commands would allow the users to see the full listing of the directory?

ls -l | less

Ann, a Linux script developer, is trying to debug a shell script that has the command ls -s in it. She suspects that an error is occurring, and she wants to send the results of the operation and any errors to a file named ~/Friday in order to examine it later. Which of the following commands should she use?

ls -s &> ~/Friday

Which of the following commands will display the attributes of a /boot/grub/grub.conf file?

lsattr /boot/grub/grub.conf

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

Fred, a Linux administrator, needs to create the directory /var/oracle/database/9i. Only the directory /var currently exists. The current working directory is the root of the filesystem. Which of the following commands will create the directory path?

mkdir -p /var/oracle/database/9i

Which of the following commands will move a file from one location to another?

mv

Joe, a bash script developer, is trying to debug a shell script named myscript. Which of the following commands would record the output of the script in a text file?

myscript >> testfile.txt

Which of the following commands utilize command substitution? (Choose TWO.)

myvar=`sort -r names.txt` myvar=$(sort -r names.txt)

While in vi Command Mode, you copy a whole line of text to the general buffer. You then navigate to a different location in the file. Which of the following commands will paste the copied text?

p

Which command displays all the environment variables defined in the shell?

printenv

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

pwd

The /home/gshant/smp directory contains several files. The directory and files need to be removed. The current working directory is /home/gshant. What would you enter at the command prompt to remove the smp directory and all the files it contains?

rm -r /home/gshant/smp

Within the /var directory is a subdirectory named backup. Ken, a Linux administrator, needs to delete the directory backup and any files that it contains. He changes directory focus to /var. Which of the following commands deletes the directory named backup and any file it contains?

rm -r backup

The /home/gshant/smp directory is empty and needs to be removed. The current working directory is /home/gshant. What would you enter at the command prompt to remove the smp directory?

rmdir /home/gshant/smp

----- ABSOLUTE UNIT of a question incoming. hold on folks ----- A user, ljenkins, contacts the help desk about an error received while removing a file from their home directory. The user received the following error when trying to use the rm command to remove the file: [ljenkins@fileserver]$ rm report.txtrm: remove write-protected regular empty file 'myfile2.txt'? yrm: cannot remove 'myfile2.txt': Operation not permitted While troubleshooting the issue, you list files in directory to see if you can discover the issue: [ljenkins@fileserver]$ ls -al total 4drwxr-xr-x. 2 ljenkins ljenkins 24 Feb 25 12:04 .drwx 15 ljenkins ljenkins 4096 Feb 25 11:04 ..-rw-rw-r--. 1 ljenkins ljenkins 346 Feb 25 11:32 report.txt When prompted to remove the write-protected file, ljenkins entered yes and received an "Operation not permitted" error message. As the help desk technician, you attempt to remove the file with root privilages and recive the same error message. You decide to view the file attributes and receive the following output: [helpdesk@fileserver]$ lsattr ----I----------- ./report.txt

sudo chattr -i report.txt && rm report.txt

Which command reads from standard input (stdin) and writes to both standard output (stdout) and a file?

tee

Which of the following commands will change the /home/gshants/smile file's modification and last accessed times to the current time?

touch /home/gshants/smil

After using the locate command, you discover some of your files are not being listed in the search results. What would you enter at the command prompt to update the /var/log/locatedb file?

updatedb

Which of the following utilities would you use to search a path for files that match a given name?

which photorec

You use a program on your Linux system called photorec. What would you enter at the command prompt to display the path to the photorec binary file?

which photorec

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

xargs

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

yy

Which command operator pipes the output of one command as the input of another command?

|

Anna, a system administrator, wants to set a global variable that can be used each time she logs in. Currently, she has to set the variable each time a terminal is opened. Which of the following files would need to be modified to make a global variable persistent? (Choose TWO.)

~./bash_profile /etc/profile


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

CSA+ Threat Management Ch1 Part 3/3

View Set

Chapter 13: Protists, Fungi & Viruses

View Set

Chapter 9b: Inventory Management

View Set

Head-to-Toe Assessment (Chapter 28)

View Set

Intro to Organizational Behavior Chapter 1

View Set

Disorders of Sodium and Water Balance

View Set