Technical Interview Question on UNIX 2016

Technical Interview Question on UNIX 2016.

1. How are devices represented bi UNIX?
All devices are represented by tiles called special /1/es that are located
inldev directory. Thus, device files and other tiles are named and accessed in the same
way. A ‘regular file’ is just an ordinary data file in the disk. A ‘block special file’ represents
a device with characteristics similar to a disk (data transfer in tems of blocks). A
‘character special tile’ represents a deice with characteristics similar to a keyboard (data
transfer is by stream of bits in sequential order).

2. What is ‘inode’?
All UNIX files have its description stored in a structure called ‘mode’. The mode
contains info about the file-size, its location, time of last access, time of last modification,
permission and so on. Directories are also represented as files and have an associated
mode. In addition to descriptions about the file, the mode contains pointers to the data
blocks of the tile. If the file is large, mode has indirect pointer to a block of pointers to
additional data blocks (this further aggregates for larger files). A block is typically 8k.
mode consists of the following fields:
File owner identifier
File type
File access permissions
File access times
Number of links
File size
Location of the file data

3. Brief about the directory represenlalioiz in UNIX
A Unix directory is a file containing a correspondence between filenames and
modes. A directory is a special tile that the kernel maintains. Only kernel modifies
directories, but processes can read directories. The contents of a directory arc a list of
filename and mode number pairs. When new directories are created, kernel makes two
entries named ‘.‘ (refers to the directory itself) and ‘..‘ (refers to parent directory).
System call for creating directory is mkdir (pathname. mode).
4. What are the U.ux si’stein calls for I/O?

open( pathname,flag,mode) – open file
creat(pathname,mode) – create tile
close(filedes) – close an open tile
read(filedcs,buffer,bytes) – read data from an open tile
write(tiledes,bufferbytes) – write data to an open tile
Iseek(tiledes,offset,from) – position an open file
dup(tiledes) – duplicate an existing file descriptor
dup2(oldfd,newfd) – duplicate to a desired file descriptor
fcntl(filedes,cmd,arg) – change properties of an open file
ioctl(filedesrequest,arg) – change the behaviour of an open tile
The difference between fcntl anf ioctl is that the former is intended for any open file,
while the latter is for device-specitic operations.

.pdf FileDownload Click here

Need More? Click Here