Linux Pre-Assess

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

You use top to examine the CPU time being consumed by various processes on your system. You discover that one process, dfcomp, is consuming more than 90 percent of your system's CPU time. What can you conclude?

Very littlE: dfcomp could be legitimately consuming that much CPU time, or it could be an unauthorized or malfunctioning program. CPU-intensive programs routinely consume 90 percent or more of available CPU time, but not all systems run such programs. Furthermore, some types of program bugs can create such CPU loads. Thus, option E is correct, and you must investigate the matter more. What is dfcomp? Is it designed as a CPU-intensive program? Is it consuming this much CPU time consistently, or was this a brief burst of activity? Options D, C, B, and A all jump to conclusions or present fictitious reasons for the behavior being normal or abnormal.

You want to run a lengthy scientific simulation program, called simbigbang, which doesn't require any user interaction; the program operates solely on disk files. If you don't want to tie up the shell from which you run the program, what should you type to run simbigbang in the background?

simbigbang & Appending an ampersand (&) to a command causes that command to execute in the background. The program so launched still consumes CPU time, but it won't monopolize the shell you used to launch it. Thus, option A is correct. The start (option B) and background (option D) commands are fictitious. Although bg (option E) does place a job into the background, it doesn't launch a program that way; it places a process that has already been suspended (by pressing Ctrl+Z) into the background. The nice utility (option C) launches a program with modified priority, but a program so launched still monopolizes its shell unless you take additional steps. For more information, see Chapter 2.

Which of the following is the most appropriate command for removing the "deleteme" directory, which is filled with files and subdirectories?

rm -R deleteme The recursive switch (-R or -r) to rm causes it to delete an entire directory tree, including all files and subdirectories in the specified target. Thus, option B is correct. Using rm without this option, as in option D, will delete just a single file. There is no -R parameter to rmdir, so option C is incorrect. The -p option to rmdir will delete an empty directory tree, but it deletes only empty directories, and the question specifies that this directory is not empty. Thus, option A is incorrect. Option E's del command is not a standard Linux command.

A text-mode program, verbose, prints a lot of bogus "error" messages to standard error. How might you get rid of those messages while still interacting with the program?

verbose 2> /dev/null The 2> redirection operator redirects standard error only, leaving standard output unaffected. Sending standard error to /dev/null gets rid of it. Thus option E is correct. Option B pipes the standard output of verbose through the quiet program, which isn't a standard Linux program. Option A sends both standard output and standard error to /dev/null, so you won't be able to interact with the program as the question specifies you must be able to do. Option D redirects standard output only to the junk.txt file, so once again, interaction will be impossible and you'll see the unwanted error messages on the screen. Option C's quiet-mode program is fictitious (or at least nonstandard), so this option is incorrect.

You work as a network administrator for Secure Web Inc. The company has a Linux-based network. The network has a mixed set of client operating systems. You want to format a new hard disk drive. The drive will have only one partition. Both the Linux and Windows operating systems need to directly access the partition. Which of the following filesystems will you use?

vfat To accomplish the task, you will have to choose the Virtual File Allocation Table (VFAT) filesystem. The VFAT filesystem is compatible with the FAT filesystem in Windows. It is recognized by both Linux and Windows operating systems.

What is the advantage of vi over graphical text editors?

vi is smaller, so it can fit on compact emergency USB flash drive systems and embedded devices. Vi is included on Linux emergency systems, embedded systems, and other systems where space is at a premium because its executable is tiny. Emacs is, in contrast, a behemoth. Thus option E is correct. Contrary to option A, vi isn't an X-based program (although X-based vi variants are available); Emacs can be used in text mode or with X. Extended Binary Coded Decimal Interchange Code (EBCDIC) is an obscure 8-bit character encoding system used on some very old mainframe OSs. When run on Linux, vi doesn't use EBCDIC; furthermore, EBCDIC offers few or no advantages over the American Standard Code for Information Interchange (ASCII). Thus option B is incorrect. Vi's modes, referred to in option C, have nothing to do with non-English language support. Option D is backward; it's Emacs that includes a web browser, email client, and other add-ons.

Which of the following files does init search to determine the runlevel?

/etc/inittab The init process determines the runlevel by looking in the /etc/inittab file. Answer option A is incorrect. The /etc/shadow file contains password information of users. Answer option D is incorrect. The /etc/passwd file stores the user configuration information. It stores user name, id, etc. Answer option B is incorrect. The /etc/fstab file stores permanent details for mounting a device during system bootup.

