Saturday, June 14, 2014




VSFTP
In Linux Like operating system vsftpd(Very Secure FTP Daemon) is ftp server , which provides the features of downloading and uploading files to the ftp space. In this article we will discuss most common ftp server interview questions along with the Answers.
Q:1 What does VSFTPD Stands for ?
Ans: VSFTPD stands for Very Secure FTP Daemon.
Q:2 What are the defaults ports used in linux ftp server ?
Ans: Port 20 – This is the data transfer port. All the all subsequent data transfers between the client and server are done using this port.
Port 21 – On this port control connection is established. All commands we send and the ftp server’s responses to those commands will go over the control connection, but any data sent back (such as “ls” directory lists or actual file data in either direction) will go over the data connection.
Q:3 What are most common features of vsftpd ?
Ans:some of the Common Features are listed below :
    Virtual IP configurations
    Virtual users
    Standalone or inetd operation
    Powerful per-user configurability
    Bandwidth throttling
    Per-source-IP configurability
    Per-source-IP limits
    IPv6
    Encryption support through SSL integration
Q:4 What is the configuration file of vsftpd ?
Ans: ‘/etc/vsftp/vsftpd.conf’

Q:5 How to restart the service of ftp server in linux ?
Ans: Service vsftpd restart or /etc/init.d/vsftpd restart
Q:6 Which Users tare not allowed to login via ftp ?
Ans: Users mentioned in the file ‘/etc/vsftpd/ftpusers’ are not allowed to login via ftp.
Q:7 How to disable standard ftpd xferlog log format and enable default vsftpd log ?
Ans : Edit the file ‘ /etc/vsftpd/vsftpd.conf’ & make the below changes:
    xferlog_std_format=NO
    log_ftp_protocol=YES
The default vsftpd log file is /var/log/vsftpd.log
Q:8 What is default directory for ftp / Anonymous user ?
Ans : ‘/var/ftp’ is the default directory for ftp or Anonymous user.
Q:9 How to change the default directory for ftp / Anonymous user ?
Ans: Edit the file ‘/etc/vsftpd/vsftpd.conf’ and change the below directive :
    anon_root=/<Path-of-New-Directory>.
After making above change either restart or reload vsftpd service.
Q:10 How to disable Anonymous user in vsftpd ?
Ans: Edit the conf file ‘/etc/vsftpd/vsftpd.conf’ and chnage below directive and restart the ftp service.
    anonymous_enable=NO.
Q:11 What is chroot environment in ftp server ?
Ans: chroot environment prevents the user from leaving its home directory means jail like environment where users are limited to their home directory only. It is the addon security of ftp server.
Q:12 How to enable chroot environment in vsftpd server ?
Ans : To enable chroot environment edit the file ‘/etc/vsftpd/vsftpd.conf’ and enable the below directives :
    chroot_list_enable=YES
    chroot_list_file=/etc/vsftpd.chroot_list

The chroot_list_file variable specifies the file which contains users that are chroot.
Q:13 How to enable only limited/allowed users are able to login via ftp ?
Ans: This can be done by editing the file ‘/etc/vsftpd/vsftpd.conf’ and add the below directives :
    userlist_enable=YES
    userlist_file=/etc/vsftpd.user_list
    userlist_deny=NO
The file specified by userlist_file will now contain users that are able to login.
Q:14 How to set ftp banner in linux ?
Ans: Open the file ‘/etc/vsftpd/vsftpd.conf’ and set the below directive :
    ftpd_banner= “Enter New Banner Here”
Q:15 How To limit the data transfer rate, number of clients & connections per IP for local users ?
Ans: Edit the ftp server’s config file(/etc/vsftpd/vsftpd.conf) and set the below directives :
    local_max_rate=1000000 # Maximum data transfer rate in bytes per second
    max_clients=50 # Maximum number of clients that may be connected
    max_per_ip=2 # Maximum connections per IP.
LVM
Q:1 Why is LVM is required ?
Ans: LVM stands for Logical Volume Manager , to resize filesystem’s size online we required LVM partition in Linux. Size of LVM partition can be extended and reduced using the lvextend & lvreduce commands respectively.
Q:2 How To check Memory stats and CPU stats ?
Ans:  Using ‘free’ & ‘vmstat’ command we can display the physical and virtual memory statistics respectively.With the help of ‘sar’ command we see the CPU utilization & other stats.
 Q:3 What does Sar provides and at which location Sar logs are stored ?
Ans: Sar Collect, report, or save system activity information. The default version of the sar command (CPU utilization report) might be one of the first facilities the  user  runs  to  begin system  activity investigation, because it monitors major system resources. If CPU utilization is near 100 percent (user + nice + system), the workload sampled is CPU-bound.

By  default log files of Sar command  is located at  /var/log/sa/sadd file, where the dd parameter indicates the current day.
 Q:4 How to increase the size of LVM partition ?
Ans: Below are the Logical Steps :
- Use the lvextend command (lvextend -L +100M /dev/<Name of the LVM Partition> , in this example we are extending the size by 100MB.
- resize2fs /dev/<Name of the LVM Partition>
- check the size of partition using ‘df -h’ command
 Q:5 How to reduce or shrink the size of LVM partition ?
Ans: Below are the logical Steps to reduce size of LVM partition :
-Umount the filesystem using umount command,
-use resize2fs command , e.g resiz2fs /dev/mapper/myvg-mylv 10G
-Now use the lvreduce command , e.g lvreduce -L 10G /dev/mapper/myvg-mylv
Above Command will shrink the size & will make the filesystem size 10GB.
 Q:6 How to create partition from the raw disk ?
Ans: Using fdisk utility we can create partitions from the raw disk.Below are the steps to create partition from the raw dsik :
- fdisk  /dev/hd* (IDE) or /dev/sd* (SCSI)
- Type n to create a new partition
-  After creating partition , type w command to write the changes to the partition table.
 Q:7 Where the kernel modules are located ?
Ans: The ‘/lib/modules/kernel-version/’ directory stores all kernel modules or compiled drivers in Linux operating system. Also with ‘lsmod’ command we can see all the installed kernel modules.
 Q:8 What is umask ?
Ans: 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.

 Q:9 How to set the umask permanently for a user?
Ans: To set this value permanently for a user, it has to be put in the appropriate profile file which depends on the default shell of the user.
 Q:10 How to change the default run level in linux ?
Ans: To change the run level we have to edit the file “/etc/inittab” and change initdefault entry ( id:5:initdefault:). Using ‘init’ command we change the run level temporary like ‘init 3′ , this command will move the system in runlevl 3.
 Q:11 How to share a directory using nfs ?
Ans: To share a directory using nfs , first edit the configuration file ‘/etc/exportfs’ , add a entry like
‘/<directory-name>  <ip or Network>(Options)’ and then restart the nfs service.
 Q:12 How to check and mount nfs share ?
Ans: Using ‘showmount’ command we can see what directories are shared via nfs e.g ‘showmount -e <ip address of nfs server>’.Using mount command we can mount the nfs share on linux machine.
 Q:13 What are the default ports used for SMTP,DNS,FTP,DHCP,SSH and squid ?
Ans: Service      Port
SMTP          25
DNS            53
FTP             20 (data transfer) , 21 ( Connection established)
DHCP         67/UDP(dhcp server) , 68/UDP(dhcp client)
SSH            22
Squid         3128
Httpd                    80
 Q:14 What is Network Bonding ?
Ans: Network bonding is the aggregation of multiple Lan cards into a single bonded interface to provide fault tolerance and high performance. Network bonding is also known as NIC Teaming.
Q:15 What  are the different modes of Network bonding in Linux ?
Ans: Below are list of modes used in Network Bonding :
   balance-rr or 0 – round-robin mode for fault tolerance and load balancing.
    active-backup or 1 – Sets active-backup mode for fault tolerance.
    balance-xor or 2 – Sets an XOR (exclusive-or) mode for fault tolerance and load balancing.
    broadcast or 3 – Sets a broadcast mode for fault tolerance. All transmissions are sent on all slave interfaces.
    802.3ad or 4  – Sets an IEEE 802.3ad dynamic link aggregation mode. Creates aggregation groups that share the same speed & duplex settings.
    balance-tlb or 5 -  Sets a Transmit Load Balancing (TLB) mode for fault tolerance & load balancing.
    balance-alb or 6 -  Sets an Active Load Balancing (ALB) mode for fault tolerance & load balancing.

 Q:16 How to check and verify the status the bond interface.
Ans: Using the command ‘cat /proc/net/bonding/bond0′ , we can check which mode is enabled and what lan cards are used in this bond. In this example we have one only one bond interface but we can have multiple bond interface like bond1,bond2 and so on.
 Q:17 How to check default route and routing table ?
Ans: Using the Commands ‘netstat -nr’ and ‘route -n’ we can see the default route and routing tables.
 Q:18 How to check which ports are listening in my Linux Server ?
Asn:  Use the Command ‘netstat –listen’ and ‘lsof -i’
 Q:19 List the services that are enabled at a particular run level in linux server ?
Ans: With the help of command ‘chkconfig –list | grep 5:on’ we can list all the service that are enabled in run level5. For other run levels just replace 5 with the respective run level.
 Q:20 How to enable a service at a particular run level ?
Ans: We can enable a service using the Command ‘chkconfig <Service-Name> on –level 3′
 Q:21 How to upgrade Kernel in Linux ?
Ans: We should never upgrade Linux Kernel , always install the new New kernel using rpm command because upgrading a kenel can make your linux box in a unbootable state.
 Q:22 How To scan newly asssigned luns on linux box without rebooting ?
Ans: There are two ways to scan newly assigned luns :
Method:1 if sg3 rpm is installed , then run the command ‘rescan-scsi-bus.sh’
Method:2 Run the Command ,  echo ” – - – ” > /sys/class/scsi_host/hostX/scan
 Q:23 How  to find WWN numbers of HBA cards in Linux Server ?
Ans: We can find the WWN numbers of HBA cards using the command ‘systool -c fc_host -v | grep port_name’
 Q:24 How to add & change the Kernel parameters ?
Ans: To Set the kernel parameters in linux , first edit the file ‘/etc/sysctl.conf’ after making the changes save the file and run the command ‘sysctl -p’ , this command will make the changes permanently without rebooting the machine.
Q:25 What is Puppet Server ?
Ans: Puppet is an open-source & enterprise software for configuration management toll in UNIX like  operating system.  Puppet is a  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 & lots of other tasks.
 Q:26 What are manifests in Puppet ?
Ans: Manifests, in Puppet, are the files in which the client configuration is specified.
 Q:27 Which Command is used to sign requested certificates in Puppet Server ?
Ans: ‘puppetca  –sign hostname-of-agent’ in (2.X)  & ‘puppet ca  sign hostname-of-agent’ in  (3.X)
 Q:28  At which location  Puppet Master Stores Certificates ?
Ans:  /var/lib/puppet/ssl/ca/signed
 Q:29 How to find all the regular files in a directory  ?
Ans: using the command ‘find /<directory -type f’.
 Q:30 What is load average in a linux ?
Ans: Load  Average is defined as the average sum of the number of process waiting in the run queue and number of process currently executing over the period of 1,5 and 15  minutes. Using the ‘top’ and ‘uptime’ command we find the load average of a linux sever.


BASIC
In this tutorial we will discuss most frequently asked linux system admin interview questions for Beginners. Below are the list of L1 level linux interview questions..
Q:1 How To check the uptime of a Linux Server ?
Ans: Using uptime command we can determine how long a linux box has been running , also uptime can be viewed by the top & w command.
Q:2 How to check which Redhat version is installed on Server ?
Ans: Use the command cat /etc/redhat-release , output of this command will tell you the redhat version.
Q:3 How to install rpm packages in Redhat & CentOS linux ?
Ans: rpm and yum command are used to install packages in redhat linux and CentOS.
Q:4 How to check the ip address of LAN Card ?
Ans: Using 'ifconfig' & 'ip address' command we can determine the ip address of LAN Card.
Q:5 How to determine the hostname of a linux box ?
Ans: On typing the hostname command on terminal we can determine the hostname of a linux server.
Q:6 How To check the default gatway ?
Ans: Using 'rount -n' command we can determine the default gateway in linux.
Q:7 Which Command is used to check the kernel Version ?
Ans: 'uname -r'
Q:8 How to check the current runlevel of a linux box ?
Ans : 'who -r' and 'runlevel' , both of these command are used to find current run level.
Q:9 What is Initrd ?
Ans: Initrd stands for initial ram disk , which contains the temporary root filesystem and neccessary modules which helps in mounting the real root filesystem in read mode only.
Q:10 What is Bootloader ?
Ans: Bootloader is a program that boots the operating system and decides from which kernel OS will boot.
Q:11 How to list hidden files from the command line ?
Ans: 'ls -a' <Folder_Name>
Q:12 What is soft link ?
Ans: Soft link is a method to create short cuts in linux. It is similar to windows short cut feature.
Q:13 How to create a blank file in linux from command line ?
Ans: Using the command 'touch <file-name>'
Q;14 What is run level 2 ?
Ans: Run level 2 is the multi-user mode without networking.
Q:15 Why linux is called OpenSource ?
Ans: Becuase One can customize the existing code and can redistribute it.
 Q:16 How to check all the installed Kernel modules ?
Ans: Using the Command 'lsmod' we can see the installed kernel modules.
Q:17 What is the default uid & gid of root user ?
Ans: Default uid & gid of root user is 0.
Q:18 How To change the password of user from the Command Line ?
Ans: 'passwd <User-Name>'
Q:19 What is a Process ?
Ans: Any program in execution is called a process.
Q:20 What is name of first process in linux ?
Ans: 'init' is the first process in linux which is started by kernel and whose pid is 1.
Q. What is a port?
A port is piece of software which is used as docking point in your machine, where remote application can communicate. This is analogy to the physical ports for entering in to a country from different sea ports.
 
Q. What is hardware port?
This is a physical peripheral connecting point to a machine from a physical device.
 
Q. What is a socket?
Socket is combination of software Port and IP address.
 
Q. What is the range of ports or how many ports are there?
Port numbers can vary from 0 to 65535, so total we can get 65536 ports
 
Q. Why port numbers are just 65536?
This is because limitation in TCP/IP stack where the port number field is just 16bit size. So we get only 2^16(2 to the power of 16) ports which are equal to 65536 available ports
 
Q.What are the well-known ports or assigned ports or default ports?
Well known ports are from 0 to 1023(total 2^10=1024 ports)
 
Q.What do you mean by default port?
Default port is a designated port for particular well-known service such as web server, mail server, ftp server etc. By default FTP uses 21 port, DNS uses 53 and Apache uses 80 port.
 
Q.Can we change default port for a service(example Apache, squid)?
Yes, we can change. In Apache and DNS we can change this using listen configuration entry in httpd.conf and named.conf. Squid have port entry in its squid.conf file to mention port number.
 
Q.What are the protocol numbers for TCP and UDP?
Do not confuse this one with port numbers. TCP and UDP have their own numbers in TCP/IP stack.
TCP protocol number:6
UDP protocol number:17
 
Q. Is there any way I can see all the port information in Linux?
Yes, you can get that from /etc/services files.
 
Q. How can I see open ports in Linux?
20 – FTP Data (For transferring FTP data)
21 – FTP Control (For starting FTP connection)
22 – SSH(For secure remote administration which uses SSL to encrypt the transmission)
23 – Telnet (For insecure remote administration
25 – SMTP(Mail Transfer Agent for e-mail server such as SEND mail)
53 – DNS(Special service which uses both TCP and UDP)
67 – Bootp
68 – DHCP
69 – TFTP(Trivial file transfer protocol uses udp protocol for connection less transmission of data)
80 – HTTP/WWW(apache)
88 – Kerberos
110 – POP3(Mail delivery Agent)
123 – NTP(Network time protocol used for time syncing uses UDP protocol)
137 – NetBIOS(nmbd)
139 – SMB-Samba(smbd)
143 – IMAP
161 – SNMP(For network monitoring)
389 – LDAP(For centralized administration)
443 – HTTPS(HTTP+SSL for secure web access)
514 – Syslogd(udp port)
636 – ldaps(both tcp and udp)
873 – rsync
989 – FTPS-data
990 – FTPS
993 – IMAPS
1194 – openVPN
1812 – RADIUS
995 – POP3s
2049 – NFS(nfsd, rpc.nfsd, rpc, portmap)
2401 – CVS server
3306 – MySql
3690 – SVN
6000-6063-X11
 
Q. What is the default Window system / Windows manager used in Linux?

Ans :X.org

Q. What is LILO?

Ans:  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.

Q. Describe Linux boot-up sequence

Ans: 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.

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

Ans: 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

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

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

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

Ans: 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
0. Halt
1. Single user mode
6. Reboot
3. Default text
5. Default GUI



Q. 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

Q. Specify special usage for each one of the following file

Ans:/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

Q. What is ‘inode’?

ANS:   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.

Q. Why do you need to have a swap file system?

Ans:  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.


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

Ans:  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.


Q. Command which is use for create quota database in Linux.

Ans:
       quotacheck -cug /home
       quotacheck -vu


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

Ans: 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.

Q.What commands can you use to review boot messages?

Ans: dmesg

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

Ans:   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.
 
Q. Explain file system of linux. The root "/" filesystem, /usr filesystem, /var filesystem, /home filesystem, /proc filesystem.

Ans: 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)

Q. How do I use chmod and chown command under Linux?

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


Q. what is the command for finding the highest memory occupied file in Linux?
#du -sh * | sort -nr


Q. 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

Q. How to see swap details?

Ans:
            cat /proc/swap
free

Q. How to see/get info about RAM in your system
  
Ans:
free
cat /proc/meminfo

Q. What is the difference between ext2 and ext3

Ans: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

Q. How to convert ext2 file system to ext3?

Ans:  tune2fs -j /dev/hda1


Q. How convert ext3 file system to ext2

Ans:   tune2fs -O^has-journal /dev/hda1

Q. What is default block/chunk size for PV

 Ans: 4MB

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

Ans:  mount -o remount,rw /home

Q.What is the partition type number for swap,RAID,LVM?
  
Ans: 82(swap),fd(RAID),8e(LVM)

Q. What is RAID?

Ans: 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.

 Q. Explain RAID 0?

Ans: 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.

Q: - Explain RAID 1?

Ans: 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.

Q . Explain RAID 5?
Ans: 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.

Q.What is LVM?
Ans: 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.

Q. What are the steps to create LVM?
Ans:  
A. Create physical volumes by “pvcreate” command
      #pvcreate /dev/sda2
B. Add physical volume to volume group by “vgcreate” command
                 #vgcreate VLG0 /dev/sda2
C. Create logical volume from volume group by “lvcreate” command.
     #lvcreate -L 1G -n LVM1 VLG0
D. Now create file system on /dev/sda2 partition by “mke2fs” command.
     #mke2fs -j /dev/VLG0/LVM1

Q. What is Volume group (VG)?
Ans: 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.

Q.Tell me all steps to remove a LVM?
Ans: To remove a logical volume from a volume group, first unmount it with the umount command:

umount /dev/<vgname>/<lvname>
and then use the lvremove command:
lvremove /dev/<vgname>/<lvname>

Q. What is disk Quota?
Ans: 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

Q. How SSL works?
Ans: 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.

Q.What is Kernel? Explain the task it performs. 

Ans: 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.

Q. Different types of Kernel.

Ans .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).


