LPI¦ÒÃD¤À¨É 1 Obj 3.1 Chapter 5 What is a shell Which of the following interprets your actions when typing at the command line for the operating system? Choose One a. Utility b. Application c. Shell d. Command Answer: c A shell is a program that acts as an intermediary between the user and the operating system. It interprets what you type and passes it to the operating system. ===== 2 Obj 3.1 Chapter 5 What is a shell What can you type at a command line to determine which shell you are using? Answer: echo $SHELL The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable's name with $. Therefore, typing echo $SHELL will display the name of your shell. ===== 3 Obj 3.1 Chapter 5 Typing at the command line You want to enter a series of commands from the command-line. What would be the quickest way to do this? Choose One a. Press enter after entering each command and its arguments b. Put them in a script and execute the script c. Separate each command with a semi-colon (;) and press enter after the last command d. Separate each command with a / and press enter after the last command Answer: c The semi-colon may be used to tell the shell that you are entering multiple commands that should be executed serially. If these were commands that you would frequently want to run, then a script might be more efficient. However, to run these commands only once, enter the commands directly at the command line. ===== 4 Obj 3.1 Chapter 5 Typing at the command line You are entering a long, complex command line and you reach the right side of your screen before you have finished typing. You want to finish typing the necessary commands but have the display wrap around to the left. Which of the following key combinations would achieve this? Choose One a. Esc, /, Enter b. /, Enter c. ctrl-d, enter d. esc, /, ctrl-d Answer: b The / is called an escape character. It tells the shell to ignore the next typed character when sending the command to the operating system. When you press the enter key, the shell wraps to the left of your display so you can see what you are typing but the NEWLINE character will not be sent to the operating system. 5 Obj 3.1 Chapter 5 Typing at the command line After typing in a new command and pressing enter, you receive an error message indicating incorrect syntax. This error message originated from Choose one a. The shell b. The operating system c. The command d. The kernel Answer: c The shell does not understand the command but merely passes it to the operating system. The operating system calls the command, however, the error message originates from the command itself. 6 Obj 3.1 Chapter 5 The Readline Library When typing at the command line, the default editor is the _____________ library. Answer: readline By default, your shell used the readline library in emacs mode as its command line editor. 7 Obj 3.1 Chapter 5 The Readline Library You typed the following at the command line ls -al /home/ hadden What key strokes would you enter to remove the space between the '/' and 'hadden' without having to retype the entire line? Choose one a. Ctrl-B, Del b. Esc-b, Del c. Esc-Del, Del d. Ctrl-b, Del Answer: b The key combination Esc-b will move your cursor to the beginning of the word to the left. In this case, it would move your cursor to the beginning of the word hadden. Then, the Del key would delete one character to the left of the cursor or the extra space. 8 Obj 3.1 Chapter 5 inputrc You would like to temporarily change your command line editor to be vi. What command should you type to change it? Answer: set -o vi The set command is used to assign environment variables. In this case, you are instructing your shell to assign vi as your command line editor. However, once you log off and log back in you will return to the previously defined command line editor. ===== 9 Obj 3.1 Chapter 5 inputrc After experimenting with vi as your command line editor, you decide that you want to have vi your default editor every time you log in. What would be the appropriate way to do this? Choose one a. Change the /etc/inputrc file b. Change the /etc/profile file c. Change the ~/.inputrc file d. Change the ~/.profile file Answer: c The /etc/inputrc file defines the default command line editor for the system. If you want to define a different editor for your use, put it in the .inputrc file in your home directory. ===== 10 Obj 3.1 Chapter 5 You have to type your name and title frequently throughout the day and would like to decrease the number of key strokes you use to type this. Which one of your configuration files would you edit to bind this information to one of the function keys? Answer: .inputrc The .inputrc file in your home directory can define key bindings as well as define you command line editor. To see which key bindings have been defined, type bind -v. ===== 11 Obj 3.1 Chapter 5 Command Line Completion In your present working directory, you have the files maryletter memo1 MyTelephoneandAddressBook What is the fewest number of keys you can type to open the file MyTelephoneandAddressBook with vi? Choose one a. 6 b. 28 c. 25 d. 4 Answer: a You could open the file MyTelephoneandAddressBook in vi using command line completion by typing vi My which is only 6 characters. Since you only have the one file that begins with "My", when you press the Tab key, the shell will enter the entire filename. ===== 12 Obj 3.1 Chapter 5 User Variables and Environment Variables A variable that you can name and assign a value to is called a _____________ variable. Answer: user There are two types of variables: user and environment variables. An environment variable is one that is already named by the program, but you can change its value. A user variable, however, is one that you can create by naming it and then assign it a value. ===== 13 Obj 3.1 Chapter 5 Path You have installed a new application but when you type in the command to start it you get the error message Command not found What do you need to do to fix this problem? Choose one a. Add the directory containing the application to your path b. Specify the directory's name whenever you run the application c. Verify that the execute permission has been applied to the command. d. Give everyone read, write and execute permission to the application's directory. Answer: a When you execute a command, the operating system looks for that command in the directories specified by the PATH environment variable. By adding the application's directory to the path, the operating system will be able to locate the command and execute it. ===== 14 Obj 3.1 Chapter 5 prompt You telnet into several of your servers simultaneously. During the day, you sometimes get confused as to which telnet session is connected to which server. Which of the following commands in your .profile file would make it obvious to which server you are attached? Choose one a. PS1='\h: \w>' b. PS1='\s: \W>' c. PS1='\!: \t>' d. PS1='\a: \n>' Answer: a The PS1 variable is used to define how your prompt appears. The string listed here would display the hostname and present working directory. Now, whenever you look at your prompt, you know which server you working on. 15 Obj 3.1 Chapter 5 home Which of the following environment variables determines your working directory at the completion of a successful login? Choose one a. HOME b. BASH_ENV c. PWD d. BLENDERDIR Answer: a The HOME environment variable contains the path to the user's home directory. After a successful login, the user is placed in his home directory. ===== 16 Obj 3.1 Chapter 5 Aliases Every time you attempt to delete a file using the rm utility, the operating system prompts you for confirmation. You know that this is not the customary behavior for the rm command. What is wrong? Choose one a. rm has been aliased as rm -i b. The version of rm installed on your system is incorrect. c. This is the normal behavior of the newest version of rm. d. There is an incorrect link on your system. Answer: a It is common for the rm command to be aliased to rm -i as a safety measure to prevent deleting the incorrect file. ===== 17 Obj 3.1 Chapter 5 history List You are running out of space in your home directory. While looking for files to delete or compress you find a large file called .bash_history and delete it. A few days later, it is back and as large as before. What do you need to do to ensure that its size is smaller? Choose one a. Set the HISTFILESIZE variable to a smaller number. b. Set the HISTSIZE to a smaller number. c. Set the NOHISTFILE variable to true. d. Set the HISTAPPEND variable to true. Answer: a The HISTFILESIZE variable defines the number of lines or events to save for the next login session. ===== 18 Obj 3.1 Chapter 5 History List In order to display the last five commands you have entered using the history command, you would type ___________. Answer: history 5 The history command displays the commands you have previously entered. By passing it an argument of 5, only the last five commands will be displayed. ===== 19 Obj 3.1 Chapter 5 fc In order to display the last five commands you have entered using the fc command, you would type ___________. Answer: fc -5 The fc command can be used to edit or rerun commands you have previously entered. To specify the number of commands to list, use -n. ===== 20 Obj 3.1 Chapter 5 fc You previously ran the find command to locate a particular file. You want to run that command again. What would be the quickest way to do this? Choose one a. fc -l find fc n b. history -l find history n c. Retype the command d. fc -n find Answer: a You can use the fc command to search for a previously entered command by passing a pattern as an argument. ===== 21 Obj 3.1 Chapter 5 Command Substitution Using command substitution, how would you display the value of the present working directory? Choose one a. echo $(pwd) b. echo pwd c. $pwd d. pwd | echo Answer: a Using the $ and parenthesis causes the value of the variable pwd to be displayed rather than echoing 'pwd'. ===== 22 Obj 3.5 Chapter 5 Processes You need to search the entire directory structure to locate a specific file. How could you do this and still be able to run other commands while the find command is still searching for your file? Choose one a. find / -name filename & b. find / -name filename c. bg find / -name filename d. &find / -name filename & Answer: a You can run any command in the background by using an ampersand (&) at the end of the command. ===== 23 Obj 3.5 Chapter 5 Processes In order to create a file called DirContents containing the contents of the /etc directory you would type ____________. Answer: ls /etc > DirContents Using the > will redirect the output of the ls /etc command to the file DirContents. ===== 24 Obj 3.5 Chapter 5 Processes What would be displayed as the result of issuing the command ps ef? Choose one a. A listing of the user's running processes formatted as a tree. b. A listing of the stopped processes c. A listing of all the running processes formatted as a tree. d. A listing of all system processes formatted as a tree. Answer: a This would show the parent child relationship of all the user's processes. ===== 25 Obj 3.5 Chapter 5 top What utility can you use to show a dynamic listing of running processes? __________ Answer: top The top utility shows a listing of all running processes that is dynamically updated. ===== 26 Obj 3.6 Chapter 5 top and nice The top utility can be used to change the priority of a running process? Another utility that can also be used to change priority is ___________? Answer: nice Both the top and nice utilities provide the capability to change the priority of a running process. ===== 27 Obj 3.5 Chapter 5 Background and Foreground Processes What key combination can you press to suspend a running job and place it in the background? Answer: ctrl-z Using ctrl-z will suspend a job and put it in the background. ===== 28 Obj 3.6 Chapter 5 Jobs You issue the command jobs and receive the following output: [1]- Stopped (tty output) pine [2]+ Stopped (tty output) MyScript How would you bring the MyScript process to the foreground? Choose one: a. fg %2 b. ctrl-c c. fg MyScript d. ctrl-z Answer: a You use the fg command to bring a process to the foreground. Since there are multiple jobs to select from, you must specify the job by either its job number or name. ===== 29 Obj 3.5 Chapter 5 Jobs You enter the command cat MyFile | sort > DirList & and the operating system displays [4] 3499 What does this mean? Choose one a. This is job number 4 and the PID of the sort command is 3499. b. This is job number 4 and the PID of the job is 3499. c. This is job number 3499 and the PID of the cat command is 4. d. This is job number 4 and the PID of the cat command is 3499. Answer: a The first number, 4, is the number of the job. The second number is the PID of the last process of the job. ===== 30 Obj 3.5 Chapter 5 Signals You attempt to log out but receive an error message that you cannot. When you issue the jobs command, you see a process that is running in the background. How can you fix this so that you can logout? Choose one a. Issue the kill command with the PID of each running command of the pipeline as an argument. b. Issue the kill command with the job number as an argument. c. Issue the kill command with the PID of the last command as an argument. d. Issue the kill command without any arguments. Answer: c You can use the kill command to terminate a process that does not want to quit. You do this by using either the PID or the name of the process as an argument. ===== 31 Obj 11.5 Chapter 11 Planning your backup You have been given the job of administering a new server. It houses a database used by the sales people. This information is changed frequently and is not duplicated anywhere else. What should you do to ensure that this information is not lost? Choose one a. Create a backup strategy that includes backing up this information at least daily. b. Prepare a proposal to purchase a backup server c. Recommend that the server be made part of a cluster. d. Install an additional hard drive in the server. Answer: a In order to protect against the loss of data, a method of backing up your information on a regular basis should be implemented. Since the data changes frequently, you might consider backing it up more frequently than daily. ===== 32 Obj 11.5 Chapter 11 Planning When planning your backup strategy you need to consider how often you will perform a backup, how much time the backup takes and what media you will use. What other factor must you consider when planning your backup strategy? _________ Answer: what to backup Choosing which files to backup is the first step in planning your backup strategy. ===== 33 Obj 11.5 Chapter 11 Backup frequency Many factors are taken into account when planning a backup strategy. The one most important one is how often does the file ____________. Answer: change If a file is static and never changes, then you can back it up less frequently. However, if a file changes daily or hourly, then you will want to back it up more frequently to prevent the loss of data. ===== 34 Obj 11.5 Chapter 11 Media selection Which one of the following factors does not play a role in choosing the type of backup media to use? Choose one: a. How frequently a file changes b. How long you need to retain the backup c. How much data needs to be backed up d. How frequently the backed up data needs to be accessed Answer: a The frequency that a file changes does not impact on the type of media you choose to use. ===== 35 Obj 11.5 Chapter 11 Types of backups When you only back up one partition, this is called a ______ backup. Choose one a. Differential b. Full c. Partial d. Copy Answer: c A partial backup is where you select only a portion of your file hierarchy or a single partition to back up. This is not dependent upon whether or not the file has changed since the last backup. ===== 36 Obj 11.5 Chapter 11 Types of backups When you back up only the files that have changed since the last backup, this is called a ______ backup. Choose one a. Partial b. Differential c. Full d. Copy Answer: b A differential backup is one where the files to backup are selected on the basis of when the last change was made and not on its location in the file hierarchy. ===== 37 Obj 11.5 Chapter 11 Types of backups The easiest, most basic form of backing up a file is to _____ it to another location. Answer: copy The easiest most basic form of backing up a file is to make a copy of that file to another location such as a floppy disk. ===== 38 Obj 11.5 Chapter 11 Restoring files from backup When is the most important time to restore a file from your backup? Choose one a. On a regular scheduled basis to verify that the data is available. b. When the system crashes. c. When a user inadvertently loses a file. d. When your boss asks to see how restoring a file works. Answer: a You should always do routine restorations in order to ensure that you will be able to use your backups if the system crashes or a user loses a file. ===== 39 Obj 11.5 Chapter 11 tar As a system administrator, you are instructed to backup all the users' home directories. Which of the following commands would accomplish this? Choose one a. tar rf usersbkup home/* b. tar cf usersbkup home/* c. tar cbf usersbkup home/* d. tar rvf usersbkup home/* Answer: b This command would create a tarfile called usersbkup containing the contents of the home directory including the directory structure. ===== 40 Obj 11.5 Chapter 11 tar What is wrong with the following command? tar cvfb / /dev/tape 20 Choose one a. You cannot use the c option with the b option. b. The correct line should be tar -cvfb / /dev/tape20. c. The arguments are not in the same order as the corresponding modifiers. d. The files to be backed up have not been specified. Answer: c In order for tar to understand what to do, the modifiers are listed first and then the arguments. The arguments have to be presented in the same order as the modifiers. In this case, the command should be tar cvfb /dev/tape 20 / ===== 41 Obj 11.5 Chapter 11 tar You need to view the contents of the tarfile called MyBackup.tar. What command would you use? __________ Answer: tar tf MyBackup.tar The t switch tells tar to display the contents and the f modifier specifies which file to examine. ===== 42 Obj 11.5 Chapter 11 Restoring files with tar You wish to restore the file memo.ben which was backed up in the tarfile MyBackup.tar. What command should you type? Answer: tar xf MyBackup.tar memo.ben This command uses the x switch to extract a file. Here the file memo.ben will be restored from the tarfile MyBackup.tar. ===== 43 Obj 11.5 Chapter 11 Restoring files with tar You are covering for another system administrator and one of the users asks you to restore a file for him. You locate the correct tarfile by checking the backup log but do not know how the directory structure was stored. What command can you use to determine this? Choose one: a. tar fx tarfile dirname b. tar tvf tarfile filename c. tar ctf tarfile d. tar tvf tarfile Answer: d The t switch will list the files contained in the tarfile. Using the v modifier will display the stored directory structure. ===== 44 Obj 11.5 Chapter 11 cpio You need to copy all the files and directories contained in the home directory to another location. What utility can you use for this? Choose one a. cpio b. cp c. mv d. mvdir Answer: a The cpio utility allows you to copy entire directory hierarchies from one location to another. ===== 45 Obj 11.5 Chapter 11 cpio What command would you type to use the cpio to create a backup called backup.cpio of all the users' home directories? _____________ Answer: find /home | cpio -o > backup.cpio The find command is used to create a list of the files and directories contained in home. This list is then piped to the cpio utility as a list of files to include and the output is saved to a file called backup.cpio. ===== 46 Obj 11.5 Chapter 11 cpio After creating a backup of the users' home directories called backup.cpio you are asked to restore a file called memo.ben. What command should you type? Answer: cpio -iF backup.cpio memo.ben The i tells cpio to extract, F specifies the archive to examine and the file to extract is memo.ben. ===== 47 Obj 11.5 Chapter 11 Compressing and Uncompressing files You want to create a compressed backup of the users' home directories so you issue the command gzip /home/* backup.gz but it fails. The reason that it failed is that gzip will only compress one _______ at a time. Answer: file The gzip utility cannot compress multiple files in a single operation. ===== 48 Obj 11.5 Chapter 11 Compressing and Uncompressing files You want to create a compressed backup of the users' home directories. What utility should you use? Answer: tar You can use the z modifier with tar to compress your archive at the same time as creating it. ===== 49 Obj 11.5 Chapter 11 zcat You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it, use the _________ utility. Answer: zcat The zcat utility allows you to examine the contents of a compressed file much the same way that cat displays a file. ===== 50 Obj 11.4 Chapter 10 Scheduling jobs Which two utilities can you use to set up a job to run at a specified time? Choose one: a. at and crond b. atrun and crontab c. at and crontab d. atd and crond Answer: c You use the at command to schedule a job to run once. The crontab command is used to schedule recurring jobs. ===== 51 Obj 11.4 Chapter 10 Scheduling jobs You have written a script called usrs to parse the passwd file and create a list of usernames. You want to have this run at 5 am tomorrow so you can see the results when you get to work. Which of the following commands will work? Choose one: a. at 5:00 wed usrs b. at 5:00 wed -b usrs c. at 5:00 wed -l usrs d. at 5:00 wed -d usrs Answer: a This command will run the script usrs at 5 am tomorrow (which in this case is Wednesday). ===== 52 Obj 11.4 Chapter 10 Scheduling jobs Several of your users have been scheduling large at jobs to run during peak load times. How can you prevent anyone from scheduling an at job? Choose one: a. delete the file /etc/at.deny b. create an empty file called /etc/at.deny c. create two empty files: /etc/at.deny and /etc/at.allow file d. create an empty file called /etc/at.allow Answer: a If there is not /etc/at.deny file, then only the superuser or root may schedule at jobs. ===== 53 Obj 11.4 Chapter 10 Scheduling jobs How can you determine who has scheduled at jobs? Choose one: a. at -l b. at -q c. at -d d. atwho Answer: a Using at with the -l option will provide a list of scheduled jobs. This is the same as using atq. ===== 54 Obj 11.4 Chapter 10 Scheduling jobs When defining a cronjob, there are five fields used to specify when the job will run. What are these fields and what is the correct order? Choose one: a. minute, hour, day of week, day of month, month b. minute, hour, month, day of month, day of week c. minute, hour, day of month, month, day of week d. hour, minute, day of month, month, day of week Answer: c When creating a cronjob, the time fields must be entered in the order of minute, hour, day of the month, month and day of the week. ===== 55 Obj 11.3 Chapter 10 crontab You have entered the following cronjob. When will it run? 15 * * * 1,3,5 myscript Choose one: a. at 15 minutes after every hour on the 1st, 3rd and 5th of each month. b. at 1:15 am, 3:15 am, and 5:15 am every day c. at 3:00 pm on the 1st, 3rd, and 5th of each month d. at 15 minutes after every hour every Monday, Wednesday, and Friday Answer: d This would run at 15 minutes after the hour on every Monday, Wednesday, and Friday of every month no matter what the date. ===== 56 Obj 11.4 Chapter 10 crontab As the system administrator you need to review Bob's cronjobs. What command would you use? Choose one: a. crontab -lu bob b. crontab -u bob c. crontab -l d. cronq -lu bob Answer: a The -l option requests a list of jobs from crontab and the -u option is used to specify which user's jobs you want to see. ===== 57 Obj 11.3 Chapter 10 crontab In order to schedule a cronjob, the first task is to create a text file containing the jobs to be run along with the time they are to run. Which of the following commands will run the script MyScript every day at 11:45 pm? Choose one: a. * 23 45 * * MyScript b. 23 45 * * * MyScript c. 45 23 * * * MyScript d. * * * 23 45 MyScript Answer: c This line will run the MyScript script at 23:45 or 11:45 pm every day of every month and every day of the week. ===== 58 Obj 11.4 Chapter 10 crontab Which daemon must be running in order to have any scheduled jobs run as scheduled? Choose one: a. crond b. atd c. atrun d. crontab Answer: a The crond daemon is responsible for insuring that scheduled jobs run as scheduled. One of its jobs is to also use atrun to ensure that at jobs are run as well. ===== 59 Obj 11.4 Managing cron jobs You want to ensure that your system is not overloaded with users running multiple scheduled jobs. A policy has been established that only the system administrators can create any scheduled jobs. It is your job to implement this policy. How are you going to do this? Choose one: a. create an empty file called /etc/cron.deny b. create a file called /etc/cron.allow which contains the names of those allowed to schedule jobs. c. create a file called /etc/cron.deny containing all regular usernames. d. create two empty files called /etc/cron.allow and /etc/cron.deny Answer: b The crond daemon will examine the file /etc/cron.allow whenever a user attempts to install a cron job. If that user's name is not in the file, he will not be able to install the cron job. ===== 60 Obj 11.3 Chapter 10 Managing cron jobs You notice that your server load is exceptionally high during the hours of 10 am to 2 noon. When investigating the cause, you suspect that it may be a cron job scheduled by one of your users. What command can you use to determine if your suspicions are correct? Choose one: a. crontab -u b. crond -u c. crontab -l d. crond -l Answer: c Using the crontab command with the -l option will display all scheduled cron jobs for all users. ===== 61 Obj 11.4 Chapter 10 Managing cron jobs One of your users, Bob, has created a script to reindex his database. Now he has it scheduled to run every day at 10:30 am. What command should you use to delete this job. Choose one: a. crontab -ru bob b. crontab -u bob c. crontab -du bob d. crontab -lu bob Answer: a As root, you can use crontab to manage any user's jobs. The -u option is used to specify which user's jobs you wich to act on. The -r option tells crontab to delete the job. ===== 62 Obj 11.3 Chapter 10 System logs What daemon is responsible for tracking events on your system? Answer: syslogd The syslogd daemon is responsible for tracking system information and saving it to specified log files. ===== 63 Obj 11.3 Chapter 10 System Logs What is the name and path of the default configuration file used by the syslogd daemon? Answer: /etc/syslog.conf If no configuration file is specified when starting syslogd, then it will start up with the configuration specified in the /etc/syslog.conf file. ===== 64 Obj 11.3 Chapter 10 System logs You have made changes to the /etc/syslog.conf file. Which of the following commands will cause these changes to be implemented without having to reboot your computer? Choose one: a. kill SIGHINT `cat /var/run/syslogd.pid` b. kill SIGHUP `cat /var/run/syslogd.pid` c. kill SIGHUP syslogd d. kill SIGHINT syslogd Answer: a When you use kill with the SIGHUP signal, it stops the daemon, rereads the /etc/syslog.conf file, and then starts the syslogd daemon. The last part of the command line extracts the PID for syslogd. ===== 65 Obj 11.3 Chapter 10 Configuring syslogd Which of the following lines in your /etc/syslog.conf file will cause all critical messages to be logged to the file /var/log/critmessages? Choose one: a. *.=crit /var/log/critmessages b. *crit /var/log/critmessages c. *=crit /var/log/critmessages d. *.crit /var/log/critmessages Answer: a Although the asterick refers to all sources, using the equal sign (=) will explicitly log those messages to the specified file. ===== 66 Obj 11.3 Chapter 10 Configuring syslogd You wish to have all mail messages except those of type info to the /var/log/mailmessages file. Which of the following lines in your /etc/syslogd.conf file would accomplish this? Choose one: a. mail.*;mail!=info /var/log/mailmessages b. mail.*;mail.=info /var/log/mailmessages c. mail.*;mail.info /var/log/mailmessages d. mail.*;mail.!=info /var/log/mailmessages Answer: d The bang (!) is used to negate what is specified. In this line, all messages from mail would be logged to the /var/log/mailmessages file except for those of type info. ===== 67 Obj 11.3 Chapter 10 Managing logs What is the name and path of the main system log? Answer: /var/log/messages By default, the main system log is /var/log/messages. ===== 68 Obj 11.3 Chapter 10 Managing logs Which log contains information on currently logged in users? Choose one: a. /var/log/utmp b. /var/log/wtmp c. /var/log/lastlog d. /var/log/messages Answer: a Information on currently logged on users is stored in the /var/log/utmp log and used by the who, q, and finger utilities. ===== 69 Obj 11.3 Chapter 10 Managing logs You have been assigned the task of determining if there are any user accounts defined on your system that have not been used during the last three months. Which log file should you examine to determine this information? Choose one: a. /var/log/wtmp b. /var/log/lastlog c. /var/log/utmp d. /var/log/messages Answer: b The /var/log/lastlog file contains information on the time each user defined in the passwd file last logged into the system. ===== 70 Obj 11.3 Chapter 10 Rotating logs You have been told to configure a method of rotating log files on your system. Which of the following factors do you not need to consider? Choose one: a. date and time of messages b. log size c. frequency of rotation d. amount of available disk space Answer: a The date and time that messages are written do not effect how or when you which to rotate log files. ===== 71 Obj 11.3 Chapter 10 Rotating logs What utility can you use to automate rotation of logs? Answer: logrotate The logrotate command can be used to automate the rotation of various logs. ===== 72 Obj 11.3 Chapter 10 Rotating logs You wish to rotate all your logs weekly except for the /var/log/wtmp log which you wish to rotate monthly. How could you accomplish this. Choose one: a. Assign a global option to rotate all logs weekly and a local option to rotate the /var/log/wtmp log monthly. b. Assign a local option to rotate all logs weekly and a global option to rotate the /var/log/wtmp log monthly. c. Move the /var/log/wtmp log to a different directory. Run logrotate against the new location. d. Configure logrotate to not rotate the /var/log/wtmp log. Rotate it manually every month. Answer: a The global options will be applied to all rotations unless a local option is defined for a particular log. By setting a local option for the /var/log/wtmp logfile you can define a different rotation schedule that would apply only to that logfile. ===== 73 Obj 11.3 Chapter 10 Archiving logs You have configured logrotate to rotate your logs weekly and keep them for eight weeks. You are running our of disk space. What should you do? Choose one: a. Quit using logrotate and manually save old logs to another location. b. Reconfigure logrotate to only save logs for four weeks. c. Configure logrotate to save old files to another location. d. Use the prerotate command to run a script to move the older logs to another location. Answer: d You can use the prerotate command to run a script before logs are rotated. You could have this script move the older logs to another location before rotation occurs. ===== 74 Obj 11.3 Chapter 10 Using logs to troubleshoot What command can you use to review boot messages? Answer: dmesg The dmesg command displays the system messages contained in the kernel ring buffer. By using this command immediately after booting your computer, you will see the boot messages. ===== 75 Obj 11.3 Chapter 10 Using logs to troubleshoot What file defines the levels of messages written to system log files? Answer: kernel.h To determine the various levels of messages that are defined on your system, examine the kernel.h file. ===== 76 Obj 11.1 Chapter 7 root What account is created when you install Linux? Answer: root Whenever you install Linux, only one user account is created. This is the superuser account also known as root. ===== 77 Obj 11.1 Chapter 7 root While logged on as a regular user, your boss calls up and wants you to create a new user account immediately. How can you do this without first having to close your work, log off and logon as root? Choose one: a. Issue the command rootlog. b. Issue the command su and type exit when finished. c. Issue the command su and type logoff when finished. d. Issue the command logon root and type exit when finished. Answer: b You can use the su command to imitate any user including root. You will be prompted for the password for the root account. Once you have provided it you are logged in as root and can do any administrative duties. ===== 78 Obj 11.1 Chapter 7 The passwd file Which file defines all users on your system? Choose one: a. /etc/passwd b. /etc/users c. /etc/password d. /etc/user.conf Answer: a The /etc/passwd file contains all the information on users who may log into your system. If a user account is not contained in this file, then the user cannot log in. ===== 79 Obj 11.1 Chapter 7 The passwd file There are seven fields in the /etc/passwd file. Which of the following lists all the fields in the correct order? Choose one: a. username, UID, GID, home directory, command, comment b. username, UID, GID, comment, home directory, command c. UID, username, GID, home directory, comment, command d. username, UID, group name, GID, home directory, comment Answer: b The seven fields required for each line in the /etc/passwd file are username, UID, GID, comment, home directory, command. Each of these fields must be separated by a colon even if they are empty. ===== 80 Obj 11.1 Chapter 7 The passwd file Which of the following user names is invalid? Choose one: a. Theresa Hadden b. thadden c. TheresaH d. T.H. Answer: a User names cannot contain spaces. Also, they should be eight characters or less. ===== 81 Obj 11.1 Chapter 7 The passwd file In order to prevent a user from logging in, you can add a(n) _____________ at the beginning of the password field. Answer: asterick If you add an asterick at the beginning of the password field in the /etc/passwd file, that user will not be able to log in. ===== 82 Obj 11.1 Chapter 7 The passwd file The beginning user identifier is defined in the _________ file. Answer: /etc/login.defs The /etc/login.defs file defines the first number that can be used as a user ID. ===== 83 Obj 11.1 Chapter 7 The passwd file Which field is used to define the user's default shell? Answer: command The last field, called either command or login command, is used to specify what shell the user will use when he logs in. ===== 84 Obj 11.1 Chapter 7 The passwd command Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command? Answer: passwd boba The passwd command is used to change your password. If you do not specify a username, your password will be changed. ===== 85 Obj 11.1 Chapter 7 The passwd file Your company has implemented a policy that users' passwords must be reset every ninety days. Since you have over 100 users you created a file with each username and the new password. How are you going to change the old passwords to the new ones? Choose one: a. Use the chpasswd command along with the name of the file containing the new passwords. b. Use the passwd command with the -f option and the name of the file containing the new passwords. c. Open the /etc/passwd file in a text editor and manually change each password. d. Use the passwd command with the -u option. Answer: a The chpasswd command takes a file containing username/password pairs and makes the appropriate changes to the /etc/passwd file. ===== 86 Obj 11.1 Chapter 7 shadow passwords You attempt to use shadow passwords but are unsuccessful. What characteristic of the /etc/passwd file may cause this? Choose one: a. The login command is missing. b. The username is too long. c. The password field is blank. d. The password field is prefaced by an asterick. Answer: c The password field must not be blank before converting to shadow passwords. ===== 87 Obj 11.1 Chapter 7 Creating users You create a new user account by adding the following line to your /etc/passwd file. bobm:baddog:501:501:Bob Morris:/home/bobm:/bin/bash Bob calls you and tells you that he cannot logon. You verify that he is using the correct username and password. What is the problem? Choose one: a. The UID and GID cannot be identical. b. You cannot have spaces in the line unless they are surrounded with double quotes. c. You cannot directly enter the password; rather you have to use the passwd command to assign a password to the user. d. The username is too short, it must be at least six characters long. Answer: c When editing the /etc/passwd file, you must not type anything in the password file. Once you have added a user, you must use the passwd command to assign a password to that account. ===== 88 Obj 11.1 Chapter 7 Creating users Which of the following tasks is not necessary when creating a new user by editing the /etc/passwd file? Choose one: a. Create a link from the user's home directory to the shell the user will use. b. Create the user's home directory c. Use the passwd command to assign a password to the account. d. Add the user to the specified group. Answer: a There is no need to link the user's home directory to the shell command. Rather, the specified shell must be present on your system. ===== 89 Obj 11.1 Chapter 7 Creating users You create a new user by adding the following line to the /etc/passwd file bobm::501:501:Bob Morris:/home/bobm:/bin/bash You then create the user's home directory and use the passwd command to set his password. However, the user calls you and says that he cannot log on. What is the problem? Choose one: a. The user did not change his password. b. bobm does not have permission to /home/bobm. c. The user did not type his username in all caps. d. You cannot leave the password field blank when creating a new user. Answer: b When you create the new user's home directory, the permissions are set with root as the owner. You need to change the ownership so that bobm can access his home directory. Otherwise, he will not be able to login. ===== 90 Obj 11.1 Chapter 7 Using the useradd command When using useradd to create a new user account, which of the following tasks is not done automatically. Choose one: a. Assign a UID. b. Assign a default shell. c. Create the user's home directory. d. Define the user's home directory. Answer: c The useradd command will use the system default for the user's home directory. The home directory is not created, however, unless you use the -m option. ===== 91 Obj 11.1 Chapter 7 Using the useradd command You issue the following command useradd -m bobm But the user cannot logon. What is the problem? Choose one: a. You need to assign a password to bobm's account using the passwd command. b. You need to create bobm's home directory and set the appropriate permissions. c. You need to edit the /etc/passwd file and assign a shell for bobm's account. d. The username must be at least five characters long. Answer: a The useradd command does not assign a password to newly created accounts. You will still need to use the passwd command to assign a password. ===== 92 Obj 11.1 Chapter 7 Using the useradd command You have created special configuration files that you want copied to each user's home directories when creating new user accounts. You copy the files to /etc/skel. Which of the following commands will make this happen? Choose one: a. useradd -m username b. useradd -mk username c. useradd -k username d. useradd -Dk username Answer: b Using the -m option with the useradd command will cause the home directory to be created. The -k option will copy files and directories contained in /etc/skel to the user's home directory with the appropriate permissions. ===== 93 Obj 11.1 Chapter 7 Using the usermod command Mary has recently gotten married and wants to change her username from mstone to mknight. Which of the following commands should you run to accomplish this? Choose one: a. usermod -l mknight mstone b. usermod -l mstone mknight c. usermod -u mknight mstone d. usermod -u mstone mknight Answer: a The -l option used with the usermod command specifies the new login name for the specified account. ===== 94 Obj 11.1 Chapter 7 Deleting users After bob leaves the company you issue the command userdel bob. Although his entry in the /etc/passwd file has been deleted, his home directory is still there. What command could you have used to make sure that his home directory was also deleted? Choose one: a. userdel -m bob b. userdel -u bob c. userdel -l bob d. userdel -r bob Answer: d The -r option is used with the userdel command to delete the user's account and his home directory. ===== 95 Obj 11.1 Chapter 7 The /etc/group file All groups are defined in the /etc/group file. Each entry contains four fields in the following order. Choose one: a. groupname, password, GID, member list b. GID, groupname, password, member list c. groupname, GID, password, member list d. GID, member list, groupname, password Answer: a Each entry must contain four fields, groupname, password, GID, and memberlist. Any empty fields must be defined by colons. ===== 96 Obj 11.1 Chapter 7 Working with groups You need to create a new group called sales with Bob, Mary and Joe as members. Which of the following would accomplish this? Choose one: a. Add the following line to the /etc/group file: sales:44:bob,mary,joe b. Issue the command groupadd sales. c. Issue the command groupadd -a sales bob,mary,joe d. Add the following line to the /etc/group file: sales::44:bob,mary,joe Answer: d One of the quickest ways to create a new group is to edit the /etc/group file adding the groupname, password, GID, and members. ===== 97 Obj 11.1 Chapter 7 Working with groups What command is used to remove the password assigned to a group? Answer: gpasswd -r The gpasswd command is used to change the password assigned to a group. Use the -r option to remove the password from the group. ===== 98 Obj 11.1 Chapter 7 Modifying and Deleting groups You changed the GID of the sales group by editing the /etc/group file. All of the members can change to the group without any problem except for Joe. He cannot even login to the system. What is the problem? Choose one: a. Joe forgot the password for the group. b. You need to add Joe to the group again. c. Joe had the original GID specified as his default group in the /etc/passwd file. d. You need to delete Joe's account and recreate it. Answer: c If a user has a GID listed that is not a valid group in the /etc/passwd file, he will not be able to log into the system. ===== 99 Obj 11.1 Chapter 7 Modifying and Deleting Groups You need to delete the group dataproject. Which two of the following tasks should you do first before deleting the group? A. Check the /etc/passwd file to make sure no one has this group as his default group. B. Change the members of the dataproject group to another group besides users. C. Make sure that the members listed in the /etc/group file are given new login names. D. Verify that no file or directory has this group listed as its owner. Choose one: a. A and C b. A and D c. B and C d. B and D Answer: b If you delete a group that is listed as a user's default group, then that user will not be able to login. Any files or directories owned by the deleted group may become inaccessible if you do not change the group ownership. ===== 100 Obj 11.1 Chapter 7 System groups When you look at the /etc/group file you see the group kmem listed. Since it does not own any files and no one is using it as a default group, can you delete this group? Type your answer: Answer: no The kmem group manages direct access to kernel memory and is necessary for your system's health. ===== 101 Obj 11.1 Chapter 7 Implementing shadow passwords When looking at the /etc/passwd file, you notice that all the password fields contain 'x'. What does this mean? Choose one: a. That the password is encrypted. b. That you are using shadow passwords. c. That all passwords are blank. d. That all passwords have expired. Answer: b The 'x' indicates that passwords are stored in the /etc/shadow file rather than /etc/passwd. ===== 102 Obj 11.1 Chapter 7 Implementing Shadow Passwords In order to improve your system's security you decide to implement shadow passwords. What command should you use? Answer: pwconv The pwconv command creates the file /etc/shadow and changes all passwords to 'x' in the /etc/passwd file. ===== 103 Obj 11.2 Chapter 7 User Startup Files What file contains the default environment variables when using the bash shell? Choose one: a. ~/.profile b. /bash c. /etc/profile d. ~/bash Answer: c The /etc/profile file contains the system default environment variables for the bash shell. ===== 104 Obj 11.2 Chapter 7 User Startup Files You have created a subdirectory of your home directory containing your scripts. Since you use the bash shell, what file would you edit to put this directory on your path? Choose one: a. ~/.profile b. /etc/profile c. /etc/bash d. ~/.bash Answer: a To make changes to the path that will only effect you, add the new directory to a path statement in the .profile file located in your home directory. ===== 105 Obj 4.1 Chapter 3 Partitions You are creating new partitions in preparation for installing Linux. You want to have five different partitions. You have successfully created four partitions, but are unable to create the fifth one. What is the problem? Choose one: a. Your hard drive is not large enough for more than four partitions. b. You need to create the swap partition last. c. You created four primary partitions. d. Linux cannot be installed on more than four partitions. Answer: c Each hard drive can have no more than four primary partitions or three primary and one extended partition. In order to install on five partitions, you must create an extended partition and then create logical drives contained in that partition. ===== 106 Obj 4.1 Chapter 3 Interpreting Partition Names You are installing Linux into a computer with two IDE hard drives. You plan on dividing each hard drive into two partitions. What are the names of the partitions? Choose one: a. hda1, hda2, hda3, hda4 b. hda1, hda2, hdb1, hdb2 c. sda1, sda2, sdb1, sdb2 d. sda1, sda2, sda3, sda4 Answer: b The first letter of the partition names refers to the controller type: 'h' for ide and 's' for SCSI. The third letter refers to which disk: 'a' for first, 'b' for second, etc., and the number refers to which partition: '1' for first, '2' for second, etc. ===== 107 Obj 4.1 Chapter 3 How many and what size? What is the minimum number of partitions you need to install Linux? Answer: 2 Linux can be installed on two partitions, one as / which will contain all files and a swap partition. ===== 108 Obj 4.1 Chapter 3 How many and what size? The recommended minimum size of the swap partition is _____ MB? Answer: 16 Normally, the swap partition should be twice the amount of the physical RAM but at least 16 MB. ===== 109 Obj 4.1 Chapter 3 How many and what size? The maximum size of the swap partition is _______ MB. Answer: 128 Although the maximum size for a swap partition is 128 MB, you can have multiple swap partitions. ===== 110 Obj 4.1 Chapter 3 fips You have a computer with Windows 95 installed and want to install Linux on it. However, there is no free space available. How could you manage to install Linux on this computer with the least amount of effort? Choose one: a. Use fips to resize the partition containing Windows 95. b. Repartition the hard drive; reinstall Windows 95 and then install Linux c. You cannot run Windows 95 and Linux on the same computer d. Create a directory under Windows 95 and install Linux in that directory. Answer: a The fips utility allows you to dynamically resize an existing partition. You can then use the free space to install Linux ===== 111 Obj 4.1 Chapter 3 fdisk You are partitioning your second SCSI hard drive. What command should you use? Choose one: a. fdisk sda2 b. fdisk sdb c. fdisk hdb d. fdisk hda2 Answer: b When using the fdisk command, you pass it the name of the drive you want to partition. In this case, you are using the second SCSI disk or sdb. ===== 112 Obj 4.1 Chapter 3 fdisk While using fdisk what command would you use to see the partition table? Choose one: a. w b. m c. w d. p Answer: d The p command will print out the partition table. ===== 113 Obj 4.1 Chapter 3 fdisk What type would you set on a partition to make it a swap partition? Choose one: a. 82 b. 83 c. s d. swap Answer: a The swap partition must be of type 82 in order for Linux to be able to use it as a swap partition. ===== 114 Obj 4.1 Chapter 3 fdisk You have a new, empty hard drive that you will use for Linux. What is the first step you use. Choose one: a. Create an extended partition to be used for data. b. Format the hard drive to use the ext2 filesystem. c. Create a swap partition of type 82. d. Create a primary partition using fdisk. Answer: d You must always first create a primary partition. Operating systems, including Linux, can only be booted from a primary partition. ===== 115 Obj 4.1 Chapter 3 fdisk You have created a primary partition, a swap partition and an extended partition. You can format the primary partition but when you try to format the extended partition it fails. What is the problem? Choose one: a. You should have created another primary partition instead of an extended partition. b. Your syntax is wrong for the format command when attempting to format the extended partition. c. You cannot format an extended partition. d. You have to use the fdformat command to format extended partitions. Answer: c You cannot format an extended partition. Rather you must create one or more logical drives within the extended partition before formating. ===== 116 Obj 4.1 Chapter 3 fdisk When you create a new partition, you need to designate its size by defining the starting and ending _____________. Answer: cylinders When creating a new partition you must first specify its starting cylinder. You can then either specify its size or the ending cylinder. ===== 117 Obj 4.1 Chapter 3 The Linux Filesystem In order to apply a filesystem to your new partitions you must format them. What command would you use to create the ext2 filesystem? Answer: mkfs The mkfs command creates the new filesystem on your partition. ===== 118 Obj 4.1 Chapter 3 format When formating your partition with the mkfs command, you must also pass to the command the type of filesystem and the number of __________? Answer: blocks When formating your partition using the mkfs utility, you must specify what filesystem type to apply and the number of blocks contained in the partition. ===== 119 Obj 4.2 Chapter 3 Filesystem organization You have new documentation that you wish to install so that it will be available to your users. Which directory would be the most appropriate to use for these files? Choose one: a. /tmp b. /usr c. /lib d. /mnt Answer: b Documentation is customarily installed in one of the subdirectories under /usr. ===== 120 Obj 4.2 Chapter 3 inodes Each inode contains extensive information on a file. Which of the following is not contained in the inode. Choose one: a. file size b. filename c. file's owner d. number of links to the file Answer: b The filename is not contained in the inode. Rather, it points to the file's physical location. ===== 121 Obj 4.2 Chapter 3 File Types When you issue the command ls -l, the first character of the resulting display represents the file's ___________. Answer: type The first character of the permission block designates the type of file that is being displayed. ===== 122 Obj 4.2 Chapter 3 Keeping your disks healthy What command should you use to check your filesystem? Answer: fsck The fsck command is used to check the integrity of the filesystem on your disk. ===== 123 Obj 4.2 Chapter 3 fsck In order to run fsck on the root partition, the root partition must be mounted as ______________. Answer: readonly You cannot run fsck on a partition that is mounted as read-write. ===== 124 Obj 4.2 Chapter 3 fsck You cannot mount /dev/hdb1 and suspect that the superblock is bad. How do you fix this? Choose one: a. Use the mkfs command. b. Use the fsck command with the -f option. c. Use the e2fsck to replace the superblock with a copy saved to another location on your disk. d. Restore the superblock from your tape backup. Answer: c The e2fsck command can be used to copy one of the copies of the superblock to the first block on the partition. ===== 125 Obj 4.2 Chapter 3 Disk Usage Why should you track the amount of free space on your disks? Choose one: a. If there is no free space, you will not be able to write to that filesystem. b. If there is no free space, you will not be able to install new applications. c. If the amount of free space becomes less than 50 percent, then your system will slow down. d. If the amount of free space is too low, your system will not boot. Answer: a You must have free space in order to write to the filesystem. ===== 126 Obj 4.2 Chapter 3 du You want to know how much space is being occupied by your user's home directories. Which of the following will provide you with this information? Choose one: a. du -l /home b. du -b /home c. du -m /home d. du -c /home Answer: d Using the -c option with the du command will show the grand total of used space for the designated directory. ===== 127 Obj 4.2 Chapter 3 df You also need to know the amount of free space on the partition containing the users' home directories. Which of the following commands will provide this information? Choose one: a. df /home b. df -i /home c. df --sync d. df -T Answer: a The df command reports on the amount of used and free space of the partition containing the designated directory. ===== 128 Obj 4.2 Chapter 3 Disk Usage You notice that the amount of free space is getting low. When you check the contents of the /tmp directory you find several hundred files so you delete them. After deleting these temp files, you check the amount of free space, however, it has not increased. What should you do? Choose one: a. Move the /tmp directory to another partition. b. Delete the partition containing the /tmp directory, recreate it and restore its contents. c. Delete the /tmp directory and recreate it. d. Run fsck on the filesystem containing the /tmp directory. Answer: c Directories will grow in size but they do not shrink. If a directory becomes too large, the only way to shrink it is to delete it then recreate it. ===== 129 Obj 4.2 Chapter 3 Disk Usage You have the /var directory on its own partition. You have run out of space. What should you do? Question Choose one: a. Reconfigure your system to not write to the log files. b. Use fips to enlarge the partition. c. Delete all the log files. d. Delete the partition and recreate it with a larger size. Answer: d The only way to enlarge a partition is to delete it and recreate it. You will then have to restore the necessary files from backup. ===== 130 Obj 6.1 Chapter 2 Starting Linux You can start Linux in many different ways. Which of the following is not one of these? Choose one: a. Type linux from a DOS prompt under Windows 95. b. Using a boot loader such as LILO c. From a floppy disk d. Type linux single at the boot: prompt. Answer: a Linux will not run as a program under Windows 95. ===== 131 Obj 6.1 Chapter 2 Starting Linux When the kernel is loading, it writes any messages to the ____________ file. Answer: /var/log/messages The messages file in the /var/log directory is used by the kernel to record all boot messages. ===== 132 Obj 6.1 Chapter 2 Starting Linux What command can you use to see the boot messages? Choose one: a. dmesg b. cat kernel.messages c. logview d. man logs Answer: a The dmesg command will display the messages from the kernel that were recorded in /var/log/messages. ===== 133 Obj 6.1 Chapter 2 The init Daemon After the kernel is loaded, it calls the _________ daemon which is responsible for creating new processes. Choose one: a. inittab b. sys.conf c. init d. syslog Answer: c The init daemon is responsible for creating processes. It is called by the kernel at the end of loading. ===== 134 Obj 6.1 Chapter 2 The /etc/inittab file Each entry in the /etc/inittab file contains four fields the third of which is the Action field. What is the purpose of this field? Choose one: a. Identifies the entry b. Specifies the command to execute c. Defines how to handle the entry. d. Defines which runlevels this line applies to. Answer: c The Action field defines how to handle the entry such as whether to respawn the process if it is stopped. ===== 135 Obj 6.2 Chapter 2 Runlevels What file should you examine to determine the defined runlevels for your system? Answer: /etc/inittab Although runlevels are defined differently from one distribution to another, they are defined in the /etc/inittab file. ===== 136 Obj 6.2 Chapter 2 Runlevels How does single user mode differ from other runlevels? Choose one: a. init does not read the /etc/inittab file b. Users can only log into the system across the network. c. Network services are disabled. d. All processes are stopped and the root filesystem is mounted as read-only when in single user mode. Answer: a When starting Linux in single user mode, init does not read the /etc/inittab file. Rather, init runs /bin/su and you are logged in as root. ===== 137 Obj 6.2 Chapter 2 Runlevels What should you type to change the runlevel of your system? Choose one: a. init [runlevel] b. halt [runlevel] c. /etc/inittab d. sys init [runlevel] Answer: a You can change the runlevel by using either the init or telinit command and specifying the desired runlevel. ===== 138 Obj 6.2 Chapter 2 Runlevels Where are the startup scripts defined? Choose one: a. /etc/initd b. /etc/scripts c. /etc/start d. /etc/inittab Answer: d The /etc/inittab defines which start up scripts to run at each runlevel. ===== 139 Obj 6.2 Chapter 2 Runlevels Which of the following tasks is not controlled by one of the rc startup scripts? Choose one: a. backup users' directories b. run fsck c. mount filesystems d. load modules Answer: a The rc scripts accomplish many start up tasks such as checking your filesystems by running fsck, mounting the filesystems, and loading modules. ===== 140 Obj 6.2 Chapter 2 Runlevels Modules are pieces of kernel code that you can load or unload. What file do you use to pass parameters to a module? Choose one: a. /etc/conf.mod b. /etc/modules c. /etc/inittab d. /etc/conf.modules Answer: d The /etc/conf.modules file is used to pass parameters to any loaded modules. This is ofter I/O addresses or IRQs for devices loaded by the modules. ===== 141 Obj 6.2 Chapter 2 Runlevels You have installed a new UPS (Uninterruptable Power Supply) and the powerd daemon. Which file should you use to define the steps to be taken in the case of a power failure? Choose one: a. /etc/ups.conf b. /etc/inittab c. /etc/power.conf d. /etc/conf.ups Answer: b The /etc/inittab file is used to define what to do in the case of a power failure. Usually, you have init shutdown the system after a short period of time. ===== 142 Obj 6.2 Chapter 2 Runlevels You have made changes to the /etc/inittab file after installing your UPS. How do you institute these configuration changes without having to reboot your computer or have your users log off? Choose one: a. Issue the command source /etc/inittab. b. Change the runlevel to single user mode. c. Issue the init q command. d. The init daemon only reads its configuration file during boot. Answer: c When you issue the init q command, it stops init, however, when you stop, init it restarts again. When init restarts it will read its configuration file and the changes you made will be implemented. ===== 143 Obj 6.1 Chapter 2 LILO Which of the following statements is not true of LILO? Choose one: a. It can be used on a floppy to boot Linux. b. It must replace the master boot record on your hard drive. c. It will work with other operating systems such as DOS and Windows. d. It can specify up to 16 different boot images. Answer: b LILO will load Linux whether it is booted from the hard drive or a boot floppy, therefore it does not have to replace the master boot record. ===== 144 Obj 6.1 Chapter 2 LILO You boot your system using LILO. Although you have four different boot images on your system, you cannot remember what you named them and you do not want to boot your default image. What should you do? Choose one: a. At the boot: prompt, press the Alt key. b. Hold the shift key down when booting until you get a prompt. c. At the boot: prompt, press the Tab key. d. You have to boot your default image and then look at the configuration file. Answer: c At the boot: prompt, you can type either Tab or a question mark (?) and LILO will display the names of the available boot images. ===== 145 Obj 6.1 Chapter 2 LILO You have made changes to the LILO configuration file but you are not sure the changes will work. How can you test the new configuration without installing it? Choose one: a. LILO -t b. LILO -c filename c. LILO -s filename d. LILO Answer: a If you call LILO with the -t option, it will test your configuration without installing it. ===== 146 Obj 6.1 Chapter 2 LILO What is the complete name of the default configuration file for LILO? Answer: /etc/lilo.conf The default configuration file for LILO is /etc/lilo.conf. You can use another file by using the -C option along with the name of the file. ===== 147 Obj 6.1 Chapter 2 LILO Part of your /etc/lilo.conf file is as follows: boot=/dev/hda map=/boot/map install=/boot/boot.b image=/boot/vmlinuz-2.0.36.0.7 label=linux root=/dev/dha1 You would like to start in single user mode but you do not get a boot: prompt. What changes should you make to the /etc/lilo.conf file to make a prompt appear everytime you boot your system? Choose one: a. Add a line containing prompt. b. Add a line containing a timeout. c. Add a line containing prompt=30 d. Change the label to boot: instead of linux. Answer: a If you add a line containing prompt, then LILO will display the boot: prompt. You would also want to add a line specifying how long to wait until the default boot image is loaded. ===== 148 Obj 6.1 Chapter 2 LILO You changed /etc/lilo.conf to cause a boot: prompt to show, however, when you restart your computer you still do not have a prompt. What should you do? Choose one: a. Rename your configuration file to /etc/lilo.conf.new. b. Install the configuration changes by issuing the command /sbin/lilo c. Install the configuration changes by issuing the command /sbin/lilo -t d. Install the configuration changes by issuing the command /sbin/lilo -u Answer: b You have to reinstall LILO in order for any configuration changes to take effect. This is done by running /sbin/lilo without any options. ===== 149 Obj 6.1 Chapter 2 LILO When booting your system after installing LILO you see LIL and then nothing happens. What could be the problem. Choose one: a. LILO loaded successfully but the kernel is corrupt. b. LILO is not installed properly. c. LILO could only complete the first stage, usually a geometry mismatch. d. LILO could not load the map file, usually media failure. Answer: d The LIL indicates that the first and second stages completed but it cannot load the map file. This is most frequently a media failure. ===== 150 Obj 6.2 Chapter 2 Shutting down Linux You are going to install a new hard disk in your system. Which of the following commands will halt your system so you can install the new hardware? Choose one: a. shutdown -k now b. shutdown -h now c. shutdown -r now d. shutdown -t now Answer: b When using the shutdown command, you must specify when shutdown is to run. The -h option instructs shutdown to halt the system after the shutdown process is completed. ===== 151 Obj 6.2 Chapter 2 Shutting down Linux You have a technician who will come in after hours to install new hardware in your system. You do not want to give him the root password, but he needs to be able to shutdown the system. How can you accomplish this? Choose one: a. You cannot do this; only root can run the shutdown command. b. Add his username to the /etc/shutdown.conf file. c. Add his username to the /etc/shutdown.allow file. d. Give him the root password and change it when you arrive the next morning. Answer: c Any user who is listed in the /etc/shutdown.allow file will be able to run the shutdown command without being root. ===== 152 Obj 6.2 Chapter 2 Shutting down Linux You are going to reboot your system but want to warn your users to log off. Which of the following commands will send a message to the users. Choose one: a. init b. halt c. reboot d. shutdown Answer: d The shutdown command will send a warning message to your users before bringing the system down. Neither the reboot or halt command send messages before stopping the system. ===== 153 Obj 8.1 Chapter 1 man Pages You want to review the man page on the files used to control hosts access, however, when you enter man hosts_access you get the man page for the routines used to programaticlly manipulate access. What is the problem? Choose one: a. The page you are looking for does not exist on your system. b. The page you are looking for resides in a directory that is searched later. c. You typed the name of the page incorrectly. d. The installation of man pages on your system is corrupt. Answer: b Each section is searched in order and the first page that matches your query is displayed. Use man -k to see all pages that meet your criteria. ===== 154 Obj 8.1 Chapter 1 man Pages You want to find how to set the manpath variable so you type man man. What would you type while displaying the page to find the location where manpath is discussed? Choose one: a. grep manpath b. find manpath c. /manpath d. locate manpath Answer: c In order to search the contents of a displayed man page, you first type '/' and then the pattern you wish to search for. ===== 155 Obj 8.1 Chapter 1 man Pages You wish to find the man page that discusses how to change a password. You type man password but get the message that no manual entry for password exists. What command will find the appropriate page? Choose one: a. man -C password b. man -k password c. man -c password d. man -q password Answer: b Using the -k option with the man command will cause man to search the short description of each page for the requested string. ===== 156 Obj 8.1 Chapter 1 man Pages You have installed an additional set of man pages but in Spanish. You have one user who wishes to use the Spanish pages rather than English ones. What should you do to accomplish this? Choose one: a. Edit the man.config file located in that user's home directory. b. Instruct the user in how to reset the MANPATH variable whenever he logs in. c. Edit the .profile file located in that user's home directory. d. You can only have one version of man pages installed on your system at a time. Answer: c You can set the MANPATH variable for a specific user by editing the .profile file in that user's home directory. ===== 157 Obj 8.1 Chapter 1 info You know that the info utility provides easier to understand documentation but you have never used it. How can you access a tutorial on using info? Choose one: a. man info b. info c. info info d. info help Answer: c If you type info info you are presented with a tutorial covering how to use the info program. ===== 158 Obj 8.1 Chapter 1 HOWTOs There is considerable documentation covering various tasks provided as HOWTOs. These documents are normally installed in which directory. Choose one: a. /etc/HOWTO b. /usr/doc/HOWTO c. /usr/HOWTO d. /usr/lib/HOWTO Answer: b The HOWTO documents are installed in the /usr/doc/HOWTO directory by default. ===== 159 Obj 8.1 Chapter 1 FAQ What does FAQ stand for? Answer: frequently asked questions FAQ's are written in question and answer format. They are intended to be used in conjunction with the HOWTOs. ===== 160 Obj 8.1 Chapter 1 Program documentation When you install a new application, documentation on that application is also usually installed. Where would you look for the documentation after installing an application called MyApp? Choose one: a. /usr/MyApp b. /lib/doc/MyApp c. /usr/doc/MyApp d. In the same directory where the application is installed. Answer: c The default location for application documentation is in a directory named for the application in the /usr/doc directory. ===== 161 Obj 8.2 Chapter 1 Internet Resources You need to update your HOWTOs. Where should you go to acquire the latest versions? Choose one: a. Linux Mall and order a new CD. b. Your local Linux Users Group should have a copy. c. The web site for your distribution. d. Linux Documentation Project Answer: d The Linux Documentation Project's web site maintains links to all the HOWTOs and where to get the latest version. ===== 162 Obj 8.1 Chapter 1 Newsgroups You have a problem installing an older CD-ROM drive on one of your Linux servers. You have checked the HOWTOs and FAQs but have not found your answer. Where could you go to search the newsgroups to look for a solution? Choose one: a. http://www.deja.com b. http://www.news.com c. http://www.linux-help.com d. http://www.lug.com Answer: a The Deja News site provides the ability to search any and all Usenet newsgroups. Frequently, when you have a problem, someone else has discussed the solution. ===== 163 Obj 8.1 Chapter 1 whereis The whereis command is helpful in finding the location of a command as well as its related man page. What is the disadvantage of using it? Choose one: a. Since it searches the entire directory tree, the whereis command can take an excessive amount of time. b. The whereis command will not find source files located on your system. c. You have to update the whereis database in order to keep it current. d. The whereis command only searches known directories that are hard coded into the command. Answer: d The whereis command only searches those known directories that are hard coded into the command itself. ===== 164 Obj 8.1 Chapter 1 which You suspect that you have two commands with the same name as the command is not producing the expected results. What command can you use to determine the location of the command being run? Type your answer: Answer: which The which command searches your path until it finds a command that matches the command you are looking for and displays its full path. ===== 165 Obj 8.1 Chapter 1 whatis You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose. Answer: whatis The whatis command displays a summary line from the man page for the specified command. ===== 166 Obj 8.1 Chapter 1 whatis What command must you run to update the database used by the whatis command? Choose one: a. makewhatis b. updatedb c. make whatisdb d. The database is updated automatically. Answer: a The makewhatis command will create the whatis database if it does not exist or update it if it does exist. ===== 167 Obj 8.1 Chapter 1 apropos What does the apropos command do? Choose one: a. It is the same as the man -f command. b. It is the same as the man -K command. c. It searches the short descriptions from the man pages. d. It uses the locatedb database to answer your query. Answer: c The apropos command searches the short description of the man pages. It is the same as the man -k command. ===== 168 Obj 8.3 Chapter 1 Writing documentation Which of the following items would not be important for you to record in your system documentation. Choose one: a. Any kernel patches you might apply. b. Applications that are installed. c. When did each user log on last. d. What problems with the system you have had. Answer: c The last login time of each of your users will change too frequently to record in the system log. In addition, it does not effect your system's performance. ===== 169 Obj 8.4 Chapter 1 User Support Which of the following would improve your ability to provide user support? Choose one: a. Create a directory containing instructions for using all installed applications. b. Email your user's your office hours. c. Whenever a user has a problem, fix it and leave. d. Use as much technical language as possible when explaining what went wrong. Answer: a Written instructions are helpful to reinforce any explanations you have given. In addition, the users can refer to these documents if they later have questions. ===== 170 Obj 3.3 Chapter 4 cd Which of the following commands will make your home directory your working directory. Choose one: a. cd b. cd home c. cd .. d. cd home/username Answer: a Issuing the cd command without any arguments will place you in your home directory no matter what your location is when you issue it. ===== 171 Obj 3.3 Chapter 4 ls Which of the following commands will show a list of the files in your home directory including hidden files and the contents of all subdirectories? Choose one: a. ls -c home b. ls -aR /home/username c. ls -aF /home/username d. ls -l /home/username Answer: b The ls command is used to display a listing of files. The -a option will cause hidden files to be displayed as well. The -R option causes ls to recurse down the directory tree. All of this starts at your home directory. ===== 172 Obj 3.3 Chapter 4 ls What command should you type to see all the files with an extension of 'mem' listed in reverse alphabetical order in the /home/ben/memos directory. Answer: ls -r /home/ben/memos/*.mem The -c option used with ls results in the files being listed in chronological order. You can use wildcards with the ls command to specify a pattern of filenames. ===== 173 Obj 3.3 Chapter 4 file You have three files in the /home/ben/memos directory called letters, tom, betty. How could you determine each file's type by issuing only one command? Answer: file letters tom betty The file utility will display the file's type for each filename that is passed as an argument. ===== 174 Obj 3.3 Chapter 4 cat Which of the following commands will combine the contents of the files tom and betty into a new file called friends? Choose one: a. ls tom betty > friends b. cat tom betty > friends c. more tom betty >> friends d. cat tom; cat betty > friends Answer: b The cat command displays the contents of one or more files. This output can be redirected to another file, as in this case, the contents of the files tom and betty are written to the file friends. ===== 175 Obj 3.3 Chapter 4 cat Which of the following cannot be accomplished with the cat command? Choose one: a. Create a new file b. Display the contents of a file c. Append information to another file d. Change the contents of a file Answer: d The cat command is used to create new files as well as display the contents of files. You can redirect the output from the cat command to have it written to another file. ===== 176 Obj 3.3 Chapter 4 more and less Which of the following commands will display a file one screen at a time? Choose one: a. less b. page c. tr d. cat Answer: a The less pager will display a file one screen at a time. You can also navigate through the file and do searches. ===== 177 Obj 3.3 Chapter 4 head and tail You are debugging a new application that is crashing. You want to watch the messages as they are being written to the log. What command should you use? Choose one: a. tail b. head c. less d. log Answer: a The tail command allows you to keep a log open and see each new message as it is written to the log. ===== 178 Obj 3.3 Chapter 4 touch Which of the following tasks cannot be accomplished with the touch command? Choose one: a. Create a new file b. Change a file's modification time c. Change a file's access time d. Change a file's creation time Answer: d The touch command is usually used to modify either a file's access or modification time. It can also be used to create a new file. ===== 179 Obj 3.3 Chapter 4 cp You want to copy the user's home directories to a new location. Which of the following commands will accomplish this? Choose one: a. cp -rP /home/* newdir b. cp -i /home/* newdir c. cp -iv /home/* newdir d. cp -b /home/* newdir Answer: a The -r option tells the cp command to recurse the directories. The -P option retains the original permissions. ===== 180 Obj 3.3 Chapter 4 dd You read an article that lists the following command: dd if=/dev/fd0 bs=512 of=/new What does this accomplish? Choose one: a. It copies the contents of a floppy disk to a file called new. b. It copies the file new to a floppy disk. c. It formats a floppy d. It erases a floppy Answer: a The dd command is a special copy command often used for floppy disks and tapes. The if= option specifies the source; the bs= is the block size; and the of= option is the output. ===== 181 Obj 3.3 Chapter 4 mv You have a directory called /home/ben/memos and want to move it to /home/bob/memos so you issue the command mv /home/ben/memos /home/bob What is the results of this action? Choose one: a. The files contained in /home/ben/memos are moved to the directory /home/bob/memos/memos. b. The files contained in /home/ben/memos are moved to the directory /home/bob/memos. c. The files contained in /home/ben/memos are moved to the directory /home/bob/. d. The command fails since a directory called memos already exists in the target directory. Answer: a When using the mv command to move a directory, if a directory of the same name exists then a subdirectory is created for the files to be moved. ===== 182 Obj 3.3 Chapter 4 rm You attempt to delete a file called sales.mem using the rm command but the command fails. What could be the problem? Choose one: a. You do not have delete rights to the file called sales.mem. b. You need to use the -i option with rm to delete a file. c. You do not have write rights to the directory containing the sales.mem file. d. You are not the owner of the file sales.mem. Answer: c In order to delete a file, you must have write rights to the directory containing the file. ===== 183 Obj 3.3 Chapter 4 mkdir You need to create two new directories in your home directory. The first one is called /home/bob/letters and the second one is /home/bob/letters/sales. Which of the following command lines should you use? Choose one: a. mkdir /home/bob/letters/sales b. mkdir letters; mkdir sales c. mkdir letters/sales d. mkdir home/bob/letters/sales Answer: a The mkdir command can create parent and child directories in a single step so this command line will create the new directory letters in your home directory and also create the sales directory as a subdirectory of the new directory letters. ===== 184 Obj 3.3 Chapter 4 rmdir You want to delete the following directories and their files /home/bob/letters /home/bob/sales so you issue the command rmdir /home/bob/letters but the command fails. What went wrong? Choose one: a. You need to first delete the sales subdirectory and its files before deleting its parent directory, letters, and its files. b. There is no such command as rmdir. c. The rmdir command cannot remove directories that are not empty. d. The rmdir command will not remove directory heirarchies. Answer: c The rmdir command can only delete empty directories. If you use the -p option, it can also remove the directory heirarchy as long as all directories are empty. ===== 185 Obj 3.7 Chapter 4 Regular Expressions You want to construct a regular expression that will match all lines that end with 'stuff'. Which of the following expressions will do this? Choose one: a. ^stuff b. stuff$ c. $stuff d. stuff^ Answer: b Using pattern$ will match to lines ending in the specified pattern. ===== 186 Obj 3.7 Chapter 4 Regular expressions You want to search for sale and sales. What regular expression should you use? Choose one: a. sale* b. sale? c. ^sale d. sale$ Answer: a Use the asterick (*) to match to zero or more characters. The '?' matches to any one character so sale? would not find sale. ===== 187 Obj 3.7 Chapter 4 grep You have a file named 'kickoff' and would like to find every line beginning with a number. Which of the following commands will accomplish this? Choose one: a. grep [0-9] kickoff b. grep ^[0-9] kickoff c. grep [0-9]$ kickoff d. grep $[0-9] kickoff Answer: b The command grep ^[0-9] kickoff will cause grep to search the file kickoff for any line beginning with a digit. ===== 188 Obj 3.7 Chapter 4 grep You want to know how many lines in the kickoff file contains 'prize'. Which of the following commands will produce the desired results? Choose one: a. grep -n prize kickoff b. grep -c prize kickoff c. grep -v prize kickoff d. grep prize kickoff Answer: b Using the -c option with the grep command will show the total number of lines containing the specified pattern rather than displaying the lines containing the pattern. ===== 189 Obj 3.7 Chapter 4 grep You search for the word prize in the file kickoff by typing grep prize kickoff. However you also find lines containing prize as part of a word such as prizes but do not find Prize. How should you change the command to find all occurrences of prize as a word and not part of a word? Choose one: a. grep -lc prize kickoff b. grep -cw prize kickoff c. grep -vi prize kickoff d. grep -iw prize kickoff Answer: d The -i option causes grep to ignore case and find the pattern irrespective of capitalization. The -w option finds the pattern as a whole word only and not as part of a word. ===== 190 Obj 3.7 Chapter 4 sed You want to verify which lines in the file kickoff contain 'Bob'. Which of the following commands will accomplish this? Choose one: a. sed -n /Bob/p kickoff b. sed /Bob/p kickoff c. sed -n 'Bob p' kickoff d. sed /Bob/ kickoff Answer: a The -n option when used with sed prints only the lines containing the pattern. In this case, the pattern is 'Bob' and the file to be searched is kickoff. ===== 191 Obj 3.3 Chapter 4 Compressing and Uncompressing Files You are using tar to create a tarfile of the files contained in the /home/bob/memos directory. After making the /home/bob/memos directory your working directory, which of the following commands will create the file? Choose one: a. tar cf memos.tar . b. tar xf memos.tar . c. tar cf memos.tar /home/bob/memos d. tar xf memos.tar /home/bob/memos Answer: a The c option with tar means to create the tarfile and the f option is used to supply the name for the new tarfile. ===== 192 Obj 3.3 Chapter 4 gzip You created a tarfile called myfiles.tar containing copies of all the files in your home directory. In order to save space you compress this file using gzip. After completing the operation, you do a listing of the contents of the directory to see how much smaller the compressed file is. How can you use the information from the listing to determine the percentage of compression? Choose one: a. Only the compressed file will be listed and not the tarfile. b. Divide the reported size of the tarfile by the reported size of the compressed file. c. Neither the tarfile nor the compressed file are listed as they are both moved to another directory by default. d. Divide the reported size of the compressed file by the reported size of the tarfile. Answer: a When you use gzip to compress a file, the original file is deleted, leaving only the compressed file. ===== 193 Obj 3.7 Chapter 4 compress You have a file called docs.Z but do not know what it is. What is the easiest way to look at the contents of the file? Choose one: a. Use zcat to display its contents. b. Use uncompress to expand the file and then use emacs to display the files contents. c. Copy the file to a floppy disk and uncompress it under Windows. d. Use tar -xt to display the file's contents. Answer: a The .Z extension indicates that this is a file that has been compressed using the compress utility. The zcat utility provides the ability to display the contents of a compressed file. ===== 194 Obj 4.3 Chapter 6 Mounting filesystems You issue the command mount without any options and the following output is displayed /dev/hda1 on / type ext2 (rw) none on /proc type proc (rw) /dev/hda9 on /home type ext2 (rw) /dev/hda7 on /tmp type ext2 (rw) /dev/hda5 on /usr type ext2 (rw) /dev/hda6 on /var type ext2 (rw) What does this output mean? Choose one: a. This is a listing of all the available filesystems that may be mounted on your system and is taken from the /etc/fstab file. b. This is a listing of all the mounted filesystems on your system and is taken from the /etc/mtab file. c. This is a listing of all the available filesystems that may be mounted on your system and is taken from the /etc/mtab file. d. This is a listing of all the mounted filesystems on your system and is taken from the /etc/fstab file. Answer: b When you issue the mount command without any arguments, it displays a list of all mounted filesystems. This information is obtained from the /etc/mtab file. ===== 195 Obj 4.3 Chapter 6 Mounting filesystems You have a new application on a CD-ROM that you wish to install. What should your first step be? Choose one: a. Read the installation instructions on the CD-ROM. b. Use the mount command to mount your CD-ROM as read-write. c. Use the umount command to access your CD-ROM. d. Use the mount command to mount your CD-ROM as read-only. Answer: d Before you can read any of the files contained on the CD-ROM, you must first mount the CD-ROM. ===== 196 Obj 4.3 Chapter 6 Mounting Filesystems You want to make it possible for your users to mount floppy disks. What do you need to do? Choose one: a. Tell your users the password for root as floppies can only be mounted by root. b. Edit the mtab file and add the user option on the floppy entry. c. Edit the fstab file and add the ro option on the floppy entry. d. Edit the fstab file and add the user option on the floppy entry. Answer: d If you add the user option to the line in the fstab file that defines how to mount your CD-ROM, then your users will be able to mount it. ===== 197 Obj 4.3 Chapter 6 Mounting filesystems You use the mount -a command to mount all your filesystems, however, you cannot access your CD-ROM. What could be the problem? Choose one: a. The CD-ROM is not defined in the fstab file. b. The CD-ROM cannot be mounted using the mount -a command. c. The command mount -a is not a valid command. d. The correct syntax to mount all filesystems is mount fstab. Answer: a The mount -a command will mount only the filesystems defined in the fstab file. ===== 198 Obj 4.3 Chapter 6 The /proc filesystem What is contained in the directory /proc? Choose one: a. System information b. Administrative procedures c. Boot procedures d. Documentation on your system Answer: a The /proc directory is a virtual filesystem that contains system information. ===== 199 Obj 4.3 Chapter 6 umount After copying a file to a floppy disk, what should you do before removing the disk? Answer: unmount the floppy If you do not unmount the floppy before removing it, the files on the floppy may become corrupted. ===== 200 Obj 4.4 Chapter 6 Disk Quotas One of your users calls to tell you that he cannot save a new file he has created in his home directory. You check his disk quota and find that he is using less than 50 percent of the space he is allotted. What could be the problem? Choose one: a. He is presently a member of a group that has exceeded its disk space quota. b. He has not named the file correctly. c. The system is corrupt. d. He needs to specify the absolute path when naming the file. Answer: a If the user's default group has exceeded its disk quota, he will not be able to create a new file although his personal quota has not be exceeded. ===== 201 Obj 4.4 Chapter 6 You have set quotas for all your users but half of your users are using more space than they have been allotted. Which of the following could be the problem? Question Choose one: a. You have too many users on your system. b. Users' home directories are located on two different partitions. c. Your kernel does not support setting disk quotas. d. You did not turn quotas on with the quotaon command. Answer: b Quotas are set on a partition by partition basis. If your users have home directories on different partitions, you will need to configure quotas for each partition. ===== 202 Obj 4.4 Chapter 6 Disk quotas What command should you use to check the number of files and disk space used and each user's defined quotas? Type your answer: Answer: repquota The repquota command is used to get a report on the status of the quotas you have set including the amount of allocated space and amount of used space. ===== 203 Obj 4.7 Chapter 6 Links You have a large spreadsheet located in the /data directory that five different people need to be able to change. How can you enable each user to edit the spreadsheet from their individual home directories? Choose one: a. Create a symbolic link in the /data directory. b. Copy the spreadsheet to each user's home directory. c. Create a hard link in each user's home directory. d. Create a script to move the spreadsheet to which ever user's home directory who needs to edit it. Answer: c By creating a link to the file in each user's home directory, each user is able to easily open and edit the spreadsheet. Also, any changes that are made are seen by all the users with access. ===== 204 Obj 4.7 Chapter 6 Links You have a file called salesdata and create symbolic links to it in bob's home directory. Bob calls you and says that his link no longer works. How can you fix the link? Choose one: a. The file salesdata has been deleted. You will have to restore it from a backup. b. You will need to delete the symbolic link in bob's directory and recreate it. c. Rename the link in bob's directory to salesdata.lnk. d. Change the owner of the link in bob's directory and change the permissions to give others read and write permissions. Answer: a Because the link in bob's directory is a symbolic link, if the file salesdata in the /data directory is deleted, the symbolic link will no longer work. ===== 205 Obj 4.7 Chapter 6 Links You have two files in two different directories with the same inode. What type of link is involved? Answer: hard Hard links all have the same inode number, unlike symbolic links. ===== 206 Obj 4.7 Chapter 6 Links You wish to create a link to the /data directory in bob's home directory so you issue the command ln /data /home/bob/datalink but the command fails. What option should you use in this command line to be successful. Answer: Use the -F option In order to create a link to a directory you must use the -F option. ===== 207 Obj 4.8 Chapter 6 find You need to locate a file called salesdata that one of your user's created in his home directory but you do not know which one. How could you use the find command to locate this file? Answer: find /home -name salesdata When using the find command to locate a file by name you must specify the starting place in the directory heirarchy and the -name option to specify the file to search for. ===== 208 Obj 4.8 Chapter 6 locate How does the locate and find commands differ in their method of searching? Choose one: a. locate uses the locatedb database and find searches the directory tree. b. find uses the finddb database and locate searches the directory tree. c. find searches the directory tree and the locate command only searches known directories. d. Both locate and find searches the directory tree. Answer: a The locate command searches the locatedb database while the find command searches the directory tree. ===== 209 Obj 4.5 Chapter 9 Permissions You issue the command ls -l memos and get the following output -rw-rw-r-- 1 bob users 17249 Sep 7 10:08 accounting -rw-rw-r-- 1 bob users 7202 Sep 17 9:10 administration -rw-rw-r-- 1 root users 13367 Sep 1 12:58 humres -rw-rw-r-- 1 bob users 9449 Sep 22 7:34 sales Bob opens the humres file and makes changes, however, he is unable to save the file after making changes. What is the problem? Choose one: a. Bob is not a member of the users group and only has read access. b. Bob's quota has been exceeded. c. Only the owner of a file can make changes to it. d. The file humres is corrupted and he needs to save his changes to another file. Answer: a Only the owner, root, and the group, users, have the permission to write to the file. Therefore, Bob must not be a member of the users group. ===== 210 Obj 4.6 Chapter 9 Changing the Owner You copy a file to Bob's home directory that Bob needs to revise. However, when Bob attempts to open the file he is unsuccessful. What command do you need to use to give Bob ownershiop of the file? Answer: chown The chown command can be used by root to give ownership of a file to any user. ===== 211 Obj 4.6 Chapter 9 Changing the Group Bob has created a new directory that will contain files that he and seven other users will be using for a new project. These eight users are the only members of the kickoff group. What does Bob need to do to give these users access to these files. Choose one: a. Change the group on the new directory to kickoff using the chgrp command. b. Make each of the other seven users the owner of the files as they are created. c. Give the others group the read and write permission to the directory. d. Place the files in the ftp directory so each user can copy them to his own home directory. Answer: a If Bob changes the group associated with the new directory to the kickoff group, then each member of the group can create and edit files in that directory. ===== 212 Obj 4.5 Chapter 9 Directory Access A listing of the /data directory shows drw-rw-r-- 1 root accounting 17249 Sep 7 10:08 accounting drw-rw-r-- 1 root admin 7202 Sep 17 9:10 administration drw-rw-r-- 1 root humres 13367 Sep 1 12:58 humres drw-rw-r-- 1 root sales 9449 Sep 22 7:34 sales George, who is a member of the admin group, attempts to delete a file contained in the humres directory but is unsuccessful. What do you and George need to do to allow George to delete files in this directory? Choose one: a. You need to add George to the humres group then George needs to make the humres group his default group. b. You need to edit the /etc/passwd file to show the humres group as George's default group. c. Give George ownership of the humres directory. d. George needs to give you a list of files to be deleted and then you should delete them. Answer: a In order to delete a file, you must have the write permission to the directory containing the file. By making George a member of the humres group, he would then have write permission to the directory after he makes the humres group his default group. ===== 213 Obj 4.5 Chapter 9 Permissions You have a file called administration with the following attributes -rw-rw-r-- 1 root admin 7202 Sep 17 9:10 administration George is a member of the admin group and Bob is a member of the sales group. Both George and Bob need to make changes to this file. What permissions do George and Bob have to the file? Choose one: a. George has read and write permissions and Bob has read permission. b. Bob has read and write permissions and George has read permission. c. Both George and Bob have read and write permissions. d. Both George and Bob have read permission only. Answer: a Since George is a member of the admin group, he inherits the permissions of that group which are read and write. Bob is neither the owner of the file or a member of the admin group, therefore, he only gets read permission. ===== 214 Obj 4.5 Chapter 9 Changing Permissions You copy the administration directory to George's home directory. -rw-rw--w- 1 root admin 7202 Sep 17 9:10 administration The only group that George is a member of is users. He calls you to say he cannot list the contents of the administration directory. Why can't he look at its contents since it is in his home directory? Choose one: a. In order to view the contents of a directory, you must have read permission. George only has write permission. b. Only the owner of a directory can list its contents. c. George needs to change his default group to admin. d. George needs to make himself the owner of the administration directory. Answer: a George only has the permissions granted to others which in this case is write. Without the read permission on the directory, he will not be able to list its contents. ===== 215 Obj 4.5 Chapter 9 Changing Permissions You have a directory with the following permissions drw-rw--w- 1 root admin 7202 Sep 17 9:10 administration and need to give everyone except root read only access to it. Which of the following commands will accomplish this? Choose one: a. chmod uo=r administration b. chmod ug+r administration c. chmod uo+r administration d. chmod ug=r administration Answer: d When using symbols, the equal sign explicitly sets permissions and revokes any pre-existing permissions. ===== 216 Obj 4.5 Chapter 9 Changing Permissions You have a file with the following permissions -rw-r--r-- 1 root admin 7202 Sep 17 9:10 phonenos You want the members of the admin group to be able to modify the file. What command should you use? Choose one: a. chmod 664 phonenos b. chmod 114 phonenos c. chmod 771 phonenos d. chmod 551 phonenos Answer: a The first digit would give the owner read and write permission (4 plus 2) and the second digit would give the group read and write permission. The last digit gives others the read permission only. ===== 217 Obj 4.5 Chapter 9 SUID and GUID You have a file with permissions set as -rw-r--r-- 1 root admin 7202 Sep 17 9:10 phonenos What would be the effect of issuing the command chmod 4755? Choose one: a. The owner would be given execute permission. b. To run the file you will have to give root's password. c. When executing the file phonenos it would be run under the same permissions as the owner's. d. Everyone would have the write permission to the phonenos file. Answer: c The first digit would set the user ID when executing the program also known as SUID. Owner would be granted read, write, and execute permissions. The group admin and others would also be granted the execute and read permissions. ===== 218 Obj 4.5 Chapter 9 Sticky bit What is meant by sticky bit? Choose one: a. When set on a directory, then only the owner of a file can delete it. b. When set on an executable, then any user can run the executable. c. When set on a file, only the owner can see the file in a directory listing. d. When set on a directory, then everyone has read, write and execute permission on the files contained in that directory. Answer: a When the sticky bit is set on a world writable directory, only the owner can delete any file contained in that directory. ===== 219 Obj 4.5 Chapter 9 Default Permissions Your default umask is 002. What does this mean? Choose one: a. Any file you create will have the permissions set as owner and group having read and write permissions; others as read only. b. Any file you create will have the permissions set as owner and group having read, write and execute permissions; others as read and execute. c. Any directoy you create will have the permissions set as owner and group having read, write and execute permissions; others as read and write permissions. d. Any directory you create will have the permissions set as owner and group having read and write permissions; others as read only. Answer: a The digits of your umask represent owner, group and others in that order. The 0 gives read and write for files and the 2 gives read only for files. ===== 220 Obj 3.2 Chapter 8 sed Which of the following commands will replace all occurrences of the word rate with the word speed in the file racing? Choose one: a. sed s/rate/speed/g racing b. sed -n s/rate/speed/ racing c. sed s/rate/speed/ racing d. sed s2/rate/speed/ racing Answer: a When using sed to do a search and replace, its default action is to only replace the first occurrence in each line. Adding the 'g' makes sed replace all occurrences of the search term even when it occurs multiple times on the same line. ===== 221 Obj 3.2 Chapter 8 sed When using sed to replace one term with another it will print every line in the file and then print each line every time it does a replacement. What option should you add to the command line to only print the lines that are changed? Choose one: a. -n b. -p c. -g d. -f Answer: a When using sed at the command line, the -n option will cause sed to only display the lines that have changes made. ===== 222 Obj 3.2 Chapter 8 sort You have a file named phonenos containing names and telephone numbers. Each line contains the telephone number followed by the name. You want to sort the file by telephone number in ascending order. Which of the following commands will accomplish this. Choose one: a. sort phonenos b. sort -c phonenos c. sort -n phonenos d. sort -r phonenos Answer: a The default action of the sort utility is to sort in ascending order. ===== 223 Obj 3.2 Chapter 8 cut You have a file called phonenos that consists of two fields per line, telephone number and name, with the fields being separated by a comma (,). You want to have a list of the names only. Which command will accomplish this? Choose one: a. cut -d, -f2 phonenos b. cut -d, -f1 phonenos c. cut -d -f2 phonenos d. cut -f2 phonenos Answer: a When using the cut utility, you can specify the character that is used to delimit the fields by using the -d option. Use the -f option to specify which field to return. ===== 224 Obj 3.2 Chapter 8 expand You have a tab delimited file called phonenos and want to change each tab to four spaces. What command can you use to accomplish this? Choose one: a. expand -t4 phonenos b. expand phonenos c. expand -n4 phonenos d. expand -t phonenos Answer: a By default, expand converts tabs to eight spaces. Use the -t option to change this behavior. ===== 225 Obj 3.2 Chapter 8 fmt You want to print out a text file called vacations however the lines are of varying length. What text filter could you use to even out the length of the lines? Answer: fmt The fmt text utility attempts to make all the lines the same lenght by joining or splitting lines. ===== 226 Obj 3.2 Chapter 8 head You issue the command head *. What would the resulting output be? Choose one: a. The first ten lines of each file in the working directory would be displayed preceeded by the file's name. b. The first five lines of each file in the working directory would be displayed preceeded by the file's name. c. The name of each file in the working directory would be displayed. d. The first ten lines of each file in your home directory would be displayed preceeded by the file's name. Answer: a If the number of lines to display is not specified, the first ten lines of the specified file is displayed. The asterick tells head to display the content of each file in the present working directory. ===== 227 Obj 3.2 Chapter 8 join You have two files each ten lines long. What text filter could you use to combine the two files so that each line of the output contains the corresponding line from each file? Answer: join The join text filter will display one line for each pair of input lines from two files. ===== 228 Obj 3.2 Chapter 8 nl What text filter can you use to display a multi-page file and place numbers at the beginning of each line. Answer: nl The nl text filter will divide a file into logical pages and number each line. ===== 229 Obj 3.2 Chapter 8 od What text filter can you use to display a binary file in octal numbers? Answer: od The od text filter will dumpt the contents of a file and display it in 2-byte octal numbers. ===== 230 Obj 3.2 Chapter 8 paste What would be the result of the command paste -s dog cat? Choose one: a. The corresponding lines from the files dog and cat would be pasted together separated by a tab. b. The corresponding lines from the files dog and cat would be pasted together separated by a space. c. The file cat would be pasted after the file dog. d. The file dog would be pasted after the file cat. Answer: c The paste text filter usually joins two files separating the corresponding lines with a tab. The -s option, however, will cause paste to display the first file, dog, then a newline character, and then the file cat. ===== 231 Obj 3.2 Chapter 8 pr You wish to print the file vacations with 60 lines to a page. Which of the following commands will accomplish this? Choose one: a. pr -l60 vacations | lpr b. pr -f vacations | lpr c. pr -m vacations | lpr d. pr -l vacations | lpr Answer: a The default page length when using pr is 66 lines. The -l option is used to specify a different length. ===== 232 Obj 3.2 Chapter 8 split You have a file called phonenos that is almost 4,000 lines long. What text filter can you use to split it into four pieces each 1,000 lines long? Type your answer: Answer: split The split text filter will divide files into equally sized pieces. The default length of each piece is 1,000 lines. ===== 233 Obj 3.2 Chapter 8 tac What would be the result of issuing the command cat phonenos? Choose one: a. The file phonenos would be displayed in reverse order with the last line shown first. b. The first word of each line of the file phonenos would be displayed. c. The file phonenos would be displayed in reverse order with the last line shown first and a newline character added at the end of each line. d. The file phonenos would be displayed with each line numbered in reverse order with the last line shown first. Answer: a The tac text filter is a reverse cat. It displays a file starting with the last line and ending with the first line. ===== 234 Obj 3.2 Chapter 8 tail You need to see the last fifteen lines of the files dog, cat and horse. What command should you use? Type your answer: Answer: tail -15 dog cat horse The tail utility displays the end of a file. The -15 tells tail to display the last fifteen lines of each specified file. ===== 235 Obj 3.2 Chapter 8 tr You have the file phonenos that contains telephone numbers and names separated by a comma. You want to change each comma to a semicolon. Which of the following will accomplish this. Choose one: a. cat phonenos | tr ',' ';' b. tr ',' ';' phonenos c. sed s/,/;/ phonenos d. tr phonenos ',' ';' Answer: a The tr utility is used to replace one string by another. Here the input for tr is provided by the cat command and the commas are all replaced by semicolons. ===== 236 Obj 3.2 Chapter 8 wc You know that there should be 1,233 entries in the phonenos file and that each entry in on a separate line. What utility can you use to verify that the file contains 1,233 lines? Type your answer: Answer: wc The wc utility will count the number of characters, words, or lines. ===== 237 Obj 3.4 Chapter 8 Input and Output Where is standard output usually directed? Answer: to the screen or display By default, your shell directs standard output to your screen or display. ===== 238 Obj 3.4 Chapter 8 Input and Output Each command has two types of output. There are standard output and standard ____________. Answer: error By default, each command sends its result as standard output and any error messages as standard error. ===== 239 Obj 3.4 Chapter 8 Redirection and pipes If you type the command cat dog > cat what would you see on your display? Choose one: a. Any error messages only. b. The contents of the file dog. c. The contents of the file dog and any error messages. d. The contents of the file dog and the file cat. Answer: a When you use > for redirection, it only effects the standard output. Any messages sent to standard error would still appear on your display. ===== 240 Obj 3.4 Chapter 8 Redirection and pipes If you type the command cat dog >& cat what would you see on your display? Choose one: a. Any error messages only. b. The contents of the file dog. c. The contents of the file dog and any error messages. d. The contents of the file dog and the file cat. Answer: b When you use >& for redirection, it only effects the standard error. Standard output would still appear on your display. ===== 241 Obj 3.4 Chapter 8 Redirection and pipes If you type the command cat dog &> cat what would you see on your display? Choose one: a. Any error messages only. b. The contents of the file dog. c. The contents of the file dog and any error messages. d. Nothing as all output is saved to the file cat. Answer: d When you use &> for redirection, it redirects both the standard output and standard error. The output would be saved to the file cat. ===== 242 Obj 3.4 Chapter 8 Redirection and pipes If you type the command cat dog 1> cat 2> horse where would the output be sent? Choose one: a. Any error messages would be saved to the file horse and the standard output would be saved to the file cat. b. Any error messages would be saved to the file cat and the standard output would be saved to the file horse. c. The contents of the file dog and any error messages would be saved to the file horse. d. The contents of the files dog and cat would be saved to the file horse. Answer: a When you use 1> for redirection, it only effects the standard output. The 2> would send standard error to the file horse. ===== 243 Obj 3.4 Chapter 8 Redirection and pipes You are not interested in any error messages from the command cat dog cat horse. What command should you enter? Choose one: a. cat dog cat horse >& /dev/null b. cat dog cat horse &> /dev/null c. cat dog cat horse d. cat dog cat horse 1> /dev/null Answer: a By redirecting the error messages, stderr, to /dev/null they are discarded and neither saved or displayed. ===== 244 Obj 3.4 Chapter 8 pipe You enter the command cat horse | tr 'x' 'X'. What is the purpose of the | character? Choose one: a. The | character is used to send the output from one command to another command as input. b. The | character is used to send the input from one command to another command as output. c. The | character is used to sequentially enter multiple commands. d. The | character is a place holder to tell the shell where one command ends and another begins. Answer: a The | character is used to send the output of one command to another command as input. ===== 245 Obj 3.4 Chapter 8 tee utility What is the results of the command cat horse | tee dog? Choose one: a. The contents of the file horse would be displayed on the screen and saved in a new file called dog. b. The contents of the file horse would be displayed on the screen. c. The contents of the file horse would saved in a new file called dog. d. The contents of the files horse and dog would be displayed on the screen. Answer: a The tee utility is used to simultaneously send the output of a command to the display and a file. ===== 246 Obj 3.4 Chapter 8 xargs What is the purpose of the command xargs? Choose one: a. xargs is used to pass arguments from one command to another. b. xargs is used to redirect standard output to a file. c. xargs is used to redirect standard error to a file. d. xargs is used to use the contents of a file as standard input. Answer: a The xargs command passes arguments from one command to another thereby allowing the receiving command to handle more arguments than would normally be possible. ===== 247 Obj 11.2 Chapter 7 User Startup Files As the system administrator you have created a directory containing some scripts that you have written. You want to have all your users to be able to run this scripts. Which file should you edit to ensure that the scripts will run without your users having to type the complete path to the script? Choose one: a. ~/.profile b. /etc/profile c. /etc/bash d. ~/.bash Answer: b To make changes to the path that will effect all of your users, add the new directory to a path statement in the /etc/profile files. ===== 248 Obj 11.2 Chapter 7 User Startup files You want to configure your system so that when you create a new user a customized .bash_logout file will be created in the new user's home directory. How can you do this? Choose one: a. Copy the .bash_logout file to the new user's home directory. b. Copy the .bash_logout file to the /etc/skel directory. c. Copy the .bash_logout file to the /etc directory. d. Rename the .bash_logout file to BASH_LOGOUT Answer: b Any files that are located in the /etc/skel directory will be copied to the new user's home directory if you use the useradd utility to create the user account and his home directory. ===== 249 Obj 4.8 Chapter 6 updatedb Which file do you need to change to alter how the updatedb database is created? Choose one: a. /etc/which.conf b. /etc/conf.updatedb c. /etc/updatedb.conf d. /etc/conf.which Answer: c The /etc/updatedb.conf file is used to manage the creation of the updatedb database. ===== 250 Obj 3.4 Chapter 8 tr You enter the command cat horse | tr 'x' 'X'. What is the result of this command? Choose one: a. The file horse will be displayed to the screen. b. Any lines in the file horse containing 'x' or 'X' will be displayed to the screen c. All instances of 'x' will be changed to 'X' and the output sent to the screen. d. All instances of 'x' will be changed to 'X' and the output written to the file called horse. Answer: c The tr utility is used to change one pattern to another. The results are then sent to the standard output, the screen.