Friday, December 12, 2014

interview question and answer

1.How do you sent a mail attachment via bash console ?
"mutt" is an opensource tool for sending emails with attachments from the linux bash command line. We can install "mutt" from the binary rpm or via packagemanager.
For Redhat / Fedor based destros,
# yum install mutt
Usage :
# mutt -s "Subject of Mail" -a "path of attachment file" "email address of recipient" < "message text containing body of the message"

Eg : mutt -s "Backup Data" -a /home/backup.tar.gz admin@example.com < /tmp/message.txt
2.What are the run levels in linux and how to change them ?
A run level is a state of init and the whole system that defines what system services are operating and they are identified by numbers.There are 7 different run levels present (run level 0-6) in Linux system for different purpose. The descriptions are given below.
0: Halt System (To shutdown the system)
1: Single user mode
2: Basic multi user mode without NFS
3: Full multi user mode (text based)
4: unused
5: Multi user mode with Graphical User Interface
6: Reboot System
To change the run level, edit the file “/etc/inittab” and change initdefault entry ( id:5:initdefault:). If we want to change the run level on the fly, it can be done using ‘init’ command.
For example, when we type ‘init 3' in the commandline , this will move the system from current runlevel to runlevl 3. Current level can be listed by typing the command 'who -r'
3.What is initrd image and what is its function in the linux booting process ?
The initial RAM disk (initrd) is an initial root file system that is mounted prior to when the real root file system is available.The initrd is bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and get at the real root file system. Thus initrd image plays a vital role in linux booting process.
4.Explain the terms suid, sgid and sticky bit ?
In addition to the basic file permissions in Linux, there are few special permissions that are available for executable files and directories.
SUID : If setuid bit is set, when the file is executed by a user, the process will have the same rights as the owner of the file being executed.
SGID : Same as above, but inherits group previleges of the file on execution, not user previleges. Similar way when you create a file within directory,it will inherit the group ownership of the directories.
Sticky bit : Sticky bit was used on executables in linux so that they would remain in the memory more time after the initial execution, hoping they would be needed in the near future. But mainly it is on folders, to imply that a file or folder created inside a stickybit enabled folder could only be deleted by the owner. A very good implementation of sticky bit is /tmp ,where every user has write permission but only users who own a file can delete them.
5.What is the difference between umask and ulimit ?
umask stands for ‘User file creation mask’, which determines the settings of a mask that controls which file permissions are set for files and directories when they are created. While ulimit is a linux built in command which provides control over the resources available to the shell and/or to processes started by it.
You can limit user to specific range by editing /etc/security/limits.conf at the same time system wide settings can be updated in /etc/sysctl.conf
6.List out few of the differences between Softlink and Hardlink ?
a) Hardlink cannot be created for directories. Hard link can only be created for a file.
b) Symbolic links or symlinks can link to a directory.
c) Removing the original file that your hard link points to does not remove the hardlink itself; the hardlink still provides the content of the underlying file.
d) If you remove the hard link or the symlink itself, the original file will stay intact.
e) Removing the original file does not remove the attached symbolic link or symlink, but without the original file, the symlink is useless
7. What is SeLinux?
SELinux is an acronym for Security-enhanced Linux. It is an access control implementation and security feature for the Linux kernel. It is designed to protect the server against misconfigurations and/or compromised daemons. It put limits and instructs server daemons or programs what files they can access and what actions they can take by defining a security policy.
8.What is the functionality of a Puppet Server ?
Puppet is an open-source and enterprise application for configuration management toll in UNIX like operating system. Puppet is an IT automation software used to push configuration to its clients (puppet agents) using code. Puppet code can do a variety of tasks from installing new software, to check file permissions, or updating user accounts and lots of other tasks.
9.Explain briefly the procedure for re-installing Grub in Linux ?
1) Download Linux Installation / Live cd
2) Boot from Linux Installation / Live cd - usb, burned cd etc.
3) During boot select "Try Linux" , Don't select install !
4) Mount your Linux root partition
sudo mount /dev/sda6 /mnt ( Assuming /dev/sda6 is the Linux root partition)
5) Install /reinstall grub
$ sudo grub-install --root-directory=/mnt/ /dev/sda ( where /dev/sda is your primary disk)
Installation finished. No error reported.
6) Reboot your system, remove bootable CD and we should have the boot menu ready when the system starts.
Note : There would be slight difference when using with other distros.

No comments:

Post a Comment