Sunday, September 21, 2008

Chapter 3 Self Test

1.) When you enter the following command, what happens and why? cat > dog

You create a new file(Or overwrite an existing one) named dog and it allows you to type text into the file. The command line tells the computer to start the cat utility and then to create the new(or overwrite the old) file using the text you type in after this is entered.

2.) What results from using the following commands?

A. who grep $USER
The computer outputs who you are, when you logged on and where you logged on from.

B. grep \$HOME file1
grep specifies a search string, \$HOME is what it is searching for, and file1 is the file you are searching for. If there is no "file1" on your computer it tells you that grep: file1: no such file or directory.

C. echo u* >> file1
The computer inputs all the files beginning with u into the end of file1.

D. echo 'u*' >> file1
The quote marks on the end tells the computer not to use the * as an undefined character and then inputs anything with the u* into the end of file1.

E. ps
Gives you a list of the processes that are currently in use.

F. . fileA
The . command tells the computer to treat the file as though we had typed it into the computer and execute the contents of the file.

G. set noclobber
If you are in the csh or tcsh shells it tells the computer to not allow files to be overwritten, but if you are in ksh or bash shells it does nothing. The correct command for ksh or bash shells would be set -o noclobber.

H. set -o
By itself this tells you which functions are on or off.

I. chmod +x file2
Changes the mode of file2 to make it an executable file.

3.) How can we change the prompt to be Next? in both families of shells(C shells and Korn shells)?

In C shells(csh and tcsh) type in set prompt='Next?'. In Korn shells(sh, bash, and ksh) type PS1='Next?'.

4.) What data is in each field in the passwd file?

username(login):password:User ID:Group ID:Info on user:Home Directory:Start-up program.

5.) What command instructs the shell not to accept CTRL-D as a signal to log off?

In the csh or tcsh shells use set ignoreeof, and in the ksh or bash shells use set-o ignoreeof.

No comments: