Part One: Fundamentals of UNIX Systems

   

Chapter 1: Getting Started with UNIX

1:

The system startup file for a UNIX shell is invoked:

A:

C. The system startup file for the /etc/profile shell is invoked when a user logs into the system.

2:

The default POSIX shell prompt for a common user is:

A:

C.

3:

When a user logs into HP-UX, the initial directory is:

A:

B.

4:

What is the difference between intrinsic and extrinsic UNIX commands?

A:

A.

5:

What is true about the superuser?

A:

C. Any user having user ID 0 is a superuser. Creating more than one user with the same user ID is another way of giving the same rights to multiple users in a system.

6:

The default shell for HP-UX users is:

A:

C.

7:

To log out of the HP-UX session, you use command:

A:

B. There is no logout command.

Chapter 2: Working with Files and Directories

1:

The cat command is used to:

A:

C. This command can be used for both creating and displaying a file.

2:

The maximum length of a file name may be:

A:

C. A file name in HP-UX may be 256 characters long.

3:

The more command is used to:

A:

A. This command is used to display text files, one page at a time.

4:

What is the function of the following command

 grep "Mark Black" /etc/passwd 
A:

A. Words enclosed in quotation marks are considered as one string. The find command can't be used to find text within a file.

5:

Consider a directory with five files in it. The file names are pg.c , pg1.c , pg2.c , pg3.cpp , and pg10.c . We use the command ls pg?.? . The files displayed are:

A:

A. The question mark is used to match only one character.

6:

How can you tell the number of user accounts on a UNIX system?

A:

D. Each user name is listed in one line in the /etc/passwd file. There is no number command in HP-UX.

7:

You are currently in the /home/boota directory. Which command will bring you the to /etc directory?

A:

D. Option A is not correct as it will move you to /home/boota/etc (if this exists). Option B is correct as you will go back two steps to the root directory and then go to etc directory. Option C is also correct as you have specified an absolute path .

Chapter 3: Environment Variables

1:

Just after login, you issue the command echo HOME . What will be the output of this command?

A:

C. Option A is not correct because to display the value of a variable you have to use a dollar sign with the variable name. Option B is not correct because the HOME variable is set when you log in. Since you have not used a dollar sign, the command will simply display the word "HOME", so option C is correct.

2:

What is not true about the PATH variable?

A:

A. The PATH variable does not show anything about the current directory.

3:

You have a variable " ABC " with value " Alphabets ". You use the following command to change its value.

 ABC='All $ABC' 

What will be the new value of the variable?

A:

A. Any string specified with single quotation marks is taken as-is by HP-UX commands.

4:

To assign the output of a command to a variable, we use:

A:

D.

5:

The value of the PS2 variable on your system is " > " (greater-than symbol). You issue an incomplete command. What will be the shell's response?

A:

D. The shell displays the value of the PS2 variable as prompt when you issue an incomplete command.

6:

What is wrong with the shell variable name 3Xyab2 ?

A:

A. Ahell variable name can't be started with a digit.

Chapter 4: Input/Output Redirection and Pipes

1:

What is the file descriptor used for stderr?

A:

C.

2:

The symbol used to append to a file when redirecting stdout to that file is:

A:

B. Option A overwrites the existing file. Option C is used for input redirection. Option D is used for stderr redirection.

3:

When you redirect both stdout and stderr to the same location, you use:

A:

C.

4:

A pipe is used to:

A:

A.

5:

Which is not true?

A:

B. A pipe can be used in a command where the stdin is redirected.

Chapter 5: Using the vi Editor

1:

You have made changes to a file and want to quit vi without saving these changes. What command will you use?

A:

C. Option A will save the changes and then quit. Option B will save the file and then quit. Option D will force saving the file.

2:

You want to replace cat with dog in your file at all locations in the vi editor. You use:

A:

C.

3:

While in command mode you press "a"; what happens?

A:

B.

Chapter 6: Regular Expressions

1:

The purpose of the command grep ^Test$ is:

A:

D.

2:

Square brackets in pattern matching are used for:

A:

C.

3:

A regular expression \<join matches:

A:

A.

4:

The grep command can use:

A:

A.

5:

Which of these is NOT a meta character?

A:

D.

Chapter 7: File Permissions

1:

A file has rwxr-xr-- permissions. It is owned by a user mark belonging to a group users . You are logged in as user jim belonging to group users . What permissions do you have for this file?

A:

C. All group members have read and execute permissions.

2:

You are logged in as user jim and create a file myfile and want to give it to a user mark by changing its ownership. The command for this is:

A:

B.

3:

The id command without any argument lists:

A:

C.

4:

You want to change your group ID temporarily. Which command will you use?

A:

A. The chgrp command changes the group ownership of a file. The id command is used to display the user and group IDs.

5:

The system administrator wants a command to be executed with superuser permissions no matter which user executes it. He or she will set:

A:

A.

6:

A file myfile already exists. You use command touch myfile . What will be the effect of this command?

A:

C.

7:

You are logged in as user boota belonging to group users . When you list files using the ll command, you see the following list.

 -rwxrw-r--   1 jim   class    0 Sep  8 18:06 myfile 

What operations can you perform on this file?

A:

C. You are neither the owner of the file nor a group member of the owner.

8:

You use the command chmod 764 myfile . It provides:

A:

D.

Chapter 8: UNIX File System Hierarchy

1:

What can be determined about file name /etc/named.boot ?

A:

B. The /etc directory contains most of the configuration files.

2:

The HP-UX file system hierarchy is based on:

A:

B.

3:

Mail files are kept in which directory?

A:

D.

4:

What is true about the lost+found directory?

A:

B.

5:

To find a command in the search path, we use the command:

A:

B.

6:

Which directory contains programs needed at boot time?

A:

A.

7:

The HP-UX kernel is located in:

A:

D.

Chapter 9: Working with the POSIX Shell and Job Control

1:

The default HP-UX shell is:

A:

C.

2:

You are in a directory having three files, file1 , file2 , and afile . You type a command ls f and then press the graphics/esc.gif key followed by the graphics/equal.gif key. What happens?

A:

D.

3:

You use the date command to see the current system time. Just after that, you press the graphics/esc.gif key followed by the graphics/j.gif key. What happens?

A:

D. This key combination is used to go to the next command in the command history. Since there is no next command, nothing will happen.

4:

What does the command r 3 do?

A:

D.

5:

For what purpose is the stty command used?

A:

D. The stty command is used for terminal related settings.

6:

Your home directory is /home/boota . You moved from your home directory to the /etc directory. How can you go back to your home directory?

A:

B. Choices A and C seem to be correct but the $ symbol is missing in the variable name with both of the choices.

7:

A job running in the foreground can be suspended by:

A:

C. No command can be used while a job is running in the foreground, so choices A, B, and D are incorrect.

8:

Background jobs are always in:

A:

D. A background job may be in any state.

Chapter 10: Introduction to Shell Programming

1:

You create a shell program and save it into a file with name " more ". Your current directory name is included in the PATH variable at the end. When you run this program by typing " more ", nothing happens and the cursor just stops at the next line. What may be the problem?

A:

C. The more command is a standard UNIX command that expects an input from stdin. Since your current directory is at the end of the PATH variable, the standard more command gets executed instead of your own program. Choice A is incorrect because, in the case of an unrecognized command, you will get an error message. Choice B is incorrect because you will get an error message if the program is not executable.

2:

What is true about variables used in shell programs?

A:

D.

3:

You use the echo $? command. The result is 2 . What do you conclude from this?

A:

B. The command prints the return code of the last command. Any return code other than 0 shows that the execution of the last command was not successful.

4:

You used shift 3 in your shell program. What will be its effect?

A:

C. The shift command shifts all command line arguments to the left.

5:

What does the echo "\a" command do?

A:

D. This is an escape character used for an alert sound.

6:

What is wrong with the command [ "ABC" -eq "ABC" ]?

A:

A. To test string equality you use the equal sign (=).

7:

A shell script with the name myscript does not have the execution bit set. How can you execute it?

A:

B.

8:

How can you list all command line arguments?

A:

A.

9:

The true return value of the test command is:

A:

C. It returns a positive integer including zero.

10:

You have a shell script as shown here. What will be the result when it is executed?

 #!/usr/bin/sh ABC=aac case $ABC in   a)     echo "First"          ;; [aa]c)   echo "Second"          ;; a*)      echo "Third"          ;; *)       echo "Last"          ;; esac 
A:

C. The only matching choice is a*.

Chapter 11: Advanced Shell Programming

1:

Which command will you use to add the values of two variables VAR1 and VAR2 , and store the result in VAR3 ?

A:

D.

2:

You want to wait for 10 seconds at the end of the loop in each loop cycle. Which command will you use?

A:

A. There is no pause command. The wait command is used to wait for a child process to terminate.

3:

Consider the following code segment. How many times does the loop execute?

 A=1 until [ $A < 10 ] do    echo $A    (( $A=$A+1)) done 
A:

A.

4:

What will be the output of the program shown here?

 #!/usr/bin/sh A=1 while [ $A -lt 10 ] do    B=1    while [ $B -lt 10 ]    do       break 2       echo "Inner loop"    done    echo "Outer Loop" done 
A:

D. The break command terminates both loops before anything is printed.

5:

While writing a program, you meet a situation where you want to break the normal execution and shift control to the beginning of the loop, skipping the remaining commands in the loop. Which command will you use?

A:

B.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net