Unix Interview Questions and Answers

Ques. What are the Unix system calls for I/O?

Ans. open(pathname,flag,mode) - open filecreat(pathname,mode) - create fileclose(filedes) - close an open fileread(filedes,buffer,bytes) - read data from an open filewrite(filedes,buffer,bytes) - write data to an open filelseek(filedes,offset,from) - position an open filedup(filedes) - duplicate an existing file descriptordup2(oldfd,newfd) - duplicate to a desired file descriptorfcntl(filedes,cmd,arg) - change properties of an open fileioctl(filedes,request,arg) - change the behaviour of an open fileThe difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for device-specific operations.