linux interview question

Upload: anurag0290

Post on 14-Apr-2018

227 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/29/2019 Linux Interview Question

    1/45

    What is Linux and why is it so popular?

    Answer - Linux is an operating system that uses UNIX like Operating system.......

    Unix interview questions with answers

    Discuss the mount and unmount system calls, What are the process states in Unix?, Whatis use of sed command?, What is 'inode'?,What are the Unix system calls for I/O?, Howare devices represented in UNIX?, Brief about the directory representation in UNIX ......

    What is LILO?

    Answer - LILO is Linux Loader is a boot loader for Linux. It is used to load Linux intothe memory and start the Operating system.......

    What is the difference between home directory and working directory?

    Answer - Home directory is the default working directory when a user logs in. On theother hand, working directory is the users current directory.......

    What is the difference between internal and external commands?

    Answer - Internal commands are commands that are already loaded in the system. Theycan be executed any time and are independent.......

    Explain the difference between a static library and a dynamic library.

    Answer - Static libraries are loaded when the program is compiled and dynamically-linked libraries are loaded in while......

    What is LD_LIBRARY_PATH?

    Answer - LD_LIBRARY_PATH is an environment variable. It is used for debugging anew library or a non standard library.......

    What is the file server in Linux server?

    Answer - File server is used for file sharing. It enables the processes required frosharing.......

    What is NFS? What is its purpose?

    Answer - NFS is Network File system. It is a file system used for sharing of files over anetwork.......

    http://www.careerride.com/Linux-Defined.aspxhttp://www.careerride.com/Unix-Interview-Questions.aspxhttp://www.careerride.com/Linux-Loader-LILO.aspxhttp://www.careerride.com/Linux-home-working-directory.aspxhttp://www.careerride.com/Linux-internal-external-commands.aspxhttp://www.careerride.com/Linux-Static-dynamic-library.aspxhttp://www.careerride.com/Linux-LD_LIBRARY_PATH.aspxhttp://www.careerride.com/Linux-file-server.aspxhttp://www.careerride.com/Linux-NFS.aspxhttp://www.careerride.com/Linux-Defined.aspxhttp://www.careerride.com/Unix-Interview-Questions.aspxhttp://www.careerride.com/Linux-Loader-LILO.aspxhttp://www.careerride.com/Linux-home-working-directory.aspxhttp://www.careerride.com/Linux-internal-external-commands.aspxhttp://www.careerride.com/Linux-Static-dynamic-library.aspxhttp://www.careerride.com/Linux-LD_LIBRARY_PATH.aspxhttp://www.careerride.com/Linux-file-server.aspxhttp://www.careerride.com/Linux-NFS.aspx
  • 7/29/2019 Linux Interview Question

    2/45

    How do I send email with linux?

    Answer - Email can be sent in Linux using the mail command. ......

    Explain RPM (Red Hat Package Manager) features.

    Answer - RPM is a package managing system (collection of tools to manage softwarepackages).......

    What is Kernel? Explain the task it performs.

    Answer - Kernel is used in UNIX like systems and is considered to be the heart of the operatingsystem.......

    What is Linux Shell? What is Shell Script?

    Answer - Linux shell is a user interface used for executing the commands. Shell is a program the

    user......

    What are Pipes? Explain use of pipes.

    Answer -A pipe is a chain of processes so that output of one process (stdout) is fed an input(stdin) to another.......

    Explain trap command; shift Command, getopts command of linux.

    Answer - Trap command: controls the action to be taken by the shell when a signal isreceived. ......

    What Stateless Linux server? What feature it offers?

    Answer -A stateless Linux server is a centralized server in which no state exists on the singleworkstations. ......

    What does nslookup do? Explain its two modes.

    Answer - Nslookup is used to find details related to a Domain name server. Details like IPaddresses of a machine, MX records,......

    What is Bash Shell?

    Answer - Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has acombination of the C and Korn shell features. ......

    Explain some Network-Monitoring Tools in Linux: ping, traceroute, tcpdump, ntop

    Answer - Network monitoring tools are used to monitor the network, systems present on thenetwork, traffic etc.......

    http://www.careerride.com/Linux-send-email.aspxhttp://www.careerride.com/Linux-RPM.aspxhttp://www.careerride.com/Linux-Kernel.aspxhttp://www.careerride.com/Linux-Shell.aspxhttp://www.careerride.com/Linux-pipes.aspxhttp://www.careerride.com/Linux-command.aspxhttp://www.careerride.com/Linux-Stateless-Server.aspxhttp://www.careerride.com/Linux-nslookup.aspxhttp://www.careerride.com/Linux-Bash-Shell.aspxhttp://www.careerride.com/Linux-Network-Monitoring-Tools.aspxhttp://www.careerride.com/Linux-send-email.aspxhttp://www.careerride.com/Linux-RPM.aspxhttp://www.careerride.com/Linux-Kernel.aspxhttp://www.careerride.com/Linux-Shell.aspxhttp://www.careerride.com/Linux-pipes.aspxhttp://www.careerride.com/Linux-command.aspxhttp://www.careerride.com/Linux-Stateless-Server.aspxhttp://www.careerride.com/Linux-nslookup.aspxhttp://www.careerride.com/Linux-Bash-Shell.aspxhttp://www.careerride.com/Linux-Network-Monitoring-Tools.aspx
  • 7/29/2019 Linux Interview Question

    3/45

    How does the linux file system work?

    Answer - Linux file structure is a tree like structure. It starts from the root directory, representedby '/', and then expands into sub-directories.......

    What are the process states in Linux?

    Answer - Process states in Linux.......

    What is a zombie?

    Answer - Zombie is a process state when the child dies before the parent process. In this casethe structural information of the process is still in the process table.......

    Explain each system calls used for process management in linux.

    Answer - System calls used for Process management......

    Which command is used to check the number of files and disk space used and the

    each users defined quota?

    repquota command is used to check the status of the users quota along with the diskspace and number of files used. This command gives a summary of the users quota thathow much space and files are left for the user. Every user has a defined quota in Linux.This is done mainly for the security, as some users have only limited access to files. Thisprovides a security to the files from unwanted access. The quota can be given to a single

    user or to a group of users.

    What is the name and path of the main system log?

    By default the main system log is /var/log/messages. This file contains all the messagesand the script written by the user. By default all scripts are saved in this file. This is thestandard system log file, which contains messages from all system software, non-kernelboot issues, and messages that go to 'dmesg'. dmesg is a system file that is written uponsystem boot.

    How secured is Linux? Explain.

    Security is the most important aspect of an operating system. Due to its uniqueauthentication module, Linux is considered as more secured than other operating systems.Linux consists of PAM. PAM is Pluggable Authentication Modules. It provides a layerbetween applications and actual authentication mechanism. It is a library of loadablemodules which are called by the application for authentication. It also allows theadministrator to control when a user can log in. All PAM applications are configured inthe directory "/etc/pam.d" or in a file "/etc/pam.conf". PAM is controlled using the

    http://www.careerride.com/Linux-file-system.aspxhttp://www.careerride.com/Linux-process-states.aspxhttp://www.careerride.com/Linux-zombie.aspxhttp://www.careerride.com/Linux-process-management.aspxhttp://www.careerride.com/Linux-file-system.aspxhttp://www.careerride.com/Linux-process-states.aspxhttp://www.careerride.com/Linux-zombie.aspxhttp://www.careerride.com/Linux-process-management.aspx
  • 7/29/2019 Linux Interview Question

    4/45

    configuration file or the configuration directory.

    Can Linux computer be made a router so that several machines may share a single

    Internet connection? How?

    Yes a Linux machine can be made a router. This is called "IP Masquerade." IPMasquerade is a networking function in Linux similar to the one-to-many (1: Many)NAT (Network Address Translation) servers found in many commercial firewalls andnetwork routers. The IP Masquerade feature allows other "internal" computers connectedto this Linux box (via PPP, Ethernet, etc.) to also reach the Internet as well. Linux IPMasquerading allows this functionality even if the internal computers do not have IPaddresses.The IP masquerading can be done by the following steps:

    1. The Linux PC must have an internet connection and a connection to LAN. Typically,

    the Linux PC has two network interfaces-an Ethernet card for the LAN and a dial-up PPPconnection to the Internet (through an ISP).

    2. All other systems on your LAN use the Linux PC as the default gateway for TCP/IPnetworking. Use the same ISP-provided DNS addresses on all systems.

    3. Enable IP forwarding in the kernel. By default the IP forwarding is not enabled. Toensure that IP forwarding is enabled when you reboot your system, place this commandin the /etc/rc.d/rc.local file.

    4. Run /sbin/iptables-the IP packet filter administration program-to set up the rules that

    enable the Linux PC to masquerade for your LAN.

    What is the minimum number of partitions you need to install Linux?

    Minimum 2 partitions are needed for installing Linux. The one is / or root which containsall the files and the other is swap. Linux file system is function specific which means thatfiles and folders are organized according to their functionality. For example, allexecutables are in one folder, all devices in another, all libraries in another and so on. / orroot is the base of this file system. All the other folders are under this one. / can beconsider as C: .Swap is a partition that will be used as virtual memory. If there is no moreavailable RAM a Linux computer will use an area of the hard disk, called swap, totemporarily store data. In other words it is a way of expanding your computers RAM.

    Which command is used to review boot messages?

    dmesg command is used to review boot messages. This command will display systemmessages contained in the kernel ring buffer. We can use this command immediatelyafter booting to see boot messages. A ring buffer is a buffer of fixed size for which anynew data added to it overwrites the oldest data in it. Its basic syntax is

  • 7/29/2019 Linux Interview Question

    5/45

    dmesg [options]

    Invoking dmesg without any of its options causes it to write all the kernel messages to

    standard output. This usually produces far too many lines to fit into the display screen allat once, and thus only the final messages are visible. However, the output can beredirected to the less command through the use of a pipe, thereby allowing the startupmessages to be viewed on one screen at a timedmesg | less

    Which utility is used to make automate rotation of a log?

    logrotate command is used to make automate rotation of log.Syntax of the command is:logrotate [-dv] [-f|] [-s|] config_file+

    It allows automatic rotation, compression, removal, and mailing of log files. Thiscommand is mainly used for rotating and compressing log files. This job is done everyday when a log file becomes too large. This command can also be run by giving oncommand line. We can done force rotation by giving f option with this command incommand line. This command is also used for mailing. We can give m option formailing with this command. This option takes two arguments one is subject and other isrecipient name.

    What are the partitions created on the mail server hard drive?

    The main partitions are done firstly which are root, swap and boot partition. But for the

    mail server three different partitions are also done which are as follows:1. /var/spool- This is done so that if something goes wrong with the mail server or spoolthan the output cannot overrun the file system.2. /tmp- putting this on its own partition prevents any user item or software fromoverrunning the system files.3. /home- putting this on its own is useful for system upgrades or reinstalls. It allow notto wipe off the /home hierarchy along with other areas.

    What are the fields in the/etc/passwd file?

    It contains all the information of the users who log into the system. It contains a list of the

    system's accounts, giving for each account some useful information like user ID, groupID, home directory, shell, etc. It should have general read permission as many utilities,like ls use it to map user IDs to user names, but write access only for the superuser (root).The main fields of /etc/passwd file are:1. Username: It is used when user logs in. It should be between 1 and 32 characters inlength.2. Password: An x character indicates that encrypted password is stored in /etc/shadowfile.

  • 7/29/2019 Linux Interview Question

    6/45

    3. User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reservedfor root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999are reserved by system for administrative and system accounts/groups.4. Group ID (GID): The primary group ID (stored in /etc/group file)

    5. User ID Info: The comment field. It allow you to add extra information about the userssuch as user's full name, phone number etc. This field use by finger command.6. Home directory: The absolute path to the directory the user will be in when they log in.If this directory does not exists then users directory becomes /7. Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this isa shell.

    Which commands are used to set a processor-intensive job to use less CPU time?

    nice command is used for changing priority of the jobs.Syntax: nice [OPTION] [COMMAND [ARG]...]

    Range of priority goes from -20 (highest priority) to 19 (lowest).Priority is given to a jobso that the most important job is executed first by the kernel and then the other leastimportant jobs. This takes less CPU times as the jobs are scheduled and are givenpriorities so the CPU executes fast. The priority is given by numbers like -20 describe thehighest priority and 19 describe the least priority.

    How to change window manager by editing your home directory?

    /.xinitrc file allows changing the window manager we want to use when logging into Xfrom that account. The dot in the file name shows you that the file is a hidden file anddoesn't show when you do a normal directory listing. For setting a window manager we

    have to save a command in this file. The syntax of command is: execwindowmanager.After this, save the file. Next time when you run a startx a new windowmanager will open and become default. The commands for starting some popular windowmanagers and desktop environments are:-KDE = startkde-Gnome = gnome-session-Blackbox = blackbox-FVWM = fvwm-Window Maker = wmaker-IceWM = icewm

    How documentation of an application is stored?

    When a new application is installed its documentation is also installed. Thisdocumentation is stored under the directory named for application. For example if myapplication name is App1 then the path of the documentation will be /user/doc/App1. Itcontains all the information about the application. It contains date of creating application,name of application and other important module of the application. We can get the basicinformation of application from the documentation.

  • 7/29/2019 Linux Interview Question

    7/45

    How shadow passwords are given?

    pwconv command is used for giving shadow passwords. Shadow passwords are given forbetter system security. The pwconv command creates the file /etc/shadow and changes all

    passwords to x in the /etc/passwd file. First, entries in the shadowed file which don'texist in the main file are removed. Then, shadowed entries which don't have `x' as thepassword in the main file are updated. Any missing shadowed entries are added. Finally,passwords in the main file are replaced with `x'. These programs can be used for initialconversion as well to update the shadowed file if the main file is edited by hand.

    How do you create a new user account?

    useradd command is used for creating a new user account. When invoked without the-D option, the useradd command creates a new user account using the values specified onthe command line and the default values from the system. The new user account will be

    entered into the system files as needed, and initial files copied, depending on thecommand line options. This command uses the system default as home directory. If moption is given then the home directory is made.

    Which password package is installed for the security of central password?

    Shadow password packages are used for security of central passwords. Security is themost important aspect of every operating system. When this package is not installed theuser information including passwords is stored in the /etc/passwd file. The password isstored in an encoded format. These encoded forms can be easily identified by the Systemcrackers by randomly encoding the passwords from dictionaries. The Shadow Package

    solves the problem by relocating the passwords to another file (usually /etc/shadow).The /etc/shadow file is set so that it cannot be read by just anyone. Only root will be ableto read and write to the /etc/shadow file.

    Which shell do you assign to a POP3 mail-only account?

    POP3 mail only account is assigned to the /bin/false shell. However, assigning bash shellto a POP3 mail only gives user login access, which is avoided. /bin/nologin can also beused. This shell is provided to the user when we dont want to give shell access to theuser. The user cannot access the shell and it reject shell login on the server like on telnet.It is mainly for the security of the shells. POP3 is basically used for downloading mail to

    mail program. So for illegal downloading of emails on the shell this account is assignedto the /bin/false shell or /bin/nologin. These both shells are same they both do the samework of rejecting the user login to the shell. The main difference between these two shellsis that false shell shows the incorrect code and any unusual coding when user login withit. But the nologin shell simply tells that no such account is available. So nologin shell isused mostly in Linux.

  • 7/29/2019 Linux Interview Question

    8/45

  • 7/29/2019 Linux Interview Question

    9/45

  • 7/29/2019 Linux Interview Question

    10/45

  • 7/29/2019 Linux Interview Question

    11/45

    http://www.linuxnix.com/2009/11/ext2-vs-ext3-file-systems.htmlhttp://www.linuxnix.com/2009/11/ext2-vs-ext3-file-systems.html
  • 7/29/2019 Linux Interview Question

    12/45

    http://www.linuxnix.com/2011/07/find-block-size-linux.htmlhttp://www.linuxnix.com/2011/07/find-block-size-linux.html
  • 7/29/2019 Linux Interview Question

    13/45

    http://www.linuxnix.com/2010/04/notes-for-vi-editor.htmlhttp://www.linuxnix.com/2012/02/linuxunix-redirection-operatorsfile-descriptors-explained-examples.html
  • 7/29/2019 Linux Interview Question

    14/45

    http://www.linuxnix.com/2009/11/linux-virtual-file-system.html
  • 7/29/2019 Linux Interview Question

    15/45

    http://www.linuxnix.com/2009/04/soft-link-vs-hard-link-in-linuxnix.htmlhttp://www.linuxnix.com/2009/04/soft-link-vs-hard-link-in-linuxnix.html
  • 7/29/2019 Linux Interview Question

    16/45

    http://www.linuxnix.com/2012/04/learn-linuxunix-find-command-50-practical-examples.htmlhttp://www.xen.org/http://www.vmware.com/http://searchenterpriselinux.techtarget.com/sDefinition/0,,sid39_gci1099982,00.htmlhttp://searchenterprisewan.techtarget.com/sDefinition/0,,sid200_gci214107,00.htmlhttp://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci1101066,00.htmlhttp://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci1101066,00.htmlhttp://searchenterpriselinux.techtarget.com/sDefinition/0,,sid39_gci1101542,00.htmlhttp://searchenterpriselinux.techtarget.com/sDefinition/0,,sid39_gci212482,00.htmlhttp://www.linuxnix.com/2008/09/disk-management-in-linux.html
  • 7/29/2019 Linux Interview Question

    17/45

  • 7/29/2019 Linux Interview Question

    18/45

    http://docs.google.com/Doc?id=dggtw8pr_1604gz89zmg4http://docs.google.com/Doc?id=dggtw8pr_1604gz89zmg4
  • 7/29/2019 Linux Interview Question

    19/45

  • 7/29/2019 Linux Interview Question

    20/45

  • 7/29/2019 Linux Interview Question

    21/45

  • 7/29/2019 Linux Interview Question

    22/45

    http://www.linuxnix.com/2010/02/file-types-in-linux.html
  • 7/29/2019 Linux Interview Question

    23/45

    http://www.linuxnix.com/2010/02/file-types-in-linux.html
  • 7/29/2019 Linux Interview Question

    24/45

    execute permissions to group and read, and execute permissions to others

    read, write and execute permissions to user =7

    read and execute permissions to group =5

    read and execute permissions to others=5

    So total permissions will be 755

    chmod 755 filename

    Example: Providing write access to a user

    chmod w+u filename

    Example: Adding write permissions to a group

    chmod w+g filename

    Example: Adding executable permissions to others

    chmod x+o filename

    Example: Adding executable and write permissions to all

    chmod wx+a filename

    Example: Replicating user permissions to a group

    chmod u=g filename

    Example: Removing execute permissions to a user

    Chmod u-x filename

    Example: Adding execute permissions to others

    Chmod o+x

    Explore your self on how to use other options. In the next post we will see more aboutchmod options and examples such as change file/folder permissions recursively, SUID,SGID and Sticky bit. And we will see practical usages of chmod too.

  • 7/29/2019 Linux Interview Question

    25/45

    Q. How can I disable or lock a password for a User inLinux?

    Some times its required to lock user not to login to the machine. This can be done byusing passwd command. this command should be executed by root or super user.Execute below command lock a user.

    Syntax:

    passwd -l username

    Example:

    passwd -l surendra.

    The above command will lock the user surendra prominently so that he can not login tothe machine.

    nce the password is locked or disabled !(negation sybol) will be added to password fieldin /etc/shadow file for that user.

    Before password lock implemented, the entry for surendra as below.

    surendra:$6$rZnP7SSN$emBz/./WkjSa9B:15615:0:99999:7:::

    After setting password lock:

    surendra:!$6$rZnP7SSN$emBz/./WkjSa9B:15615:0:99999:7:::

    If you try to login, you will get Login incorrect, This error is because ! in thepassword field of /etc/shadow file for user surendra.

    How to unlock a user account in Linux?

    Some times on Linux boxes the user account will be locked due to issues such as wrong

    password entry, account expiry etc. In this post we will see how to unlock user accountwith different commands.

    Example1: Check if the password is disabled by viewing /etc/shadow file for user entry.

    grep username /etc/shadow

    http://www.linuxnix.com/2011/06/linux-shadow-file-explained-detail.htmlhttp://www.linuxnix.com/2011/06/linux-shadow-file-explained-detail.html
  • 7/29/2019 Linux Interview Question

    26/45

    if you are able to see ! in the second field starting that indicates that password is disabled,you have to enable it back by using passwd with -u option

    passwd -u username

    Example:

    passwd -u surendra

    Unlocking password for user temp.

    passwd: Success

    Example2: Check if the user expiry date is reached or not by using chage command

    chage -l username

    Examplechage -l surendra

    Last password change : Jan 05, 2012

    Password expires : never

    Password inactive : never

    Account expires : Jan 01, 2012

    Minimum number of days between password change : 0

    Maximum number of days between password change : 99999

    Number of days of warning before password expires : 7

    If you see that the account expires use usermod or chage command to extend the user

    expiry time.

    usermod -e yyyy-mm-dd username

    usermod -e 2012-05-10 surendra

    or

    chage -E yyyy-mm-dd username

    chage -E 2012-05-10 surendra

    this will extend user expiry time to 5 more months.

    Example3: Check if the user shell is set to a valid shell or not, if its not set it to a validone.

    grep username /etc/passwd

  • 7/29/2019 Linux Interview Question

    27/45

    Example:

    grep surendra /etc/passwd

    If the user shell in seventh feild is set to /sbin/nologin or /bin/false set it back to /bin/bash

    or /bin/ksh

    usermod -s /bin/bash usrename

    usermod -s /bin/bash surendra

    Share your thoughts on this and let us know if you have other ideas to unlock useraccounts in Linux.

    How to lock user account in Linux?

    Some times its required to lock user account so that he can not login to the machine. Thisis done for security reasons so that unauthorized users are not allowed to login. Lockinguser account can be done in many ways. Below are some ways you can disable an user inLinux.

    1)Disable the login with passwd command

    2)Set the user account expiry time with usermod command or chage command.

    3)Set the nologin shell to user.

    and many more.

    Example1:Disable or lock user account using passwd command. Use passwd commandwith -l option to lock the user account, as the passwd is disabled for the user.

    passwd -l username

    Example:

    passwd -l surendra

    Locking password for user surendra.

    passwd: Success

    Example2: Disable user account by setting expiry date with usermod command

    usermod -e yyyy-mm-dd username

  • 7/29/2019 Linux Interview Question

    28/45

    Example:

    usermod -e 2012-01-10 surendra

    ssh [email protected]

    [email protected] password:Your account has expired; please contact your system administrator

    Example3: Disable user account by setting expiry date with chage command

    chage -E yyyy-mm-dd username

    Example:

    chage -E 2012-01-10 surendra

    ssh [email protected]@192.168.100.166s password:

    Your account has expired; please contact your system administrator

    Example4: Setting user shell to /sbin/nologin so that he can not login to the machine

    usermod -s /sbin/nologin username

    Example:

    usermod -s /sbin/nologin surendra

    This account is currently not available.

    Share your thoughts if you have any on other ways to disable user accounts in Linux.

    Linux Directory Structure explained: /dev folder

    Jan 10, 2013

    This is our fourth post on Linux Directory structure series. Some of the posts alreadycovered are

    Linux Directory Structure explained: /boot folder

    Linux Directory Structure explained: /bin folder

    What is lost+found directory in Linux/Unix?

    Today we will see what is /dev folder and its uses. Linux/Unix treat everything as files.One classic example is it treats hardware devices too as files. All hardware files are

    http://www.linuxnix.com/2013/01/linux-directory-structure-explained-dev-folder.htmlhttp://www.linuxnix.com/2012/09/linux-directory-structure-explained-boot-folder.htmlhttp://www.linuxnix.com/2012/10/linux-directory-structure-explained-bin-folder.htmlhttp://www.linuxnix.com/2012/12/lostfound-directory-linuxunix.htmlhttp://www.linuxnix.com/2013/01/linux-directory-structure-explained-dev-folder.htmlhttp://www.linuxnix.com/2012/09/linux-directory-structure-explained-boot-folder.htmlhttp://www.linuxnix.com/2012/10/linux-directory-structure-explained-bin-folder.htmlhttp://www.linuxnix.com/2012/12/lostfound-directory-linuxunix.html
  • 7/29/2019 Linux Interview Question

    29/45

    present in /dev(Device ) folder. If we observe the /dev folder you can find files/foldersrelated to different hardwares present in the machine.

    Below are some hardware files and their uses and explanation.

    1. /dev/alarm

    This is a hardware file used to keep track of time when system goes hibernation orsuspended when it is idle. When your system goes hibernation most of your hardwarewill be shutdown, HDD rotation is reduced to as low as possible in order to save power.This file is very much useful to keep track of system time, to do calender updates to useretc. You can say in other words that /dev/alarm will have current time status. This file isused in portable devices such as laptops and mobiles mostly. Click here to know moreabout this file.

    2. /dev/autofs

    This file is used to mount remote directories locally. This is done automatically whenuser tries to login by mounting remote directory. The mounting is done by using thishardware file. With out this hardware file we can not do automount in a Linux box.

    3. /dev/block folder

    This folder is legacy location for your block devices. This is still existing to supportlegacy applications.

    4. /dev/cdrom, /dev/dvd, /dev/cdrw, /dev/dvd-rw etc

    These files corresponds to Compact-Disk(/dev/cdrom or /dev/cdrw) hardware or toDigital Versatile Disk(/dev/dvd or /dev/dvd-rw) hardware. These files are required tomount your local CDrom and DVDs so that you can access the content of the file. Knowhow to mount your CD/DVD in Linux.

    5. /dev/char

    This is the folder where char files are located in legacy machines. This is still kept tosupport legacy applications.

    6. /dev/console, /dev/tty, /dev/tty1 to /dev/tty63, /dev/ttyS, /dev/ttyS0 to/dev/ttyS31 files and /dev/pts folder

    These device files are called as terminals or consoles which are char files used forcommunication between user and system. /dev/console file is used inRunlevel1 andnone of these terminals are available for access on runlevel 1. tty(Teletype) is a devicefile to do remote connection so that we can work remotely The name is derived fromtypewriters which are default communicating devices in early stages of Computers. The

    http://lwn.net/Articles/429925/http://www.linuxnix.com/2012/09/how-to-mount-dvd-or-cdrom-in-linux.htmlhttp://www.linuxnix.com/2008/05/the-runlevels.htmlhttp://lwn.net/Articles/429925/http://www.linuxnix.com/2012/09/how-to-mount-dvd-or-cdrom-in-linux.htmlhttp://www.linuxnix.com/2008/05/the-runlevels.html
  • 7/29/2019 Linux Interview Question

    30/45

    terminals range from tty0 to tty63 and serial port terminals(ttys or ttyS) are from 0 to 31.We have pseudo terminals which is used when users login from remote machines, thesevirtual terminals are kept in /dev/pts folder in most Linux flavors.

    7. /dev/loop(/dev/loop0 to /dev/loop7)

    A loop device is a Pseudo device useful for mounting Virtual CD(ISO files), HDD etc.The loop devices are useful for mounting already formatted drive and access the data in afolder mounted on different filesystem. Virtual devices are nothing but a hardware filecreated by kernel/OS so that we can use them as a physical drives. These loop devices arealso used by virtual softwares such as KVM, VMWARE to mount CD-ROMs,HDD(.img files for example) as physical devices in your Virtual machine. Planing tomount your ISO file, know it how to do it here.

    8. /dev/sda, /dev/hda etc

    These files corresponding to hard disks and storage devices such as USB hard disks,SATA disks and External HDDs. For Intel machines you may find /dev/hda, /dev/hdb,/dev/hdc, /dev/hdd corresponds to Primary master, Primary slave, Secondary master andSecondary Slave devices. Partitions with in disks are created as /dev/sda1, sda2 etc and soon.

    9. /dev/random and /dev/urandom

    Used for generating random chars for Kernel purpose.

    10. /dev/null and /dev/zero

    Used for generating empty files, observing unwanted outputs etc. Click hereto know thedifference

    11. /dev/ppp

    This file is used to connect your mobile or GPRS/3Genabled devices to connect and communicate. This ispseudo file which communicates with GPRS enabledhardware file to send data. Click here to know how to

    connect internet using your GPRS/3G enabled device.What is UMASK and how to set UMASK inLinux/Unix?

    Dec 27, 2011

    http://flavors.linuxnix.com/http://www.linuxnix.com/2012/08/how-to-mount-iso-image-files-in-linux.htmlhttp://www.linuxnix.com/2013/04/linuxunix-difference-between-devnull-and-devzero-files.htmlhttp://www.linuxnix.com/2013/04/linuxunix-difference-between-devnull-and-devzero-files.htmlhttp://www.linuxnix.com/2011/08/connect-reliance-netconnect-ubuntu.htmlhttp://www.linuxnix.com/2011/08/connect-reliance-netconnect-ubuntu.htmlhttp://www.linuxnix.com/2011/12/umask-define-linuxunix.htmlhttp://www.linuxnix.com/2011/12/umask-define-linuxunix.htmlhttp://flavors.linuxnix.com/http://www.linuxnix.com/2012/08/how-to-mount-iso-image-files-in-linux.htmlhttp://www.linuxnix.com/2013/04/linuxunix-difference-between-devnull-and-devzero-files.htmlhttp://www.linuxnix.com/2011/08/connect-reliance-netconnect-ubuntu.htmlhttp://www.linuxnix.com/2011/08/connect-reliance-netconnect-ubuntu.htmlhttp://www.linuxnix.com/2011/12/umask-define-linuxunix.htmlhttp://www.linuxnix.com/2011/12/umask-define-linuxunix.html
  • 7/29/2019 Linux Interview Question

    31/45

    UMASK(User Mask or User file creation MASK) is the default permission or base permissions givenwhen a new file(even folder too, as Linux treats everything as files) is created on a Linux machine. Most ofthe Linux distros give 022(0022) as default UMASK. In other words, It is a system default permissions fornewly created files/folders in the machine.

    How to calculate UMASK in Linux?

    Though umask value is same for files and folders but calculation of File base permissionsand Directory base permissions are different.

    The minimum and maximum UMASK value for a folder is 000 and 777

    The minimum and maximum UMASK value for a file is 000 and 666

    Why 666 is the maximum value for a file?

    This is because only scripts and binaries should have execute permissions, normal andregular files should have just read and write permissions. Directories require executepermissions for viewing the contents in it, so they can have 777 as permissions.

    Below are the permissions and its values used by UMASK. If you are a Linux/Unix useryou will observe these are inverse to actual permissions values when setting uppermissions to files/folders with CHMOD command.

    0 --Full permissions(Read, Write, Execute)

    1 --Write and read

    2 --Read and execute

    3 --Read only

    4 --Write and execute

    5 --Write only

    6 --Execute onlyadminadmin

    7 --No permissions

    How to remember these and calculate the file and folder permissions?

    Consider above values are inverse to actual permissions. Suppose your UMASK value is0027(027).

    For folder:

    To calculate actual folder permissions from UMASK is done in two steps

    Step1:Logical Negate the UMASK

    Not(027) = 750

    Step2: Logical AND this number with 777

    777 AND 750 = 750

    http://www.linuxnix.com/2011/12/chown-command-linuxunix-explained-examples.htmlhttp://www.linuxnix.com/2011/12/chown-command-linuxunix-explained-examples.html
  • 7/29/2019 Linux Interview Question

    32/45

    So actual folder permissions is 750 when its created. Owner will get full permission,group gets execute and write permissions and others no permissions

    In other words and simple way..We have to subtract 027 from 777 then we will get the actual folder permissions.

    777 - 027 = 750

    which is nothing but full permissions for the owner, read anFor files:To get actuall file permissions from UMASK is done in two steps

    Step1:Logical Negate the UMASK

    Not(027) = 750

    Step2: Logical AND this number with 666

    666 AND 750 = 640

    For your understanding purpose we have calculated this below equation to get whatactuall AND operator do.

    110 + 111 = 110(6)

    110 + 101 = 100(4)

    110 + 000 = 000(0)

    How to see default UMASK?

    just type umask and you will get whats the default UMASK

    umask

    Output

    0022

    Some FAQ related to umask:

    1)How to setup or change default UMASK for all the new users?

    The UMASK value can be set in /etc/profile for all the new users. Open this file as rootuser and given the below line in the file.

    umask 027

    2)How to setup or change default UMASK for existing users?

    For existing users you can edit ~/.bashrc file in their home directory. This should bedone for all the users one by one or if the machine is having lots and lots of users thenyou can write a shell script for this.

  • 7/29/2019 Linux Interview Question

    33/45

    3)I see people are using 0022 and 022 as UMASK, is there any difference between

    them?

    There is no difference between these two, both indicates one and the same. The preceding0 indicates there is no SUID/SGID/Sticky bit information set.

    4)What is the perferred UMASK value for a system for Security reasons?

    Prefered is 027(0027) for security reasons becasue this will restrict others not toread/write/execute that file/folder

    5)I see umask value as 022 in my vsftpd config file? what actually this mean to

    world?

    When you see 022 as umask value in vsftpd config file that indicates that users who aregoing to create files will get 644 and for folders its 755 respectively.

    d execute permissions for group and no permissions for others.

    Questions : 1When and how linux developedAnswers : 1

    The Linux operating system was conceived and implemented in 1969 at AT&T's BellLaboratories in the United States by Ken Thompson, Dennis Ritchie, Douglas McIlroy,and Joe Ossanna. It was first released in 1971 and was initially entirely written inassembly language, a common practice at the time. Later, in a key pioneering approach in

    1973, Unix was re-written in the programming language C by Dennis Ritchie. Theavailability of an operating system written in a high-level language allowed easierportability to different computer platforms. With a legal glitch forcing AT&T to licensethe operating system's source code,linux quickly grew and became widely adopted byacademic institutions and businesses.

    Questions : 2What the commond used for List the contents of your homedirectory , current directory and ALL subdirectories Answers : 2

    A word List formed a command LS that show contents of home directory like below$ ls ~

    To show everything in a vertical column used like below$ ls -alit will show like belowdrwxr-xr-x 5 root root 3090 Jun 19 20:39 boot/drwxr-xr-x 8 root root 4509 Jul 21 09:56 dev/drwxr-xr-x 94 root root 4096 Jul 12 10:35 etc/show directories in the current directory$ ls -d */

    http://www.linuxnix.com/2011/12/suid-set-suid-linuxunix.htmlhttp://www.linuxnix.com/2011/12/sgid-set-sgid-linuxunix.htmlhttp://www.linuxnix.com/2012/01/sticky-bit-set-linux.htmlhttp://www.linuxnix.com/2011/12/suid-set-suid-linuxunix.htmlhttp://www.linuxnix.com/2011/12/sgid-set-sgid-linuxunix.htmlhttp://www.linuxnix.com/2012/01/sticky-bit-set-linux.html
  • 7/29/2019 Linux Interview Question

    34/45

    show ALL subdirectories$ ls *

    Questions : 3how you will Create new folder / directories and how to remove fileand folder in linux Answers : 3

    mkdir

    Create new folder or directory, if they do not already exist alreadysyntex like belowmkdir [Options] directoriesOPTIONS-m, --mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask-p, --parents no error if existing, make parent folder as neededmkdir creates the standard entries . (dot) for the current folderand .. (dot dot) for its parentcd used for Change Directory

    rm To Remove filesrmdir To Remove folder(s)

    Questions : 4What the command used for Search file or files for specific text.Answers : 4grep command used for files for specific text.

    Main Difference between Redhat & Ubuntu

    Ubuntu is based on Debian system. It uses .deb packages. While redhat uses it own

    package system .rpm (red hat package manager ).

    Redhat is free but it is charged for support (updates), when Ubuntu is totally free withsupport for desktop users only professional support is chargeable.

    There are several points between these two to differentiate them. In easy wordsdifferences are:

    1. Ubuntu Desktop enterprise edition (Business Desktop Remix) is free to use but

    Redhat is not.2. Ubuntu focuses on Desktop users, in other hand Redhat main focus is Serverplatform.

    3. Red Hat is made by Red Hat Inc. is founded by Young and Ewing while Ubuntuis headed by Shuttleworth, owner of Canonical Ltd.

    4. Ubuntu is based on Debian (a very famous and stable Linux OS), but Redhat hasnothing like this.

  • 7/29/2019 Linux Interview Question

    35/45

    5. Ubuntu executable file extension is .deb (which uses other Debian based OS i.e.Linux Mint), whether Redhat executable file extension is .rpm (which meansRedhat Package Manager).

    Red Hat Enterprise Linux is not free, and its also used for business.Red Hat Linux,

    assembled by the company Red Hat, was a popular Linux based operating system. RedHat Linux 1.0 was released on November 3, 1994. It was originally called Red HatCommercial Linux It is the first Linux distribution to use the packaging system, theRPM Package Manager as its packaging format, and over time has served as the startingpoint for several other distributions, such as Mandriva Linux and Yellow Dog Linux.

    Red Hats Features:

    Red Hat Linux introduced a graphical installer called Anaconda, intended to be

    easy to use for novices, and which has since beenadopted by some other Linux distributions.

    It also introduced a built-in tool called Lokkit for configuring the firewallcapabilities. It uses .rpm package called Red Hat Package Manager.

    RPM Package Manager (RPM) is a powerful command line driven package management

    system capable of installing, uninstalling, verifying, querying, and updating software

    packages.

    Each software package consists of an archive of files along with information about thepackage like its version, a description, etc.

    Ubuntu Ubuntu is an operating system, like windows. Ubuntu is a Linux distribution thatstarts with the breadth of Debian and adds regular releases (every six months), a clearfocus on the user and usability (it should Just Work, TM) and a commitment to securityupdates with 18 months of support for every release. Ubuntu ships with the latest Gnomerelease as well as a selection of server and desktop software that makes for a comfortabledesktop experience off a single installation CD.

    Ubuntu uses the.deb apt package:- Ubuntu uses .deb package for package

    installation as like .rpm of Red Hat. Ubuntu also uses apt-get package installer to install packages by using command

    mode. To install package Graphically, synaptic package

    manager.

    What are Pipes? Explain use of pipes.

    Answer

    A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin)to another. UNIX shell has a special syntax for creation of pipelines. The commands arewritten in sequence separated by |. Different filters are used for Pipes like AWK, GREP.

  • 7/29/2019 Linux Interview Question

    36/45

    e.g. sort file | lpr ( sort the file and send it to printer)

    Uses of Pipe

    Several powerful functions can be in a single statement

    Streams of processes can be redirected to user specified locations using >

    Linux - What are Pipes? Explain use of pipes - August 21, 2008 at 22:00 pm by Rajmeet Ghai

    What are Pipes? Explain use of pipes.

    Pipe is a symbol used to provide output of one command as input to another command.The output of the command to the left of the pipe is sent as input to the command to theright of the pipe. The symbol is |.

    For example:

    $ cat apple.txt | wc

    In the above example the output of apple.txt file will be sent as inputfor wc command which counts the no. of words in a file. The filefor which the no. of words counts is the file apple.txt.Pipes are useful to chain up several programs, so thatmultipWhat is Kernel? Explain the task it performs.

    Answer

    Kernel is used in UNIX like systems and is considered to be the heart of the operatingsystem. It is responsible for communication between hardware and software components.

    It is primarily used for managing the systems resources as well.

    Kernel Activities:

    The Kernel task manager allows tasks to run concurrently.

    Managing the computer resources: Kernel allows the other programs to run and

    use the resources. Resources include i/o devices, CPU, memory. Kernel is responsible for Process management. It allows multiple processes to run

    simultaneously allowing user to multitask. Kernel has an access to the systems memory and allows the processes to access

    the memory when required.

    Processes may also need to access the devices attached to the system. Kernelassists the processes in doing so.

    For the processes to access and make use of these services, system calls are

    used.

    Linux - What is Kernel? Explain the task it performs - May 11, 2009 at 16:00 pm by Vidya Sagar

    What is Kernel? Explain the task it performs.

  • 7/29/2019 Linux Interview Question

    37/45

    Kernel is the component that is responsible for managing the resources of a computersystem.

    The tasks are:

    - Provides the abstraction level for resources such as memory, processors, and I/Odevices.-Performs inter process communication-Responds to system calls-Provides methods for synchronization and communication between processes.

    le commands can execute at once without using a shell script. Whatare the process states in Linux?

    Answer

    Process states in Linux:

    Running: Process is either running or ready to run

    Interruptible: a Blocked state of a process and waiting for an event or signal

    from another process Uninterruptible: a blocked state. Process waits for a hardware condition and

    cannot handle any signal Stopped: Process is stopped or halted and can be restarted by some other process

    Zombie: process terminated, but information is still there in the process table.

    Linux - What are the process states in Linux? - August 21, 2008 at 22:00 pm by Rajmeet Ghai

    What are the process states in Linux?

    The following are the process states:

    1. Running: This is a state where a process is either in running or ready to run.2. Interruptible: This state is a blocked state of a process which awaits for an event or asignal from another process3. Uninterruptible: It is also a blocked state. The process is forced to halt for certaincondition that a hardware status is waited and a signal could not be handled.4. Stopped: Once the process is completed, this state occurs. This process can berestarted

    5. Zombie: In this state, the process will be terminated and the information will still beavailable in the process table.

    Linux - What is Linux Shell? What is Shell Script? - August 21, 2008 at 22:00 pm by Rajmeet Ghai

  • 7/29/2019 Linux Interview Question

    38/45

    What is Linux Shell? What is Shell Script?

    Answer

    Linux shell is a user interface used for executing the commands. Shell is a program theuser uses for executing the commands. In UNIX, any program can be the users shell.

    Shell categories in Linux are:

    Bourne shell compatible, C shell compatible, nontraditional, and historical.

    A shell script, as the name suggests, is a script written for the shell. Script here means aprogramming language used to control the application. The shell script allows differentcommands entered in the shell to be executed. Shell script is easy to debug, quicker ascompared to writing big programs. However the execution speed is slow because itlaunches a new process for every shell command executed. Examples of commands arecp, cn, cd.

    Linux - What is Linux Shell? What is Shell Script? - August 21, 2008 at 22:00 pm by Rajmeet Ghai

    What is Linux Shell? What is Shell Script?

    Linux shell is the user interface to communicate with Linux operating system. Shellinterprets the user requests, executes them. Shell may use kernel to execute certainprograms. Shell Script: A shell script is a program file in which certain Linux commandsare placed to execute one after another. A shell script is a flat text file. Shell scripts areuseful to accept inputs and provide output to the user. Everyday automation process canbe simplified by a shell script.

    What is a zombie?

    Answer

    Zombie is a process state when the child dies before the parent process. In this case thestructural information of the process is still in the process table. Since this process is notalive, it cannot react to signals. Zombie state can finish when the parent dies. Allresources of the zombie state process are cleared by the kernel

    Linux - What is a zombie? - May 11, 2009 at 14:00 pm by Vidya Sagar

    What is a zombie?

    Dead process is called a zombie. The processes will die eventually at the time when theybecome zombies. A dead process cannot be killed. The parent process will send a signalto the operating system that is not needed the zombie by using wait () system call.

    inux - What are Pipes? Explain use of pipes - August 21, 2008 at 22:00 pm by Rajmeet Ghai

  • 7/29/2019 Linux Interview Question

    39/45

    What are Pipes? Explain use of pipes.

    Answer

    A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin)to another. UNIX shell has a special syntax for creation of pipelines. The commands are

    written in sequence separated by |. Different filters are used for Pipes like AWK, GREP.

    e.g. sort file | lpr ( sort the file and send it to printer)

    Uses of Pipe

    Several powerful functions can be in a single statement

    Streams of processes can be redirected to user specified locations using >

    Linux - What are Pipes? Explain use of pipes - August 21, 2008 at 22:00 pm by Rajmeet Ghai

    What are Pipes? Explain use of pipes.

    Pipe is a symbol used to provide output of one command as input to another command.The output of the command to the left of the pipe is sent as input to the command to theright of the pipe. The symbol is |.

    For example:$ cat apple.txt | wc

    In the above example the output of apple.txt file will be sent as input for wc commandwhich counts the no. of words in a file. The file for which the no. of words counts is the

    file apple.txt.Pipes are useful to chain up several programs, so that multiple commands can execute atonce without using a shell script.

    Explain trap command, shift Command, getopts command of linux.

    Answer

    Trap command: controls the action to be taken by the shell when a signal is received.

    Trap [OPTIONS] [ [arg] signspec..]

    Arg is the action to be taken or executed on receiving a signal specified in signspec.

    e.g. trap rm $FILE; exit // exit (signal) and remove file (action)

    Shift Command: Using shift command, command line arguments can be accessed. Thecommand causes the positional parameters shift to the left. Shift [n] where n defaults to 1.It is useful when several parameters need to be tested.

  • 7/29/2019 Linux Interview Question

    40/45

    Getopts command: this command is used to parse arguments passed. It examines the nextcommand line argument and determines whether it is a valid option

    Getopts {optstring} {variable1}. Here, optsring contains letters to be recognized if aletter is followed by a colon, an argument should be specified. E.g (whether the argument

    begins with a minus sign and is followed by any single letter contained inside options ) Ifnot, diagnostic messages are shown. It is usually executed inside a loop.

    Linux - Trap command, shift Command, getopts command - May 11, 2009 at 21:00 pm by Vidya Sagar

    Explain trap command; shift Command, getopts command of linux.

    trap command is used to catch a signal that is sent to a process. An action is taken basedon the signal by using the action which is defined in the trap command instead of takingthe default effect on the process.

    Example:

    $ trap echo interrupt signal received INT.

    shift command is used to replace the parameters that were sent from command line. Forexample

    $ shift will replace $1 by $2

    getopts command is used for the purpose of parsing positional parameters.

    Rajmeet Ghai

    What is Linux and why is it so popular?

    Answer

    Linux is an operating system that uses UNIX like Operating system. However, unlikeUNIX, Linux is an open source and free software. Linux was originally created by LinusTorvalds and commonly used in servers.

    Popularity of Linux is because of the following reasons

    It is free and open source. We can download Linux for free and customize it as

    per our needs. It is very robust and adaptable.

    Immense amount of libraries and utilities

    Linux - What is Linux and why is it so popular? - May 11, 2009 at 13:00 pm by Vidya Sagar

    What is Linux and why is it so popular?

  • 7/29/2019 Linux Interview Question

    41/45

    Linux is a multiuser, multitask GUI based open source operating system developed byLinus Torvalds Torvalds has invited the community to enhance the Linux kernel andthousands of system programmers worked on to enhance.

    Prior to Linux, there is UNIX. The desktop work stations from various companies were

    based on UNIX. Later a numerous companies entered and each one of them had theirown UNIX version. As the proprietary authority is owned by each company and the lackof central authority weaken UNIX. As Linux is free and runs on any PC platform itgained the popularity very quickly. The following are few more reasons for its popularity:

    - People who are familiar with UNIX can work on Linux with ease and comfort.

    - People who want great control over network security and on opernux - How does the

    linux file system work? - August 21, 2008 at 22:00 pm by Rajmeet Ghai

    How does the linux file system work?

    Answer

    Linux file structure is a tree like structure. It starts from the root directory, represented by'/', and then expands into sub-directories. All the partitions are under the root directory. Ifa partition is mounted (The mount point defines the place of a particular data set in thefile system) anywhere apart from a device, the system is not aware of the existence ofthat partition or device. Directories that are only one level below the root directory areoften preceded by a slash, to indicate their position.

    Explain file system of linux. The root "/" filesystem, /usr filesystem, /var filesystem, /home filesystem,

    /proc filesystem.

    Answer

    Root "/" file system: The kernel needs a root file system to mount at start up. The rootfile system is generally small and should not be changed often as it may interrupt inbooting. The root directory usually does not have the critical files. Instead sub directoriesare created. E.g. /bin (commands needed during bootup), /etc (config files) , /lib(sharedlibraries).

    /usr filesystem : this file system is generally large as it contains the executable files to beshared amongst different machines. Files are usually the ones installed while installingLinux. This makes it possible to update the system from a new version of the distribution,or even a completely new distribution, without having to install all programs again. Subdirectories include /bin, /include, /lib, /local (for local executables)

    /var filesystem : this file system is specific to local systems. It is called as var becausethe data keeps changing. The sub directories include /cache/man (A cache for manpages), /games (any variable data belong to games), /lib (files that change), /log (log fromdifferent programs), /tmp (for temporary files)

    /home filesystem: - this file system differs from host to host. User specific configurationfiles for applications are stored in the user's home directory in a file. UNIX creates

  • 7/29/2019 Linux Interview Question

    42/45

    directories for all users directory. E.g /home/my_name. Once the user is logged in ; he isplaced in his home directory.

    /proc filesystem : this file system does not exist on the hard disk. It is created by thekernel in its memory to provide information about the system. This information is usually

    about the processes. Contains a hierarchy of special files which represent the current stateof the kernel .Few of the Directories include /1 (directory with information about processnum 1, where 1 is the identification number), /cpuinfo (information about cpu), /devices(information about devices installed), /filesystem (file systems configured), /net(information about network protocols), /mem (memory usage)

    Linux - How does the linux file system work? - May 11, 2009 at 21:00 pm by Vidya Sagar

    How does the Linux file system work?

    At the time of installation of Linux, a file system is assigned and persists in the hard disk.This file system structure resembles a tree.A file can be a list of names and numbers or executable programs. Linux treats everyprogram as a file. Linux treats directories and computer components also as files.A file could be a list of names and numbers, a cheesecake recipe, or an executableprogram. But under Linux, everything is a file. In addition to data and executable files,Linux treats directories and even the various components of your computer as files. Itcould be a keyboard, console, and printer, RAM or ROM. These are referred as specialfiles known as devices. These files are available in /dev directory. Linux performs thecommunication with these devices by simply reading from or writing to these specialfiles.

    Describe initial process sequence while the system boots up.

    1) BIOS 2) Master Boot Record (MBR) 3) LILO or GRUB 4) Kernel 5) init 6) RunLevels.............

    What is a shell? What are shell variables?

    A shell us an interface to the user of any operating system..............

    Explain how the inode maps to data block of a file.

    There are 13 block addresses in inode. The file descriptions type of file, accessrights.............

    Explain some system calls used for process management.

    The following are the system calls: fork() - For creating child process .............

    http://www.careerride.com/Linux-initial-process-sequence.aspxhttp://www.careerride.com/Linux-what-is-a-shell-and-shell-variables.aspxhttp://www.careerride.com/Linux-how-inode-maps-to-data-block.aspxhttp://www.careerride.com/Linux-system-calls-used-for-process-management.aspxhttp://www.careerride.com/Linux-initial-process-sequence.aspxhttp://www.careerride.com/Linux-what-is-a-shell-and-shell-variables.aspxhttp://www.careerride.com/Linux-how-inode-maps-to-data-block.aspxhttp://www.careerride.com/Linux-system-calls-used-for-process-management.aspx
  • 7/29/2019 Linux Interview Question

    43/45

    Explain how to get/set an environment variable from a program.

    An environment variable can get using the function getenv()..............

    Describe how a parent and child process communicates each other.

    The inter communication between a child process and a parent process can be donethrough normal communication.............

    What is a Daemon?

    Daemon is the short form for Disk and Execution Monitor..............

    What is 'ps' command for?

    The shortage for process status is ps. This command is used to display the currentlyrunning processes on Linux/Unix systems..............

    How the Swapper works?

    Moving the information from fast access memory and slow access memory and viceversa is known as swapping..............

    What is the difference between Swapping and Paging?

    Swapping performs the whole process to transfer to the disk, where as pagingperforms.............

    What is Expansion swap?

    Expansion swap is a part of hard disk. This is reserved for the purpose of storing chunksof a program.............

    What is Fork swap?

    For creation of child process, fork() system call is invoked. At the time of processing thefork() call by parent.............

    What are the requirements for a swapper to work?

    The functionality of a swapper is on the scheduling priority which is highest. Theswapper searches.............

    What is the principle of locality?

    The next most data item or instruction is the closest to the current data item orinstruction..............

    http://www.careerride.com/Linux-get-set-an-environment-variable.aspxhttp://www.careerride.com/Linux-parent-and-child-process.aspxhttp://www.careerride.com/Linux-what-is-a-daemon.aspxhttp://www.careerride.com/Linux-what-is-ps-command-for.aspxhttp://www.careerride.com/Linux-how-the-swapper-works.aspxhttp://www.careerride.com/Linux-difference-between-swapping-and-paging.aspxhttp://www.careerride.com/Linux-what-is-expansion-swap.aspxhttp://www.careerride.com/Linux-what-is-fork-swap.aspxhttp://www.careerride.com/Linux-what-are-requirements-for-a-swapper.aspxhttp://www.careerride.com/Linux-what-is-the-principle-of-locality.aspxhttp://www.careerride.com/Linux-get-set-an-environment-variable.aspxhttp://www.careerride.com/Linux-parent-and-child-process.aspxhttp://www.careerride.com/Linux-what-is-a-daemon.aspxhttp://www.careerride.com/Linux-what-is-ps-command-for.aspxhttp://www.careerride.com/Linux-how-the-swapper-works.aspxhttp://www.careerride.com/Linux-difference-between-swapping-and-paging.aspxhttp://www.careerride.com/Linux-what-is-expansion-swap.aspxhttp://www.careerride.com/Linux-what-is-fork-swap.aspxhttp://www.careerride.com/Linux-what-are-requirements-for-a-swapper.aspxhttp://www.careerride.com/Linux-what-is-the-principle-of-locality.aspx
  • 7/29/2019 Linux Interview Question

    44/45

    What is page fault? Its types.

    One of the critical parts of code in the Linux kernel. It has a major influence on memorysubsystems performance..............

    Difference between the fork() and vfork() system call.

    fork: Both the parent and child share all of the page tables until any one of them does awrite..............

    What is BSS(Block Started by Symbol)?

    UNIX linkers produce uninitialized data segments..............

    What is Page-Stealer process? Explain the paging states for a page in memory.

    The pages that are eligible for swapping are found by the Page-Stealer.............

    Explain the phases of swapping a page from the memory.

    The phases of swapping a page from the memory are:.............

    What is Demand Paging? Explain the conditions for a machine to support Demand Paging.

    The process of mapping a large address space into a relatively small amount of physicalmemory is known as demand paging..............

    Difference between Fault Handlers and the Interrupt handlers.

    Fault handlers can sleep, where as interrupt handlers cannot..............

    What is validity fault? In what way the validity fault handler concludes?

    Validity fault is the result of non setting of valid bits in main memory at the time ofrefererring a page by a process ..............

    What is protection fault?

    Protection fault is a name of an error. This error occurs when accessing storage space istried.............

    Explain how the Kernel handles both the page stealer and the fault handler.

    When the memory shortage occurs then the page stealer and fault handlerthrashes..............

    What is ex and vi? Explain their purposes.

    http://www.careerride.com/Linux-what-is-page-fault-and-types.aspxhttp://www.careerride.com/Linux-fork-and-vfork-system-call.aspxhttp://www.careerride.com/Linux-what-is-BSS.aspxhttp://www.careerride.com/Linux-what-is-page-stealer-process.aspxhttp://www.careerride.com/Linux-phases-of-swapping-a-page.aspxhttp://www.careerride.com/Linux-what-is-demand-paging.aspxhttp://www.careerride.com/Linux-fault-handlers-and-interrupt-handlers.aspxhttp://www.careerride.com/Linux-what-is-validity-fault.aspxhttp://www.careerride.com/Linux-what-is-protection-fault.aspxhttp://www.careerride.com/Linux-page-stealer-and-fault-handler.aspxhttp://www.careerride.com/Linux-what-is-ex-and-vi.aspxhttp://www.careerride.com/Linux-what-is-page-fault-and-types.aspxhttp://www.careerride.com/Linux-fork-and-vfork-system-call.aspxhttp://www.careerride.com/Linux-what-is-BSS.aspxhttp://www.careerride.com/Linux-what-is-page-stealer-process.aspxhttp://www.careerride.com/Linux-phases-of-swapping-a-page.aspxhttp://www.careerride.com/Linux-what-is-demand-paging.aspxhttp://www.careerride.com/Linux-fault-handlers-and-interrupt-handlers.aspxhttp://www.careerride.com/Linux-what-is-validity-fault.aspxhttp://www.careerride.com/Linux-what-is-protection-fault.aspxhttp://www.careerride.com/Linux-page-stealer-and-fault-handler.aspxhttp://www.careerride.com/Linux-what-is-ex-and-vi.aspx
  • 7/29/2019 Linux Interview Question

    45/45

    ex the line editor mode of vi editor. It allows to.............

    What is kill()? Explain its possible return values.

    kill() is a system call which stops a process. The return values of kill() are:.............

    Explain the steps that a shell follows while processing a command.

    The sequence of executing commands by shell are as follows:.............

    What is the difference between cmp and diff commands? Provide an example for each.

    Byte by byte comparision performed for two files comparision and displays the firstmismatch byte..............

    What is the use of grep command? Provide an example

    Grep stands for regular expression. grep command is used to find the patterns in a textfile provided by the user..............

    Difference between cat and more command.

    The file contents are displayed by cat command..............

    What is du command? What is its use?

    The du (disk usage) command is used to report the size of directory trees..............

    Explain the various prompts that are available in a UNIX system.

    UNIX supports 4 prompts: PS1: default prompt.............

    Describe how the kernel differentiates device files and ordinary files.

    There are 2 device files. They are character device file and block device file..............

    Explain how to switch to a super user status to gain privileges.

    The command ?su? is used to get super user status..............

    http://www.careerride.com/Linux-what-is-kill.aspxhttp://www.careerride.com/Linux-steps-that-a-shell-follows.aspxhttp://www.careerride.com/Linux-difference-between-cmp-and-diff-commands.aspxhttp://www.careerride.com/Linux-use-of-grep-command.aspxhttp://www.careerride.com/Linux-difference-between-cat-and-more-command.aspxhttp://www.careerride.com/Linux-what-is-du-command.aspxhttp://www.careerride.com/Linux-various-prompts-available.aspxhttp://www.careerride.com/Linux-how-kernel-differentiates-device-files-and-ordinary-files.aspxhttp://www.careerride.com/Linux-how-to-switch-to-a-super-user-status.aspxhttp://www.careerride.com/Linux-what-is-kill.aspxhttp://www.careerride.com/Linux-steps-that-a-shell-follows.aspxhttp://www.careerride.com/Linux-difference-between-cmp-and-diff-commands.aspxhttp://www.careerride.com/Linux-use-of-grep-command.aspxhttp://www.careerride.com/Linux-difference-between-cat-and-more-command.aspxhttp://www.careerride.com/Linux-what-is-du-command.aspxhttp://www.careerride.com/Linux-various-prompts-available.aspxhttp://www.careerride.com/Linux-how-kernel-differentiates-device-files-and-ordinary-files.aspxhttp://www.careerride.com/Linux-how-to-switch-to-a-super-user-status.aspx