5 avg. rating (100% score) - 1 votes
Want to shift your career to Unix/Linux? Then we will provide you with the complete details about the Interview question and Answers on our site page. We have provided all level of expertise question and answers to clear an interview on the first attempt itself. Linux is an intimate of free and open-source software operating systems built round the Linux kernel. Naturally, Linux is packaged in a form known as a Linux delivery for both desktop and server use. If you are good at the Unix/Linux there are many leading companies that offer various job role like DevOps Professional - Unix/Linux/Scripting, UNIX/Linux Administrator, UNIX/Linux Administrator (IT Engineer, Staff), UNIX Shell Scripting and many other roles too. For any further details about the Unix/Linux jobs and Unix/Linux Interview Question and Answers visit our site www.wisdomjobs.com.
All devices are represented by files called special files that are located in/dev directory. 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).
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:
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 '.' (refers to the directory itself) and '..' (refers to parent directory).
System call for creating directory is mkdir (pathname, mode).
The difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for device-specific operations.
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).
To change mode of myfile to 'rw-rw-r–' (ie. read, write permission for user - read,write permission for group - only read permission for others) we give the args as:
Each operation is represented by discrete values
'r' is 4
'w' is 2
'x' is 1
Therefore, for 'rw' the value is 6(4+2).
To change mode of myfile to 'rwxr–r–' we give the args as:
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).
The system call mknod creates special files in the following sequence:
If the device is a disk, major device number refers to the disk controller and minor device number is the disk.
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. When you insert a cdrom to your unix system's drive, the file system in the cdrom automatically mounts to /dev/cdrom in your system.
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.
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.
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:
with IDs 1,2 and 3 respectively.
This is done by executing the file /etc/init. 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).
Unix identifies each process with a unique integer called ProcessID. The process that executes the request for creation of a process is called the 'parent process' whose PID is 'Parent Process ID'. 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 `fork()' used to create a new process from an existing process. The new process is called the child process, and the existing process is called the parent. We can tell which is which by checking the return value from `fork()'. The parent gets the child's pid returned to him, but the child gets 0 returned to him.
Hello World!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.(once by the parent process and other by child). The statement before fork() is executed only by the parent process.
"Hello World" will be printed 8 times.
2^n times where n is the number of calls to fork()
System calls Description:
Getting the value of an environment variable is done by using `getenv()'. Setting the value of an environment variable is done by using `putenv()'.
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.
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.)
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.
Zombie : The process is dead but have not been removed from the process table.
Unix/Linux Related Tutorials
|Perl Scripting Tutorial||Shell Scripting Tutorial|
|Python Tutorial||Core Java Tutorial|
|Linux Tutorial||Linux Embedded systems Tutorial|
Unix/Linux Related Interview Questions
|Perl Scripting Interview Questions||Shell Scripting Interview Questions|
|Python Interview Questions||Core Java Interview Questions|
|Linux Interview Questions||Linux Embedded systems Interview Questions|
|Red Hat Linux System Administration Interview Questions||IBM AIX Interview Questions|
|Sybase Interview Questions||IBM AIX 7 Administration Interview Questions|
|Unix Shell Scripting Interview Questions||Linux Shell Scripting Interview Questions|
Unix/Linux Related Practice Tests
|Perl Scripting Practice Tests||Shell Scripting Practice Tests|
|Python Practice Tests||Core Java Practice Tests|
|Linux Practice Tests||Linux Embedded systems Practice Tests|
|Red Hat Linux System Administration Practice Tests||IBM AIX Practice Tests|
|Sybase Practice Tests||IBM AIX 7 Administration Practice Tests|
|Autosys Practice Tests|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.