Sunday, 9 June 2013

Linux Interview Question & Answer part-3

21) How to setup never expired user password

Ans chage -E never username

22) Restricting insertion into file if full permission are assigned to all

Ans chattr +i filename

23) Display or Kill all processes which are accessing any folder/file

Ans Display User who are using file/folder : fuser -u file/folder
Kill All Processes which are using file/folder: fuser -k file/folder

24) Kill any user's all processes

Ans killall -u username

25) How can we have system analysis and reports over mail

Ans Use logwatch

26) What we have to do if we do required to rotate logs without moving and creating new log file

Ans We can use "logrotate"'s "copytruncate" option which will simply copy original file and 
truncate original file :)

27) Command to collect detailed information about the hardware and setup of your system

Ans dmidecode , sysreport

28) Command to check PCI devices vendor or version

Ans lspci

29) What is the difference between cron and anacron

Ans  Cron :
                     1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed
                         every minute)
                     2) Cron job can be scheduled by any normal user ( if not restricted by super
                          user )
                     3) Cron expects system to be running 24 x 7. If a job is scheduled, and
                         system is down during that time, job is not executed
                     4) Ideal for servers
                     5) Use cron when a job has to be executed at a particular hour and minute

      Anacron :
                     1) Minimum granularity is only in days
                     2) Anacron can be used only by super user ( but there are workarounds to
                         make it usable by normal user )
                     3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled,
                         and system is down during that time, it start the jobs when the system
                         comes back up.
                     4) Ideal for desktops and laptops
                     5) Use anacron when a job has to be executed irrespective of hour and
                          minute

30)  Default Port numbers used by ssh,ftp,http,https,telnet,smtp,pop3,pop3s,imap,imaps

Ans SSH 22, ftp 20/21, http 80, https 443, SMTP/SMPTS 25/465, POP3/POP3S 110/995, IMAP/IMAPS 143/993

31)  How to setup ACLs in following case:
         1) Create a file FILE1 and this should be read,write,executable for all user but Read only  for user USER1
        2) Copy FILE1 ACLs to FILE2 ACL
        3) Delete a USER1's rule for FILE1 which were setup in step 1)

Ans 1) touch FILE1 ; chmod 777 FILE1 ; setfacl -m u:USER1:r FILE1
        2) getfacl FILE1 | setfacl --set-file=- FILE2
        3) setfacl -x u:USER1 FILE1

32)  How to make USB bootable?

Ans Write efidisk.img from RHEL 6 DVD images/ subdirectory to USB

dd if=efidisk.img of=/dev/usb (usb device name)

33)  How can we check disk/device status/failure/errors using smartctl utility?

Ans Try following to check:

        Enable/Disable SMART on device/disk : smartctl -s on /dev/sda
        Check device SMART health : smartctl -H /dev/sda
        Check device SMART capabilities : smartctl -c /dev/sda
        Enable/Disable automatic offline testing on device : smartctl -o on/off /dev/sda
        Show device SMART vendor-specific Attributes and values : smartctl -A /dev/sda
        Show device log [TYPE : error, selftest, selective, directory,background, 
                                     scttemp[sts,hist]] : smartctl -l TYPE /dev/sda
        Run test on device [TEST: offline short long conveyance select,M-N pending,N 
                                     afterselect,[on|off] scttempint,N[,p] : smartctl -t /dev/sda

34)  What is the difference between ext2 vs ext3 vs ext4?

Ans - dear friends read our next blog to get diffrences.

35)  Disable ping to avoid network/ICMP flood

Ans Set following in /etc/sysctl.conf : net.ipv4.icmp_echo_ignore_all = 1

      Then "sysctl -p"
  
      or 
   
   echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

36)  What is SYN Flood, ICMP Flood

Ans SYN Flood : A SYN flood occurs when a host sends a flood of TCP/SYN packets, often with a 
          fake/forged sender address. Each of these packets is handled like a connection request, causing the 
          server to spawn a half-open connection, by sending back a TCP/SYN-ACK packet(Acknowledge), and 
          waiting for a packet in response from the sender address(response to the ACK Packet). However, 
          because the sender address is forged, the response never comes. These half-open connections 
          saturate the number of available connections the server is able to make, keeping it from responding to 
          legitimate requests until after the attack ends

      ICMP Flood : There are three types of ICMP Flood :
    
       1) Smurf Attack : http://en.wikipedia.org/wiki/Smurf_attack
       2) Ping Flood :  http://en.wikipedia.org/wiki/Ping_flood
       3) Ping of Death : http://en.wikipedia.org/wiki/Ping_of_death

37)  What is the difference between Unix vs Linux Kernels?

Ans- wait for new update blog.

38) How to setup Password less remote login/ssh?

Ans Use "ssh-keygen -t dsa or rsa" at local system for creating public and private keys

        Then copy /root/.ssh/id_dsa.pub to remote_server by name /root/.ssh/authorized_keys
        Change permissions of /root/.ssh/authorized_keys file at remote_server "chmod 0600 ~/.ssh/authorized_keys"

        Now try to login from local system to remote_server "ssh root@remote_server"

39) Command to see default kernel image file

Ans "grubby --default-kernel"

40) How to create lvm mirror

Ans lvcreate -L 50G -m1 -n LVMmirror vg0

4 comments:

  1. That was a great message in my carrier, and It's wonderful commands like mind relaxes with  understand words of knowledge by information's.
    Linux Training in Chennai

    ReplyDelete
  2. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
    #Linux #Training in #Delhi
    Linux Server Corporate Training in India | Linux Institute in Delhi

    ReplyDelete
  3. Hello Krishna,


    Interesting piece! Great to see someone write Redhat linux training- KR Network Cloud who is not a fanatic or a complete skeptic.

    I know how annoying it can be for people to ask questions without reading posts but my course has already started and I need to be sure that any installations I make are compatible. I have an Samsung n150 plus. It runs so slow that it's really frustrating to work with but I can't afford a new laptop. Specs are below. Is there a Linux distribution that will enable my aging laptop to run at a decent speed? Fastest possible please. The catch is I need a distribution that is compatible with Blackboard Collaborate Launcher, only lists options for MAC and Windows is there a way for me to use while running Linux?
    I am so grateful for your blog. Really looking forward to read more.


    Merci Beaucoup,
    Abhiram

    ReplyDelete