Part One: Fundamentals of the UNIX Systems

   

Chapter 1: Getting Started with UNIX

1:

What is the role of the shell in a UNIX system?

A:

The shell is a command interpreter for UNIX users. It reads input from users and performs an action depending upon that input.

2:

What is the difference between intrinsic and extrinsic commands?

A:

Intrinsic commands are built into the shell while extrinsic commands are stored s separate files.

3:

What restrictions apply to an HP-UX password?

A:

The length of a password is between six and eight characters .

It must be a combination of characters and numbers .

At least two characters of the password must be letters and one must be a number or a pecial character such as, a dash ( - ), underscore ( _ ), or asterisk ( * ).

If you use a password of length greater than eight, any characters after the ighth character are ignored.

4:

What are shell startup files? Is it possible for a user to have no startup file?

A:

There are two shell startup files: a system startup file and a user startup file. The system startup file is /etc/profile , while the user startup file is .profile and it is tored in the home directory of the user.

Chapter 2: Working with Files and Directories

1:

What restrictions apply to UNIX file names ?

A:

The maximum length of a file name is 256 characters.

A file name can be a combination of letters, numbers, or special characters.

All letters, both upper (AZ) and lower case (az) can be used in file names.

Numbers from 0 to 9 can be used in file names.

Special characters like plus ( + ), minus ( - ), underscore ( _ ), or dot ( . ) can be used in file names.

2:

What is the difference between the home directory and the root directory?

A:

The root directory is the reference point for UNIX file systems and is represented by the / character. The home directory is particular to a user. When a user logs into a UNIX system, he or she goes into the home directory just after the login.

3:

Is it possible to create multiple directories with a single command line?

A:

You can use the mkdir command to create multiple directories.

4:

What is the difference between the cp and mv commands?

A:

The cp command copies a file, leaving the original file in place. The mv command copies a file to a new location and then deletes the original file. The mv command can also be used to rename a file.

5:

How do absolute path names differ from relative path names?

A:

Absolute path names start with the / character while relative paths do not.

6:

Write a command to list all files that start with my , with any characters in the third to fifth positions , and that end with the e.txt pattern.

A:

[click here]

 ls my???e.txt 

Chapter 3: Environment Variables

1:

What is the difference between environment and shell variables?

A:

Environment variables are inherited by all child processes while shell variables re not.

2:

What is the role of the time zone ( TZ ) variable in a company with offices in many countries ?

A:

It can be used to differentiate between older and newer files.

3:

Why do you export a variable?

A:

A variable is exported to make it visible for child processes.

4:

Name any four predefined environment variables.

A:

[click here]

 $HOME $PATH $SHELL $TERM 

Chapter 4: Input/Output Redirection and Pipes

1:

UNIX is a " file-based " system. What does that mean?

A:

All system resources (disks, printers, keyboards, etc.) are referenced using file names in UNIX.

2:

What if we redirect output of a command to a file that already exists?

A:

The existing file will be overwritten if the redirection is made using a single greater-than sign " > ". The data will be appended to the file if a double greater-than sign >> " is used.

3:

What if we pipe output of a command to another command that expects nothing as input?

A:

The second command will ignore the input received from the first command. Output of the second command will be printed on the screen.

4:

Can we redirect both input and output to same file?

A:

Theoretically we can do so, but the file will be destroyed .

Chapter 5: Using the vi Editor

1:

What is the difference between the insert and command modes of the vi editor?

A:

In the insert mode, every typed character is inserted into a file buffer. In the ommand mode, every typed character is considered a command.

2:

How is cut-paste different from import-export?

A:

Cut-paste is carried out in the opened file buffers. Import-export is done to disk iles.

3:

Is it possible to edit binary files with the vi editor?

A:

The vi editor is used for text files.

4:

What is the role of the .exrc file?

A:

When this file is placed in the home directory of a user, it is used for vi settings.

Chapter 6: Regular Expressions

1:

Describe the process used by the UNIX shell for command execution.

A:

If the command is an intrinsic command, it is executed by the shell itself. If it is an extrinsic command, the command execution process is completed in the following steps.

  • The shell looks for a valid command by searching all directories specified by PATH variable.

  • Options and arguments are parsed and arguments are expanded depending on the special characters used.

  • The command is invoked.

  • The results of the command are displayed back to the user.

2:

What is the command to find all lines in a file that start or end with the word "an"?

A:

Create a file with the name f2 with the following two lines.

 ^an an$ 

Now use the following command:

 grep -f f2 filename 

where filename is the name of the file you want to search.

3:

What is the result of the following command?

 grep ^[a-z]$ ? 
A:

It matches all lines that have only one lowercase letter.

4:

Write a command that lists all users in the /etc/passwd file whose name starts with a vowel and who are assigned the POSIX shell ( /usr/bin/sh ).

A:

