Unix Test02 All quizzes

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Inside a Bourne shell script, you can access the PID of the script with the following environment variable

$# $! $$ $* $&

Under Bourne shell, the values of all of the command line arguments are passed to a shell script in the following shell variable

$* $#argv $# $$ $!

[Process2] By convention, UNIX System shells associate the file descriptor __ with the standard input of a process.

0 1 2 3 -1

[Process2] Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. if (pid=fork()) {fork();} if (pid=fork()) {fork();} if (pid=fork()) {fork();}

8 9 16 27 32

The following command sends a signal to the foreground process

<Ctrl-C> <Ctrl-D> <Ctrl-S> <Ctrl-A> <Ctrl-F>

The following command increments the value of a Bourne shell variable, sum, by one

@ sum++ sum=`expr $sum + 1` sum += 1 sum=sum + 1 sum=sum++

[APUE01] ___ is a command-line interpreter that reads user input and executes commands.

A console A script A shell A terminal An IDE

[APUE01] An executing instance of a program is called _____, a term used on almost every page of this text. Some operating systems use the term task to refer to a program that is being executed.

A process A program A thread A socket A shell

[APUE01] ___ is an executable file residing on disk in a directory. ____ is read into memory and is executed by the kernel as a result of one of the seven exec functions.

A process A program A thread A socket A shell

[Shell] If your search path does not include the path to a particular shell, and you try to run that shell by typing its name on the command line, what happens?

All shells run simultaneously, so you will be successful. You will get an error message. Your shell prompt will change. Your protection from spam will be decreased. You will get a suggestion to add the shell path.

Under Bourne shell, the following command will do ___ echo `who | more`

Display output of the "who | more" command Displays the text "who | more" Is illegal Is unpredictable Display an error message

[APUE03] With File "lseek" call, which one of the following statements is not correct?

Every open file has an associated "current file offset" Current file offset of an opened file is normally a non-negative integer that measures the number of bytes from the beginning of the file. Read and write operations normally start at the current file offset and cause the offset to be incremented by the number of bytes read or written. By default, this "current file offset" is initialized to 0 when a file is opened, unless the O_APPEND option is specified. The "current file offset" is initialized to 0 and the next write pointer is set to the end of the file if the O_APPEND option is specified.

. (a dot symbol)

Matching any single character.

[APUE03] With File "open" call, this option ____ creates the file if it doesn't exist.

O_CREAT O_CREATE O_CRONLY O_CRT O_CREATEONLY

[Proc1] This signal is generated by the terminal driver when we press the interrupt key (often DELETE or Control-C).

SIGINT SIGJVM1 SIGTSTP SIGUSER1 SIGCNTLC

[Process2] What would be a proper way to set a signal handler (sig_int) for SIGINT?

SIGINT(sig_int); sigint(SIGINT); SIGINT(signal, sig_int); signal(SIGINT, sig_int); signal(sig_int, SIGINT);

[APUE01] _____ developed by Steve ____ at Bell Labs, has been in use since Version 7 and is provided with almost every UNIX system in existence. The control-flow constructs of this shell are reminiscent of Algol 68.

The Bourne shell The C shell The Korn shell The Bourne-again shell The TENEX C shell

[APUE03] Which one of the following choices is NOT correct about v-node.

The v-node was invented to provide support for multiple file system types on a single computer system. The (v-node) work was done independently by Peter Weinberger (Bell Laboratories) and Bill Joy (Sun Microsystems). Sun called this work (v-node) the Virtual File System and called the file system-independent portion of the i-node the v-node [Kleiman 1986]. The v-node propagated through various vendor implementations as support for Sun's Network File System (NFS) was added. The first release from Berkeley to provide v-nodes was the 4.3BSD Reno release, when NFS was added. In SVR4, the v-node replaced the file system-independent i-node of SVR3. Solaris is derived from SVR4 and, therefore, uses i-nodes only. Instead of splitting the data structures into a v-node and an i-node, Linux uses a file system-independent i-node and a file system-dependent i-node.

[APUE03] For file IO with buffering, consider the following statistics for a benchmark. The file was read using the program here with standard output redirected to /dev/null. The file system used for this test was the Linux ext4 file system with 4,096-byte blocks. Which one of the following statements is NOT correct?

This accounts for the minimum in the system time occurring at the few timing measurements starting around a BUFFSIZE of 4,096. Increasing the buffer size beyond this limit of a BUFFSIZE of 4096 has little positive effect. Most file systems support some kind of read-ahead to improve performance. When sequential reads are detected, the system tries to read in more data than an application requests, assuming that the application will read it shortly. The effect of read-ahead can be seen here, where the elapsed time for buffer sizes as small as 32 bytes is as good as the elapsed time for larger buffer sizes. Bigger the buffer size means better in performance evidenced in this statistics.

A\{4,\}B

To match AAAAB or AAAAAAAB, but not AAAB

A\{2\}B

To match AAB

A\{2,4\}B

To match AAB, AAAB, AAAAB

[.*0]

To match anything before or after the 0

[^.*$]

To match anything in line

[0-9]\{2\}-[0-9]\{2\}-[0-9]\{4\}

To match date in format of dd-mm-yyyy

^d..x..x..x

To match directory listings with "execute" set for user, group and other

[0-9]\{3\}\.[0-9]\{3\}\.[0-9]\{3\}\.[0-9]\{3\}

To match ip address in format of nnn.nnn.nnn.nnn

^.$

To match lines with only one character

[a-z][a-z]*

To match string with at least one lower case letter

[^0-9\$]

