Tuesday, July 14, 2015

Linux Configuration Files and their explanations

System wide environment and startup script program.
The /dev/MAKEDEV file is a script written by the system administrator that creates local only device files or links such as device files for a non-standard device driver.
Where the user's name is matched to a nickname for e-mail.
The configuration for the BOOTP server daemon.

Lists commands and times to run them for the cron deamon.
The configuration file for the DHCP server daemon.
File for RARP mapping from hardware addresses to IP addresses. See the man page ethers(5).
The file describing exported filesystems for NFS services.
The floppy disk parameter table. Describes the formats of different floppy disks. Used by setfdprm.
Can be used to set the filesystem probe order when filesystems are mounted with the auto option. The nodev parameter is specified for filesystems that are not really locally mounted systems such as proc, devpts, and nfs systems.
Lists the filesystems mounted automatically at startup by the mount -a command (in /etc/rc or equivalent startup file).
Similar to /etc/passwd but for groups rather than users.
May contain passwords that let a user join a group.
Used to hold the group password and group administrator password information for shadow passwords.
Specifies how host names are resolved.
List hosts for name lookup use that are locally required.
Shows the host name of this host. Used for support of older programs since the hostname is stored in the /etc/sysconfig/network file.
Configuration file for init, controls startup run levels, determines scripts to start with.
Sets up the services that run under the inetd daemon.
Output by getty before the login prompt. Description or welcoming message.
Output for network logins with LINUX version
Configuration file for ld.so, the run time linker.
Configuration file for LILO.
Limits users resources when a system has shadow passwords installed.
In Debian the system time zone is determined by this link.
Sets user login features on systems with shadow passwords.
Configures the logrotate program used for managing logfiles.
The configuration file for file types. Contains the descriptions of various file formats for the file command.
The message of the day, automatically output by a successful login.
A list of currently mounted file systems. Setup by boot scripts and updated by the mount command.
Used for domain name servers.
Lists names and addresses of your own and other networks, used by the route command.
If this file exists, non-root logins are disabled. Typically it is created when the system is shutting down.
Name service switch configuration file.
The user database with fields giving the username, real name, home directory, encrypted password and other information about each user.
A configuration file for printers.
/etc/profile, /etc/cshlogin,
Files executed at login or startup time by the Bourne or C shells. These allow the system administrator to set global defaults for all users.
Describes DARPA internet protocols available from the TCP/IP subsystem. Maps protocol ID numbers to protocol names.
/etc/rc or /etc/rc.d or /etc/rc?.d
Scripts or directories of scripts to run at startup or when changing run level.
Contains files used to control run level 0. Usually these files are softlink files.
Contains files to control run level 1. Scripts beginning with an S are for start, K for kill.
Init runs this when it starts.
Configures the name resolver, specifying the address of your name server and your domain name.
Identifies secure terminals from which root is allowed to log in.
Lists the network services that the system supports.
Shadow password file on systems with shadow password software installed. Shadow passwords move the encrypted password files from /etc/passwd to /etc/shadow which can only be read by root.
Systems with shadow passwords may have this file.
Lists trusted shells. The chsh command allows users to change their login shell to shells listed only in this file.
Can be used by administrator to set the editor environment variable to some editor that is friendly to new users.
A list of users with special privileges along with the commands they can execute.
The configuration file for setting up Samba services.
Used to configure the auto mount daemon.
Used to configure the system clock to Universal or local time and set some other clock parameters.
Controls the system font settings.
This file is used to set some terminal characteristics and environment variables.
Used to configure the keyboard.
This file is used to configure the mouse.
Defines a network interface.
Used to configure pcmcia network cards.
Sets up dynamic routing policies.
Configures static routes on a network.
Used for backup tape device configuration.
The configuration file for the X server.
Configuration file for the syslogd daemon.
The terminal capability database. Describes by what "escape sequences" various terminals can be controlled. See terminfo, termcap, curs_termcap man pages.
Details for terminal I/O.
This file is used to impose special access restrictions on users.
User aliases, path modifier, and functions.
Users environment stuff and startup programs.
User actions to be done at logout.
When this file exists in the user's home directory, it will prevent check for mail, printing of the last login time, and the message of the day when the user logs in.
Contains keybindings and other bits.
Has networking and environment info.
Information about the processor such as its type, make and performance.
A list of devices configured into the currently running kernel.
Shows which DMA channels are being used at the moment.
Filesystems that are configured into the kernel. The file used to detect filesystems if the /etc/filesystems does not exist.
Shows which I/O ports are in use at the moment.
Shows which interrupts are in use and how many of each there have been.
An image of the physical memory of the system.
Messages output by the kernel. These are also routed to syslog.
Symbol table for the kernel.
The load average of the system.
Information about memory usage, both physical and swap.
Which kernel modules are currently loaded.
Contains information on filesystems currently mounted, similar to /etc/mtab
Contains status information about network protocols.
A symbolic link to the process directory of the program that is looking at /proc. When 2 process look at proc, they get different links.
Various statistics about the system such as the number of page faults since the system was booted.
The time the system has been up.
The kernel version.
FVWM-M4 defines. Contains networking, Xwindows, other setup info.
Time zone datafiles are stored here on the Debian system
Used by finger to tell when a user was last logged in.
Binary info on users that have been logged on. The last command uses this info.
Contains information about users currently logged in. Who and w commands use this file.
Used for domain name server. Placed here optionally, but this is the normal location.
Files used by domain name server. Placed here optionally, but this is the normal location.
Used to store information about failed logins. This file must be first created to activate it.
Contains information about the last time a login was done on the system. Works with lastb(1).
The normal system mail log file.
The main system message log file.
System tracking of user logins. Check this file periodically.
Where mailboxes are usually stored.

