section 4 practice questions

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

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 .bashrc /etc/profile .sh

.profile

Which of the following paths represents the root directory? /home/root / /boot /root

/ The forward slash (/) character represents the root filesystem of the Linux system. The /root directory is the root user's home directory. Do not confuse /root with the root filesystem (/).

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? .bashrc .bash_profile /etc/profile .bash_login

/etc/profile

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

/proc

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

/root

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

/usr/share/man /usr/man Man pages are typically stored in the /usr/man or /usr/share/man directory. Subdirectories store man pages for different types of commands or languages.

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 actions can be used to define a persistent alias? Add the command defining the alias to the appropriate shell configuration file. Add the command defining the alias to the $ALIAS environment variable. Add the command defining the alias to the /etc/default/alias.conf file. Use the alias command at the shell prompt with the -P option.

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

Which of the following is a characteristic of a symbolic link? Valid pointer to the linked file's data even if the original linked file is deleted. Dash (-) as the first character in the permission string. Indistinguishable from the original linked file. Distinct (non-duplicate) inode.

Distinct (non-duplicate) inode. The pointer in a symbolic link is broken when the original linked file is deleted. A symbolic link has a lower case L (l) as the first character in the permission string. For example, lrwxrwxrwx. A symbolic link is only a pointer to a linked file and can be distinguished by both a lower case l as the first character in the permission string and also by the (->) characters that follow the symbolic link name when the ls -l command is run.

Which of the following commands configures the shell to retain 300 recently used commands in the ~/.bash_history file for multiple shell sessions? BASH=300 HISTFILESIZE=300 HISTSIZE=300 HISTFILE=300

HISTFILESIZE=300 The HISTSIZE environment variable is wrong because it specifies the number of past commands remembered for the current shell session. The HISTFILE shell variable is wrong because it specifies the filename where past commands are stored, which is ~/.bash_history by default.

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

HISTSIZE

LAB: 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 LANG SHELL TERM

HOME=/root LANG=en_US.UTF-8 SHELL=/bin/bash TERM=linux Use the set command to view a list of variables, or use the echo $variable command to show each variable individually. For example, use the echo $SHELL command to see the value for SHELL.

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

