Unix Interview Questions and Answers
Question - 91 : - Can you write a command to erase all files in the current directory including all its sub-directories?
Answer - 91 : -
rm –r* is used to erase all files in the current directory including all its sub-directories. rm is used for deleting files, but with the addition of option -r it erases all files in directories and subdirectories, and finally, an asterisk represents all entries.
Question - 92 : - What do you know about the MBR?
Answer - 92 : -
It stands for Master Boot Record and is a small program that is executed when the computer is booting up in order to find the OS and load it into memory. During the first stage of the system boot-up process, the BIOS (basic input-output system) searches for the MBR and then loads it into memory, after which the MBR takes over.
Question - 93 : - Explain the file system in UNIX
Answer - 93 : -
These are a fundamental component of the file system:
- Boot lock
- Inode lock
- Data Block
- Super Block
The UNIX file system has many different file system types such as ufs (UNIX filesystem), NFS(Network file system), vxfs(Veritas file system), and cdfs(CD-ROM filesystem). Among these, the ufs file system type is the most standard UNIX file system. Reads and writes to a ufs file system are done in blocks depending on the size of the file system block size. Block sizes can range from 1 KB to 8 KB depending on the file system type selected.
Question - 94 : - In shell scripting, what is the significance of the Shebang line?
Answer - 94 : -
It gives information about the location of where the engine is placed. The engine is the one that executes the given script. It is placed at the top of the script.
Question - 95 : - Can you enlist some commonly used network commands?
Answer - 95 : -
Some commonly used networking commands in Unix are:
- telnet: This is used for remote login and for communication with another hostname.
- ping: This is used for checking network connectivity.
- hostname: This gives the IP address and domain name.
- nslookup: This performs a DNS query.
- xtraceroute: This is used to determine the number of hops and response time required to reach the network host.
- netstat: This provides information about system and ports, routing tables, interface statistics, etc.
- tcpdump: This provides info about both incoming and outgoing network traffic.
Question - 96 : - Explain a path in UNIX and different types of pathnames.
Answer - 96 : -
A Path is the unique location of a file/directory and a way to access it within the hierarchy of directories. There are basically two types of pathnames that are used in Unix.
- Absolute Pathname: The complete path specifying the location of a file/ directory from the very start of the actual file system(root directory).
Ex- /usr/local/Cellar/mysql/bin- Relative Pathname: The path from the current working directory where the user is i.e. the present working directory (pwd).
Ex- If current directory is /usr/local/Cellar the the relative path for bin is ./mysql/bin
Question - 97 : - Explain Superblock in UNIX.
Answer - 97 : -
A SuperBlock is a program that contains records of specific file systems such as the block size, the empty and the filled blocks and their respective counts, the size of the block groups, the disk block map, the size and location of the inode tables, and usage information. There are basically two types of superblocks:
- Default superblock: It is a fixed offset from the beginning of the system’s disk partition.
- Redundant superblock: There are multiple copies of superblocks of a default one and are referenced when the default superblock is affected by a system crash or some errors.
Question - 98 : - Enlist some file manipulation commands in UNIX.
Answer - 98 : -
These are few file manipulation commands:
- cat filename - Displays contents of the file.
- cp source destination - Copy the source file into the destination.
- mv old_name new_name - Move/rename.
- rm filename - Remove/delete filename.
- touch filename - creating/changing modification time.
- In [-s] old_name new_name - Creating a soft link on an old name.
- Is –F - Displays information about the file type.
- ls -ltr - This will display in long format sorted by modified time with oldest first.
Question - 99 : - What is a wildcard and how is it used?
Answer - 99 : -
A wildcard is a symbol that takes the place of an unknown character or set of characters. The asterisk(*) and question mark(?) are wildcard characters usually used. The wildcards are majorly used in searching files with unknown characters in the filename (or directory).
Question - 100 : - What are system calls and library functions in terms of Unix commands?
Answer - 100 : -
System calls: System calls are an interface to the kernel itself that further requests the operating system to perform tasks on behalf of user programs. Whenever a system call is invoked within the operating system, the application program performs a context switch from user space to kernel space. These are not portable.
Library functions: These are functions that are not part of the kernel but are used by the different application programs. As compared to the system call it takes less time for execution and is portable and can perform certain tasks only in ‘kernel mode’.