3337 Exam2

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

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

0

[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()

3

What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '[0-9][0-5][0-6]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

4

[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 ____

4

Sets the user ID when the program is executed

4000

[Korn08] How many times printf() is executed in the following program code? main() { for (int i=0;i<3;i++) fork(); printf("pid= %d\n",getpid()); }

8

[Sobell1-4] The file "assign4.html" has permissions set as: "r w x r w x r w x". This means that:

Everyone can read, write, and execute the file.

[Sobell1-4] (T/F) The command "grep -i hello" prints all the lines in file, not containing the string "hello".

False

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

O_CREAT

[APUE] Pressing Ctrl-C generate the signal ____.

SIGINT

[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.

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.

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the command "chmod og+rx abc", the file abc executable and readable by all.

True

[Sobell1-4] (T/F) The command "grep hello file" prints all lines in "file" that contains hello.

True

Make the file executable only if it is a directory

X

[Korn08] Mark one (of the choices below) which is not a help facility.

about

[Sobell1-4] Make a copy of file "upper" in the directory two levels up.

cp upper ../..

[Sobell] This creates an archive, restores files from an archive, or copies a directory hierarchy.

cpio

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

cygwin

[Sobell] This displays the classification of a file

file

[Sobell] This searches for a pattern in files

grep

[Sobell1-4] What is the command to search all files in your current directory for the word "hello"?

grep hello *

[Sobell] Use This as a last resort to destroy any jobs or programs that you suspended and are unable to restart.

kill

[APUE07] This ___ command displays library dependencies.

ldd

[Sobell] This will move a file.

mv

[Sobell] ___Renames or moves a file

mv

[Sobell] This displays information about programs (i.e., processes) that are currently running.

ps

Sets the sticky bit

t

[Sobell1-4] The figure below shows a sample of a passwd file. The field #3 is _____. oracle:x:1021:1020:Oracle user:/data/network/oracle:bin/bash

user identifier

Sets write permission

w

[Sobell] If you use this, you also get a list of what they are doing.

w

[Sobell] With ls command, use this option to list all the "dot" files (configuration files that begin with a period, such as .login or .profile).

-a

[Unix&Shell1] This "find" command option will go and look at all the files first before hitting any of the directories or sub-directories.

-depth

[Sobell1-4] The figure below shows a sample of ____ file. oracle:x:1021:1020:Oracle user:/data/network/oracle:bin/bash

/etc/passwd

[Sobell1-4] Which of the following represents an absolute path?

/usr/bin/cat

Only Others can execute the file

0001

Only Others can write the file

0002

Only Others can read the file

0004

Only Group can execute the file

0010

Only Group can write the file

0020

Only Group can read the file

0040

Only Owner can execute the file

0100

Only Owner can write to the file

0200

Only Owner can read the file

0400

[Sobell] With this option of chmod command, Owner can read, write, and execute the file; group and other can execute the file.

0711

Sticky bit

1000

Consider the following program code. How many times will it output "Hello"? main() { fork( ); fork( ); fork( ); fork( ); printf("Hello"); }

16

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

2

Sets the group ID when the program is executed

2000

[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();}

27

What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '48[34]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

3

[APUE] Which one of the following statements is NOT correct for Process File Descriptors and Kernel's File Table? The File Descriptor Table can be thought of as an array of pointers indexed by the file descriptors. A File Descriptor entry of a process is an array of file attributes The pointers in the File Descriptor Table point to entries in the File Table, which is in the kernel area. An entry in the File Table contains a pointer to a Vnode Table The in-memory Vnode Table contains copies of the inodes that are being used.

A File Descriptor entry of a process is an array of file attributes

* (an asterisk symbol)

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

[APUE07] Which one of the following statements is NOT correct? The virtual address space for a process is the set of virtual memory addresses that a process can use. The virtual address space for each process is private and cannot be accessed by other processes. A virtual address does not represent the actual physical location of an object in memory. A virtual address space is also called a physical address. A virtual address space always starts from address 0 for each process. The system maintains a page table for each process A page table for each process is an internal data structure used to translate virtual addresses into their corresponding physical addresses

A virtual address space is also called a physical address.

[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.

Associated with each file descriptor are the file descriptor flags and a pointer to a file table entry, and inode.

[Korn08] This points out the one which is not a section of "man" page.

BRIEF

[Korn08] 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

CVS can manage well a complex distributed source control

[APUE] Which one of the following items is NOT provided as a standard Unix or Linux IPC means? pipe UNIX domain sockets Semaphore Message queues Cloud

Cloud

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the command "chmod o+x abc", the file "abc" is executable by group.

False

[Sobell1-4] (T/F) The command pwd is normally used to change the password.

False

[Sobell1-4] The command history prints ALL the commands you typed.

False

[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.

In general, the term atomic operation refers to an operation consisting of multiple steps where each step can be interruptible for an atomic signal.

[APUE07] Which one of the following statements is correct for Data Segment?

It contains the global variables that are initialized by the programmer, and has a fixed size, but is not read-only

[APUE07] Which one of the following statements is correct for Text(Code) Segment?

It is the portion of the virtual address space that contains executable instructions.

[Korn08] If a program executing in background attempts to read from the default STDIN (that is, keyboard), then ____

Its execution will be suspended.

. (a dot symbol)

Matching any single character.

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

O_DIRECTORY

[Korn08] What is the output of the below code? void exit_handler1(); void exit_handler2(); int main() { int pid; atexit(exit_handler1); atexit(exit_handler2); pid = fork(); if(pid == 0) { _exit(0); } else { sleep(2); exit(0); } return 0; }

Only parent executes the exit_handler1 and exit_handler2.

[Sobell1-4] Which of these expressions shows the proper way to add the directory /usr/bin to your path?

PATH=$PATH:/usr/bin

[Korn08] Which mode of the gdb debugger ascertains the cause of the crash by examining the core files?

Post-mortem mode

[Korn08] Which of the following signals cannot be handled or ignored?

SIGKILL

[Korn08] Default action of SIGSEGV is _____

Start Core dump

[Korn08] Which of the following values for STAT (status) column of ps command is NOT correct?

Status E means exited

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

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.

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. The result of the following command "chmod og+rx abc" is equivalent to the command "chmod 755 abc"

True

[Sobell1-4] (T/F) The command "ls" lists the contents of a directory.

True

[Sobell1-4] (T/F) UNIX supports a hierarchical directory structure.

True

[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.

Unix does not have v-node. Instead, a generic i-node structure is used.

[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.

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.

[APUE] System calls using signals. ____ causes the system to generate a SIGALRM signal for the process after the specified number of real-time seconds have elapsed

alarm call

[Korn08] Which command option (of ar command) is used to add a file to the library?

ar -r

[Process2] Signals provide a way of handling ___ events

asynchronous

[Sobell1-4] Which of the following is not a UNIX file type?

batch file

[Sobell] This will print a calendar for a specified month and/or year.

cal

[Sobell] This outputs the contents of a text file. You can use it to read brief files or to concatenate files together.

cat

[Sobell1-4] Which command will print the contents of all files in the current directory whose names start with the character "a" and end with a period (".") followed by any two characters followed by a number?

cat a*.??[0-9]

[Sobell] This selects characters or fields from input lines and writes them to standard output.

cut

[Sobell] This displays the current day, date, time, and year.

date

[Korn08] To show only the current month-name is: ____

date +%h

[Sobell] This reports file system disk usage (i.e., the amount of space taken up on mounted file systems).

df

[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.

exec

[Sobell] This (utility) evaluates an expression and sends the result to standard output.

expr

[Sobell] This is most commonly used to find all of the files that have a certain name.

find

[Unix&Shell1] _____ is a very powerful tool and command, searching through the system or just current directory, locating all or certain files or directories.

find

[Unix&Shell1] This ___ is to find all '*.txt' files in the current directory you are in and any sub-directories,

find . -name "*.txt" -print

[Unix&Shell1] This is ___ to find files with a permission of ____ which is "read, write and executable" by owner and "read and execute" by everyone else.

find . -perm 755 -print

[Unix&Shell1] To find files that are over 10 blocks in length (that's 512 bytes a block) use:

find . -size +10 -print

[Unix&Shell1] To find files that are over 10 bytes in length using the character format use:

find . -size +10c -print

[Unix&Shell1] To find files in /var/adm directory that have not been modified in the last five days:

find / -mtime +5 -print

[Unix&Shell1] This find command does find first for all 'passwd*' files, for example passwd, passswd.old, passwd.bak, then runs grep to see if there is a user 'richard' located in the files.

find /etc -name "passwd*" -exec grep "richard" {} \;

[Unix&Shell1] To find all directories in /etc

find /etc -type d -print

[Unix&Shell1] To find all symbolic linked files in /etc:

find /etc -type l -print

[Sobell] The ___ utility compresses files, the ___ utility restores files compressed with gzip, and the ___ utility displays files compressed with this utility.

gzip, gunzip, zcat

[Sobell] This displays the beginning of a file

head

[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

incremented by the multiples of file block size

[Korn08] A user issues the following command sequence: $ a.out & $ bash $ a.out & If the user kills the bash process, then which of the following is true?

init process becomes parent of second a.out process

[Sobell] This displays text files, one screen at a time

less

[Sobell] This lets you read text without it scrolling quickly off your screen.

less

[Sobell] This makes a link to a file

ln

[Sobell] This sends files to printers

lpr

[Unix&Shell2] To list filenames where the first two characters can be any character, followed by an 'R', followed by any string:

ls ??R*

[Unix&Shell2] To match filenames that start with 'CPP', followed by any two characters, followed by any non-digit string:

ls CPP??[!0-9]*

[Unix&Shell2] To match filenames that start with 'CPP', where the next two characters can be anything, but the next character must be a '1':

ls CPP??[1]

[Unix&Shell2] To match only numbered filenames use:

ls [0-9]*

[Sobell] ___ Changes the priority of a command

nice

[Sobell] ___ Numbers lines from a file

nl

[APUE07] This command displays Symbols in a given file (a binary executable).

nm

[Sobell] ___ Runs a command that keeps running after you log out

nohup

Sets the specified permissions to those of others

o

[Sobell] ___ Dumps the contents of a file

od

[Sobell] ___ Opens files, directories, and URLs

open

[Korn08] A Command used for changing user password is ____.

passwd

[Sobell] ___ Joins corresponding lines from files

paste

[APUE] System calls use signals. ____ suspends the calling process until it receives a signal.

pause call

[Korn08] Process attributes are stored in ___

process table

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

renice

[Sobell] ___ Changes the priority of a process

renice

[Sobell] This will remove (delete) a file.

rm

[Sobell] ___ Removes a file (deletes a link)

rm

[Sobell1-4] To delete a file called mynotes.txt, which command do you use?

rm -i mynotes.txt

Set the user ID or group ID of the file while the file is being executed

s

[Sobell] ___ Securely copies one or more files to or from a remote system

scp

[Korn08] A Command to record your session is ____.

script

[Sobell] ___ Edits a file noninteractively

sed

[Sobell] This displays or changes various settings and options associated with your Unix session.

set

[Sobell1-4] The figure below shows a sample of a passwd file. The field #7 is _____. oracle:x:1021:1020:Oracle user:/data/network/oracle:bin/bash

shell

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

signal(SIGINT, sig_int);

[APUE07] This ___ command displays the size of these sections in an executable file.

size

[Sobell] ___ Creates a process that sleeps for a specified interval

sleep

[Sobell] ___ Sorts and/or merges files

sort

[Sobell] ____ Divides a file into sections

split

[Sobell] ___ Securely runs a program or opens a shell on a remote system

ssh

[Korn08] Which command in debugger is used to execute the next statement but descends into a function?

step

[Sobell] ___ Displays or sets terminal parameters

stty

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

system

[Sobell] ___ Displays the last part (tail) of a file

tail

[Sobell] ___ Stores or retrieves files to/from an archive file

tar

[Sobell] ___ Copies standard input to standard output and one or more files

tee

[Sobell] ___ Check file types and compare values

test

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

the child process id

[Unix&Shell1] The -follow option with find command is ____.

to chase down the source of the files for symbolic linked files

[Sobell] If you use this, you also get the IP numbers or computer names of the terminals they are using.

who

[Sobell] ___ Displays information about logged-in users

who

[Korn08] A Command to get your userid is ____.

who am i

[Sobell] With this option of chmod command, Owner can read, and write the file; group can read the file, and other cannot access the file.

0640

[Sobell] With this option of chmod command, Owner can read, and write the file; group and other can read the file.

0644

[Sobell] With this option of chmod command, Owner can read, write, and execute the file; group and other can read and execute the file.

0755

[Sobell] With this option of chmod command, Owner, group, and others can read, write, and execute the file.

0777

[Korn08] PID of init process is ___

1

[Unix&Shell4grep] What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '^[0-9][0-5][0-6]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

1

What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '[Ss]ept' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

2

[Unix&Shell4grep] What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '^[^48]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

2

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

3

[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();

8

[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?

Bigger the buffer size means better in performance evidenced in this statistics.

[Sobell1-4] What will the following command do? chmod og+r *.jpg

Change the permissions on any file ending with .jpg to be readable by all others

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

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

[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.

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.

[APUE] Consider the pipe for the commands (for example, "ls | wc -l") in C using a pipe (set with fildes[2] array) where ls is processed by child process, and wc command is processed by parent process. Which one of the statements is NOT correct? First, create a pipe by parent process Use fork to generate two processes: parent and child, to handle two commands, respectively. In the child process, use exec to replace itself with the ls command In the child process, use dup to redirect the standard output of ls to pipe's input (fildes[0]) In the parent process, use exec to replace itself with wc In the parent process, use dup to redirect standard input from pipe's output

In the child process, use dup to redirect the standard output of ls to pipe's input (fildes[0])

[APUE07] Which one of the following statements is correct for Stack Segment?

It contains the stack frames which keep track of the return addresses of calling functions as well as arguments passed to functions and local variables.

[APUE] Which one of the following statements is NOT correct for Process Table? It is maintained by each process in the kernel's memory space It is a table containing all of the information that must be saved when the CPU switches from running one process to another in a multitasking system It contains the information (Process priority, CPU time consumed recently, recent sleep time) of each process It contains the information (Pointers to the text, data, stack segments, the values of registers) for each process d. It contains the information (about Signals - which are ignored, which are temporarily blocked, etc.) for each process It contains the information (about Process state (O, S, T, Z), events being waited for, PID, parent's PID) for each process

It is maintained by each process in the kernel's memory space

[APUE07] Which one of the following statements is correct for Heap Segment?

It is used for runtime allocation of memory by processes

[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_EXCL

[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

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

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.

[APUE] Which one of the following statements is NOT correct for "signal"? shell command trap to pick up an interrupt signal SIGINT a library signal handler may be set and used to pick up the signal SIGCHLD, which was generated by kernel when a child process dies Some of the signals can't be picked up and will kill the process for sure The sigaction() system call allows the calling process to examine or specify the action to be taken on delivery of a specific signal SIGKILL can be handled by a process signal handler

SIGKILL can be handled by a process signal handler

[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.

The lseek function modifies only the current file offset in the file table entry. It forces I/O take place.

[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.

The number of bytes actually read is always same as the amount requested for a successful read.

[APUE] Which one of the following statements is NOT correct for Environment? Shell's environment variables are stored in a process's virtual address space To access the global environment variables, use the variable ("extern char **environ") defined in <unistd.h> The array "environ" stores the pointers to all the environment variables in the form of name=value The order in which strings appear in the environment variable ("environ") is significant, and the same name must not appear more than once The last element of the array is a null pointer

The order in which strings appear in the environment variable ("environ") is significant, and the same name must not appear more than once

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the following command: "chmod g+x abc", the result will be is equivalent to the result of command: chmod 710 abc.

True

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. The result of the following command "chmod 700 abc" is equivalent to "chmod og-rwx abc".

True

\ (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,m}

Use this to match any number of occurrences between n and m of the preceding pattern.

{n,}

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

[APUE] Which one of the following statements is NOT correct for Child Process termination? When a child process dies, the kernel places the exit status in the process table When a child process dies, the kernel change its state to zombie The kernel notifies the parent with a signal called SIGCHLD The parent must acknowledge the death of the child by explicitly calling the system call wait, or until its end of execution When a child process dies, the parent process must be wake up.

When a child process dies, the parent process must be wake up.

[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.

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.

[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.

With dup2, if fd2 is already open, it will generate FD_CLOEXEC to close the file and then open it.

[Korn08] A Graphical User Interface supported by every Unix system is generally known as ____.

X Windows

[Sobell1-4] When creating a directory as an ordinary user, which of the following is true?

You must be in your home directory or its subdirectories.

[Korn08] A new line (in echo) will be done with this ___.

\n

[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

a file descriptor

[Sobell1-4] When you use the ln command, which of the following occurs?

a file is created that points to an existing file

[Shell] What is a shell in UNIX?

a program through which users can issue commands to UNIX

[Sobell1-4] To create a new file "new.txt" that is a concatenation of "file1.txt" and "file2.txt" is done by which command?

cat file1.txt file2.txt > new.txt

[Sobell] This changes your current directory location.

cd

[Sobell1-4] Change the current directory to /usr/local/bin

cd /usr/local/bin

[Sobell] This changes the permission information associated with a file.

chmod

[Sobell1-4] The file "mypage.html" has permissions set for read and write only for owner. Which of the following command will change the permissions so that the file can be viewed on the WWW?

chmod og+r mypage.html

[Process2] Consider a code segment for a pipe (e.g., to run "ls | wc") as we discussed in the classes, shown below. What would it be the code segment for the "parent" process here after the fork but before exec (of "ls" or "wc")?

close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]);

[Sobell] This displays the differences between two files on a byte-by-byte basis.

cmp

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

co -l

[Korn08] The delimiter (to separates one piece of path name from other path name) in PATH variable is ___

colon (":")

[Sobell] This compares sorted files

comm

[Sobell1-4] What is the generic syntax for all UNIX commands?

command name, followed by options, followed by arguments

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

commit

[Sobell] This configures the source code automatically.

configure

[Sobell] This copies a file, preserving the original and creating an identical copy.

cp

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

descriptor

[Sobell] For each mounted file system, this reports the file system device, the number of blocks, the number of blocks available, and the directory where the file system is mounted.

df

[Korn08] Which command is used to display lines of source code in gdb debugger?

display

[Sobell] This reports disk usage (i.e., the amount of space taken up by a group of files).

du

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

dup2

[Korn08] The directory "a" contains its subdirectory "b" and there is no other entry in the directory "a". You want to display "the contents of directory a are: b". The contents are to be displayed using "ls" command. Which command helps you accomplish that?

echo "The contents of directory a are: `ls a`"

[Korn08] There is a variable "var". Its value is set to the number 5. If one tries to print "The value: 5". Which one of the commands will do that?

echo "The value: $var"

[Unix&Shell1] To find all files that have been modified in the last five days:

find / -mtime -5 -print

[Unix&Shell1] This find command does find all the ordinary files and then test each file for its type.

find / -type f -print | xargs file

[Unix&Shell1] This is to find all the files in the /apps directory but do not search in /apps/bin:

find /apps -name "/apps/bin" -prune -o -print

[Unix&Shell1] To find all files but not directories in /etc

find /etc !-type d -print

[Unix&Shell1] This find command does find all ordinary files older then 7 days in /var/logs and delete them.

find /var/logs -type f -mtime +7 -exec rm {} \;

[Sobell] This utility displays the usernames of users, together with their full names, terminal device numbers, times they logged in, and other information.

finger

[Korn08] ___ creates a process by spawning a process.

fork

[Sobell1-4] Which of these is not a common UNIX shell discussed in class (or textbook or lecture)? bash sh fresh ksh

fresh

[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.

frok

[Sobell] This utility verifies the integrity of a filesystem and reports on and optionally repairs problems it finds.

fsck

Sets the specified permissions to those of the group

g

[Sobell] This ___ will compile C and C++ programs

gcc

[Sobell1-4] The figure below shows a sample of a passwd file. The field #4 is _____. oracle:x:1021:1020:Oracle user:/data/network/oracle:bin/bash

group identifier

[Sobell1-4] How do you print the first 15 lines of all files ending by ".txt"?

head -15 *.txt

[Sobell1-4] The figure below shows a sample of a passwd file. The field #6 is _____. oracle:x:1021:1020:Oracle user:/data/network/oracle:bin/bash

home directory

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

how two processes can share a file

[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.

i-node

[Sobell] This reports any programs that you suspended and still have running or waiting in the background (if you had pressed Ctrl-z to suspend an editing session, for example).

jobs

[Sobell] This joins lines from two files based on a common field

join

[Sobell] This terminates a process by PID

kill

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

lowest

[Sobell] This lists all of the files within a directory and its subdirectories that match a set of conditions.

ls

[Sobell] This will list the files and the subdirectories in a directory.

ls

[Sobell] ___ Displays information about one or more files

ls

To list the permissions on files, which of the following commands will work?

ls -l

[Sobell] To output only the permissions of the files in the working directory, which of the following commands will do it?

ls -l | cut -c2-10

[Sobell1-4] Count the files that you own in all your directories (where your userid is myusername).

ls -lR | grep myusername | wc -l

[Unix&Shell2] To match all your .files (that is, any hidden files begins with a period).

ls .*

[Unix&Shell2] To match filenames starting with an upper case letter only:

ls [A-Z]*

[Unix&Shell2] To match filenames starting with a lower case letter only:

ls [a-z]*

[Unix&Shell2] To list all filenames that start with an 'i' or 'o':

ls [io]*

[Unix&Shell2] To match all filenames that start with 'f', followed by any two characters, followed by any string; the end character must be an 's':

ls f??*s

[Unix&Shell2] To list all filenames (log followed by some string) but with no numbers.

ls log.[!0-9]*

[Unix&Shell2] To match filenames that begin with 'log.', followed by a single number, followed by any character (including none).

ls log.[0-9]*

[Korn08] Mail utility that POSIX requires all unix systems to support is ____.

mailx

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

make

[Sobell] ____ Keeps a set of programs current (to compile, link edit, clean, etc).

make

[Sobell] ___ Displays documentation for utilities

man

[Sobell1-4] How do you get help about the command "cp"?

man cp

[Sobell] This will make a new subdirectory.

mkdir

[Sobell] ___Creates a directory

mkdir

[Sobell1-4] Which command is used to create the directory "abc" in the previous (parent) directory?

mkdir ../abc

[Sobell1-4] How do you create a new directory called "flower"?

mkdir flower

[Sobell] ___Creates a filesystem on a device

mkfs

[Sobell] This displays the contents of a file one screen at a time, waiting for you to press the Spacebar between screens.

more

[Sobell1-4] Which of the following is not a benefit of the fact that many UNIX commands operate on plain ASCII text files? the same file can be used by many programs output to the terminal and to files can be done in the same way most current UNIX installations have a graphical user interface these commands can be used as filters for the output of other commands

most current UNIX installations have a graphical user interface

[Sobell1-4] To rename the file "a.html" to "b.html", which command do you use?

mv -i a.html b.html

[Sobell1-4] How do you rename file "new" to be "old"?

mv new old

[Sobell] ___ Creates an archive, restores files from an archive, or copies a directory hierarchy

pax

[Korn08] Which one of the following methods is NOT correct for two processes to communicate each other? pipe message queue shared memory socket livespot

pipe

[Korn08] ps fetches attributes from ___

process table

[Sobell] ___ Displays process status

ps

[Sobell1-4] Which of the following commands displays the full pathname of the directory you are currently positioned in?

pwd

Sets read permission

r

[Sobell1-4] In Unix, the octal number "5" corresponds to which ___ file permission.

r - x

[Sobell1-4] In Unix, if you wanted to allow a user to list the contents of a directory, you would give the directory what permission, at least?

read

[Sobell] This will remove (delete) a subdirectory.

rmdir

[Sobell] ___ Removes directories

rmdir

[Sobell] ___ Securely copies files and directory hierarchies over a network

rsync

[Sobell] ___ Displays information about files

stat

[Sobell1-4] What is the default datatype of variables in bash or ksh shell scripts?

string

[Sobell] ____ Displays strings of printable characters from files

strings

[Korn08] A Command to display current terminal settings is ____.

stty -a

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

symbolic link

[Unix&Shell1] The -name option with find command is ____.

to find files by filename

[Unix&Shell1] The -user option with find command is ____.

to find files by user ownership

[Unix&Shell1] The -type option with find command is ____.

to find files that are a certain type

[Unix&Shell1] The -mtime option with find command is ____.

to find files that were accessed or modified some days ago

[Unix&Shell1] The -newer option with find command is ____.

to find files that were accessed or modified some days ago

[Unix&Shell1] The -perm option with find command is ____.

to find files with different access or permission bits on a file

[Korn08] Which command is used to display (and update) a dynamic list of currently running processes of a system in real-time?

top

[Sobell] ___ Dynamically displays process status

top

[Sobell1-4] What UNIX command is used to update the modification time of a file?

touch

[Sobell] ___ Creates a file or changes a file's access and/or modification time

touch

[Sobell] ___ Replaces specified characters

tr

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

twice

[Korn08] This command shows which version of a particular command(example: echo) will be executed.

type echo

[Sobell1-4] What is the effect of the command alias up2="cd ../.."?

typing "up2" at a shell prompt takes you up two levels in the directory tree

Sets the specified permissions to those of the owner

u

[Sobell] ___ Specifies the file-creation permissions mask

umask

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

uname -r

[Sobell] ____ Displays unique lines from a file

uniq

[Sobell] This lists all users logged into the computer.

w

[Sobell] ____ Displays information about local system users

w

[Sobell] ___ Displays the number of lines, words, and bytes in one or more files

wc

[Sobell] ___ Shows where in PATH a utility is located

which

[Sobell1-4] In Unix, if you wanted to allow a user to delete a file, you would give the file the what permission?

write

[Sobell1-4] In Unix, if you wanted to allow a user to modify file permissions in a directory, you would give the directory what permission?

write

Sets execute permission

x

[Sobell] ____ Converts standard input to command lines

xargs

[Korn08] When parent process doesn't wait till child's death, the child enters into ____

zombie state


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

Attempt 2 quiz 5 marriage and family

View Set

Sherpath - Acute Respiratory Failure

View Set

Chapter 21: Title, Risk and Insurable Interest

View Set

Properties of Matter Study Guide

View Set