To match string without a number or dollar sign

[0][0][0]*

To match three or more zeros

[APUE04] Which one of the following statements is NOT correct? Consider the file and/or directory access, and chmod command.

To open the file /usr/include/stdio.h, we need execute permission in the directory /, execute permission in the directory /usr, and execute permission in the directory /usr/include. If the current directory is /usr/include, then we need execute permission in the current directory to open the file stdio.h. Read permission lets us read the directory, obtaining and searching through a list of all the filenames in the directory. Execute permission lets us pass through the directory when it is a component of a pathname that we are trying to access (in order to search the directory to look for a specific filename). If the PATH environment variable specifies a directory that does not have execute permission enabled, the shell will never find executable files in that directory.

The ENV shell environment variable changes what?

Which shell you are running. The name of the system mailbox file. The path along which UNIX looks to find configuration files. The name of the current working directory. To set ENV path.

[APUE01] Every process has a ____ directory. This is the directory from which all relative pathnames are interpreted. A process can change its ___ directory with the chdir function.

absolute home relative root working

The following command can be used to copy the sample file into the example file and preserve file attributes such as onwer ID, group ID, and modification times:

cp sample example cp -f sample example cp -p sample example cp -a sample example cp -af sample example

The command to display lines in the sample file that do not contain strings John or Jake is

grep -n "John|Jake" sample grep -v "John|Jake" sample grep -l "John|Jake" sample grep -u "John|Jake" sample grep -o "John|Jake" sample

[Sobell-process] _____ lowers the priority, whereas _____ raises the priority with nice utility.

value greater than or equal to 20, value less than 20 value greater than 20, value less than or equal to 20 value greater than 10, value less than 10 positive value, negative value negative value, positive value

[Process2] After fork, the return value for the parent process is ___

-1 0 +1 the child process id the process id of the parent process

[Process2] After fork, the return value for the child is ___

-1 0 +1 a new process ID for the child process the process id of the parent process

[Sobell-process] Priorities (of processes) range from ____ (the highest priority) to ____ (the lowest priority).

-10 to 10 -20 to 19 -100 to 100 0 to 20 0 to 50

[Sobell-process] This option of nice utility changes the priority by the increment (or decrement) specified by value.

-a value -c value -n value -p value -v value

[Sobell-process] This option of ps utility produces a long listing showing more information about each process.

-b -c -d -e -f -l

Sobell-process] This option of top utility runs top in secure mode, restricting the commands you can use while top is running to those that pose less of a security risk.

-d -i -n -p -S -s

[Sobell-process] This option of top utility causes top to run in cumulative mode. In cumulative mode, the CPU times reported for processes include forked processes and CPU times accumulated by child processes that are now dead.

-d -i -n -p -S -s

[Sobell-process] This option of top utility monitors the process with a PID of n. You can use this option up to 20 times on a command line or specify n as a comma-separated list of up to 20 PID numbers.

-d n -i n -n n -p n -S n -s n

[Sobell-process] With renice utility, this option interprets the following arguments as process ID (PID) numbers (default).

-pid -i -id -p -u

[Sobell-process] With renice utility, this option interprets the following arguments as usernames or user ID numbers.

-uid -u -id -p -u

[APUE01] There is also a group file that maps group names into numeric group IDs. The group file is usually ____.

/etc/group /etc/passwd /etc/userid /etc/host /etc/usergroup

[APUE01] The system then looks up our login name in its password file, usually the file ____.

/etc/passwd /system/password /admin/pass /usr/bin/pwfile /sbin/passwd

[Proc1] After fork, the return value in the child is ___

0 1 -1 process id of the parent process id of the child

[Process2] By convention, all shells in Unix open ___ file descriptors whenever a new program is run.

0 1 2 3 4 as many as needed

[Proc1] By convention, UNIX System shells associate file descriptor __ with the standard input of a process.

0 (zero) 1 (one) 2 (two) 3 (three) None of the above

[Korn08] PID of init process is ___

1 2 -1 1000 depends on each startup

[Process2] Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. if (fork()) fork();

1 2 3 4 0

[Process2] Given fork program as shown below, what would be the total number of processes at the end including the process running this program. for (i=1; i < nprocs; i++) { childpid = fork(); } When nprocs = 3, then the total number of processes after this code will be ____

1 2 4 8 16

[Process2] Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. fork(); fork(); fork();

1 4 6 8 16

[Process2] Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. if (fork() < 0) {fork();}

1 2 3 4 0

[Process2] Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. if (pid=fork() && pid2 = fork()) {fork();} if (pid=fork() && pid2 = fork()) {fork();} if (pid=fork() && pid2 = fork()) {fork();}

16 27 32 48 64

[APUE01] Which one of the following statements is NOT correct?

A directory is a file that contains directory entries. A directory could be any physical device which represents the hierarchical file system. Logically, each directory entry could be considered as containing a filename along with a structure of information describing the attributes of the file. The attributes of a file are such things as the type of file (regular file, directory), the size of the file, the owner of the file, permissions for the file (whether other users may access this file), and when the file was last modified. The stat and fstat functions return a structure of information containing all the attributes of a file.

[Shell] A hidden file is also called what?

A secret file A system file A private file A dot file A system file

Under Bourne shell, the environment variable PATH contains the absolute pathname of ____

A set of directory paths to be searched to locate an external command Your home directory Your current directory Your working directory Your shell default directory

* (an asterisk symbol)

A single character followed by an *, will match zero or more occurrences.

[APUE03] Which one of the following statements is NOT correct? Consider Unix file IO (e.g., read and write).

