Article feb2006.tar

Test Your Knowledge

Emmett Dulaney

Think you're ready to whip out the company credit card and register for that certification exam that has caught your eye? Before you do, test your knowledge with this sample exam of questions covering basic to intermediate-level Linux/Unix topics.

One caveat: over time, I've learned that there are risks involved in writing practice tests. The risks fall into two categories: first, there is almost always more than one way to do the same task in Linux or Unix, and second, *nix users love to point out that none of the possible answers are the way they would do it; they have a script they wrote, an application they purchased, or a friend who knows a guy who has a tool, etc.

When you take an exam, however, whether it's Linux+ from CompTIA, an exam from the Linux Professional Institute, or any other non-lab-based test, you have to pick the best answer from those choices presented to you. Don't over-think the question and talk yourself out of the correct answer.

With that said, let's see how well you do! (The answers can be found at the end of this article.)

Questions

1. Which utility is available in many Linux workstation implementations for use in configuring the sound card?

A. sndadmin
B. sndmin
C. sndconfig
D. radius

2. Which of the following represents the output of the following command: echo "alpha-beta" | sed 's/-.*$//'

A. alpha-beta
B. alpha
C. beta
D. alpha-****
E. alpha-*eta

3: You need to create a file named cow and send the output to it from the who -z command. You want all output -- including standard errors -- to go to this file. Which command should be used to accomplish this?

A. who -z > cow
B. who -z 2> cow
C. who -z >&1 cow
D. who -z > cow 2>&1

4. Which of the following runlevels will reboot the system?

A. 0
B. 2
C. 4
D. 6

5. The value of the BOSS variable has been set to TRUITT. What will the output of the command echo '$BOSS' be?

A. TRUITT
B. BOSS
C. $BOSS
D. $TRUITT

6. You need to view all but the first seven lines of the similar.log file. What command should be used to accomplish this?

A. head -7 similar.log
B. head +7 similar.log
C. tail -7 similar.log
D. tail +7 similar.log

7. What is the default subnet mask for a network beginning with 216?

A. 127.0.0.1
B. 255.0.0.0
C. 255.255.0.0
D. 255.255.255.0
E. 255.255.255.255

8. What authentication method does telnet use when the user is attempting to log on to a remote host?

A. username
B. password
C. username and password
D. /etc/telnet.hash

9. You are late for a meeting. You need to start the qwerty utility before heading to the meeting so it will run for the next few hours and compile weekly system usage results. Currently, you are logged in as a regular user, but the qwerty script requires root permission to run. How should you execute the script?

A. su ; qwerty
B. su qwerty
C. su -c qwerty
D. su : qwerty

10. You want to allow users to access the CD-RW device on your machine from any other host on the network via NFS. Further, you only want them to have read-only access to the device. Which line should you add to the /etc/exports file to allow this?

A. /mnt/cdrom *(ro)
B. /mnt/cdrom *(r)
C. /mnt/cdrom *
D. /mnt/cdrom

11. What protocol does ping utilize to bounce packets?

A. TCP
B. IP
C. ICMP
D. IGMP

12. Which configuration file is used to identify where system log messages are recorded?

A. logrotate.conf
B. syslog.conf
C. conf.modules
D. modules.conf

13. You want users to be able to download files through anonymous FTP and do nothing further. What access should they have in the directory they will access?

A. Read
B. Write
C. Execute
D. Run

14. Which tool can be used to check IP to MAC address resolution?

A. ping
B. arp
C. ifconfig
D. ipconfig

15. You want to extract an archive from a tape. The archive was created using tar, and you want to copy all the contents from the tape back to the system. What one option must you use with tar to accomplish this?

A. c
B. x
C. v
D. r

16. By default, which protocol runs at port 110?

A. LDAP
B. Telnet
C. POP3
D. SMTP

17. Which of the following commands can be used with FTP to place several files on a remote host?

A. mget
B. get
C. put
D. mput

18. You have been assigned the task of recommending password guidelines for users across the network. Which of the following should you recommend for users creating passwords?

A. Use a common word and misspell it.
B. Use a mixture of upper- and lower-case letters, as well as numbers and symbols.
C. Use a mixture of random numbers.
D. Use a mixture of random letters that do not produce an actual word.

