sppn.info Art Unix Interview Questions Answers Pdf


Thursday, September 12, 2019

Linux, Windows etc. Here I have collected UNIX interview questions with their answers for your reference. If you require download UNIX Faqs in PDF format. UNIX command Questions Answers asked in Interview. UNIX or Linux operating system has become default Server operating system and for whichever. It is intended as a tutorial on the Unix, and commonly asked qestions in all interviews. Contains Important Unix Interview Questions with Answers and Unix FAQs.

Unix Interview Questions Answers Pdf

Language:English, Spanish, Hindi
Published (Last):
ePub File Size: MB
PDF File Size: MB
Distribution:Free* [*Regsitration Required]
Uploaded by: DONALD

unix interview questions with answers, unix shell scripting interview questions, unix commands, General UNIX interview questions, Some UNIX Interview. what is unix, unix shell, steps UNIX shell follows while processing a command, cmp & diff in UNIX, grep command, cat & more UNIX prompts. Unix and Linux Command Interview Questions and Answers .. I download all these UNIX interview questions and answers in PDF format?.

Construct pipes to execute the following jobs. Output of who should be displayed on the screen with value of total number of users who have logged in displayed at the bottom of the list. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a file. Name of cities should be accepted from the keyboard. This list should be combined with the list present in a file. Explain the following commands. It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to the file specified by the user.

The input from a pipe can be combined with the input from a file. In the above command the output from who becomes the std input to sort , meanwhile sort opens the file logfile, the contents of this file is sorted together with the output of who rep by the hyphen and the sorted output is redirected to the file newfile. Which of the following commands is not a filter man , b cat , c pg , d head Ans: man A filter is a program which can receive a flow of data from std input, process or filter it and send the result to the std output.

Explain the steps that a shell follows while processing a command. After the command line is terminated by the key, the shell goes ahead with processing the command line in one or more passes. The sequence is well defined and assumes the following order. Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless quoted.

All consecutive occurrences of a space or tab are replaced here with a single space. Command substitution: Any command surrounded by backquotes is executed by the shell which then replaces the standard output of the command into the command line.

Any word containing a wild-card is replaced by a sorted list of filenames that match the pattern. The list of these filenames then forms the arguments to the command. What difference between cmp and diff commands? It searches for the pattern, specified in the command line with appropriate option, in a file s. Syntax : grep Example : grep 99mx mcafile What is the difference between cat and more command?

Cat displays file contents. If the file is large the contents scroll off the screen before we view it. So command 'more' is like a pager which displays the contents page by page. Write a command to kill the last background job? Which command is used to delete all files in the current directory and all its sub-directories?

What will the following command do? Is it possible to create new a file system in UNIX? Is it possible to restrict incoming message? What is the use of the command "ls -x chapter[]" ls stands for list; so it displays the list of the files that starts with 'chapter' with suffix '1' to '5', chapter1, chapter2, and so on. If so, what is its use? With the help of this command you can find the disk capacity and free space of the disk.

Is it possible to count number char, line in a file; if so, How? Yes, wc-stands for word count. Name the data structure used to maintain file identification? How many prompts are available in a UNIX system? How does the kernel differentiate device files and ordinary files?

Kernel checks 'type' field in the file's inode structure. How to switch to a super user status to gain privileges? The system asks for password and when valid entry is made the user gains super user admin privileges. What are shell variables?

UNIX Interview Questions

Shell variables are special variables, a name-value pair created and maintained by the shell. What is redirection? Directing the flow of data to the file or from the file for input or output. How to terminate a process which is running and the specialty on command kill 0? With the help of kill command we can terminate the process. Syntax: kill pid Kill 0 - kills all processes in your system except the login shell.

TOP 70+ Best UNIX Interview Questions with Answers

What is a pipe and give an example? A pipe is two or more commands separated by pipe char ' '. That tells the shell to arrange for the output of the preceding command to be passed as input to the following command. Example : ls -l pr The output for a command ls is the standard input of pr. When a sequence of commands are combined using pipe, then it is called pipeline.