After each write is complete, the current file offset in the file table entry is incremented by the number of bytes written. If this causes the current file offset to exceed the current file size, the current file size in the i-node table entry is set to the current file offset (for example, the file is extended). If a file is opened with the O_APPEND flag, a corresponding flag is set in the file status flags of the file table entry. Each time a write is performed for a file with this append flag set, the current file offset in the file table entry is first set to the current file size from the i-node table entry. This forces every write to be appended to the current end of file. If a file is positioned to its current end of file using lseek, all that happens is the current file offset in the file table entry is set to the current file size from the i-node table entry. The lseek function modifies only the current file offset in the file table entry. It forces I/O take place.

[APUE01] Which of the following statements is not correct?

All operating systems provide service points through which programs request services from the kernel. All implementations of the UNIX System provide a well-defined, limited number of entry points directly into the kernel called system calls. Version 7 of the Research UNIX System provided about 50 system calls, 4.4BSD provided about 110, and SVR4 had around 120. More recent systems have seen incredible growth in the number of supported system calls. Linux 3.2.0 has 380 system calls and FreeBSD 8.0 has over 450. The system call interface has always been documented in Section 2 of the UNIX Programmer's Manual. The definition of each system call is in the C language, no matter which implementation technique is actually used on any given system to invoke a system call. With many recent operating systems, the kernel entry points are defined in the Java language.

[APUE03] Which one of the following statements is NOT correct?

By convention, UNIX System shells associate three file descriptors and their values are standardized by POSIX.1. In POSIX-compliant applications, file descriptor 0 is replaced with the symbolic constants STDERR_FILENO For the file-descriptor constants, these constants (e.g., STDIN_FILENO) are defined in the <unistd.h> header. File descriptors range from 0 through OPEN_MAX - 1. Early historical implementations of the UNIX System had an upper limit of 19, allowing a maximum of 20 open files per process, but many systems subsequently increased this limit to 63.

[APUE03] Which one of the following statements is NOT correct?

By convention, UNIX System shells associate file descriptor 0 with the standard input of a process. By convention, UNIX System shells associate file descriptor 1 with the standard output of a process. By convention, UNIX System shells associate file descriptor 2 with the standard error of a process. This convention of the designation of the file descriptors 0,1,2 (of a running process) is a standard and feature of the UNIX kernel. Many applications would break if these associations weren't followed.

[Sobell-process] Which one of the following choices is NOT one of the four columns of ps command normally displayed?

CMD PID TIME TTY USER

What is not an advantage or a feature of CVS?

CVS can handle group of files CVS can let two or more users concurrently change files CVS can be used over network CVS can manage well a complex distributed source control CVS is a source control system

[ ] (a square-bracket open-close symbol)

Character enclosed inside it will be matched. One can use the - to include a range inclusively.

[APUE01] Which of the following statements is not correct? The UNIX System maintains various time values for a process. One of them is ___.

Clock time Wall Clock time User CPU time System CPU time Signal Interrupt time

[Process2] The new file descriptor returned by dup is guaranteed to be the ___ numbered available file descriptor

Correct lowest highest fixed stack arbitrary

Under Bourne shell, the following command will do: name=John Doe

Creates a user-defined variable, called name, and initializes it to John Doe Creates a user-defined variables name and initializes it to John, and tries to execute Doe as a command and displays an error message Create a user-defined variable, called name, and initializes it to John and declares a string variable, called Doe Update a system variable, called name, to be set to John Results in an unpredictable result

[APUE01] Which of the following statements is not correct?

Historically, UNIX systems have maintained two different time values: Calendar time and Process time. Calendar time counts the number of seconds since the Epoch: 00:00:00 January 1, 1970, Coordinated Universal Time (UTC). Process time is called CPU time and measures the central processor resources used by a process. Process time is measured in clock ticks, which have historically been 50, 60, or 100 ticks per micro-second. The primitive system data type clock_t holds these various time values.

[APUE04] Which one of the following statements is NOT correct? Consider the file and/or directory access. The file access tests that the kernel performs each time a process opens, creates, or deletes a file depend on the owners of the file (st_uid and st_gid), the effective IDs of the process (effective user ID and effective group ID), and the supplementary group IDs of the process, if supported. The two owner IDs are properties of the file, whereas the two effective IDs and the supplementary group IDs are properties of the process. The tests performed by the kernel are as follows:

If the effective user ID of the process is 0 (the superuser), access is allowed. This gives the superuser free rein throughout the entire file system. If the effective user ID of the process equals the owner ID of the file (i.e., the process owns the file), access is allowed if the appropriate user access permission bit is set. Otherwise, permission is denied. If the process is executing the file, the user-execute bit must be on if the process group ID of the process equals the group ID of the file (i.e., the process group owns the file). If the effective group ID of the process or one of the supplementary group IDs of the process equals the group ID of the file, access is allowed if the appropriate group access permission bit is set. Otherwise, permission is denied. If the appropriate other access permission bit is set, access is allowed. Otherwise, permission is denied.

[APUE03] With "read" function, which one of the following statements is NOT correct?

If the read is successful, the number of bytes read is returned. If the end of file is encountered, 0 is returned. The number of bytes actually read is always same as the amount requested for a successful read. The read operation starts at the file's current offset. Before a successful return, the offset is incremented by the number of bytes actually read.

[APUE03] With "lseek" call options, which one of the following statements is NOT correct?