19. What is the best location for storing a Tripwire database on your system?

A. On an attached CD-R system
B. In the root directory
C. On a backup tape storage drive
D. On a Web database that is not located within the central network

20. Which of the following files defines how FTP connection requests are processed by the TCP Wrapper?

A. ftpusers
B. /etc/hosts.allow and /etc/hosts.deny
C. ftpaccess
D. xferlog

21. A variable has been set with the command WORD=BINGO. Which command can be used to show that the variable WORD now has a value?

A. set
B. env
C. show
D. cat

22. For legacy reasons, a huge file must be copied on a floppy to be transferred to another machine. What command can be used to make a file fill more than one floppy?

A. limit
B. cut
C. chop
D. split

23. What search criteria would best be used to find the lines within the SYSADMIN file about booth "spaces" for an upcoming trade show?

A. grep spaces SYSADMIN
B. find spaces SYSADMIN
C. sed spaces SYSADMIN
D. search spaces SYSADMIN

24. You want to combine two files together such that the fields from each file are combined into a single output. The first field of each of the two files you will be using are identical. What utility can you use to create this file?

A. od
B. join
C. paste
D. comb

25. Which command will show all the files, including files beginning with a dot, in the long format?

A. ls -a | ls -l
B. ls -a ; ls -l
C. ls -la
D. ls -a\l

26. Which of the following will set the variable DAY equal to FRIDAY with the BASH shell?

A. DAY FRIDAY
B. DAY=FRIDAY
C. DAY:FRIDAY
D. $DAY FRIDAY

27. You need to find all the files in your current directory that begin with "c", "r", "u", "s", or "h", and end with "G", "R", "A", "P", or "E". Which command should you use to accomplish this?

A. ls crush*GRAPE
B. ls c*G c*R c*A c*P c*E r*G r*R
r*A r*P r*E u*G u*R u*A u*P u*E
s*G s*R s*A s*P s*E h*G h*R h*A
h*P h*E

C. ls [crush]?[GRAPE]
D. ls [crush]*[GRAPE]

28. After giving the command PS1="Kansas" on a server named System 9, what will the prompt now be?

A. Kansas$
B. Kansas
C. [System 9 Kansas]
D. $

29. What variable can you echo, in BASH, to see the PID of the last jobs started?

A. $$
B. $?
C. $!
D. !!

30. Which of the following devices would be the first SCSI hard disk on a Linux system, assuming devfs is not being used?

A. /dev/sd0
B. /dev/sd1
C. /dev/sda
D. /dev/sdb

31. You are using the BASH shell and want to send your history file to development so they can figure out why problems keep occurring. What file should you attach to email?

A. bash_history
B. bashrc
C. .bashrc
D. .bash_history

32. Which utility can be used to list modules, remove modules, and add modules?

A. modprobe
B. insmod
C. rmmod
D. depmod

33. You are currently in the /usr/home/spencer/lists/phone directory. Your HOME variable is set to /usr/home/spencer and the PATH is set to /sbin:/usr/sbin. The OLDPWD variable is set to /root. When you give the command pwd, what directory will you then be in?

A. /root
B. /sbin
C. /usr/home/spencer
D. /usr/home/spencer/lists/phone

34. Which of the files holds configuration information on how to manage terminal devices (respawn them)?

A. /etc/initd
B. /etc/inetd
C. /etc/inittab
D. /dev/inetd

35. You are in the empty directory "abcd" and you give the command touch abcd. What will the result of this command be?

A. An error message will be returned.
B. The times associated with the directory will be updated.
C. A new file will be created.
D. A new directory will be created.

36. A user named kevin copies a file from the home directory of sarah. Within sarah's home directory, the owner of the file was root. The directory that kevin copies the file into is evan's home directory, and owned by evan. Who will appear as the owner of the file in evan's home directory?

A. kevin
B. sarah
C. root
D. evan

37. Kristin is doing a number of operations on her system as she attempts to clean up files and make the system more manageable. Which of the following operations will take the least amount of time to complete?

A. cp certification exam
B. mv certification exam
C. dd certification exam
D. cp -i certification exam

38. Kristin has been cleaning up files that are no longer used on her system. Inadvertently, she typed rm -r * when one directory further back than she thought she was. How can she restore the files that were accidentally deleted?