Saturday, July 11, 2015

linux interview questions and answers on file system

1.         Name the Linux specific partition types?
Ans.    0x82                     >          Linux swap
            0x83                     >          Linux
            0x8e                      >          Linux LVM
            0xfd                      >          Linux RAID auto
            0x5                        >          Extended
            0xf                         >          Windows partition
2.         How many partitions are supported by Linux?
Ans.       The maximum number of partitions supported by Linux kernel is:
            63 for IDE drives , 15 for SCSI drives
3.         Why partitions required?
Ans. Separate partitions improve performance by keeping data together which reduces the disk head seek.
4.         What are the tools used to create or manage partitions?
Ans.      Fdisk,  sfdisk             parted (GNU) - An advanced partition manipulation tool (create, copy,    resize etc.)
5.         What is the function of partprobe?
Ans.              Reinitializes the kernel's in memory copy of the partition table.
6.         How to create a filesystem?
Ans.      The mkfs command is used to create the filesystem.
            mkfs.ext2 / mkfs.ext3     >          To create ext2/ext3 filesystem
            mkfs.minix                       >          minix filesystem
            mkfs.msdos                      >          MS-DOS filesystem

7.         What is the difference between ext2 and ext3 filesystem?
Ans.        ext3 filesystem supports journaling, where as ext2 does not.
9.         What are the journaling modes supported by ext3 filesystem?
Ans.      Ordered                >          Journals only metadata (This is the default)
            Journaled              >          Journals data as well as metadata
            Writeback            >          Journal updates are not atomic, but this gives
                                                      better performance.
10.       How to convert an ext2 filesystem to ext3?
Ans       Change the /etc/fstab to specify ext3 for desired filesystem(s)
            Create the ext3 journal on the ext2 filesystem(s) as:
            # tune2fs  -j 
            If the kernel needs to have access to the ext3 module at boot time, create  a new initial ramdisk as:
            # mkinitrd  /boot/initrd-.img
11.       How to connect a file system to a Linux box?
Ans.           Mount command is used.
12.      How to find currently mounted and available filesystems?
Ans.  Use mount command without arguments.
13.      Which filesystem is referred by mount when displaying mounted & available filesystems?
Ans.   When mount command is invoked without any arguments it referes to the /etc/mtab filesystem.
14.      How to disconnect a filesystem from a Linux box?
Ans.             The umount command is used.
15.      Which command is used to display information about the processes using a filesystem?
Ans.            The fuser command is used.