If whence is SEEK_SET, the file's offset is set to offset bytes from the beginning of the file. If whence is SEEK_CUR, the file's offset is set to its current value plus the offset. If whence is SEEK_END, the file's offset is set to the size of the file plus the offset. If whence is SEEK_NEXT, the file's offset is set to the size of the file plus the offset of the file's block size. Because a successful call to lseek returns the new file offset, one can seek zero bytes from the current position to determine the current offset.

On receiving a signal, a process can take the following action. Which one is not correct?

Ignore the signal Redirect the signal to another process Accept the default action as determined by the UNIX kernel Undo signal or return signal back to the sender Run its own signal handler

[Proc1] A process can do ___, for dealing with the signal.

Ignore the signal. Let the default action occur. Provide a function that is called when the signal occurs. All of the above None of the above

[APUE03] Which one of the following statements is NOT correct?

In general, the term atomic operation refers to an operation consisting of multiple steps where each step can be interruptible for an atomic signal. If the operation is performed atomically, either all the steps are performed (on success) or none are performed (on failure). If the operation is performed atomically, it must not be possible for only a subset of the steps to be performed. The Single UNIX Specification includes two functions (pread and pwrite) that allow applications to seek and perform I/O atomically. One case for a need of an atomic operation is when the file is created by one process between the two (open and creat) function calls, and if that other process writes something to the file, that data is erased when this creat is executed.

The ssh command ____

Invokes the Secure Shell client on your machine Allows you to do file transfer to a remote machine Allows you to block a remote machine Allows you to deny a log in request from a remote machine Allow you to send an email to a remote machine

The following code (note backquotes around the ls ... done command) echo `ls | more | while read file do ls $file done `

Is illegal Displays name of all the files (excluding hidden files) in your current directory Displays name of all the files (excluding hidden files) in your home directory Displays name of all the files (including hidden files) in your current directory Displays content of all the files (excluding hidden files) in your home directory

[APUE01] In Unix, The interface to the kernel is a layer of software called the ____ calls.

Library System Utility Driver Service

Under Bourne shell, the "export place" command ___

Makes a copy of the current value of the shell variable place available to the commands/scripts executed under the shell Initializes the shell variable place to New Haven Is illegal Is unpredictable Display an error message

[APUE04] Which one of the following statements is not correct? Consider umask.

Most users of UNIX systems never deal with their umask value. umask value is usually set once, on login, by the shell's start-up file, and never changed. Writing programs that create new files, if we want to ensure that specific access permission bits are enabled, we must modify the umask value while the process is running. To ensure that anyone can read a file, we should set the umask to 0777. The umask value that is in effect when our process is running can cause permission bits to be turned off.