It contains the directory prefixes used to search for programs and files. The HISTFILE shell variable specifies the filename where past commands are stored. The PS1 shell variable specifies the characters the shell prompt that indicates either a normal user ($) or root user (#). The PWD environment variable contains the path of the current (or present) working directory.

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 PATH=/sbin/special PATH=PATH&/sbin/special PATH=$PATH:/sbin/special

PATH=$PATH:/sbin/special

Drag the permission string on the left to the category on the right. Some permission strings will not be used. lrwxrwxrwx drwxr-xr-x -rwxr-xr-x srwxr-xr-x prwxr-xr-x Symbolic link Hard link

Symbolic link lrwxrwxrwx Hard link -rwxr-xr-x

Which of the following statements BEST describes the effects of the split -50 -d -a 3 AllNames FiftyNames- command if there are 103 lines and 240 bytes in the file? The FiftyNames file is split into five files containing 50 bytes or less. The output is AllNames-001, AllNames-002, AllNames-003, AllNames-004, and AllNames-005. The AllNames file is split into three files containing 50 lines or less. The output is FiftyNames-001, FiftyNames-002, and FiftyNames-003. The AllNames file is split into three files containing 50 lines or less. The output is FiftyNames-1, FiftyNames-2, and FiftyNames-3. The AllNames file is split into five files containing 50 bytes or less. The output is FiftyNames-001, FiftyNames-002, FiftyNames-003, FiftyNames-004, and FiftyNames-005.

The AllNames file is split into three files containing 50 lines or less. The output is FiftyNames-001, FiftyNames-002, and FiftyNames-003.

Which of the following statements BEST describe the purpose of the Filesystem Hierarchy Standard (FHS)? (Select TWO). The FHS allows users to create a custom hierarchy of directories. The FHS allows software installation routines to determine the permissions of specific directories. As users create files, the FHS forces users to place the files in specific directories. 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.

The FHS allows software installation routines to predict where to place configuration files. The FHS allows users to predict where to find system configuration files. Users can create and place files in any directory if they have the correct permissions. While the software installation routines can determine the permissions of specific directories, doing so is not FHS's purpose. While users can create a custom hierarchy of directories, doing so is not FHS's purpose.

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 be overwritten. 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 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 beginning of the file. The contents of the /usr/bin directory are written to both the screen and to a file named /tmp/list.txt. Previous file contents are overwritten.

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. The shantsgems file is a link to the mydata file. The shantsgems file is a backup of the mydata file. The mydata file is a hard link to the shantsgems file.

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

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 files would not be deleted because duplicate files were created when Ted created the links. The symbolic links still exist in Ted's home directory, but they are useless because the link has been broken. The links in Ted's home directory are automatically removed when the administrator deletes the files. Ted can still access the files until the system is rebooted even though they are deleted because the links point to a cached copy of the files in memory.

The symbolic links still exist in Ted's home directory, but they are useless because the link has been broken. When a symbolic link is created, a new entry is created in the file system. If the original file is deleted, the link still exists, but is broken. No duplicate files are created when symbolic links are created. Symbolic links are stored in the file system, not in memory. Deleting a file will not automatically delete symbolic links that point to the file.

Which of the following statement describes file globbing? Using wildcards to match specific files. Determining the category of the file or command. Indexing files for the locate command. Displaying which commands use specific files.

Using wildcards to match specific files. File globbing uses wildcards (e.g., *, *.*, *.txt, [], ?) to match specific files. File globbing is useful with several commands, including find and ls.

Which of the following is a characteristic of a hard link? Answer Works across volumes and file systems. Lowercase L (l) as the first character in the permission string. Distinct (non-duplicate) inode. Valid inode for the file data even if the original file is deleted.

Valid inode for the file data even if the original file is deleted. A hard link maintains a valid inode for the file data even if the original file is deleted. A hard link has a duplicate inode. A hard link must be on the same partition and do not work across volumes and file systems. A hard links has a dash as the first character in the permission string (example: -rwxrwxrwx).

Which of the following is a valid metacharacter that can be used in the bash shell to escape or ignore the shell's special meaning for the character that immediately follows? {} ; * \

\ To escape a character, you put a backslash (\) in front of it so that anything that follows the \ is treated like a regular character, not a metacharacter.

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

alias

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" export sysmesg="tail -f /var/log/messages" env alias="tail -f /var/log/messages" export alias="tail -f /var/log/messages"

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? Answer allfiles=$((ls -a)) allfiles="ls -a" allfiles=$(ls -a) allfiles="exec ls -a" allfiles=${ls -a}

allfiles=$(ls -a) allfiles=$(ls -a) stores the output from the ls -a command in the shell variable allfiles. This is command substitution. allfiles=$((ls -a)) stores the value of zero in the variable allfiles. allfiles="exec ls -a" stores the exec ls -a string in the variable allfiles. allfiles="ls -a" stores the ls -a string in the variable allfiles. allfiles=${ls -a} utilizes command expansion and does not produce a command output.

Which awk/sort command combination displays a sorted list of usernames in the /etc/passwd file? awk '{print $A}' /etc/passwd | sort awk -F: '{print $1}' /etc/passwd | sort awk -F: '{print $2}' /etc/passwd | sort awk '{print $1}' /etc/passwd | sort

awk -F: '{print $1}' /etc/passwd | sort -F: indicates that the file separator is a colon (:), the separator that is used in the /etc/passwd file. The string '{print $1}' allows the command to print column number 1 (column numbers start at 0). $A is incorrect because awk needs a column number (numeric), not an alpha. The string /etc/passwd represents the file to process, and the string | sort pipes the print output to the sort routine.

Which of the following commands can be used to combine the content of three files into a single text stream? nl cut pr cat

cat The cat command displays the contents of a file. If multiple files are added to the command, the contents of each file will be displayed in a single text stream. The cut command removes sections from each line of a file. The pr command formats a text file for printing. The nl command places a line number in front of each line in a text file and sends the result to standard output.

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 cat /usr/wordlist1 | /usr/wordlist2 | sort cat /usr/wordlist1 >> /usr/wordlist2 | tee cat /usr/wordlist1 > /usr/wordlist2 | sort

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 sortedwordlist cat /usr/wordlist1 /usr/wordlist2 | sort sortedwordlist cat /usr/wordlist1 /usr/wordlist2 | tee sortedwordlist cat /usr/wordlist1 /usr/wordlist2 | sort | tee sortedwordlist

cat /usr/wordlist1 /usr/wordlist2 | sort | tee sortedwordlist The cat /usr/wordlist1 /usr/wordlist2 | tee sortedwordlist command does not perform a sort. The cat /usr/wordlist1 /usr/wordlist2 | sort sortedwordlist command attempts to sort a file named sortedwordlist that, most likely, does not exist. The cat /usr/wordlist1 >> /usr/wordlist2 | sort sortedwordlist command will append the contents of the wordlist1 file to the wordlist2 file and will attempt to sort a file named sortedwordlist that, most likely, does not exist.

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

cat turbo Using the turbo file as an argument of the cat command causes the turbo file to be used as input. The < operator results in the same action. The contents of the turbo file are redirected to the cat command as input. The 1> turbo construct writes the output of the cat command to the turbo file. The 2> turbo construct writes any errors generated by the cat command to the turbo file. The &> turbo construct writes both the output of the cat command and any errors generated by the cat command to the turbo file.

Which of the following commands 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 -q /temp /home/gshant cp -r /temp /home/gshant cp -R /temp /home/gshant cp /temp /home/gshant cp -s /temp /home/gshant

cp -R /temp /home/gshant cp -r /temp /home/gshant The cp -r and cp -R command copies directories and files recursively. It also leaves the source contents intact. The cp command without the -r or -R option only copies the specified file or directory. The cp -s command creates a symbolic link instead of copying the file or directory. The cp -q command displays an error because there is no -q option.

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 /mnt/usb:letter.doc /root cp /media/usb/letter.doc /root cp /media/usb/letter.doc home: cp /dev/usb/letter.doc /root

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 with a filename that includes the current local weekday name? xargs /var/log/auth.log ~/auth$(date +%A).log tee /var/log/auth.log > date +%A -log cp /var/log/auth.log ~/auth$(date +%A).log cp /var/log/auth.log ~/auth${date +%A}.log

cp /var/log/auth.log ~/auth$(date +%A).log The $(date +%A) operator performs a command substitution so that the new filename will include the current local weekday name. The ${date +%A}.log operator attempts to substitute the contents of a variable.

Which of following commands displays information found in the second column of the tab delimited ~/smarts file? fmt - t2 ~/smarts join -t2 ~/smarts expand -f2 ~/smarts cut -f2 ~/smarts

cut -f2 ~/smarts

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? cat $HISTSIZE cat /etc/profile | grep "HISTSIZE" echo $HISTSIZE HISTSIZE=

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 echo LANG echo $LANG echo %LANG%

echo $LANG

Which of the following commands would display this output? Frank said, "Linux is fun!" echo Frank said, \"Linux is fun\!\" echo "Frank said," "Linux is fun!" echo Frank said, "Linux is fun!" echo Frank said, "Linux is fun\!"

echo Frank said, \"Linux is fun\!\" The " and ! must be escaped to display correctly.

You are searching the standard input for any line containing "JAMESTOWN" at the end of a line. Which egrep constructor should you enter at the command prompt?

egrep JAMESTOWN$

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? display env print echo

env

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

env printenv

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? COMP=1745 set COMP to 1745 set COMP=1745 export COMP=1745

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? unset HOST export HOST set HOST env HOST

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 exec val echo $val=5000 declare val

export val=5000

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

file

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 '* gold *' find .. -print0 '* blue *' -o '*gold*' find / -name '* blue *' -o -name '* gold *' find . -name '* blue *' -o -name '* gold *'

find / -name '* blue *' -o -name '* gold *' To search the whole file system (that is, the root of the file system), begin the search from '/'. Use -o to use the or operator when searching with multiple criteria. To search the current directory and subdirectories, begin the search from '.'. To search the parent directory and subdirectories, begin the search from '..'.

Which of the following commands finds files with the .txt extension in the /home/gshant directory? find /home/gshant -type f -name '*text*' find /home/gshant -type d -name '*text*' find /home/gshant -name '*txt*' find /home/gshant -name '*.txt'

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

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 /home/gshant -size +300k

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. Which of the following commands will limit the lines in the file to the limits on the terminal? cut -w 75 /home/shants/depsmark pr -w 75 /home/shants/depsmark nl -w 75 /home/shants/depsmark fmt -w 75 /home/shants/depsmark

fmt -w 75 /home/shants/depsmark

Which of the following commands displays the user groups that dblair is a member of? grep -e dblair /etc/group which group dblair find /etc/group -name dblair members dblair

grep -e dblair /etc/group The -e option specifies a literal pattern. The command will show each group line that includes dblair and may list a few extra lines beside the groups to which dblair belongs. The members command (if installed) lists the members of the dblair group. The which group dblair command attempts to find the executable files associated with the group and dblair commands (which most likely doen't exist). The find /etc/group -name dblair command attempt to find a file or directory named dblair starting in the /etc/group directory (which most likely doesn't exist).

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 grep -n Karen blue_and_gold grep -n blue_and_gold Karen grep -v blue_and_gold Karen

grep -v Karen blue_and_gold

An application named ABCD is generating system errors when it starts. Which of the following commands searches the system message log file for these errors? top /var/log/ABCD.log tail -n25 /var/log/ABCD.log grep ABCD /var/log/messages tail -n25 /var/log/messages

grep ABCD /var/log/messages The tail -n25 /var/log/messages command shows the last 25 lines of the message file, but does not guarantee that any error messages from application ABCD will be displayed. The tail -n25 /var/log/ABCD.log command shows the last 25 lines of the ABCD.log file (if it exists). Unless otherwise configured, all system error messages would be sent to /var/log/messages rather than /var/log/ABCD.log. The top /var/log/ABCD.log command displays real-time system statistics, not files.

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

grep world MTS

Which of the following commands will merge two files based on identical fields of text? join od paste pr

join

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

ll

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 /usr/bin/scrub /opt/corp/scrub ln -s /usr/bin/scrub /opt/corp/scrub ln /opt/corp/scrub /usr/bin/scrub ln -s /opt/corp/scrub /usr/bin/scrub

ln -s /usr/bin/scrub /opt/corp/scrub only a symbolic link works across different file systems.

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

locate The type command displays the category of the command. The cat command displays the contents of a file in the shell. The tail command lists the last 10 lines of a specified file by default.

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

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

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 dir -al /etc ls -ae /etc ld -ae /etc

ls -al /etc

A directory intended to be used only by administrators keeps filling with files. Which of the following commands would you use to see only the names of the users saving files in the directory? ls -l | join -d " " -f5 ls -l | grep -d " " -f5 ls -l | cut -d " " -f5 ls -l | find -d " " -f5

ls -l | cut -d " " -f5

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 ls -p ls -l | less ls -paged

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 ls -s >> ~/Friday ls -s < ~/Friday ls -s &> ~/Friday

ls -s &> ~/Friday The &> operator redirects both successful output (1) and error results (2) to the same file. The > operator only redirects the output. The >> operator only redirects the output and appends the new information to the ~/Friday file. The < operator passes the contents of the ~/Friday file to the ls command as input. In this case, the ls command will ignore the input.

Which of the following commands will display the attributes of a /boot/grub/grub.conf file? lsattr /boot/grub/grub.conf cat /boot/grub/grub.conf vi /boot/grub/grub.conf ls -l /boot/grub/grub.conf

lsattr /boot/grub/grub.conf

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 mkdir /var/oracle/database/9i md -path /var/oracle/database/9i mkd /var/oracle/database/9i

mkdir -p /var/oracle/database/9i The mkdir -p /var/oracle/database/9i command creates all the directories that do not exist in the directory path. The mkdir /var/oracle/database/9i command displays an error since the /var/oracle/database directory does not exist.

Which of the following commands will move a file from one location to another? copy -r mv cp -d move

mv

Which of the following commands will change the /home/pmallory/reports file's name to reports.bak? touch -n /home/pmallory/reports /home/pmallory/reports.bak cp -n /home/pmallory/reports /home/pmallory/reports.bak rm /home/pmallory/reports /home/pmallory/reports.bak mv /home/pmallory/reports /home/pmallory/reports.bak

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

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

myscript >> testfile.txt The myscript >> testfile.txt command uses the >> operator to redirect the output of the executed myscript script to a file named testfile.txt. The echo myscript >> testfile.txt command appends the contents of the myscript file to the testfile.txt file.

Which of the following commands utilize command substitution? (Choose TWO.) Answer echo -e "sort -r names.txt" myvar=`sort -r names.txt` myvar=$(sort -r names.txt) myvar="echo 'sort -r names.txt'"

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

Which of the following statements BEST describes the nl -s ": " myfile command? nl adds the link, a colon, and a space to the front of each line in the file. nl adds the octal format, a colon, and a space to the front of each line in the file. nl adds the number, a colon, and a space to the front of each line in the file. nl adds a colon and a space to the front of each line in the file.

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

You want to display the contents of ~/franksdep in hexadecimal format. You change to your home directory. How should you enter the command at the command prompt?

od -x franksdep

Which of the following commands merges two files on a line-by-line basis and separate each line with a tab? pr join od paste

paste

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 backup rm -r backup rm -r backup/* rm backup/*

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 Use rm -r to delete a directory that still has contents. The -r option deletes directories (and all files) in the directories. The rmdir command only deletes empty directories.

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 Use the rmdir to delete an empty directory. Use rm to delete a directory which still has contents. In this case, rmdir or rm will delete the directory.

Which sed flag or option allows you to exchange one string of characters for another string of characters in a file? s g d -f

s

Which of the following utilities will substitute an existing string with a new string within a file? sed egrep grep fgrep

sed The grep command searches through files for a specified character string. The fgrep command searches for fixed strings rather than regular expressions. The egrep command uses regular expressions in the search strings.

Which of the following sed commands replaces all the occurrences of the string foo with the string bar in myfile.txt? sed -e 's/foo/bar/g' myfile.txt sed -e 's/foo/bar/' myfile.txt sed -e 'sub/foo/bar/glob' myfile.txt sed -e '/foo/bar/g' myfile.txt

sed -e 's/foo/bar/g' myfile.txt s means substitute. /foo/bar/ is the substitution string meaning substitute the first item, foo, with the second item, bar. g means global.

Which of the following commands will display each line in a text file in alphabetic order? tr uniq sort split

sort

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 -altotal 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 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 sudo lsattr report.txt | rm report.txt sudo rm -vR report.txt sudo rm --force report.txt

sudo chattr -i report.txt && rm report.txt The directory listing shows that ljenkins has sufficient permissions to delete the file because ljenkins owns the file. Troubleshooting the issue further reveals that a user with root permissions cannot remove the file. The next step is to check the file attributes with the lsattr command. The lsattr command reveals that the file has the (i) immutable attribute set, which prevents even users with elevated privileges from deleting the file. sudo chattr -i report.txt && rm report.txt removes the immutable attribute and then deletes the file.

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? ls /home/gshants/smile cat /home/gshants/smile rm /home/gshants/smile touch /home/gshants/smile

touch /home/gshants/smile The touch /home/gshants/smile command will change the /home/gshants/smile file's modification and last accessed times to the current time. Touch will also create a new file if the file does not already exist.

Which of the following commands transposes characters in a text steam? sort pr tr nl

tr

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

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

wc -lwc /home/gshant/servepath wc /home/gshant/servepath wc -lwc /home/gshant/servepath will print the line count, word count, and byte count, respectively, in the /home/gshant/servepath file. You can also use wc without any options to print the same information.

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 whereis -b photorec

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

xargs

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

| The pipe (|) operator directs the output of one command into 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.) /etc/profile ~./bash_history ~./bash_logout ~./bash_profile

~./bash_profile /etc/profile

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? ~/.profile ~/.bash_profile ~/.bash_login ~/.bash_logout

~/.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. Each answer is an independent solution.) /etc/bashrc ~/.bashrc ~/.profile ~/.bash_logout /etc/profile

~/.profile ~/.bashrc


Ensembles d'études connexes

Missouri State University Theatre 101 Foster FINAL

View Set

GCSE Identifying Rocks and Textures under the Microscope

View Set

Chapter 25 Study Guide - The Immortal Life of Henrietta Lacks

View Set