16.      How to display who/what is acting on a filesystem?
Ans.            # fuser  -v  mnt_point
17.      How to kill all actions on a filesystem?
Ans.                  # fuser  -km  mnt_point
18.      How to view all the mounted and unmounted partitions?
Ans.     Use the fdisk -l command to view all the mounted and unmounted
             filesystems available on your system.   
19.      How to view only the mounted filesystems?
Ans. Use the df -k command, which shows only mounted filesystems but has the big advantage of giving you the mount points too.
20.      What is the function of e2label command?
Ans. With the help of e2label command a filesystem label can be written into the superblock of ext2/ext3 filesystem.
Eg:-           #e2label  /dev/hda3  datadisk3
 Will create a label of datadisk3 on the filesystem on partition /dev/hda3.
21.      How to display the label for a device (/dev/hdb2)?
Ans.             # e2lable  /dev/hdb2
 22.      What is the function of /etc/fstab?
Ans.  This file is referenced each time the system boots to create the desired filesystem hierarchy.
23.      What are the fields /etc/fstab containd?
Ans.            The /etc/fstab fields are:
                  Device                        >          Special device/filesystem
                                                                   label dev to mount
                  Mount_Point             >          The path used to access the
                  fs_type                       >          The filesystem type
                  Options                       >          List of Options (each is
                                                                   separated by a comma)
                  Dump frequency        >          Level 0 dump freq (0 = never
                                                                  dump, 1 = daily &
                                                                  2 = every other day)
                  fsck Order                  >         0 = ignore, 1 = first (root
                                                                  should have this value),
                                                                  2 to 9 = 2nd, 3rd and so on.
                                                                  NFS & CD-ROM s should                                                                    be ignored (i.e., value 0).

24.      How to list the ext2/ext3 filesystem attributes?
Ans.    lsattr  command displays file attributes

25.      How to change the ext2/ext3 filesystem attributes?
      Ans.   chattr command changes the file attributes.

26.    What is swap space?
Ans.  Swap space is supplement to system RAM.

27.    How to set up swap partition?
Ans.  Steps involved in setting up swap partition.
         Create a partition using a partitioning program (fdisk/sfdisk/parted)
         Set partition id type to 0x82.
         Create the signature on the partition using the mkswap command
         # mkswap  -v1  /dev/hdb3
        Add an entry for the swap in /etc/fstab file as:
        /dev/hdb3   swap   swap   defaults    0   0
        Activate the swap partition using
        # swapon -a
        Check the swap partition status using
        # swapon  -s

28.    How to create a swap file?
Ans.  Create a file as
         # dd  if=/dev/zero  of=swapfile   bs=512  count=N
         (Where N is the file size in KB)
         Run the mkswap to create signature
         Activate the swap file with swapon command (OR) initialize it in the startup
         script /etc/rc.d/rc.local

29.    Why fsck used?
Ans.  fsck (filesystem check) is used to maintain filesystem consistency.

30.    When the system runs the fsck and which script invokes it?
Ans.  When the system boots,  the rc.sysinit script runs the fsck on any filesystems
         marked for checking in /etc/fstab file. If any of these filesystems are markes as 
         dirty or have data in the journal, fsck will attempt to repair them. If it succeeds,
         the filesystems will be mounted and boot process continues, else rc.sysinit will
         run sulogin and will report that fsck needs to be run manually.

31.    What is e2fsck command?
Ans.  fsck is a front end tool for e2fsck.

32.    What is journaling?
33.    Types of journals and their function?
Ans.  Ordered          :    This is the default and journal only meta-data
         Journaled        :    Journals data and meta-data
         Writeback       :    Journal updates are not atomic.

34.    Differentiate ext2 and ext3 file systems?
Ans.  ext3 filesystem supports journaling concept where ext2 does not.

35.    What is the function of tune2fs command?
Ans.  This is used to modify the filesystem attributes (Like converting ext2 to ext3).

36.    What is the function of dump2fs command?
Ans.  Provides a dump of file system information to standard out (Console). Can be
         redirected to a file.

37.    What is the function of debugfs command?
Ans.  This utility is used to to examine and debug an ext2 filesystem. This can also be
         used to manually verify the inode integrity and an aid to recover data.

38.    What is the function of resize2fs command?
Ans.  This can be used to change the size of an ext2 or ext3 filesystem.