Linux Ch 2 Questions

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which of the following files would you use to create aliases that are applied when a specific user starts a bash session? (Select TWO. Each answer is an independent solution.)

~/.bashrc ~/.profile

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

According to the command help, which of the following options can be added to the killall command to kill a process group instead of just a process? Type killall -h or killall --help at the prompt to answer this question.

-g

A user has requested that each time she presents credentials to log in, a particular entry be written to a log file. This action will only apply to her, and she is using the bash shell. Which of the following configuration files is the BEST to modify to enable this action?

.profile

Type ls -a /hr at the prompt to answer the question. What is the name of the hidden directory in /hr?

.sanford

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

The /etc/shells file contains a list of shells that are available on the current system. Type cat /etc/shells at the prompt to answer the following question: Which of the shells listed below is not available on the system?

/bin/ksh

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

/dev

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 of the following shell configuration files should you place this variable in?

/etc/profile

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

/etc/profile ~./bash_profile

Type pwd at the prompt to answer the following question: What is your current working directory?

/home/wadams

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 contains data files that change constantly, including email, print jobs, and proxy cache files?

/var

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

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

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 command displays a list of the currently defined aliases on the system?

Alias

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

All system information

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

Bourne-again shell(bash)

Your company uses a proprietary graphics program called Imitator that's stored in the /root directory. Maggie Brown (mbrown) needs to create and modify images with the Imitator program. In this lab, your task is to create a symbolic link file to /root/imitator as follows: Use imitator_link as the symbolic link name. Create the file in /home/mbrown.

Complete this lab as follows: At the prompt, type ln -s /root/imitator /home/mbrown/imitator_link. Press Enter to create the symbolic link.

Will Adams (wadams) owns and maintains a database file in /home/wadams called contacts.db. The file holds contact information for perspective clients. Brenda Cassini (bcassini) and Vera Edwards (vedwards) want to access and add contact information to the file to share the data among the three users. In this lab, your task is to create hard link files to /home/wadams/contacts.db as follows: Use contacts_link as the hard link name. Create the file in the following directories:/home/bcassini/home/vedwards

Complete this lab as follows: At the prompt, type ln /home/wadams/contacts.db /home/bcassini/contacts_link and press Enter. Type ln /home/wadams/contacts.db /home/vedwards/contacts_link and press Enter.

You are preparing to manage a new project code named White Horse. You need to prepare directories for White Horse documents. You are logged in as the wadams user. Use the mkdir command to create directories. You may create the directories as follows: Use the mkdir command with the absolute path to the directory you want to create. Navigate to a parent directory and use the mkdir command with a path relative to the current directory. The current working directory is /home/wadams. In this lab, your task is to create the following directories inside the /home directory for wadams as follows: Create a directory called wh directly inside /home/wadams. Create the following directories in /home/wadams/wh: plan research implement When you are finished, use the ls command to verify the creation of the directories.

Complete this lab as follows: At the prompt, type mkdir wh and press Enter. Type mkdir wh/plan and press Enter. Type mkdir wh/research and press Enter. Type mkdir wh/implement and press Enter. Type ls -l /home/wadams/wh and press Enter to verify the creation of the directories.

In this lab, you'll explore the nano editor by configuring DNS name resolution on the ITAdmin workstation. In this lab, your task is to: Use nano /etc/resolv.conf to open the file in the nano editor. Modify the file to include the following information: nameserver 163.128.78.93 nameserver 163.128.80.93 Type CTRL + O to save the file. Type CTRL + X to exit.

Complete this lab as follows: 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.

Someone created duplicate versions of three project documents. To avoid version control problems, you need to delete the duplicate files. Use the rm -f command to delete a file without prompting. In this lab, your task is to delete the following files from the /projects directory: darkhorse1 camouflage1 endgame1 When you're finished, use the ls command to verify the deletion.

Complete this lab as follows: At the prompt, type rm -f /projects/darkhorse1 and press Enter. Type rm -f /projects/camouflage1 and press Enter. Type rm -f /projects/endgame1 and press Enter. Type ls -l /projects to verify the deletion of the files.

The White Horse project is complete. Everything produced under the code name has been backed up and removed from the system. Now you need to remove the White Horse directory structure from your system. The rm command removes the directory and all its contents. The -r option deletes directories and all files in the directories. The -f option deletes without prompting. In this lab, your task is to: Delete the /home/wadams/wh directory and all of its contents.

Complete this lab as follows: At the prompt, type rm -rf wh. Press Enter to delete a directory and all of its contents.

Your company recently changed directions and decided to terminate three products. All of the necessary files have been backed up, archived, and deleted. Now, you need to remove the directories from the /projects directory. Because the directories are empty, use the rmdir command to delete each directory. You can use absolute paths or change into the parent directory to delete each directory. In this lab, your task is to delete the following directories in the /projects directory: heartbt heartmon heartstrng When you're finished, use the ls command to verify the deletion.