Explain kill and its possible return values. This implies that a process exists with the given PID, and the system would allow you to send signals to it. It is system-dependent whether the process could be a zombie. On some systems, the process could be a zombie. This means that either the process exists again, it could be a zombie or draconian security enhancements are present e.

What is relative path and absolute path. Absolute path : Exact path from root directory. Relative path : Relative to the current path. How are devices represented in UNIX? Thus, device files and other files 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 terms of blocks.

A 'character special file' represents a device with characteristics similar to a keyboard data transfer is by stream of bits in sequential order. What is 'inode'?

All UNIX files have its description stored in a structure called 'inode'. The inode 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 inode.

In addition to descriptions about the file, the inode contains pointers to the data blocks of the file. If the file is large, inode has indirect pointer to a block of pointers to additional data blocks this further aggregates for larger files. A block is typically 8k. Inode 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 Brief about the directory representation in UNIX A Unix directory is a file containing a correspondence between filenames and inodes.

A directory is a special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. The contents of a directory are a list of filename and inode number pairs.

Post navigation

When new directories are created, kernel makes two entries named '. System call for creating directory is mkdir pathname, mode. How do you change File Access Permissions? Every file has following attributes: owner's user ID 16 bit integer owner's group ID 16 bit integer File access mode word 'r w x -r w x- r w x' user permission-group permission-others permission r-read, w-write, x-execute To change the access mode, we use chmod filename,mode.

Example 1: To change mode of myfile to 'rw-rw-r--' ie. Example 2: To change mode of myfile to 'rwxr--r--' we give the args as: chmod myfile, What are links and symbolic links in UNIX file system?

A link is a second name not a file for a file. Links can be used to assign more than one name to a file, but cannot be used to assign a directory more than one name or link filenames on different computers.

Symbolic link 'is' a file that only contains the name of another file. Operation on the symbolic link is directed to the file pointed by the it.

Both the limitations of links are eliminated in symbolic links. FIFO are otherwise called as 'named pipes'. FIFO first-in-first-out is a special file which is said to be data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the order written.

It is used in interprocess communication where a process writes to one end of the pipe producer and the other reads from the other end consumer. How do you create special files like named pipes and device files?

The system call mknod creates special files in the following sequence. If it is a device file, it makes the other entries like major, minor device numbers.

For example: If the device is a disk, major device number refers to the disk controller and minor device number is the disk. Discuss the mount and unmount system calls The privileged mount system call is used to attach a file system to a directory of another file system; the unmount system call detaches a file system. When you mount another file system on to your directory, you are essentially splicing one directory tree onto a branch in another directory tree.

The first argument to mount call is the mount point, that is , a directory in the current file naming system. The second argument is the file system to mount to that point. How does the inode map to data block of a file? Inode has 13 block addresses. The first 10 are direct block addresses of the first 10 data blocks in the file. The 11th address points to a one-level index block.

The 12th address points to a two-level double in-direction index block. The 13th address points to a three- level triple in-direction index block. This provides a very large maximum file size with efficient access to large files, but also small files are accessed directly in one disk read. What is a shell? A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface.

The shell converts them to system calls to the OS or forks off a process to execute the command. System call results and other information from the OS are presented to the user through an interactive interface. Commonly used shells are sh,csh,ks etc. Brief about the initial process sequence while the system boots up.

While booting, special process called the 'swapper' or 'scheduler' is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper inturn creates 3 children: the process dispatcher, vhand and dbflush with IDs 1,2 and 3 respectively. Process dispatcher gives birth to the shell.

Unix keeps track of all the processes in an internal data structure called the Process Table listing command is ps -el.

What are various IDs associated with a process? Unix identifies each process with a unique integer called ProcessID. Every process is associated with a particular user called the 'owner' who has privileges over the process. The identification for the user is 'UserID'. Owner is the user who executes the process. Process also has 'Effective User ID' which determines the access privileges for accessing resources like files. The new process is called the child process, and the existing process is called the parent.

The parent gets the child's pid returned to him, but the child gets 0 returned to him. Hello World! Explanation: The fork creates a child that is a duplicate of the parent process.