Which files contain essential system information such as IRQs, direct-memory access channels, and I/O addresses?

/proc/dma /proc/interrupts /proc/ioports There are no files called /proc/ioaddresses or /proc/hardware, so options E and C are both incorrect. All the other files listed contain useful information; /proc/ioports holds information about I/O ports, /proc/dma holds information about DMA port usage, and /proc/interrupts holds information about IRQs.

Which file would you examine to learn what interrupts (IRQs) are in use on Linux?

/proc/interrupts The /proc filesystem is a virtual filesystem whose files hold information about system hardware and software. The /proc/interrupts file (option C), in particular, can tell you about the interrupts that are used by various devices. Option B is a directory that holds udev rules, but these rules usually don't refer to IRQs. Options A and E both describe fictitious files. Option D's the /etc/inittab file is a SysV startup control file that doesn't reference IRQs.

Which of the following umask values will result in files with rw-r----- permissions?

027 Files start with a 666 permission bit octal number setting. Depending upon the umask setting, permission bits may be removed, but not added. Option E, 027, removes write permissions for the group and all world permissions. (Files normally don't have execute permissions set, but explicitly removing write permissions when removing read permissions ensures reasonable behavior for directories.) Therefore, Option E is correct. Option C, 640, is the octal equivalent of the desired rw-r----- permissions, but the umask sets the bits that are to be removed from permissions, not those that are to be set. Option B, 210, would remove write permission for the owner, but it wouldn't remove write permission for the group, which is incorrect. This would also leave all world permissions open. Option A, 022, wouldn't remove world read permission. Option D, 138, is an invalid umask because all the digits in the umask must be between 0 and 7.

Which SysV runlevels are reserved by init for reboot, shutdown, and single-user mode purposes? (Select three.)

1,0,6 Runlevel 0 (option B) is the reserved runlevel for halting the system. Runlevel 1 (option A) is reserved for single-user mode. Runlevel 6 (option C) is reserved for rebooting. Runlevel 2 (option E) is the default runlevel on Debian and most distributions derived from it, but it does none of the things described in the question. Runlevel 5 (option D) is a regular, user-configurable runlevel, which isn't normally used for the things described in the question. (Many systems use it for a regular boot with a GUI login prompt.)

What are common IRQs for RS-232 serial ports?

4,3 IRQs 3 and 4 are common defaults for RS-232 serial ports, so options B and A are both correct. IRQ 1 is reserved for the keyboard, so option C is incorrect. IRQ 8 is reserved for use by the real-time clock, so option E is incorrect. Although IRQ 16 exists on modern systems, it didn't exist on early x86 systems, and its purpose isn't standardized.

Which of the following runlevels boots a Linux computer in graphical user interface (GUI) mode?

5 A runlevel is a state of a Linux system that defines which system services are operating. The runlevel 5 is used for multi-user mode with network services and presents a graphical user interface. Answer option B is incorrect because the runlevel 0 is used to halt the system. Answer option D is incorrect because the runlevel 1 switches the system to single-user mode. It is frequently used for system maintenance. Answer option C is incorrect because this is not a standard runlevel.

How should you configure a system that uses Yum to access an additional Yum software repository?

Download a package from the repository site, and install it with RPM, or place a configuration file from the repository site in the /etc/yum.repos.d directory. Yum uses files in the /etc/yum.repos.d directory to locate its repositories, so you can add to the repository list by adding files to this subdirectory, as option B specifies, typically either by installing an RPM or by adding a file manually. Option C describes a method of adding a repository to a computer that uses APT, not Yum. Option A's add-repository subcommand is fictitious. Although the /etc/yum.conf file described in options E and D is real, it doesn't store repository data.

Which of the following are journaling filesystems for Linux? (Select three.)

Ext3fs XFS ReiserFS ReiserFS (option E) was written from scratch for Linux. The Third Extended Filesystem (ext3fs; option B) is a journaling filesystem based on the older non-journaling Second Extended Filesystem (ext2fs; option A). The Extents Filesystem (XFS; option C) is a journaling filesystem written by SGI for Irix and later ported to Linux. The Virtual File Allocation Table (vfat; option D) is a non-journaling filesystem designed by Microsoft for Windows. For more information, see Chapter 3, "Configuring Hardware."

Which of the following pieces of information can df not report?

How long the filesystem has been mounted default use of df reports the percentage of disk space used (option B) and the mount point for each filesystem (option A). The number of inodes (option D) and filesystem types (option C) can both be obtained by passing parameters to df. This utility does not report how long a filesystem has been mounted (option E), so that option is correct.

An administrator types the following command on an RPM-based Linux distribution: # rpm -ivh megaprog.rpm

If the megaprog.rpm package exists, is valid, and isn't already installed on the computer, it is installed. The -i operation installs software, so option C is correct. (The -v and -h options cause a status display of the progress of the operation, which wasn't mentioned in the option.) Uninstallation is performed by the -e operation, and rebuilding source RPMs is done by the --rebuild operation (to either rpm or rpmbuild, depending on the RPM version), so options D and B are incorrect. Although the filename megaprog.rpm is missing several conventional RPM filename components, the rpm utility doesn't use the filename as a package validity check, so option A is incorrect. Option E describes a package upgrade, which is handled by the -U operation, not -i as in the question, so option E is incorrect.