Complete this lab as follows: At the prompt, type rmdir /projects/heartbt and press Enter. Type rmdir /projects/heartmon and press Enter. Type rmdir /projects/heartstrng and press Enter. Type ls -l /projects and press Enter to verify the deletion of the files.

Peter Lacy (placy) has taken an extended leave from the company for personal reasons. However, he was working on a critical project code named White Horse with several other employees. The project leader requested that you move any White Horse documents in Peter Lacy's home directory to Brenda Cassini's (bcassini's) home directory. You're logged on as wadams. Use the mv command to move files. You must log in as the root user to have the necessary permissions to move other people's files. In this lab, your task is to: Switch to the root user using 1worm4b8 for the root user password. You must have root user permissions to move other people's files. Move the following files in placy's home directory to bcassini's home directory. confid_wh projplan_wh When you're finished, use the ls command to verify the new location of the files.

Complete this lab as follows: At the prompt, type su - and press Enter. Type 1worm4b8 as the password and press Enter. Type mv /home/placy/confid_wh /home/bcassini and press Enter. Type mv /home/placy/projplan_wh /home/bcassini and press Enter. Type ls -l /home/bcassini and press Enter to verify the new location of the files.

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. In this lab, your task is to: Open /etc/pref_shell in vim. Modify the environmental variable line SHELL=/bin/csh to read SHELL=/bin/tcsh. Save your changes.

Complete this lab as follows: 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.

You need to create a script file in vim editor to change and export the SHELL environmental variable as the C-shell. In this lab, your task is to: Open the vim editor with a new file named /etc/pref_shell. Add the following lines to the file:SHELL=/bin/cshexport SHELL Save and close the file.

Complete this lab as follows: 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 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.

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

Which values are set for the following environment variables? Type echo $variable at the prompt to answer the question. The variables are case sensitive.

HOME /root LANG en_US.UTF-8 SHELL /bin/bash TERM linux

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?

II

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

It contains the directory prefixes 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.

Match the vi command on the left with the description of the cursor movement the on the right.

Move the cursor up a line. (k) Move the cursor one space to the left. (h) Move the cursor one space to the right. (I) Move the cursor down a line. (j)

View the contents of the /root/.bash_profile file. Type cat /root/.bash_profile at the prompt to answer the question. What is the last word in the file?

PATH

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

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

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

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

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

What does the -M switch do when used with the useradd command? Type useradd -h or useradd --help at the prompt to answer the question.

The home directory is not created, regardless of system settings.

Match the vi mode on the left to the correct definition on the right.

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) The vi mode that works with the file system. Use it to save files after editing them. (Command Line Mode) The vi mode that vim uses to write and edit text in the file. (Edit Mode)

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.

Ted, a Linux user, creates symbolic links in his home directory to 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.

According to the command help, which of the following is the result of adding -G to the usermod command as a single option? Type usermod -h or usermod --help at the prompt to answer the question.

The user is assigned to a new list of supplementary groups.

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

Type :wq Press the Esc key

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

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

You need to view detailed information for the hr directory in the root (/) directory. Type ls -l / at the prompt to answer the following questions

What is the directory size? 12586 What is the modified date? March 15 2009

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

^G (Ctrl+G)

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: cd /home/mbrown/logs ls -al She wants a persistent alias named logcheck 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"

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 name allfiles?

allfiles=$(ls-a)

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 results 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 ith all of its files, sub- directories, and files in the sub-directories to the /home/gshant directory . (Select TWO. Each answer represents and 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

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

Leroy needs to create a link to a file in the /opt/corp directory that points to the original file in /usr/bin directory. The file is named "scrub". The /opt directory is on a separate physical drive with a separate file system than /usr/bin. Which of the following commands will work?

ln -s /usr/bin/scrub /opt/corp/scrub

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

ls -a /home/jerrys

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 name ~/Friday in order to examine it later.

ls-s &> ~/Friday

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

lsattr /boot/grub/grub.conf

Which of the following commands searches man pages for a specific keyword? (Select THREE.)

man -k apropos whatis

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/pracle/database/9i

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

mv

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

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

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

myscript >> testfile.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

Within the /var directory is a sub-directory named backup. Ken, a Linux administrator, needs to delete the directory 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 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 smp

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 smp

A user, ljenkins, contacts the help desk about and 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:

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/smilefile's modification and last accessed times to the current time?

touch /home/gshants/smile

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 pies the output of one command as the input of another command?

|

After a user starts a bash session and the script in /etc/profile is applied, if all of the following files exist, which will be run next?

~/.bash_profile


Ensembles d'études connexes

Unit 1-3 Vocab. F words and G words

View Set

We the People Supreme Court Cases

View Set

Drone certification reference questions

View Set

chapter 1. what is statistics? smartbook

View Set

1125 PrepU Teaching & Learning/Patient Education

View Set

MNMT 300: CH 8 Learning and Decision Making

View Set