Q.What is Initial Ram disk?
Ans: 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.

Q. Explain Different Option for updating kernel?

Ans:
A. install new kernel from rmp file
a. Get the Newest kernel and put in /tmp
b. rpm -i  /tmp/kernal-2.4.19-3.i386.rpm (Not ugrading.can be switched to old keranl if need)
c. Now Kernal ,RamDisk etc..are installed in /boot
d. New stanza added to grub.com (you need alter "default")

B. customizes, install and configure from kernel source code.
Required RMP's tool for customizing kernel source code.
             1. Kernel-source-*
             2.glibc-kernheaders-*
             3.glibc-deve;-*
             4.cpp-*
             5.binutils-*
             6.gcc-*
             7.tcl-*
             8.tk-*

Q. Explain the Steps to compile and install kernel?
Ans:    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 kernel
            make modules -- Builds the modules
            make modules_install -- Install kernel modules
            make install -- copy the new kernel files to associated directory.

Q.Explain Linux Services ?. 
Ans: 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:l

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.
Q. What command is used to list the contents of directory?

Ans:

ls

ls -l
Q.How to list a directory containing millions of files?
 Ans:When you list all files using "ls ,find os.listdir " all command hung since the folder contains too many files.
The “ls” command, by default, will sort its output. To do that, it must first slurp the name of every file into memory. Confronted with a very large directory, it will sit there, reading in file names, and taking up more and more memory until eventually listing the files all at once, in alphanumerical order.