What does the following command accomplish? $ wc report.txt | tee wc

It displays a count of newlines, words, and bytes in the report.txt file and copies that output to the wc file. The wc command displays a count of newlines, words, and bytes in the specified file (report.txt). Piping this data through tee causes a copy of the output to be stored in the new file (wc in this example, you shouldn't run this command in the same directory as the wc executable file!). Thus, option C is incorrect. Contrary to option D, wc is not an editor, and the remaining syntax wouldn't cause two files to open in separate windows even if wc were an editor. Contrary to option C, wc doesn't count windows or open a new window. Option B describes the effect of wc report | wc, that is, it overlooks the tee command. Contrary to option A, wc has nothing to do with cleaning up memory leaks, and tee doesn't directly use the report.txt file. For more information, see Chapter 1, "Exploring Linux Command-Line Tools."

What does the grep command accomplish?

It searches files' contents for a pattern. The grep command scans files to find those that contain a specified string or pattern, as described by option C. In the case of text files, grep displays the matching line or lines; for binary files, it reports that the file matches the pattern. The method of creating a pipeline (option D) involves separating two commands with a vertical bar (|). The grep command can be used in a pipeline, but it doesn't create one. The command that concatenates files (option B) is cat, and the command that displays the last several lines of a file (option A) is tail. Several commands, such as find, locate, and whereis locate files (option E), but grep is not among them. For more information, see Chapter 1.

Which is true of using both RPM and Debian package management systems on one computer?

It's generally inadvisable because the two systems don't share installed-file database information. The two systems use different databases, which makes coordinating between them difficult. Therefore, using them both simultaneously is inadvisable, making option E correct. Package management systems don't share information, but neither do their databases actively conflict, so option D is incorrect. Installing the same libraries using both systems would almost guarantee that the files served by both systems would conflict with one another, making option C incorrect. Actively using both RPM and Debian packages isn't common on any distribution, although it's possible with all of them, so option B is incorrect. The alien program converts between package formats. Although it requires that both systems be installed to convert between them, alien is not required to install both these systems, thus option A is incorrect.

What is an advantage of a journaling filesystem over a conventional (non-journaling) filesystem?

Journaling filesystems require shorter disk checks after a power failure or system crash. The journal of a journaling filesystem records pending operations, resulting in quicker disk checks after an uncontrolled shutdown, so option C is correct. Contrary to option E, journaling filesystems are, as a class, newer than non-journaling filesystems; in fact, the journaling ext3fs is built upon the non-journaling ext2fs. Although disk checks are quicker with journaling filesystems than with non-journaling filesystems, journaling filesystems do have fsck utilities, and these may still need to be run from time to time, so option A is incorrect. All Linux-native filesystems support Linux ownership and permissions; this isn't an advantage of journaling filesystems, contrary to option B. The journal of a journaling filesystem doesn't provide an unlimited "undo" feature, so option D is incorrect.

n which of the following locations can the LILO bootloader install its boot configuration files?

MBR Root partition The Master Boot Record (MBR) and the first sector of the partition (root partition) are the locations where the LILO bootloader can install its boot configuration files. When more than one operating system is installed on a computer, LILO should be installed in MBR. The MBR contains the first boot record on a disk. The main work of the tiny software on an MBR is to locate and run the necessary operating system files which are required to read more data from a disk. In the context of the operating system, the software on the MBR is also known as the boot loader. If the boot loader is infected or corrupted, the operating system will not boot. In the Linux operating system, a user can place the boot loader (LILO or GRUB) either into the MBR or in the root partition. This flexibility can cause a failure at boot time since the system's startup code (the BIOS, EFI, or UEFI code) must load the boot loader into memory and start it. Some BIOS versions cannot access portions of the disk beyond certain locations, such as the 1024th cylinder. The boot loader must be within the limitations supported by the system's startup code. If the BIOS cannot read all of the boot loader, the boot fails. Answer options D and B are incorrect. BIOS and swap are not used by the LILO bootloader to install its boot configuration files.

You want to create a link from your home directory on your hard disk to a directory on a DVD drive. Which of the following link types might you use?

Only a symbolic link Symbolic links can point across filesystems, so creating a symbolic link from one filesystem (in which your home directory resides) to another (on the DVD) isn't a problem, making option E correct. Hard links, as in options A, B, and C, are restricted to a single filesystem and so won't work for the described purpose. Because symbolic links will work as described, option D is incorrect.

How do you exit vi's insert mode to type command-mode commands?

Press the Esc key. The Esc key exits vi's insert mode, as option D specifies. Typing a tilde (˜) inserts that character into the file, so option C is incorrect. The Ctrl+X, Ctrl+C key combination exits from Emacs, but it's not a defined vi key sequence, so option E is incorrect. The F10 key and the Shift+Insert key combination also aren't defined in vi, so options A and B are both incorrect.

You see the usrquota and grpquota options in the /etc/fstab entry for a filesystem. What is the consequence of these entries?

Quota support will be available if it's compiled into your kernel, but you must activate it with the quotaon command. Using quotas requires kernel support, the usrquota or grpquota (for user or group quotas) filesystem mount option, and activation via the quotaon command (which often appears in system startup scripts). Thus, option E is correct. Option A suggests that quotaon is not necessary, which is incorrect. Option B's statement that grpquota is invalid is incorrect. Option C's statement that these options disable quota support is backward. The usrquota and grpquota options are both valid, so option D is incorrect.

Which of the following statements is correctly stated about the Soft limit? Each correct answer represents a complete solution. Choose two.

The Soft limit acts as a maximum amount of space that a user is expected to use. The Soft limit acts as an alarm if the user crosses the quota limit. The Soft limit is the maximum amount of space a user can have on its partition. If the grace period is set, then this will act as an alarm when the user crosses the limit. If the grace period is set for the soft limit, it is necessary to set the grace period for the hard limit also. Answer option C is incorrect. The absolute limit that a user can use is called the Hard limit. Answer option B is incorrect. The repquota command is used to report the summary of quotas.

You want to create a link to the /usr/local/bin directory in another location. Which of the following statements is true?

The link will probably have to be a symbolic link Hard links to directories are not permitted by most filesystems, so you'll probably have to create a symbolic link, as noted in option C. Links don't rely on a filesystem journal, so option B is incorrect. Contrary to option A, anybody may create a link, not just the original owner. Option E describes a restriction of hard links, but because this link will probably have to be a symbolic link, this restriction is not important and option E is incorrect. Option D describes a more severe restriction than option A, but it's incorrect for the same reasons. For more information, see

You want to move a file from your hard disk to a USB flash drive. Which of the following is true?

The mv command will delete the file on the hard disk after copying it to the flash drive. When moving from one partition or disk to another, mv must necessarily read and copy the file and then delete the original if that copy was successful, as stated in option A. If both filesystems support ownership and permissions, they'll be preserved; mv doesn't need an explicit --preserve option to do this, and this preservation does not rely on having exactly the same filesystem types. Thus, option D is incorrect. Although mv doesn't physically rewrite data when moving within a single low-level filesystem, this approach can't work when you're copying to a separate low-level filesystem (such as from a hard disk to a USB flash drive); if the data isn't written to the new location, it won't be accessible should the disk be inserted in another computer. Thus, option C is incorrect. Although not all filesystems support ownership and permissions, many do, and these attributes are preserved when moving files between them, so option B is incorrect. Although FAT is a common choice on removable media because of its excellent cross-platform support, other filesystems will work on such disks, so option E is incorrect.

Which is true of source RPM packages?

They can sometimes be used to work around dependency problems with a binary package. Some dependencies result from dynamically linking binaries to libraries at compile time, and so they can be overcome by recompiling the software from a source RPM, so option C is correct. Option A describes Debian source packages, not RPM packages. Recompiling a source RPM requires only issuing an appropriate command, although you must also have appropriate compilers and libraries installed. Thus, option B is overly pessimistic. Source tarballs can also be used to compile software for RPM systems, although this results in none of RPM's advantages. Thus, option D is overly restrictive. The RPM format doesn't impose any licensing requirements, contrary to option E. For more information, see Chapter 2.

What is the surest way to run a program (say, myprog) that's located in the current working directory?

Type ./ followed by the program name: ./myprog. The dot (.) character refers to the current working directory, and the slash (/) is a directory separator. Thus preceding a program name by ./ unambiguously identifies the intention to run the program that's stored in the current directory. Option A will run the first instance of the program that's found on the current path. Because paths often omit the current directory for security reasons, this option is likely to fail. The run command isn't a standard Linux command, so option B is unlikely to do anything, much less what the question specifies. Option C would be correct except that it reverses the order of the two characters. The effect is to attempt to run the .myprog file in the root (/) directory. This file probably doesn't exist, and even if it did, it's not the file the question specifies should be run. Option D runs the first instance of myprog found on the path, and additionally it runs the program in the background.

You want to enable all members of the music group to read the instruments.txt file, which currently has 0640 (-rw-r-----) permissions, ownership by root, and group ownership by root. How might you accomplish this goal?

Type chgrp music instruments.txt in the file's directory Type chown :music instruments.txt in the file's directory. The chgrp and chown commands can both change the group ownership of a file. The chgrp command takes a group name and a filename as parameters, as in option B. The chown command normally changes a file's owner; but if you provide a group name preceded by a dot (.) or a colon (:), as in option E, it changes the group of a file. The chown command as used in option A, will change the primary ownership of the file to the music user, if such a user exists on the system; it won't change the group ownership. There is no standard chgroup command, as in option C. Option D will change the permissions to 0600 (-rw-------), which will be a step backward with respect to the goal stated. For more information, see Chapter 4.

You're experiencing sporadic problems with a Secure Shell (SSH) login server—sometimes users can log in and sometimes they can't. What might you try immediately after a failure to help diagnose this problem?

Type tail /var/log/messages to look for error messages from the server. Log files, such as /var/log/messages and sometimes others in /var/log, often contain useful information concerning server errors. The tail program displays the last few lines of a file, so using it to examine log files immediately after a problem occurs can be a useful diagnostic procedure. Option C correctly combines these features. The http://localhost:631 URL of option E accesses the Common Unix Printing System (CUPS) configuration utility, which has nothing to do with SSH. There is no standard diagnose utility (option D) to help diagnose server problems, and there is no standard /dev/ssh file (option B). The sshd program is the SSH server itself, so option A will simply launch the server. For more information, see Chapter 5.

What are the safe procedures for removing a USB flash drive, mounted from /dev/sdb1 at /media/usb, from a Linux computer?

Type umount /media/usb, wait for the command to return and disk-activity lights to stop, and then unplug the drive. Option D correctly describes the safe procedure for removing a removable medium that lacks a locking mechanism from a Linux computer. (Instead of typing umount /media/usb, you could type umount /dev/sdb1; in this context, the two commands are equivalent.) Option C reverses the order of operations; the umount command must be typed before you physically remove the flash drive. Option B also has it backward; the sync command would need to be issued before removing the drive. (The sync command can prevent damage when removing disks, but it isn't a complete substitute for umount.) There is no standard usbdrive-remove command in Linux, and if you were to write a script that calls umount and call it usbdrive-remove, pulling the flash drive quickly, as option A describes, would be exactly the wrong thing to do. The fsck command of option E checks a filesystem for errors. It's not necessary to do this before removing a disk, and it won't unmount the disk, so option E is incorrect.

Which of the following are restrictions on ordinary users' abilities to run renice? (Select two.)

Users may not modify the priorities of other users' processes. Users may not increase the priority (that is, decrease the priority value) of their own processes. Linux insulates users' actions from one another, and this rule applies to renice; only root may modify the priority of other users' processes, so option C is correct. Similarly, only root may increase the priority of a process in order to prevent users from setting their processes to maximum priority, thus stealing CPU time from others, so option D is correct. Option E correctly describes nice, but not renice. The whole point of renice is to be able to change the priorities of existing processes. Contrary to option A, renice doesn't care about the shell from which renice or the target program was launched. Users may use renice to decrease their own processes' priorities, contrary to option B.

Which of the following, when typed in vi's command mode, saves a file and quits the program?

ZZ :wq The colon (:) starts ex mode, from which you can enter commands. In ex mode, r includes a file in an existing one, w writes a file, e loads an entirely new file, and q quits the program. Thus the desired combination is :wq (option E). As a special case, ZZ does the same thing, so option C is also correct. For more information, see Chapter 5.

Rick works as a sales manager for Perfect Solutions Inc. The company has a Linux-based network. Rick wants to combine the contents of the Sale1.txt and Sale2.txt files to a new file named FinSale.txt. Which of the following commands will he use to accomplish the task?

cat Sale1.txt Sale2.txt > FinSale.txt cat is a command that is used to display or print the contents of a file. For example: cat /var/log/dmesg The above command will display the contents of the /var/log/dmesg file. Note: The more command is used in conjunction with the cat command to prevent scrolling of the screen while displaying the contents of a file. So, for example, if the /var/log/dmesg file is longer than a page, the command 'cat /var/log/dmesg | more' will pause after displaying a page at a time. > is the symbol for output redirection. It is placed between a command that can generate output and a filename. If the specified file already exists, it overwrites that file's contents. Example 1: cat file1 > file2 Will first create a file named 'file2' and then copy the contents of 'file1' into it. No output will be shown on the screen. Answer options D and B are incorrect. The ls command is used to list files on a Linux computer. The syntax of the ls command is as follows: ls [options] [files] Several options are used with the ls command. The following is a list of some important options: Options Descriptions -a Lists all entries including hidden files. -d Lists only the name of a directory and not the contents. -R Lists the contents of subdirectories also. -r Lists filenames reverse sorted. For example, the following command displays all the files (including hidden files) in the /home directory and the contents in the subdirectories: ls -aR /home Answer option A is incorrect. The < redirection operator redirects the FinSale.txt file as an input to the command cat Sale1.txt Sale2.txt.

Which of the following commands is the most commonly used option to change file access permissions in Linux?

chmod

What command would you type (as root) to change the ownership of somefile.txt from ralph to tony?

chown tony somefile.txt Option C is the correct command. Typing chown ralph:tony somefile.txt, as in option B, sets the owner of the file to ralph and the group to tony. The chmod command used in options A and D is used to change file permissions, not ownership. Option E reverses the order of the filename and the owner.

You want to use dpkg to remove a package called theprogram, including its configuration files. Which of the following commands will you use to accomplish the task?

dpkg -P theprogram An uppercase -P invokes the purge operation, which completely removes a package and its configuration files, so option C is correct. The -e parameter uninstalls a package for rpm, but not for dpkg, so option D is incorrect. The lowercase -p causes dpkg to print information about the package's contents, so option E is incorrect. The -r parameter removes a package but leaves configuration files behind, so options A and B are both incorrect. (Option B also specifies a complete filename, which isn't used for removing a package-you should specify only the shorter package name.)

Which of the following commands uninstalls a package but leaves its configuration files for re-installation in future?

dpkg -r The dpkg -r command uninstalls a package but leaves its configuration files for re-installation in future. The Debian package manager (dpkg) is a command that performs various actions such as installing, configuring, removing, or unpacking a Debian package. The dpkg command maintains package information in /var/lib/dpkg. The available file keeps a list of all available packages, and the status file keeps package attributes, such as whether a package has been installed or has been marked for removal. Answer option B is incorrect. The dpkg -l command lists packages matching a given pattern. If no package-name-pattern is given, it lists all packages in /var/lib/dpkg/status, excluding the ones marked as not-installed. Answer option C is incorrect. The dpkg -C command searches for packages that have been installed only partially on your system. dpkg will suggest what to do with them to get them working. Answer option D is incorrect. The dpkg -s command reports the status of the specified package. This just displays the entry in the installed package status database.

Which of the following commands is implemented as an internal command in bash?

echo The echo command is implemented internally to bash, although an external version is also available on most systems. The cat, less, tee, and sed commands are not implemented internally to bash, although they can be called from bash as external commands.

John works as a network administrator for Perfect Solutions Inc. The company has a Linux-based network. John is working as a root user on the Linux operating system. He has a data.txt file in which each column is separated by the TAB character. Now, he wants to use this file as the input for data mining software he has created. The problem preventing him from accomplishing his task is that with his data mining software, he has used TAB as a delimiter to distinguish between columns. Hence, he is unable to use this file as the input for the software. However, if he somehow replaces the TAB characters of the file with SPACE characters, he can use this file as an input file for his data mining software. Which of the following commands will John use to replace the TAB characters of the file with SPACE characters?

expand -t 1 data.txt > data.txt According to the scenario, John can replace the TAB characters with single space characters with the expand command. With the expand -t 1 data.txt > data.txt command, the TABs of data.txt are changed into single spaces and are redirected by using the > command into the data.txt file. Now, John can use the data.txt file as the input file for his data mining software.

You have a data file, data.txt, to be processed by a particular program. However, the program cannot handle data separated by tabs. The data.txt file's data is separated by a tab stop at every eight characters. What command should you use before processing the data file with the program?

expand data.txt > data1.txt The expand command will remove tab stops at every eight characters. With newly formatted data stored in data1.txt via the > redirection symbol, option A is the correct choice. The od command will not remove tabs. Therefore, option C is incorrect. Option D does remove the tabs; however, the resulting data file, data.txt, will contain duplicate data records (due to the >> redirection option), some with tabs and some without. Therefore, option D is incorrect. There is not a --remove-tabs option on the fmt command, and thus optionE is incorrect. The unexpand command does the opposite of the expand command, adding tab stops instead of removing them. Therefore, option B is incorrect

You want to track down all of the files in /home that are owned by karen. Which of the following commands will do the job?

find /home -user karen The find command includes the ability to search by username using the -user name option, where name is the username; thus option D is correct. The -uid option to find can also locate files owned by a user, but it takes a numeric user ID (UID) as an argument, so option C isn't quite correct. The locate command provides no ability to search by user, so options E and A are incorrect. Although option B is a valid find command, it finds all of the files under /home with a filename of karen, not all files owned by the user karen, so this option is incorrect.

Which of the following commands is used to search for files?

find and locate locate is a command that searches files by names. This command relies upon a database. find is a command that searches desired files in the directories as well as subdirectories. Answer option A is incorrect. The sed command is a stream editor for filtering and transforming text. Answer option D is incorrect. touch is a command that is used to change a file's access and modification timestamps. It is also used to create a new empty file.

What tool can diagnose and fix many common Linux filesystem problems?

fsck Option C, fsck, is Linux's filesystem check utility. It's similar in purpose to the DOS and Windows CHKDSK and ScanDisk utilities (similar to options C and D), but these DOS and Windows utilities don't work on Linux filesystems like ext2fs or ReiserFS. Option D, mkfs, creates new filesystems; it doesn't diagnose or fix filesystem problems. Option E, fdisk, is a tool for creating or modifying disk partitions; it doesn't manage the filesystems they contain. For more information, see Chapter 3.

Which command is used to install GRUB Legacy into the MBR of your first SATA hard drive?

grub-install /dev/sda You use grub-install to install the GRUB Legacy boot loader code into an MBR or boot sector. When using grub-install, you specify the boot sector on the command line. The MBR is the first sector on a hard drive, so you give it the Linux device identifier for the entire hard disk, /dev/sda. Hence, option D is correct. Option B specifies using the grub utility, which is an interactive tool, and the device identifier shown in option B is a GRUB-style identifier for what would probably be the /dev/sda3 partition in Linux. Option A is almost correct, but it installs GRUB to the /dev/sda1 partition's boot sector rather than to the hard disk's MBR. Option E is the command to install LILO to the MBR rather than to install GRUB. Option C contains the same error as option A, and it also uses the fictitious grub-legacy command.

Which of the following commands can be used to maintain the /etc/ld.so.cache file?

idconfig The ldconfig command can be used to maintain the /etc/ld.so.cache file. It configures as well as fixes the errors in the shared libraries. It creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib). The cache checks the header and filenames of the libraries and determines which versions should have their links updated. Answer option A is incorrect. The ldd command is used to print the shared libraries required by each program or shared library specified on the command line. Answer option B is incorrect. The ld.so library loads the shared libraries needed by a program, prepares the program to run, and then runs it. Answer option C is incorrect. This is not a valid Linux command.