A. dd
B. rm -i
C. Ctrl-Z
D. Restore from backup

39. Karen wants to create a path consisting of several subdirectories that do not presently exist. Which command should be used for this purpose?

A. md
B. md -p
C. mkdir
D. mkdir -p

40. With a umask value of 012, what are the default permissions assigned to newly created files?

A. ---x--x-wx
B. -rw-rw-r--
C. -r-xr-xr--
D. -rw-rw----

41. Which of the following would produce the same display as ps -e?

A. ps -f
B. ps -A
C. ps -l
D. ps -u

42. Which of the following will start a job in the background?

A. -
B. +
C. %
D. &

43. A process with a PID number of 9876 has entered runaway mode. You have tried to remove it with a standard kill command, but it will not go away. What command can you use to be assured the process will terminate?

A. kill -NOW 9876
B. kill -HUP 9876
C. kill -15 9876
D. kill -9 9876

44. You are getting ready to leave the office for the day. About a minute ago, you started a job in the background to compile a report that may run for hours. When the compilation ends, you need another process to run to print the results. Which of the following commands will accomplish this?

A. bg {process}
B. fg {process}
C. wait $! ; {process}
D. sleep ; {process]

45. You have accidentally started a job that consumes a great deal of resources. You feel that this has the possibility of negatively affecting how other jobs run on the system. Which command can you use to alter the priority level of this job?

A. nice
B. start
C. renice
D. ps

46. The fsck utility has found a number of corrupted files and you have chosen to correct the filesystem. To which directory are the corrupted files written?

A. lost+found
B. tmp
C. etc
D. /

47. Which ports, by default, are used by the SNMP protocol?

A. UDP ports 20 and 21
B. TCP ports 15 and 16
C. UDP ports 161 and 162
D. LDAP ports 163 and 164

48. Which field of the /etc/passwd file defines the shell the user will receive?

A. first
B. second
C. sixth
D. seventh

49. Which of the following are valid IP addresses available for assignment to a host?

A. 200.127.127.1
B. 1.5.10.256
C. 256.1.1.1
D. 127.0.0.2

50. You want to find all the three-letter files in the current directory that end with the letter y. What command should you use?

A. ls *y
B. ls *y*
C. ls ??y
D. ls ??y*

Answers

1. Sndconfig is a sound configuration tool that originally shipped with Red Hat. Answer: C.

