This set of Basic Unix Questions and Answers focuses on “File handling System Calls – 2”.
1. ____ system call is used for renaming a file, directory or symbolic link.
Explanation: The rename call is used for renaming any type of file. It can rename a file, a directory or a symbolic link.
2. S_IFxxx macros are used for checking the file types.
Explanation: All UNIX systems provide a set of macros beginning with S_IF (often called S_IFxxx macros) that provide us with a function of checking the file type. But modern UNIX system performs this task in a more simplified manner using S_ISxxx macros.
3. Which of the following macro returns true if the file type is a directory?
Explanation: The S_ISDIR macro returns true if the file type is a directory. The S_ISREG returns true if the file type is regular.
4. For checking a file access rights, ___ system call is used.
Explanation: By using the access system call, we can check the file’s access rights. It looks at the real UID and real GID of the user running the program and determines that whether the file is accessible by the real user.
5. Which of the following is used with access call for checking the owner’s permissions?
d) R_OK, W_OK, X_OK
Explanation: By using the access system call, we can check the file’s access rights. We’ve to specify one of the following four values to define the permission which is needed to be tested.
R_OK - read permission OK W_OK - write permission OK X_OK - execution permission OK F_OK - file exists
6. chmod and fchmod calls are used for changing file permissions.
Explanation: chmod and fchmod calls are used for changing the file permissions. Chmod uses pathname for identifying a file while fchmod uses the file descriptor.
7. Both the owner and group owner can be changed by ____ call.
Explanation: The chown system call is used to change both the owner and group owner. It has three states; chown, fchown, lchown.
8. For changing the time stamps, _____ system call is invoked.
Explanation: utime system call is used to change a file’s modification and access times.
9. System calls and library functions are same.
Explanation: System calls are built into the kernel, but library functions are built on top of them. When a system call is invoked, the pre-processor switches to kernel mode and returns to the user mode when the call completes.
10. Which of the following system call uses file descriptor as an argument?
d) read, write, close
Explanation: A file descriptor is an integer which is allocated when a file is opened. It is used by all system calls that perform some operations on file -like read, write, close, lseek.
Sanfoundry Global Education & Learning Series – Unix.
To practice basic questions and answers on all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.