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 Commands Interview Questions – Subscribe to FREE & Exclusive UNIX Commands Interview. Questions. Check for your FREE Bonuses at the end of. what is unix, unix shell, steps UNIX shell follows while processing a command, cmp & diff in UNIX, grep command, cat & more UNIX prompts.
|Language:||English, Spanish, French|
|Genre:||Academic & Education|
|ePub File Size:||22.53 MB|
|PDF File Size:||18.16 MB|
|Distribution:||Free* [*Regsitration Required]|
1) What is UNIX? It is a portable operating system that is designed for both efficient multi-tasking and multi-user functions. Its portability allows it. 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. job you give interview you find some UNIX command interview questions there. various UNIX command interview questions asked to Java developers or.
Ephemeral ports are port used by Operating system for client sockets. Command [-argument] [-argument] [--argument] [file] 4 Is there a way to erase all files in the current directory, including all its sub-directories, using only one command? But this scheme needs synchronization. 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. How would you kill a process? The shell executes only those commands that are enclosed in backquotes. UNIX is a multi-user multitasking-optimized operating system that can run on various hardware platforms.
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. 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: 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: 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. Commands for linking files are: 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. 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: 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! 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: The process is either running or it is ready to run. The process is waiting for an event or for a resource. 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. It can also be defined as the background process that does not belong to a terminal session.
Many other daemons may exist. Some of the most common daemons are: Takes over the basic running of the system when the kernel has finished the boot process. Responsible for starting network services that do not have their own stand-alone daemons. For example, inetd usually takes care of incoming rlogin, telnet, and ftp connections.
Responsible for running repetitive tasks on a regular schedule. What is 'ps' command for? The ps command prints the process status for some or all of the running processes. The information given are the process identification number PID ,the amount of time that the process has taken to execute so far etc. How would you kill a process? The kill command takes the PID as one argument; this identifies which process to terminate. 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? 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. 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.
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 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. How do you set environment variable which will be accessible form sub shell?
How do you check if a particular process is listening on a particular port on remote host? To read more about telnet read networking command in UNIX.
Either by using "uname -a" command or by using "arch" command. How do you find which processes are using a particular file? By using lsof command in UNIX. It wills list down PID of all the process which is using a particular file. How do you find which remote hosts are connecting to your host on a particular port say ?
By using netstat command execute netstat -a grep "port" and it will list the entire host which is connected to this host on port What is nohup in UNIX? An UNIX process started with nohup will not stop even if the user who has stared log off from system. What is ephemeral port in UNIX? Ephemeral ports are port used by Operating system for client sockets. There is a specific range on which OS can open any port specified by ephemeral port range.
If one process is inserting data into your MySQL database? How will you check how many rows inserted into every second? Purpose of this Unix Command Interview is asking about watch command in UNIX which is repeatedly execute command provided with specified delay.
You have a tab separated file which contains Name, Address and Phone Number, list down all Phone Number without there name and Addresses? CUT use tab as default separator so you can use. Your application home directory is full? How will you find which directory is taking how much space?
By using disk usage DU command in Unix for example du —sh. By using uptime command in UNIX. You have an IP address in your network how will you find hostname and vice versa? This is a standard UNIX command interview question asked by everybody and I guess everybody knows its answer as well. Please share any interesting UNIX command interview you have come across and I will add into this list.
If you are going for any Unix interview on brokerage firm or stock trading company or any Investment bank you can have a quick look here, though most of questions you might already know but its good to review it.
Share to Twitter Share to Facebook. United States. Anonymous said May 16, at 3: May 16, at 7: May 17, at 1: In cases wherein an error message was returned, the reason maybe that the command was not in your path, or that the command itself does not exist. Every process is uniquely identified by a process identifier. It is possible to view details and status regarding a process by using the ps command. A directory, being a special type of file, follows the same naming convention as that of files.
Letters and numbers are used, along with characters like underscore and dot characters.
The root account is very important, and with abusive usage, can easily lead to system damage. That's because safeguards that normally apply to user accounts are not applicable to the root account. The tee command does two things: When using the cat command to display file contents, large data that does not fit on the screen would scroll off without pausing, therefore making it difficult to view. On the other hand, using the more command is more appropriate in such cases because it will display file contents one screen page at a time.
Parsing is the process of breaking up of a command line into words. This is made possible by using delimiters and spaces. In the event that tabs or multiple spaces are part of the command, these are eventually replaced by a single space. Pid is short for Process ID. It is used primarily to identify every process that runs on the UNIX system, whether it runs on the foreground or runs in the background. Every pid is considered unique. However, the semicolon and the ampersand characters can also serve as command terminators.
They are replaced by the shell with a sorted list of files whose pattern matches the input command.
Wild-card characters are used to setup a list of files for processing, instead of having it specified one at a time. At the same time, "sort" opens logfile, arranges it together with the output from the command "who", and places the final sorted output to the file newfile.
In order to switch from any user type to a superuser, you use the su command. However, you will be asked to key in the correct superuser password before full access privileges are granted to you. TXT, while at the same time excluding duplicate entries. To change a prompt, we use the PS1 command, such as this: Give me a U!
Give ma a N! Give me a I! Give me a X! Java is the most popular programming language in the world. Learning Java will undoubtedly boost