The child begins from the fork. All the statements after the call to fork will be executed twice. The statement before fork is executed only by the parent process. How can a parent and child process communicate? A parent and child can communicate through any of the normal inter-process communication schemes pipes, sockets, message queues, shared memory , but also have some special ways to communicate that take advantage of their relationship as a parent and child.

One of the most obvious is that the parent can get the exit status of the child. What is a zombie? What are the process states in Unix? As a process executes it changes state according to its circumstances. Unix processes have the following states: Running : The process is either running or it is ready to run. Waiting : The process is waiting for an event or for a resource. Stopped : The process has been stopped, usually by receiving a signal. What Happens when you execute a program?

When you execute a program on your UNIX system, the system creates a special environment for that program. This environment contains everything needed for the system to run the program as if no other program were running on the system. Each process has process context, which is everything that is unique about the state of the program you are currently running. Every time you execute a program the UNIX system does a fork, which performs a series of operations to create a process context and then execute your program in that context.

The steps include the following: Allocate a slot in the process table, a list of currently running programs kept by UNIX. Assign a unique process identifier PID to the process. Return the new PID to the parent process. This enables the parent process to examine or control the process directly. After the fork is complete, UNIX runs your program.

What Happens when you execute a command? When you enter 'ls' command to look at the contents of your current working directory, UNIX does a series of things to create an environment for ls and the run it: The shell has UNIX perform a fork. This creates a new process that the shell will use to run the ls program. The shell has UNIX perform an exec of the ls program. This replaces the shell program and data with the program and data for ls and then starts running that new program.

The ls program is loaded into the new process context, replacing the text and data of the shell. The ls program performs its task, listing the contents of the current directory. What is a Daemon? A daemon is a process that detaches itself from the terminal and runs, disconnected, in the background, waiting for requests and responding to them. How will you run a process in background? How will you bring that into foreground and how will you kill that process?

For bringing it back in foreground use command "fg jobid" and for getting job id you use command jobs, for killing that process find PID and use kill -9 PID command. This is indeed a good Unix Command interview questions because many of programmer not familiar with background process in UNIX. How do you know if a remote host is alive or not? You can check these by using either ping or telnet command in UNIX.

This question is most asked in various Unix command Interview because its most basic networking test anybody wants to do it. How do you see command line history in UNIX?

How do you copy file from one host to other? Many options but you can say by using "scp" command. You can also use rsync command to answer this UNIX interview question or even sftp would be ok. How do you find which process is taking how much CPU? How do you check how much space left in current drive? By using "df" command in UNIX. For example "df -h. This is part of anyone day to day activity so I think this Unix Interview question will be to check anyone who claims to working in UNIX but not really working on it.

What is the difference between Swapping and Paging? Swapping: Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems.

Paging: Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly. What is difference between ps -ef and ps -auxwww?

This is indeed a good Unix Interview Command Question and I have faced this issue while ago where one culprit process was not visible by execute ps —ef command and we are wondering which process is holding the file.

How do you find how many cpu are in your system and there details? When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status. To be able to get this information, the parent calls 'wait '; In the interval between the child terminating and the parent calling 'wait ', the child is said to be a 'zombie' If you do 'ps', the child will have a 'Z' in its status field to indicate this.

Zombie : The process is dead but have not been removed from the process table. What is "chmod" command?

The line you see shows the permission for three different set of people : user, group and others. User is the currently logged in user, while group is for all other member which are part of certain group and others means anyone other than user and group member. So in above line, user has only read permission, group members has write permissions and other people has only execute permission.

If it is a directory then you need execute permission to go inside that directory.

See here for more detailed answer. In a file word UNIX is appearing many times?The shell first breaks up the command line into words, using spaces and the delimiters, unless quoted.

For bringing it back in foreground use command "fg jobid" and for getting job id you use command "jobs", for killing that process find PID and use kill -9 PID command. A Map is an Array, which contains the addresses of the free space in the swap device that are allocatable resources, and the number of the resource units available there.

Write command to list all the links from a directory? In addition to descriptions about the file, the inode contains pointers to the data blocks of the file. A Map is an Array, which contains the addresses of the free space in the swap device that are allocatable resources, and the number of the resource units available there.

The input from a pipe can be combined with the input from a file.