ls and practically every other method of listing a directory (including python os.listdir, find .) rely on libc readdir(). However readdir() only reads 32K of directory entries at a time, which means that if you have a lot of files in the same directory .it is going to take an insanely long time to read all the directory entries, especially on a slow disk.
The reason it was taking forever to list the directory was because ls was reading the directory entries file 32K at a time, and the file was 513M. 
So it would take around 16416 system calls of getdents() to list the directory.  That is a lot of calls, especially on a slow virtualized disk. (see for more info http://www.olark.com/spw/2011/08/you-can-list-a-directory-with-8-million-files-but-not-with-ls/ )
On the other hand, ls -1 -f does not perform any sorting. It just reads the directory and displays files immediately.
Below table list contains the File system and its capacity.
FAT32:
    Maximum number of files: 268,435,437
    Maximum file size: 4GB
    maximum number of files per directory: up to 65535, or less depending on file names
NTFS:
    Maximum number of files: 4,294,967,295
    Maximum file size: 16TB currently (16EB theoretically)
Ext2:
    Maximum number of files: 10¹
    Maximum file size: 2TB
    theoretical file per directory limit: 1.3 × 10²
files
Ext3:
    Maximum number of files: number of bytes in volume/2¹³.
    Maximum file size: 16GB (1KB block) to 2TB (4KB block)
Q.Will Hard link share same Inode.?What will happen if i delete the hard link ?
Ans:Yes.Hard Link shares same inode. If you delete the hard link other copy of file will be exist so that you can retrieve your data.

Q.What command is used to list the top 10 files / directories size wise?

Ans: for X in $(du -s * | sort -nr | cut -f 2); do du -hs $X ; done

Q.What command is used to display a list of currently running processes?

Ans:

ps

top

pstree

pgrep

/proc file system


Q.What command is used to check a file system for errors?


Ans:

fsck

fsck.ext3

fsck.nfs

fsck.ext2

fsck.vfat

fsck.reiserfs

fsck.msdos

Q. Explain UNIX file types ?

Ans:

Directory

Pipes

Fifo

Symbolic link

Named pipe

Socket

Device file

Door

Regular file

Q.What is a login shell?

Ans: A program gets executed when a user logs into UNIX box. E.g. bash, sh, ksh, csh

Q.What is UID?

Ans: User identification number which is assigned to each UNIX / Linux user; it may or may not be unique (unique number is recommended to avoid security related issues). UID and user relationship defined in /etc/passswd file.

Q.What GID? What SUID?

Ans: Definition: GID: Group identification number for the process. Valid group numbers are given in /etc/group, and in the GID field of /etc/passwd file. When a process is started, its GID is set to the GID of its parent process.

Q: What is EUID?

Ans: Definition: EUID: Expands to the effective user ID of the current user or process, initialized at shell startup. 

Q.Explain Linux files permissions?

Ans: Every file on your Linux system, including directories, is owned by a specific user and group. Therefore, file permissions are defined separately for users, groups, and others.

User: The username of the person who owns the file. By default, the user who creates the file will become its owner.



Group: The usergroup that owns the file. All users who belong into the group that owns the file will have the same access permissions to the file. This is useful if, for example, you have a project that requires a bunch of different users to be able to access certain files, while others can't. In that case, you'll add all the users into the same group, make sure the required files are owned by that group, and set the file's group permissions accordingly.



Other: A user who isn't the owner of the file and doesn't belong in the same group the file does. In other words, if you set a permission for the "other" category, it will affect everyone else by default. For this reason, people often talk about setting the "world" permission bit when they mean setting the permissions for "other."



There are three types of access permissions on Linux: read, write, and execute. These permissions are defined separately for the file's owner, group and all other users.



Read permission. On a regular file, the read permission bit means the file can be opened and read. On a directory, the read permission means you can list the contents of the directory.



Write permission. On a regular file, this means you can modify the file, aka write new data to the file. In the case of a directory, the write permission means you can add, remove, and rename files in the directory. This means that if a file has the write permission bit, you are allowed to modify the file's contents, but you're allowed to rename or delete the file only if the permissions of the file's directory allow you to do so.

Execute permission. In the case of a regular file, this means you can execute the file as a program or a shell script. On a directory, the execute permission (also called the "search bit") allows you to access files in the directory and enter it, with the cd command, for example. However, note that although the execute bit lets you enter the directory, you're not allowed to list its contents, unless you also have the read permissions to that directory.
What does the output of ls -l mean? The very first column, the one that looks like a bunch of mumbo jumbo, shows the file type and permissions. The second column shows the number of links (directory entries that refer to the file), the third one shows the owner of the file, and the fourth one shows the group the file belongs to. The other columns show the file's size in bytes, date and time of last modification, and the filename.


The first column, the one that shows the file's permissions and looks like mumbo jumbo, is organized into four separate groups, although it certainly doesn't look very organized.

The first group consists of only one character, and it shows the file's type. For example, d means a directory and - means a normal file, so if you take a look at our example output, you'll notice dir is a directory, while file and other file are regular files.



The first character can be any of these:



d = directory

- = regular file

l = symbolic link

s = Unix domain socket

p = named pipe

c = character device file

b = block device file

The next nine characters show the file's permissions, divided into three groups, each consisting of three characters. The first group of three characters shows the read, write, and execute permissions for user, the owner of the file. The next group shows the read, write, and execute permissions for the group of the file. Similarly, the last group of three characters shows the permissions for other, everyone else. In each group, the first character means the read permission, the second one write permission, and the third one execute permission.

The characters are pretty easy to remember.

r = read permission

w = write permission

x = execute permission

- = no permission


You can set file permissions with the chmod command. Both the root user and the file's owner can set file permissions. chmod has two modes, symbolic and numeric.


Wipe out all the permissions but add read permission for everybody:

$ chmod a=r testfile


After the command, the file's permissions would be -r--r--r--



Which user?

u          user/owner

g          group

o          other

a          all

What to do?

+          add this permission

-           remove this permission

=          set exactly this permission

Which permissions?

r           read

w         write

x          execute


The other mode in which chmod can be used is the numeric mode. In the numeric mode, the file permissions aren't represented by characters. Instead, they are represented by a three-digit octal number.


4 = read (r)

2 = write (w)

1 = execute (x)

0 = no permission (-)


To get the permission bits you want, you add up the numbers accordingly. For example, the rwx permissions would be 4+2+1=7, rx would be 4+1=5, and rw would be 4+2=6. Because you set separate permissions for the owner, group, and others, you'll need a three-digit number representing the permissions of all these groups.

Let's have an example.

$ chmod 755 testfile

The numeric mode may not be as straightforward as the symbolic mode, but with the numeric mode, you can more quickly and efficiently set the file permissions. This quick reference for setting file permissions in numeric mode might help:

Which number?

0          ---

1          --x

2          -w-

3          -wx

4          r--

5          r-x

6          rw-

7          rwx


Q. What is SSH?

Ans: Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices.RFC 4252 The two major versions of the protocol are referred to as SSH1 or SSH-1 and SSH2 or SSH-



Q.Explain /etc/passwd file format ?

Ans: Passwd is a text file that contains a list of the system’s accounts giving for each account some useful information like user ID, group ID, home directory, shell, etc. Often, it also contains the encrypted passwords for each account.

Q.Explain /etc/ shadow file

Ans: pwconv command is used for giving shadow passwords. Shadow passwords are given for better system security.  /etc/shadow file stores actual password in encrypted format for user’s account with additional properties related to user password i.e. it stores secure user account information. All fields are separated by a colon (J symbol. It contains one entry per line for each user listed in /etc/passwd file Generally, shadow file entry looks as follows (click to enlarge image):

No comments:

Post a Comment