[Return to question 4.]

 grep ^[aeiou] /etc/passwd  grep "/usr/bin/sh"$ 

Chapter 7: File Permissions

1:

How many types of users are present in UNIX and what is the use of groups?

A:

There are basically three types of users.

  • owner of a file

  • group members of the file owner

  • all other users

Groups are useful to grant additional permissions to some users of the system. Usually users working on common problems are placed in one group.

2:

What is the advantage of placing a user in more than one group?

A:

A user may be member of more than one group depending upon his or her responsibilities. For example, a finance manager may be placed in the finance group as well as the managers group because she has both types of responsibilities.

3:

What is the use of SETUID from the system administration point of view?

A:

A system may use SETUID so that some programs run with root privileges. An example is the passwd command.

4:

Write a command to find all files in a directory with the sticky bit set and copy these files to the /tmp directory.

A:

[Return to question 4.]

 find / -perm -u+s -exec cp {} /tmp \; 
5:

What if the SUID for a file is set but the file is not executable?

A:

The SUID without execute access rights shows a mandatory file lock.

6:

Why are the Access Control Lists used?

A:

The ACLs are used to grant file access rights on an individual user basis.

Chapter 8: UNIX File System Hierarchy

1:

Why are static directories also called shared directories?

A:

Static directories can be shared across systems on a network to save disk space. For example, the manual pages may be placed on only one system on the network and used by all other systems. That is why these directories are called shared directories.

2:

If you install a new application on the system, where would you like to place its files? What is the recommended place for its configuration and log files?

A:

The recommended place for applications is the /opt directory. The log files should go to the /var/opt directory and configuration files to the /etc directory. However this is not mandatory and you can place any application anywhere in the file system hierarchy.

3:

What is the use of the /tmp directory?

A:

It is used to place temporary files.

4:

What are spool files and where are they placed in the HP-UX file system hierarchy?

A:

The spool files are temporary files waiting for processing by some application. For example, the print spool files are waiting for printing and the mail spool files are waiting for transmission to the destination. These files are kept in the /var/spool directory.

5:

What are device files and how are they arranged?

A:

Device files are used to access different devices attached to the system. These are places in the /dev directory.

6:

What is the relation between physical disks and the directory structure of HP-UX?

A:

There is no relation of physical disks to the HP-UX directory structure.

7:

What is the difference between the whereis and which commands?

A:

The whereis command locates source, binary, and manual pages for a program while the which command displays the path name for a program file.

Chapter 9: Working with the POSIX Shell and Job Control

1:

List two features that are present in the POSIX shell but not in the Bourne shell.

A:

history

line editing

file name completion

2:

What types of substitutions are used in the POSIX shell? What are their advantages?

A:

Tilde substitution is used to substitute a directory name in the command line.

Variable substitution is used to substitute the value of a variable in the command line.

Command substitution is used to substitute the output of a command in the ommand line.

3:

What is meant by job control?

A:

Job control is a process of managing jobs where a user is able to move jobs from the foreground to background and vice versa.

4:

What are the differences between foreground and background jobs?

A:

The background job gives the command prompt back to the user so that another command may be issued. The foreground job does not give the command prompt back until these are finished

Chapter 10: Introduction to Shell Programming

1:

What problem may arise if you don't provide the shell name inside a program?

A:

A program may be executed by a wrong shell. Since every shell has different control structures, the execution may not be successful.

2:

Is it necessary to make a file containing a shell program executable?

A:

A shell program may be executed by spawning a subshell without making a shell program executable. For example, a shell program prog may be executed as follows .

 $ /usr/bin/sh prog 
3:

Create a shell program that reads three command line arguments and then prints these in reverse order.

A:

There may be multiple ways to write such a script. One of the choices is shown below.

 #!/usr/bin/sh echo  echo  echo 
4:

What is the importance of exit codes?

A:

The exit codes are used to verify if a program executed successfully.

5:

Write a shell program that uses the test command in explicit mode to check if the first and second command line arguments have the same value.

A:

[Return to question 5.]

 #!/usr/bin/sh if test  -eq  then    echo "The arguments are equal" else    echo "The arguments are NOT equal" fi 
6:

What is the major difference between the if and case structures?

A:

The if structure is used to make a choice between two options while the case structure makes a choice among several options.

Chapter 11: Advanced Shell Programming

1:

What is the difference between the test and let commands?

A:

The test command performs logic operations. The let command is used to perform both arithmetic and logic operations.

2:

Explain the unary and binary negative signs.

A:

The binary negative sign is used for subtraction. The unary negative sign is used for negation.

3:

Consider the following program. What may be the possible problem?

 VAR=1 (($VAR=$VAR+1)) while [ $VAR -lt 10 ] do    echo $VAR done 
A:

The loop variable is not incremented inside the loop resulting in an infinite loop.


   
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