Which of the following commands displays help on topic, when typed in a Linux shell? (Select two.)

info topic man topic The correct answers, man and info (options B and D), are two common Linux help packages. Although ? (option C) is a common help command within certain interactive programs, it isn't a help command in bash or other common Linux shells. There is no common command called manual (option E), nor is hint (option A) a valid bash command or common program name. For more information, see Chapter 1.

You work as a network administrator for World Perfect Inc. The company has a Linux-based network. You have configured a Linux Web server on the network. A user complains that the Web server is not responding to requests. The process list on the server shows multiple instances of the HTTPD process. You are required to stop the Web service. Which of the following commands could you use to resolve the issue?

killall httpd killall is a command that terminates multiple processes running with the same name. For example, killall httpd terminates all httpd processes running on a Linux computer.

You want to know what kernel modules are currently loaded. What command would you type to learn this information?

lsmod

Which utility should you use by itself to rename the file pumpkin.txt to lantern.txt?

mv The mv utility can be used to rename files as well as move them from one location to another, so option B is correct. The dd utility (option E) is used to copy files to backups, rm (option D) is used to remove (delete) files, cp (option C) copies files, and ln (option A) creates links. For more information, see Chapter 4.

What mount point should you associate with swap partitions?

none of these Swap partitions aren't mounted in the same way as filesystems, so they have no associated mount points, making option E correct.

