Linux Basics

What is the default Window system / Windows manager used in Linux?

X.org

What is LILO?

LILO stands for Linux boot loader. It will load the MBR, master boot record, into the memory, and tell the system which partition and hard drive to boot from.

Describe Linux boot-up sequence

BIOS reads the MBR where Boot Loader sits, Boot Loader reads Kernel into memory, Kernel starts Init process, Init reads inittab, executes rc.sysinit, the rc script than starts services to reach the default run level and once this is done the last thing that gets run is the rc.local script.

Is Linux / UNIX file system case sensitive? Give one example

Yes, test.txt and TEST.txt are two different files

What file contains the list of drives that are mounted at boot?

   /etc/fstab – Linux / Other UNIX version
   /etc/vfstab – Solaris UNIX

Explain the usage of the fourth field in /etc/fstab?

It is formatted as a comma separated list of options. Read mount command man page for all the option.

What is /etc/inittab file? In what file is the default run level defined?

System V init examines the ‘/etc/inittab’ file for an ‘initdefault’ entry, which tells init whether there is a default runlevel. init is the program on Unix that spawns all other processes. It runs as a daemon and typically has PID 1.
       cat /etc/inittab
Common runlevle values on RHEL
    1. Halt
    1. Single user mode
    1. Reboot
    1. Default text
    1. Default GUI

What is POSIX? Name 2 POSIX-oriented operating systems?

Portable Operating System Interface is the collective name of a family of related standards specified by the IEEE to define the application programming interface (API). HP-UX, Solaris, AIX etc

Specify special usage for each one of the following file

  • /dev/null – Send unwanted output
  • /dev/random – Random number generation
  • /dev/zero – Cache or Destroy data on a partition – dd if=/dev/zero of=/dev/sda98

What is ‘inode’?

All files have its description stored in a structure called ‘inode’. The inode contains info about the file-size, access and modification time, permission and so on. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file.Inodes store information on files such as user and group ownership, access mode (read, write, execute permissions) and type of file. There is a fixed number of inodes, which indicates the maximum number of files each file system can hold.

Why do you need to have a swap file system?

