Ch 2 Using Linux

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

All system information

You want to make an alias persistent across all reboots of your Linux server. In which of the following files do you need to place the alias command to make the alias persistent?

/etc/profile /home/user/.bashrc

You have just entered the apropos grep command at the command prompt. What can you expect to be displayed?

A one-line man page description for the grep command.

You are managing a Linux server with a console (without a GUI installed). Which of the following key combinations would you press to switch to the fourth shell session?

Ctrl+Alt+F4

Match the nano shortcut on the left to the correct shortcut definition on the right.

Cuts the current line (or selected text) and stores it in the cutbuffer. ^K (Ctrl+K) Closes the current buffer or exits from nano. ^X (Ctrl+X) Uncuts (pastes) the text from the cutbuffer into the current line. ^U (Ctrl+U) Moves forward one word in the current line. ^Space (Ctrl+Space) Displays the help text, which includes a list of all keyboard shortcuts. ^G (Ctrl+G)

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

touch /home/gshants/smile

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

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

#82

As an IT 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 commands configures the shell to retain 300 recently used commands in the ~/.bash_history file for multiple shell sessions?

HISTFILESIZE=300

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 would you enter at a command prompt to start a new Bourne again shell (Bash) session?

bash

Which of the following commands can you use to combine the content of three files into a single text stream?

cat

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

cat turbo

Which of the following commands will (by itself) copy the entire /temp directory with all of its files, sub-directories, and files in the sub-directories to the /home/gshant directory? (Select two.)

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

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

ll

What type of shell runs after the user successfully logs in using an ID and password? (Type the answer in the blank field.)

login

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

pwd

Which of the following nano editor keyboard shortcuts displays help text, including a list of all keyboard shortcuts?

^G (Ctrl+G)

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

echo $LANG

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

xargs

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

./ni /root/ni

Each time you present credentials to log in, you want a particular entry to be written to a log file. This action will only apply to yourself. You are using the bash shell. Which of the following configuration files is the BEST to modify to enable this action?

.profile

In which of the following files is the user's preferred shell normally set?

/etc/passwd

Which of the following actions defines a persistent alias?

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

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

alias

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

Within the /var directory is a subdirectory named backup. You need to delete the directory backup and any files that it contains. You change the directory focus to /var. Which of the following commands will delete 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

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 command displays all the environment variables defined in the shell?

printenv

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

~/.profile ~/.bashrc

Which of the following Linux features lets you store a shortcut in memory or as part of the shell configuration file that runs a specific command?

Alias

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

You want to search all the man pages for information available for the Bluetooth protocol. Which of the following commands would you enter to display this information?

man -k bluetooth

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

mv

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 let you paste the copied text?

p

When creating a custom alias, how many commands can you add to the alias?

1 or more

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 correct 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. l Move the cursor down a line. j

What type of shell runs when a user opens a shell after first authenticating with a user ID and password? (Type the answer in the blank field.)

Non-login

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

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

The initial mode used when vi 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 used to write and edit text in the file. Edit Mode

When you enter the ls command for the current working directory, you see the following: 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 listed?

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

You have deleted an annual_report_finances.png file from your Linux file system. However, when you enter the ls -a command on the directory where the file is located, you still see the file listed with the following permissions: -rwxr-xr-x Why is the file still listed?

There is still a hard link associated with the file data.

Which of the following are characteristics make info nodes different from man pages? (Select two.)

They are more verbose and emphasize how to use commands and utilities. They contain hypertext links to navigate between nodes.

Which of the following are examples of a user running a non-login shell? (Select two.)

When a user runs the sudo <user ID> command without the -i option. When a user opens a shell session (terminal application) from within the GUI.

Which of the following are examples of a user running a login shell? (Select two.)

When the Linux system does not have a GUI and the user logs in using the text-based interface. When a user runs the sudo -i <user ID> command and enters the correct password.

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 Mary enter into the shell configuration file to create this persistent alias?

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

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

allfiles=$(ls -a)

You want to create an exact copy of /home/mary/june_report in /home/jeremy/ creating a hard link called project_june. What command would you enter at the command prompt to create this link?

cp -l /home/mary/june_report /home/jeremy/project_june

As a Linux script developer you are trying to debug a shell script that has the command ls -s in it. You suspect that an error is occurring, and want 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 you use?