2. The sed utility will search for the dash (-) specified and then replace everything from it to the end of the line (signified by the dollar sign) with nothing (signified by the empty //). Answer: B.

3. The who -z 2>&1 > cow command will send standard output (1) and standard error (2) to the same place (&), which is specified as the cow file. Answer: D.

4. A runlevel of 6 brings the system down and starts it back up again -- rebooting it. Answer: D.

5. The single quotations (') allow the variable to be taken literally, thus the valued echoed back is simply $BOSS. Answer: C.

6. Using the tail + command, you are able to see all the file except the number of lines at the beginning specified. In this case, all but the first seven are shown. Answer: D.

7. A network beginning with 216 falls in the Class C category. The default subnet mask for all Class C networks is 255.255.255.0. Answer: D.

8. The telnet utility uses both the username and password to authenticate the user. Answer: C.

9. The -c option with allows you to specify a command to run with the elevated privileges. Answer: C.

10. While this is not the most likely place to mount a CD-RW drive, it is important to be able to do so from here. Answer: A.

11. The ping utility verifies connectivity between hosts by bouncing echoes using the ICMP protocol. Answer: C.

12. The syslog.conf file controls the output of the syslogd daemon. Answer: B.

13. You must set the execute bit on a directory in order for users to be able to access files in the directory. Answer: C.

14. The arp utility can be used to check IP to MAC address resolution. Answer: B.

15. The x option is used with tar to extract. Answer: B.

16. By default, POP3 runs at port 110. LDAP runs at port 389, Telnet at 23, and SMTP at 25. Answer: C.

17. The mput command in FTP can be used to place multiple files on a remote host. Answer: D.

18. Strong passwords should contain upper- and lower-case letters, as well as numbers and symbols. Answer: B.

19. For security reasons, Tripwire databases should be stored on media that is not read-only. Answer: A.

20. While this could also be done with inetd.conf or xinetd.conf, neither of those are possible answers. That leaves hosts.allow and hosts.deny as the only other answer that fits the question. Answer: B.

21. Until a variable is exported, it will not show up in the environment (choice B), but will display with the set command. Answer: A.

22. The split utility will chop a file into smaller segments that can then fit onto a floppy. Answer: D.

23. A thorough knowledge of grep and find is required for almost any exam, while knowledge of sed is required for many higher level exams. Answer: A.

24. The join utility will combine the two files based on the same value being in the first file of each. If you did not want to use any intelligence whatsoever (in other words, the two files do not have any field in common), you could use paste. Answer: B.

25. The ls -la command combines both options -a (show all files -- including those that begin with a dot) with -l (use the long listing). Answer: C.

26. Most Linux/Unix exams can be considered BASH-centric, so it is important to know how to set variables and work within the features/limitations of them. Answer: B.

27. Using brackets ([ ]), you can set the search parameters to only entries within them. Answer: D.

28. Setting the prompt to the literal value, it will become only that value. When doing this, you should always include a space before the last quotation mark, or some other character such as a greater than sign (>), to be able to see the difference between the prompt and the commands you are giving. Answer: B.

29. The value of $! will be the process ID number of the last job. Answer: C.

30. The syntax used to denote disks makes sda the only correct choice. Answer: C.

31. The BASH history file is stored in the user's home directory as a hidden file named .bash_history. Answer: D.

32. The modprobe utility can be used to list modules, remove modules, and add modules. Answer: A.

33. Since the pwd command only echoes the directory you are presently in, you will still be in /usr/home/spencer/lists/phone. Answer: D.

34. The /etc/inittab file is used to manage terminal devices, and you should know how many fields are in each entry and what values can be in each field. Answer: C.

35. The touch utility is used to change the date on a file. If no file exists by that name (the question states that the directory is empty), it will create a new file by that name. Answer: C.

36. Since Kevin is creating the new file through the copy operation, he is the owner. If the file were moved, the original owner would be kept, but copy must always use the person performing the operation as the owner. Answer: A.

37. "mv" renames a pointer and will be finished in a faction of a second regardless of the file size. Answer: B.

38. The only way to restore deleted files in Linux is to break out the backup tapes and restore from there. Answer: D.

39. By default, mkdir (choice C) will only allow you to create one file, and the -p option must be used to create a path including subdirectories. Answer: D.

40. The default permissions for newly created files are 666 (-rw-rw-rw-). When you "subtract" from the default with umask, you really are performing a "logical or" from what is there. A umask of 012 is equal to (------x-w-). When you remove that from the default, the correct answer is 664 (-rw-rw-r--). Answer: B.

41. The -e option asks for everything, while the -A option asks for all. The -f option (choice A) gives a full listing, but only for the current user. The -l option (choice C) gives a long listing -- again it would be only for the current user in this case. The -u option (choice D) adds user-related information. Answer: B.

42. The ampersand (&) is used to start a job in the background. Answer: D.

43. While there is no guarantee that kill -9 will terminate a zombie process, it is the best chance you have of so doing, and the best answer choice here. Answer: D.

44. The dollar and bang signs ($!) represent the last process started in the background. When used with wait, the background process must end before the next process begins. Answer: C.

45. Nice is a utility to start a job at a priority other than the default, but cannot be used once the job is running. Only renice can be used to change the priority of running jobs. Answer: C.

46. The /lost+found directory holds the corrupted files. Usually they are so corrupted that their names are no longer known, and thus the files are written here by inode number. Answer: A.

47. By default, SNMP uses UDP ports 161 and 162. Answer: C.

48. The seventh, and final, field of the /etc/passwd file holds the shell entry for the user. If the field is blank, they automatically receive the default shell. Answer: D.

49. To be a valid IP address for use by a host, the first octet must be between 1-223 (with the exception of 127), and the remaining octets can be between 0-255. Answer: A.

50. The question mark character (?) indicates a single item, while the asterisk (*) signifies any item. Since you only want three-letter entries, use two question marks and the last letter. Answer: C.

Emmett Dulaney, Linux+, LPI, etc. is the author of several books on Linux/Unix and certification as well as a columnist for UnixReview. Emmett can be reached at: edulaney@iquest.net. Feel free to send him feedback on this sample test.