A swap file (or swap space or, in Windows NT, a pagefile) is a space on a hard disk used as the virtual memory extension of a computer's real memory (RAM). Having a swap file allows your computer's operating system to pretend that you have more RAM than you actually do. The least recently used files in RAM can be "swapped out" to your hard disk until they are needed later so that new files can be "swapped in" to RAM. In larger operating systems (such as IBM's OS/390), the units that are moved are called pages and the swapping is called paging.
One advantage of a swap file is that it can be organized as a single contiguous space so that fewer I/O operations are required to read or write a complete file.

What is the difference between Hard Link and Soft Link in Linux?

Hard Link is a mirror copy of the original file. Hard links share the same inode. Any changes made to the original or Hard linked file will reflect the other. Even if you delete any one of the files, nothing will happen to the other.Hard links can’t cross file systems.
Soft Link is a symbolic link to the original file. Soft Links will have a different Inode value.A soft link points to the original file. If you delete the original file, the soft link fails. If you delete the soft link, nothing will happen. Soft links can cross file systems.

Command which is use for create quota database in Linux.

  • quotacheck -cug /home
  • quotacheck -vu

What is the main advantage of creating links to a file instead of copies of the file?

The main advantage is not really that it saves disk space (though it does that too) but, rather, that a change of permissions on the file is applied to all the link access points. The link will show permissions of lrwxrwxrwx but that is for the link itself and not the access to the file to which the link points. Thus if you want to change the permissions for a command, such as su, you only have to do it on the original. With copies you have to find all of the copies and change permission on each of the copies.

What commands can you use to review boot messages?

dmesg

Write a command to find all of the files which have been accessed within the last 30 days.

     find / -type f -atime -30 > December.files   
This command will find all the files under root, which is ‘/’, with file type is file. ‘-atime -30′ will give all the files accessed less than 30 days ago. And the output will put into a file call December.files.

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

  • Root "/" file system : The kernel needs a root file system to mount at start up. The root file system is generally small and should not be changed often as it may interrupt in booting. The root directory usually does not have the critical files. Instead sub directories are created. E.g. /bin (commands needed during bootup), /etc (config files) , /lib(shared libraries).
  • /usr filesystem : this file system is generally large as it contains the executable files to be shared amongst different machines. Files are usually the ones installed while installing Linux. 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. Sub directories include /bin, /include, /lib, /local (for local executables)
  • **/var filesystem **: this file system is specific to local systems. It is called as var because the data keeps changing. The sub directories include /cache/man (A cache for man pages), /games (any variable data belong to games), /lib (files that change), /log (log from different programs), /tmp (for temporary files)
  • /home filesystem : - this file system differs from host to host. User specific configuration files for applications are stored in the user's home directory in a file. UNIX creates directories for all users directory. E.g /home/my_name. Once the user is logged in ; he is placed in his home directory.
  • **/proc filesystem **: this file system does not exist on the hard disk. It is created by the kernel 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 state of the kernel .Few of the Directories include /1 (directory with information about process num 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)


How do I use chmod and chown command under Linux?

Use chown command to change file owner and group information. Use chmod command to change file access permissions such as read, write etc.

what is the command for finding the highest memory occupied file in Linux?

    du -sh * | sort -nr    

How to create swap if you don’t have free partition?

This is some what tricky question if you are new to Linux Administration here is the command to create swap if you don’t have free partition before doing this you have switch off the swap
     swapoff -a
     dd if=/dev/zero of=/root/swapfile bs=1k count=1024
     swapon filename

How to see swap details?

     cat /proc/swap
     free

How to see/get info about RAM in your system

    free
    cat /proc/meminfo

What is the difference between ext2 and ext3

      ext3=ext2+journaling   
"Journaling" is an add-on to a file system that records changes as they are made. ext2 files system is fast ,less disk writes ext2 file system in less stable/secure .ext2 file system required to run fsck command if the system get crashed

How to convert ext2 file system to ext3?

   tune2fs -j /dev/hda1

How convert ext3 file system to ext2

  tune2fs -O^has-journal /dev/hda1

What is default block/chunk size for PV

   4MB

What is the command to update the disk quota on file system

  mount -o remount,rw /home

What is the partition type number for swap,RAID,LVM?

82(swap),fd(RAID),8e(LVM)

What is RAID?

RAID, stands for Redundant Array of Inexpensive Disks. RAID is a method by which same data or information is spread across several disks, using techniques such as disk striping (RAID Level 0), disk mirroring (RAID Level 1), and disk striping with parity (RAID Level 5) to achieve redundancy, lower latency, increased bandwidth, and maximized ability to recover from hard disk crashes.

Explain RAID 0?

RAID level 0 works on “striping” technique. In RAID 0 the array is broken down into strips and data is written into strips. RAID 0 allows high I/O performance but provides no redundancy. RAID 0 Array Size is equal to sum of disks in array. If one drive fails then all data in the array is lost.

Explain RAID 1?

RAID Level 1 is based on Mirroring technique. Level 1 provides redundancy by writing identical data to each member disk of the array. The storage capacity of the level 1 array is equal to the capacity of one of the mirrored hard disks in a Hardware RAID or one of the mirrored partitions in a Software RAID. RAID 1 provides redundancy means good protection against disk failure. In RAID 1 write speed is slow but read speed is good.

Explain RAID 5?

RAID Level 5 is based on rotating parity with striping technique. RAID-5 stores parity information but not redundant data (but parity information can be used to reconstruct data). The storage capacity of Software RAID level 5 is equal to the capacity of the member partitions, minus the size of one of the partitions if they are of equal size. The performance of RAID 5 is based on parity calculation process but with modern CPUs that usually is not a very big problem. In RAID 5 read and write speeds are good.

What is LVM?

LVM stands for Logical Volume Manager. LVM, is a storage management solution that allows administrators to divide hard drive space into physical volumes (PV), which can then be combined into logical volume groups (VG), which are then divided into logical volumes (LV) on which the file system and mount point are created.

What are the steps to create LVM?

  • Create physical volumes by “pvcreate” command
        pvcreate /dev/sda2
    
  • Add physical volume to volume group by “vgcreate” command
        vgcreate VLG0 /dev/sda2
    
  • Create logical volume from volume group by “lvcreate” command.
       lvcreate -L 1G -n LVM1 VLG0
    
  • Now create file system on /dev/sda2 partition by “mke2fs” command.
      mke2fs -j /dev/VLG0/LVM1
    

What is Volume group (VG)?

The Volume Group is the highest level abstraction used within the LVM. It gathers together a collection of Logical Volumes and Physical Volumes into one administrative unit.

Tell me all steps to remove a LVM?

To remove a logical volume from a volume group, first unmount it with the umount command: umount /dev//
and then use the lvremove command:
    lvremove /dev/<vgname>/<lvname>

What is disk Quota?

Disk quota is nothing but restricting the disk-space usage to the users. Disk quota can be implemented in two ways,
  • One on INODE
  • two on BLOCK
Soft limit - this is the disk limit where the user gets just a warning msg saying that your disk quota is going to expire. This is just a warning, no restriction on data creation
Hard limit - this is the disk limit where user gets error message, I repeat user gets error message stating that unable to create data

How SSL works?

The Secure Sockets Layer (SSL) is a commonly-used protocol for managing the security for transmission of messages on the Internet. It not only encrypts the data but determines whether both client and server has the expected authentication.
Working of SSL :
  • Web Browser checks for the certificate to make sure that the site you are connecting to is the real site and not someone intercepting.
  • Determine encryption types that the browser and website server can both use to understand each other.
  • Unique codes are send to the browser & server which are used for encryption (server side) & decryption (browser side)
  • The browser and Server start communicating; the web browser shows the encrypting icon and web pages are processed secured.
SSL has recently been succeeded by Transport Layer Security (TLS), which is based on SSL. The TLS protocol allows client/server applications to communicate across a network in a way designed to prevent eavesdropping and tampering.
Working of TLS : A TLS client and server negotiate on various parameters used to establish the connection securily by using a handshaking procedure.
The handshake begins when a client connects to a TLS-enabled server requesting a secure connection and presents a list of supported ciphers and hash functions.
From this list of supported ciphers & has functions, the server chooses the strongest cipher and hash function that it can support and notifies the client about decision.
The server sends back its identification in the form of a digital certificate. The certificate usually contains the server name, the trusted certificate authority (CA) and the server's public encryption key.
Now the client confirms the validity of the certificate by verifing it with CA.
The client encrypts a random number with the server's public key and sends the result to the server. Only the server should be able to decrypt it, with its private key. This random number, is used for encryption (server side) & decryption (browser side).If any one of the above steps fails, the TLS handshake fails and the connection is not created.
TLS and SSL are an integral part of most Web browsers (clients) and Web servers. If a Web site is on a server that supports SSL, SSL can be enabled and specific Web pages can be identified as requiring SSL access. Any Web server can be enabled by using Netscape's SSLRef program library which can be downloaded for noncommercial use or licensed for commercial use. TLS and SSL are not interoperable. However, a message sent with TLS can be handled by a client that handles SSL but not TLS.

What is Kernel? Explain the task it performs.

Kernel is used in UNIX like systems and is considered to be the heart of the operating system. 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. Kernel assists the processes in doing so.For the processes to access and make use of these services, system calls are used.

Different types of Kernel .

Monolithic Vs Modular Kernel
Monolithic kernel is one single program that contains all of the code necessary to perform every kernel related task. Most UNIX and BSD kernels are monolithic by default.
Some advantages hinge on these points:
  • Since there is less software involved it is faster. As it is one single piece of software it should be smaller both in source and compiled forms.
  • Less code generally means less bugs which can translate to fewer security problems.
Modular kernel allows an administrator to add functionality only when required. Keeping only what's necessary in kernel memory reduces the kernel's memory footprint and increases its overall performance. A few advantages to the modular kernel are: Faster development time for drivers that can operate from within modules. No reboot required for testing (provided the kernel is not destabilized). On demand capability versus spending time recompiling a whole kernel for things like new drivers or subsystems. Faster integration of third party technology (related to development but pertinent unto itself nonetheless).

What is Initial Ram disk?

An initial ram disk is a temporary file system used in the boot process of the Linux kernel. initrd and initramfs refer to slightly different schemes for loading this file system into memory. Both are commonly used to make preparations before the real root file system can be mounted.

Explain Different Option for updating kernel?

1.Install new kernel from rmp file
  • Get the Newest kernel and put in /tmp
  • rpm -i /tmp/kernal-2.4.19-3.i386.rpm (Not ugrading.can be switched to old keranl if need)
  • Now Kernal ,RamDisk etc..are installed in /boot
  • New stanza added to grub.com (you need alter "default")
  1. Customizes, install and configure from kernel source code. Required RMP's tool for customising kernel source code.
  • Kernel-source-*
  • glibc-kernheaders-*
  • glibc-deve;-*
  • cpp-*
  • binutils-*
  • gcc-*
  • tcl-*
  • tk-*

Explain the Steps to compile and install kernel?

make mrproper -- clean up the directory tree make xconfig -- tools for customixing the kernal make dep --- makes and build the dependecies make clean --- cleans any unecessary files used to build the previous steps make bzimage -- actually builds the kernelmake modules -- Builds the modules make modules_install -- Install kernel modules make install -- copy the new kernel files to associated directory.

Explain Linux Services ?.

A Linux service is an application (or set of applications) that runs in the background waiting to be used, or carrying out essential tasks.
Directory /etc/rc.d , Here you will find either a set of files named rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6, or a set of directories named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. You will also find a file named /etc/inittab. The system uses these files (and/or directories) to control the services to be started.
If you look in the file /etc/inittab you will see something like: id:4:initdefault:
0:0:wait:/etc/rc.d/rc.0l
6:6:wait:/etc/rc.d/rc.6x
1:4:wait:/etc/rc.d/rc.4
The boot process uses these parameters to identify the default runlevel and the files that will be used by that runlevel. In this example, runlevel 4 is the default and the scripts that define runlevel 4 can be found in /etc/rc.d/rc.4. Services that get started at a certain runtime are determined by the contents of the various rcN.d directories. Most distributions locate these directories either at /etc/init.d/rcN.d or /etc/rcN.d. (Replace the N with the run-level number.).In each run-level you will find a series of if links pointing to start-up scripts located in /etc/init.d. The names of these links all start as either K or S, followed by a number. If the name of the link starts with an S, then that indicates the service will be started when you go into that run level. If the name of the link starts with a K, the service will be killed (if running).The number following the K or S indicates the order the scripts will be run.

Comments

  1. Thanks Prashant for posting this valuable information which is expansive and simple to understand. Thanks for putting in simple-to-understand laymans language :)

    ReplyDelete
  2. Dear Prasant,

    I would like to thank you for your valuable information. It's very easy to be hard to understand.

    Regards,
    Vijay

    ReplyDelete
  3. Dear Prashanth P.Nair,

    Thanks a lot for posting this valuable interview question and answers.

    Thanks & Regards,
    Vasant

    ReplyDelete
  4. Nice blog. Very informative. Thanks for sharing. Keep updating. If you want to learn Linux course in online, please visit below site.
    Linux Online Training
    linux online course
    Linux Online Training in Hyderabad
    Linux Online Training in Bangalore
    Linux Online Training in Chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

Docker ,MakeFile and Jenkins pipeline

Networking Basics

Continuous Deployment - Jenkins , Capistrano And Docker.