ls -s &> ~/Friday

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

man -k whatis apropos

You want to view the Linux help information for the mkdir command. While viewing the information, you want to be able to scroll through the onscreen help. What is the command you would use to display and be able to scroll through the mkdir help information?

mkdir --help | more

Which of the following commands will change the /home/pmallory/reports filename to reports.bak?

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

You want to rename the quarterlyreports.txt file in the /sales/reports directory to qreports.txt. You are currently in the root directory at the command prompt. What command can you enter to rename the file?

mv /sales/reports/quarterlyreports.txt /sales/reports/qreports.txt

Which of the following commands utilize command substitution? (Select two.)

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

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

An employee has mistakenly copied a secure, private file from a network directory to their local hard drive. You want to completely overwrite the file data on the hard drive, as well as delete the file inode (file metadata). Which of the following commands would you use to perform this task?

shred -u

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.txt rm: remove write-protected regular empty file 'myfile2.txt'? y rm: cannot remove 'myfile2.txt': Operation not permitted While troubleshooting the issue, you list files in the directory to see if you can discover the issue: [ljenkins@fileserver]$ ls -al total 4 drwxr-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 privileges and receive the same error message. You decide to view the file attributes and receive the following output: [helpdesk@fileserver]$ lsattr ----I----------- ./report.txt Which of the following commands would resolve the problem and allow the file to be deleted?

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

You want to move a directory (and its files) to a destination directory that stores some of the same files using the mv command. You want to include the mv command in a script without monitoring the copy process. In addition, you do not want to overwrite the files in the destination directory. Which of the following mv command options would you use to prevent overwriting files?

-n

What command would you enter while in vi Command Mode to find the word Sam?

/Sam

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

DESCRIPTION

The ls command displays the contents of a directory and includes several options. From the list on the left, drag an option to its correct description on the right.

Displays directories but not files. -d Displays extended information including the owner, modified date, size and permissions. -l Reverses the sort order of the list. -r Displays all directory contents, including hidden content. -a Displays the contents of a directory and all of its subdirectories. -R

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

Distinct (non-duplicate) inode.

Select the file type from the drop-down list below that is also called by non-login shell configuration files.

*.sh files in /etc/profile.d

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

<Esc>:wq

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?

Answer:exec ./myapp

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

Bourne again shell (bash)

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

~./bash_profile /etc/profile

A user starts a bash session and the script in /etc/profile. If all of the following files exist, which will be run next?

~/.bash_profile

From the drop-down list below, select the file that is called by the non-login shell configuration file.

~/.bashrc

Leroy tries to copy some files to an ext3 volume and receives 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.

You create symbolic links in your 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 you created?

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

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

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

You want to create a grepcolor alias that provides a lime green (36) background color to the search terms when using the grep command. You want this command to be persistent when rebooting your Linux server. What command would you enter into the shell configuration file to create this persistent alias?

alias grepcolor="grep --color=36"

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

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 with a filename that includes the current local weekday name?

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

You are at a terminal command prompt in a Linux GUI interface that someone else has been using and want to find out which shell type is currently being used by the terminal. What command can you enter to find out the current shell type?

echo $0

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

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 an environment variable that will be inherited by subsequent child shells and processes?

export HOST

Tim, a technician, creates a local variable named val and sets 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 val as an environment 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 have forgotten what information is provided by the whoami command, and simply want a short description of the command. Which of the following help commands could you enter to view that short description?

help -d whoami

Which of the following commands would you enter to view info node information about the sysctrl command?

info sysctrl

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 /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

Which of the following commands lists the node numbers for the files in your Linux file system?

ls -i

You attempt 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 you to see the full listing of the directory?

ls -l | less

Which of the following commands displays the attributes of the /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

As a Linux administrator, you need 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

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 testfile.txt text file?

myscript >> testfile.txt

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

tee

You have created a listgroups alias that you now want to remove. Which of the following commands will remove the alias?

unalias listgroups

You have created a project_ln soft link and now want to remove the link from your Linux file system. Which of the following commands will remove the soft link?

unlink project_ln


Conjuntos de estudio relacionados

Metabolic Functions of the Liver

View Set

Vocabulary Workshop Lessons 3 and 4

View Set

Ancient Civilizations TCI Units 3-6 Terms Template - Unit 3 Ancient India

View Set