HTML Comment Box is loading comments...

Cracking IT Interview

Questions Set A


UNIX:


  1. How to list out only directories among all the files ?
  2. How to create a directory structure at single command ?
  3. What is the difference between Hard link and Symbolic link ?
  4. If I have 3 files A, B and C and I want to create one new file D with the contents of these 3 files consecutively, how to do this in single command ?
  5. How to change the file modification time as per current date and time ?
  6. How to delete a blank lines in a file ?
  7. How to list out system processes in full format? Is it possible to kill them ?
  8. What is zombie process ? How to display it in screen ?
  9. How to find files which are older than 30 days and delete it from system ?
  10. How to connect to a different server from server you are present ? How to transfer files there ?


Shell scripting:


  1. What is the first line in shell script ? why we are writing this line ?
  2. What are the shell variables ? give some examples with their meaning. 
  3. How to print numbers from 1 to 10 in shell script, illustrate with syntax ?


Answers Set A


UNIX


  1. ls -ltr | grep '^d'       OR         ls -lF | grep '/$'
  2. with -p option; mkdir -p A/B/C  where A,B,C are directory name.
  3. There are few limitations of the hard link which is removed by the Symbolic link:
    you can't create a hard link for the file which is in different file system, i.e: you can't link one file from /usr file system to another /home file system. But it can be done using soft link.
    you can't link directory even within the same file system using hard link, you can do it using soft link.
  4. cat A B C > D
  5. touch -m filename.
  6. grep -v '^$' filename >> $$; mv $$ filename
  7. ps -eaf ; Yes by kill command.
  8. Zombie process is harmful dead child process which entry is still there in process table. It is waiting for its parent process to pick its exit status. Once it's exit status is picked by wait() system call, it is removed from the process table. It is a kind of process we can't kill it.
  9. go to that directory and give this command:   find . -type f -mtime +30 -exec rm {}\;
  10. sftp hostname/ip then give password, use put command to transfer file there, get command to take files from that server.


Shell scripting:


  1. #!/bin/sh - it's called hash bang line, shebang line, or interpreter line. This line tells the shell that in which shell the rest codes are going to be interpreted. "/bin/sh" is the path of the shell and here in this case it's a Bourne shell.  
  2. Shell variables are also called environmental variables, these are system variables containing with some system defined default values. E.g - $HOME (contain yous home path), $SHELL (keeps shell path), $USER (user name), $$ (PID of shell), $? (last exit status) etc.
  3. i=1
    while [ $i -le 10 ]
    do
    echo "$i"
    i=$(($i+1))
    done