Sunday, March 16, 2008

Chapter 6

1. Which of the following are valid shells that are available in Linux?
a. /bin/bash
c. /bin/ksh
d. /bin/tcsh

2. Which of the following files are executed when you start another shell following login?
c. ~/.bashrc

3. Which of the following files could you edit to create a variable that must exist in all shells that are started by users on your system?
a. ~/.bash_login

4. You have just edited your ~/.bashrc file and added a line that loads a variable. How can you read this file into your current shell environment?
d. source ~/.bashrc

5. Which of the following may be used to protect the $ character in the phrase $DIR from being interpreted specially by the bash shell?
a . \$DIR

6. You wish to recall a previous command that starts with the letters "cron". After you type the letters "cron" on the command line, what key combination could you use to search the command history for previous commands that start with "cron"?
Ctrl + R

7. Which key may be used to complete the name of a file or a directory on the command line?
b. Tab

8. Which of the following commands can be used to view the contents of the $NOVELL variable?
b. echo $NOVELL

9. What command could you use to create a variable called TEST that is available to child processes in subshells?
export TEST="Good Morning"
bash

10. What function call is used by a shell to create a subshell for program execution.
exec

11. Which of the following commands may be used to view all shell and environment variables on the system?
a. env

12. What command could you use to create an alias called c that runs the clear command in your current shell.
alias c=clear

13. Which of the following files are best suited to storing aliases?
d. /etc/bash.bashrc

14. Which command can be used to view all files in the /etc directory that are three characters long and start with either A or B?
a. ls /etc/[AB]??

15. Which of the following output redirection symbols will not overwrite an existing file?
d. >>

16. What command could you enter at a command prompt to view a long listing of files in the /proc directory and save the stdout and stderr to the file results in your current directory?
ls -l /proc > results 2>&1

17. Which of the following demonstrates correct syntax?
b. command >file
d. command | command

18. To which device file can you redirect stderr in order to ignore stderr completely?
/dev/null

19. Which of the following will run the command echo "I Found It!" only if the command grep localhost /etc/hosts is successful?
c. grep localhost /etc/hosts && echo "I found it!"

20. What command accepts information from stdin and sends it to both a file and stdout?
tee

21. Which key can you use to switch from command mode to insert mode in the vi editor?
b. i

22. Which key sequence in the vi editor will allow you to save your changes and quit?
a. :wq
c. :x
23. What sed command would you use to replace all occurrences of the word mom with dad in the file letter?
sed y/mom/dad/

24. What sed command would you use to delete all lines that begin with a # character in the file /etc/samba/smb.conf ?
sed '1~1d,#' /etc/samba/smb.com

25. What awk command would you use to print the third and fifth fields of the colon-delimited /etc/passwd file?

1 comment:

Egypt Trip 2008 said...

Nice job! See you in class. Don't forget Spring Break next week!