Which of the following commands will install an RPM package file called theprogram-1.2.3-4.i386.rpm on a computer?

rpm -Uvh theprogram-1.2.3-4.i386.rpm rpm -i theprogram-1.2.3-4.i386.rpm The -Uvh parameter (option C) issues an upgrade command (which installs the program whether or not an earlier version is installed) and creates a series of hash marks to display the command's progress. The -i parameter (option D) installs the program if it's not already installed but causes no progress display. Option E uses a package name, not a complete filename, and so it will fail to install the package file. The -e option (option A) removes a package. Option B's -Vp option verifies the package file but doesn't install it. For more information, see Chapter 2.

What command will you use to find the current runlevel of an active Linux session?

runlevel The runlevel command is used to find the current runlevel of an active Linux session. Answer option A is incorrect. The init command is used to change the runlevel of a Linux system. Answer options B and C are incorrect. These are not valid commands to find the runlevel.

Which of the following commands will change all occurrences of dog in the animals.txt file to mutt in the screen display?

sed 's/dog/mutt/g' animals.txt The sed utility can be used to "stream" text and change one value to another. In this case, the s option is used to replace dog with mutt, making option C correct. The syntax in option E is incorrect, and choices D and B are incorrect because grep doesn't include the functionality needed to make the changes. Option A combines fmt, cut, and redirection in a way that simply won't work to achieve the desired goal.