The result of the following command is to ____ mv dir1/* dir2

Move all the files in the dir1 directory to the dir2 directory Move all the files in the dir1 directory without extensions to the dir2 directory Move all the files in the directory dir1, excluding directories, to the dir2 directory Move all the files in the dir2directory to the dir1 directory Copy all the files in the dir1 directory to the dir2 directory

[APUE03] With File "open" call, this option ____ generates an error if O_CREAT is also specified and the file already exists. This test for whether the file already exists and the creation of the file if it doesn't exist is an atomic operation.

O_EXISTS O_OPEN O_ERROR O_EXCL O_FILEEXISTS

[APUE03] With File "open" call: if path refers to a FIFO, a block special file, or a character special file, this option ___ sets the nonblocking mode for both the opening of the file and subsequent I/O.

O_NONBLOCK O_BLOCK O_FIFO O_RDONLY O_SETBLOCKOFF

[APUE03] With File "open" call, this option ____ generates an error if path doesn't refer to a directory.

O_PATH O_ERROR O_DIRECTORY O_DIR O_DIRNOTFOUND

[APUE03] Which one of the following statements is NOT correct? For file "open" function call, one of the constants for the options is ___.

O_RDONLY [open for reading only]. O_WRONLY [open for writing only]. O_APONLY [open for appending only]. O_RDWR [Open for reading and writing]. O_EXEC [Open for execute only].

[APUE03] Which one of the following statements is NOT correct? Consider the following figure.

One process has the file open on descriptor 3 and that the other process has that same file open on descriptor 4. Each process that opens the file gets its own file table entry Each process that opens the file gets only a single v-node table entry is required for a given file. One reason each process gets its own file table entry is so that each process has its own current offset for the file. One reason each process gets its own file table entry is so that each process can share its own current file IO status with the other.

[Proc1] Historically, a C program has been composed of the following pieces: Text segment, Initialized data segment, Uninitialized data segment, stack, and heap. Among them, ___ is consisting of the machine instructions (program) that the CPU executes.

Text segment Initialized data segment Uninitialized data segment stack heap

[Proc1] Historically, a C program has been composed of the following pieces: Text segment, Initialized data segment, Uninitialized data segment, stack, and heap. Among them, ___ is where automatic variables are stored, along with information that is saved each time a function is called (for example, the address of where to return to and certain information about the caller's environment, such as some of the machine registers).

Text segment Initialized data segment Uninitialized data segment stack heap

[Proc1] Historically, a C program has been composed of the following pieces: Text segment, Initialized data segment, Uninitialized data segment, stack, and heap. Among them, ____ is where dynamic memory allocation usually takes place.

Text segment Initialized data segment Uninitialized data segment stack heap

[APUE01] This shell _____ is considered a successor to the Bourne shell and was first provided with SVR4. This is developed by David ___ at Bell Labs, runs on most UNIX systems, but before SVR4 was usually an extra-cost add-on, so it is not as widespread as the other two shells. It is upward compatible with the Bourne shell and includes those features that made the C shell popular: job control, command-line editing, and so on.

The Bourne shell The C shell The Korn shell The Bourne-again shell The TENEX C shell

[APUE01] _____ is the GNU shell provided with all Linux systems. It was designed to be POSIX conformant, while still remaining compatible with the Bourne shell. It supports features from both the C shell and the Korn shell.

The Bourne shell The C shell The Korn shell The Bourne-again shell The TENEX C shell

[APUE03] Which one of the following statements is NOT correct?

The UNIX System supports the sharing of open files among different processes. The kernel uses three data structures to represent an open file, and the relationships among them determine the effect one process has on another with regard to file sharing. Every process has an entry in the process table maintained by the kernel. Within each process table entry is a table of open file descriptors Associated with each file descriptor are the file descriptor flags and a pointer to a file table entry, and inode.

[Shell] If you type echo $PATH on the Bourne shell command line, what is displayed?

The current setting of the PATH variable The name of the currently-running shell program The numeric value of the PATH variable The location of the currently-running shell in the file system structure. It will display: $PATH

[APUE01] Which of the following statements is not correct?

The fork returns the non-negative process ID of the new child process to the parent process The fork returns 0 to the child process. Because fork creates a new process, we say that it is called once—by the parent—but returns twice—in the parent and in the child. In the child process, one may call execlp to execute Unix or Linux command. The fork call replaces the child process with the new program file. The combination of fork followed by exec is called spawning a new process on some operating systems.

[APUE04] Which one of the following statements is NOT correct? Using mkdir command, testdir has been just created. Consider the figure below as a result.

The i-node whose number is 2549 has a type field of ''directory'' and a link count equal to 3. Any leaf directory (a directory that does not contain any other directories) always has a link count of 2. The value (the link count) of 2 for the i-node of 2549 comes from the directory entry that names the directory (testdir) and from the entry for dot in that directory. The i-node whose number is 1267 has a type field of ''directory'' and a link count that is greater than or equal to 3. Every subdirectory in a parent directory causes the parent directory's link count to be increased by 1.

[APUE03] Which one of the following statements is NOT correct? Consider the following dup and dup2 calls. #include <unistd.h> int dup(int fd); int dup2(int fd, int fd2);

The new file descriptor returned by dup is guaranteed to be the lowest-numbered available file descriptor. With dup2, one specifies the value of the new descriptor with the fd2 argument. With dup2, if fd2 is already open, it is first closed. With dup2, if fd2 is already open, it will generate FD_CLOEXEC to close the file and then open it. With dup2, if fd equals fd2, then dup2 returns fd2 without closing it.

[APUE04] Which one of the following statements is NOT correct? Consider the file and/or directory access.

The read permission for a file determines whether we can open an existing file for reading: the O_RDONLY and O_RDWR flags for the open function. The write permission for a file determines whether we can open an existing file for writing: the O_WRONLY and O_RDWR flags for the open function. We must have write permission for a file to specify the O_TRUNC flag in the open function. We cannot create a new file in a directory unless we have write permission and execute permission in the directory. To delete an existing file, we need only the write permission for the file itself. Execute permission for a file must be on if we want to execute the file using any of the seven exec functions. The file also has to be a regular file.

[APUE04] Every process has six or more IDs associated with it. Which one of the following statements is NOT correct?

The real user ID and the real group ID The effective user ID and the effective group ID The saved set-user-ID and the saved set-group-ID The virtual user ID and the virtual group ID The supplementary group ID

[APUE04] Every process has six or more IDs associated with it. ____ contain copies of the effective user ID and the effective group ID, respectively, when a program is executed.

The real user ID and the real group ID The effective user ID and the effective group ID The saved set-user-ID and the saved set-group-ID The virtual user ID and the virtual group ID The system user ID and the system group ID

[APUE04] Every process has six or more IDs associated with it. ____ identify who we really are. These two fields are taken from our entry in the password file when we log in. Normally, these values don't change during a login session, although there are ways for a superuser process to change them.

The real user ID and the real group ID The effective user ID and the effective group ID The saved set-user-ID and the saved set-group-ID The virtual user ID and the virtual group ID The system user ID and the system group ID

[APUE04] Every process has six or more IDs associated with it. Normally, the effective user ID and the effective group ID equals ____ respectively.

The real user ID and the real group ID The effective user ID and the effective group ID The saved set-user-ID and the saved set-group-ID The virtual user ID and the virtual group ID The system user ID and the system group ID

[APUE04] Every process has six or more IDs associated with it. The saved set-user-ID and saved set-group-ID contain copies of ___, respectively, when a program is executed.

The real user ID and the real group ID The effective user ID and the effective group ID The saved set-user-ID and the saved set-group-ID The virtual user ID and the virtual group ID The system user ID and the system group ID

[APUE04] Every process has six or more IDs associated with it. This ____ determines one's file access permissions.

The real user ID and the real group ID The effective user ID and the effective group ID The saved set-user-ID and the saved set-group-ID The virtual user ID and the virtual group ID The system user ID and the system group ID

[Process2] After fork, the differences between the parent and child are ____

The return values from fork The process IDs The different parent process IDs All of the above None of the above

[Proc1] After fork, the differences between the parent and child are ____

The return values from fork The process IDs The different parent process IDs all of the above none of the above

[APUE04] Which one of the following statements is NOT correct? Consider umask bits.

The umask value 0000 is to allow anyone to do read, write, or execute the files The umask value 0002 is to prevent others from writing the files The umask value 0022 is to prevent group members and others from writing the files The umask value 0027 is to prevent group members from writing your files and others from reading, writing, or executing the files. The umask value 0700 is to allow the user (owner) to read, write, or execute the files

^[^l]

To match all but to exclude directory listings of linked directories

[A-Za-z]*

To match all words

[A-Za-z]

To match any case of letter

[A-Za-z0-9]

To match any letter or number

[a-z]

To match any lower case letter

[^a-zA-Z]

To match any non-alpha character, while

[^0-9]

To match any non-numeric character.

[0-9]

To match any single number

[APUE03] Which one of the following statements is NOT correct?

To the kernel, all open files are referred to by file descriptors. A file descriptor is a non-negative integer. When one opens an existing file, the kernel returns a file descriptor to the process. For a new file, the kernel returns a file descriptor to the process after the file being created and opened first. The file descriptor is returned by creat as an argument to either read or write.

\ (a back-slash symbol)

Use this to escape the special meaning of a metacharacter.

{n}

Use this to match a specific number of occurrences specified by n that contains the preceding pattern

{n,}

Use this to match at 'least' n occurrence of the preceding pattern.

[APUE04] Which one of the following statements is NOT correct? Consider umask command.

Users can set the umask value to control the default permissions on the files they create. The umask value is expressed in octal, with one bit representing one permission to be masked off. With umask value, the permissions can be denied by setting the corresponding bits. The Single UNIX Specification requires that the umask command support a symbolic mode of operation. Like the octal format with umask command, the symbolic format specifies which permissions are to be denied (i.e., clear in the file creation mask) instead of which ones are to be denied (i.e., set in the file creation mask).

[APUE04] Which one of the following statements is NOT correct?

Using mkdir command, a directory ("testdir") has been just created under a directory. This will create two new links: one link pointing to "dot" directory entry and the other for "dot-dot" directory entry. Every i-node has a link count that contains the number of directory entries that point to it. Only when the link count of i-node goes to 0 can the file be deleted, thereby releasing the data blocks associated with the file. The operation of "unlinking a file" does not always mean "deleting the blocks associated with the file." The function which removes a directory entry is always called "delete."

[APUE04] Every process has six or more IDs associated with it. Which one of the following statements is NOT correct?

When one executes a program file, the effective user ID of the process is usually the virtual user ID, and the effective group ID is usually the virtual group ID. One can set a special flag in the file's mode word (st_mode) to say, ''When this file is executed, set the effective user ID of the process to be the owner of the file (st_uid).'' One can set another bit in the file's mode word that causes the effective group ID to be the group owner of the file (st_gid). These two bits (st_mode and st_uid) in the file's mode word are called the set-user-ID bit and the set-group-ID bit. If the owner of the file is the superuser and if the file's set-user-ID bit is set, then while that program file is running as a process, it has superuser privileges.

[APUE03] With "read" function, consider the cases for the number of bytes actually read is less than the amount requested. Which one of the following statements is NOT correct?

When reading from a regular file, if the end of file is reached before the requested number of bytes has been read. When reading from a terminal device. Normally, up to one line is read at a time. When reading from a network. Buffering within the network may cause less than the requested amount to be returned. When reading from a pipe or FIFO. If the pipe contains fewer bytes than requested, read will return only what is available. When reading from a record-oriented device. Some record-oriented devices, such as magnetic tape, can return up to a single record at a time. When reading a full data done but a signal may cause its partial data to be lost.

^ (a cap/caret symbol)

Will match the beginning of the line only.

$ (a dollar symbol)

Will match the end of the line only.

[APUE01] The UNIX file system is _____ arrangement of directories and files.

a hierarchical a network a relational a physical a conceptual

[Sobell-process] Only a user working with root privileges can specify a _____ value for a priority of nice utility.

a positive value a negative value a value greater than 10 a value greater than 20 a value greater than 50

[APUE01] When one logs in, the default directory is set to be one's ___ directory which is obtained from our entry in the password file.

absolute home relative root working

[APUE04] The ____ function sets the file mode creation mask for the process and returns the previous value.

access chmod mask mode umask

[Proc1] ___ allocates a specified number of bytes of memory. The initial value of the memory is indeterminate.

alloc malloc calloc noalloc free

[Proc1] ___ allocates space for a specified number of objects of a specified size. The space is initialized to all 0 bits.

alloc malloc calloc noalloc free

[Sobell-process] The ____ utility reports the priority of the shell or alters the priority of a command. An ordinary user can decrease the priority of a command, but only a user working with root privileges can increase the priority of a command.

alter nice priority ps chpri user

[Sobell-process] Without an option, this ____ utility defaults to an adjustment of 10, lowering the priority of the command by 10—typically from 0 to 10.

alter nice priority ps chpri user

[Korn08] Which command/tool is used for building and maintaining groups of programs from source code?

autotool make run compile gcc

[Proc1] In Unix/Linux a file ___ is normally small non-negative integer that the kernel uses to identify the files accessed by a process.

buffer information descriptor cabinet lock

[Process2] A file ___ is normally small non-negative integer that the kernel uses to identify the files accessed by a process.

buffer table descriptor i-node entry

[Sobell-process] The ____ utility alters the priority of a running process.

chps nice renice ps priority process

[Korn08] Which command is used to check out the files in RCS?

co -l ci -l get -f rlog check -file

[Shell] If you have any empty directory called ~/backups, you can copy directory ~/courses into it by using the following command:

cpdir ~/courses ~/backups cp -r ~/courses ~/backups cp -d ~/courses ~/backups cp -all ~/courses ~/backups cp -d ~/courses ~/backups

[Process2] The ____ contains all the information about the file: the file type, the file's access permission bits, the size of the file, pointers to the file's data blocks, and so on.

cylinder disk file block i-node dup

[APUE01] In Unix, it is easy to measure the clock time, user time, and system time of any process: simply execute the ___ command, with the argument for what we want to measure.

date time cputime ps pstime

[Process2] Signals provide a way of handling ___ events

deadlocked racing asynchronous synchronous idle-process

[Proc1] A disk drive is divided into one or more ____(s) where each ___ can contain a file system

disk partition cylinder directory i-node

[Proc1] The ____ contains all the information about the file: the file type, the file's access permission bits, the size of the file, pointers to the file's data blocks, and so on.

disk partition cylinder file block i-node

[Process2] If a process needs a child process to do some of its work, it will call ___ to make a copy of the current process.

dup clone thread fork dup

[Proc1] For a convenience, ___ call is used to execute a command string from within a program.

dup pipe socket thread system

[Shell] If the current value of the Bourne shell variable total is 10, the following command displays 100

echo `10 \* 10` echo `expr $total \* 10` echo `$total \* $total` output $total output `total`

[APUE01] The ___ character separates the filenames that form a pathname.

escape back-slash slash null special

[APUE01] For portability, POSIX.1 recommends restricting filenames to consist of the following characters: letters (a-z, A-Z), numbers (0-9), period (.), dash (-), and _____ character.

escape back-slash slash null underscore

[Proc1] With dup2(int fd, int fd2), specify the value of the new descriptor with the __ argument. If __ is already open, it is first closed.

fd fd2 dup process fork

[APUE01] ____ is normally small non-negative integer that the kernel uses to identify the file accessed by a process. Whenever it opens an existing file or creates a new file, the kernel returns ____ that we use when we want to read or write the file.

file flag file descriptor file table accessor i-node pointer v-node pointer

[Korn08] Process attributes are stored in ___

file table list table process table function table kernel table

[Korn08] ps fetches attributes from ___

file table list table process table function table kernel table

[APUE04] Which one of the following statements is not correct? The stat function returns ___ of the following file information.

file type & mode (permissions) i-node number (serial number) v-node number number of links user ID of owner size in bytes, for regular files time of last access time of last modification

The following command can be used to display information about the user (john) on the utdallas.edu host

finger [email protected] rwho [email protected] info [email protected] search [email protected] display [email protected]

[Proc1] When a process calls one of the ____ functions, that process is completely replaced by the new program, and the new program starts executing at its main function. It merely replaces the current process—its text, data, heap, and stack segments—with a brand-new program from disk.

fork exec dup or dup2 pipe socket

[Proc1] After creating a(n) ____, the process typically spawns a new process (for the child inherits open file descriptors).

fork thread socket pipe lock

[Process2] When a process calls this API call (or one of these API calls), that process is completely replaced by the new program, and the new program starts executing at its main function. It merely replaces the current process its text, data, heap, and stack segments with a brand-new program from disk.

fork exec pipe dup system

[Korn08] Which is NOT a version control tool used in UNIX?

git RCS CVS cygwin SVN

[Sobell-process] While top is running, you can issue the following commands to modify its behavior. This ___ displays a summary of the commands you can use while top is running.

h k n q r S s

[Sobell-process] While top is running, you can issue the following commands to modify its behavior. This ____ changes the priority of a running process. Unless you are working with root privileges, you can change the priority of only your own processes and only to lower the priority by entering a positive value. A user working with root privileges can enter a negative value, increasing the priority of the process.

h k n q r S s

[Sobell-process] While top is running, you can issue the following commands to modify its behavior. This ____ prompts for the number of seconds to delay between updates to the display (3 is the default). You may enter an integer, a fraction, or 0 (for continuous updates). Under Linux, this command is disabled when you are working in secure mode.

h k n q r S s

[Sobell-process] While top is running, you can issue the following commands to modify its behavior. When you give this ____, top asks you to enter the number of processes you want it to display. If you enter 0 (the default), top shows as many processes as fit on the screen.

h k n q r S s

[Process2] This instruction ___ takes two (file descriptor) arguments, to duplicate the first one (file descriptor) to be set for the second one.

hidden dup dup2 fd pipe

[APUE03] Which one of the following statements is correct? The following figure shows ____.

how a process can have a file opened with two file descriptors how two processes can share a file how a process maintains two entries in the file table how two file descriptors of a process can be integrated in v-node table virtually how two v-nodes can be shared by one process

[APUE03] Which one of the following choices is NOT correct about i-node.

i-node contains the owner of the file i-node contains the size of the file i-node contains the pointers to where the actual data blocks for the file are located on disk Unix does not have v-node. Instead, a generic i-node structure is used. Although the implementations differ, the v-node is conceptually the same as a generic i-node.

[Process2] A process may do ___ with the signal

ignore the signal let the default action occur provide a function to handle the signal all of the above none of the above

[Korn08] Which command is used to update the files in CVS?

init update commit add finalize

[Sobell-process] The ____ utility sends a signal to one or more processes. Typically this signal terminates the processes.

kill ps send signal system terminate

[Sobell-process] To terminate all processes that the current login process initiated and have the operating system log you out, give the command _____

kill -all kill -pid kill -p all kill -9 0 kill -0

[Proc1] The new file descriptor returned by dup is guaranteed to be the ___ numbered available file descriptor.

lowest- highest- fixed- arbitrary- stack-

[APUE03] With "lseek" call, which one of the following statements is NOT correct?

lseek only records the current file offset within the kernel lseek does not cause any I/O to take place. The current file offset after the lseek call can be then used by the next read or write operation. The file's offset can be greater than the file's current size, in which case the next write to the file will extend the file. Using the file's offset greater than the file's current size, one can create a hole in a file and is not allowed as a legal file operation.

Under Bourne shell, the following command creates a user-defined shell variable, called name, and initializes it to John Doe.

name John Doe name "John Doe" name="John Doe" name=John doe $name="John Doe"

[Process2] The new process created by fork is called the child process. This function is called once but returns ___.

none once twice three times as many as needed

[Proc1] The new process created by fork is called the child process. This function is called once but returns ___.

none once twice three times none of the above

[APUE01] In the root directory, dot-dot is the same as ____

null /bin/null file-system dot the previous directory

[APUE03] Most file I/O on a UNIX system can be performed using only five functions. Which one of the following is NOT correct?

open read write seek close

[Proc1] A(n) ___ has only one thread of control—one set of machine instructions executing at a time.

pipe process program signal socket

[APUE03] Which one of the following statements is NOT correct? With FreeBSD 8.0, Linux 3.2.0, Mac OS X 10.6.8, and Solaris 10, the limit of the maximum number of file descriptors is ___.

possibly essentially infinite bounded by the amount of memory on the system bounded by the size of an integer bounded by any hard and soft limits configured by the system administrator. incremented by the multiples of file block size

[Sobell-process] The ___ utility displays status information about processes running on the local system.

pr process ps task status

[Korn08] The priority of a running process can be changed using ____.

priority renice priority cannot be changed for a running process only superuser can change the priority ps

[Sobell-process] The ____ utility dynamically displays information about the status of the local system, including information about current processes.

process ps showps status syslog top

[Sobell-process] The first line of ____ utility is the same as the output of the uptime utility and shows the current time, the amount of time the local system has been running since it was last booted, the number of users logged in, and the load averages from the last 1, 5, and 15 minutes.

process ps showps status syslog top

[Sobell-process] The following screenshot shows the result of ____ utility.

process ps showps status syslog top

[Proc1] A ____ is an executable file residing on disk in a directory

process thread pipe socket program

[Proc1] All ___ within a process share the same address space, file descriptors, stacks, and process-related attributes.

processes threads pipes sockets semaphores

Under Bourne shell, you can use the following command to read a line from stdin into a variable called word

read word set word = `head -1` @word=`head -1` input word echo word < stdin

[APUE01] ___ refers to the current directory.

root home directory . (called dot) .. (called dot-dot) .profile

[APUE01] This filename is automatically created whenever a new directory is created.

root home directory . (called dot) hidden file .profile

[Proc1] What would be a proper way to set a signal handler (sig_int) for SIGINT?

signal(SIGINT, sig_int); signal(sig_int, SIGINT); sig_int(SIGINT); SIGINT(sig_int); SIGINT(signal, sig_int);

[Process2] ___ is a type of file that points to another file.

symbolic link directory file FIFO pipe dupe

[Proc1] Signals provide a way of handling ___ events

synchronous asynchronous deadlocked all of the above none of the above

[APUE01] In Unix file system, everything starts in the directory called ____, whose name is the single character /.

system root superdirectory partition home directory

[APUE04] The directories /tmp and /var/tmp are typical candidates for ___. These are directories in which any user can typically create files. The permissions for these two directories are often read, write, and execute for everyone (user, group, and other). But users should not be able to delete or rename files owned by others.

the directory access bit the user write bit the user execute bit the sticky bit the special bit

[APUE04] On contemporary systems, the use of ___ has been extended. The Single UNIX Specification allows this bit to be set for a directory. If this is set for a directory, a file in the directory can be removed or renamed only if the user has write permission for the directory and meets one of the following criteria: (a) Owns the file, (b) Owns the directory, and (c) Is the superuser.

the directory access bit the user write bit the user execute bit the sticky bit the special bit

The directory names stored in the PATH variable form what is known as

the environment. the search path. the path of least resistance. the metacharacter. the default home directory

[APUE03] Which one of the following statements is NOT correct? The kernel maintains a file table for all open files of which each file table entry contains _____.

the file status flags for the file, such as read, write, append, sync, and nonblocking. the current file offset a pointer to the v-node table entry for the file a file descriptor

[Process2] For a convenience, ___ call is used to execute a command string (e.g., "ls -la | wc") within a program.

thread process pipe fork system

^$

to match blank line

[Korn08] A Command to get the version or release of your operating system is ____

uname -k uname -v uname -r uname -n uname -l

Under Bourne shell, you can unset a shell variable by using the following command

unsetenv unset@ unset undo set -undo

[Sobell-process] Consider the priority of a running process. Which one of the following choices is NOT correct?

use nice to set the priority of a running process. use renice to change the priority of a running process. B. use top's r command to change the priority of a running process. Lower values mean that the kernel schedules a job less often. Priority is ranging from -20 to 19. with root privileges a job is to run at the highest priority.

[Proc1] By convention, all shells in Unix open ___ descriptors whenever a new program is run.

zero one two three many


संबंधित स्टडी सेट्स

UCF Dr. Dow Anatomy Exam 3 study guide

View Set

Chapter 71: Caring for Clients with Chemical Dependence

View Set

Medical Words Grammar Explanation: Commands - Correct Pronoun Placement

View Set

Chapter 1- Learning objective two + three

View Set

compound and complex sentences, sentence types, subjects and predicates

View Set

Menuju Skripsi - Istilah Pendidikan

View Set