What command would you use to change to single-user mode on a running systemd system?

systemctl isolate rescue.target The isolate command for the systemctl program allows you to change the target of the system. The rescue target specifies single-user mode. Option D changes the system to the default target, which may or may not be single-user mode. The journalctl program in option E displays the systemd log files. The systemd program isn't used to change targets (option A), and the start command only starts a single unit, not a target (option B).

What program would you use to display the end of a configuration file?

tail The tail command displays the final 10 lines of a file, so option B is correct. (You can change the number of lines displayed with the -n option.) The uniq command (option D) removes duplicate lines from a list. The cut command (option C) echoes the specified characters or fields from an input text file. The wc command (option A) displays counts of the number of characters, words, and lines in a file. The fmt command (option E) is a plain-text formatter.

You have made a program secure.c to display which ports are open and what types of services are running on these ports. You want to write the program's output to standard output and simultaneously copy it into a specified file. Which of the following commands will you use to accomplish the task?

tee You will use the tee command to write its content to standard output and simultaneously copy it into the specified file. tee is a command that is used to split the output of a program so that it can be displayed on screen and also be saved in a file. It can also be used to capture intermediate output before the data is altered by another command or program. The tee command reads standard input, then writes its content to standard output, and simultaneously copies it into the specified file(s) or variables. The syntax of the tee command is as follows: tee [-a] [-i] [File] where, the -a option appends the output to the end of the file instead of writing over it and the -i option is used to ignore interrupts.

Which of the following characters defines the end of an OS or kernel definition in /boot/grub/grub.cfg?

} The grub.cfg filename indicates a GRUB 2 configuration file. In such files, each OS or kernel stanza begins with a menuentry line and an open curly brace ({) and ends with a close curly brace (}). Thus, option A is correct. Some configuration files and programming languages use semicolons (;) at the end of most lines, but this isn't true of GRUB 2, so option C is incorrect. Although close parentheses ()) are used to terminate some types of options in some configuration files, including disk identifiers in GRUB 2's configuration file, they aren't used to terminate whole OS or kernel definitions in this file, so option B is incorrect. The string */ terminates comments in C program files but isn't commonly used in GRUB 2 configuration files, so option E is incorrect. Option D would be correct if the question had asked about a GRUB Legacy configuration file (menu.lst or grub.conf), but the question specifies a GRUB 2 configuration file (grub.cfg); the two boot loaders terminate their OS/kernel stanzas differently, so option D is incorrect. For more information, see Chapter 5, "Booting Linux and Editing Files


Ensembles d'études connexes

Accounting Information and Controls

View Set

History of Western Art Practice Test #4

View Set