Tutorial corner

Informatica,ETL,oracle,sql/plsql

Top unix interview question with answer :Part -2

Spread the love

Collection of Top unix interview question with answer :  In our first part ,Top unix interview question with answer :Part -1 , we went through some of the theory and command based unix interview questions with answer. Hope you enjoyed those questions and it must have boosted up your unix skills. Here we are going to start with Part -2 of “Top unix interview question with answer” series.

Top unix interview question with answer

Top unix interview question with answer

Unix interview question with answer

Ques: What is the command to find out operating system of your unix system?

Ans : By using command “uname -a” in UNIX

Ques: How to check space left in your current drive?

Ans : “df” command can be used  here. “df -h “ will tell us the space occupied in current directory.

Ques: How to display the Disk Usage of file sizes under each directory in current Directory?

Ans : du -k * | sort -nr

Ques: How to create read only file in unix ?

Ans : By using below command

touch filename ; chmod 400 filename

Ques: How to run command in background ?

Ans : By adding “&”  at the end of command.

Ques: How to bring back a process into foreground that is running in background ?

Ans: First get job id of the command by using “jobs” command and then run “fg jobid” to bring it back to foreground.

Ques: How to kill process in unix?

Ans: First get process id of command by using “ps” command and then kill the process by using

kill -9 processid.

Ques: How to know about the resource utilization on a server?

Ans : By using “Top” command. It will tell us the memory/CPU and many more details related to resources utilize by each process.

Ques: What is history command in UNIX?

Ans : “history” command can be used to find out the list of command recently run in a session.

Ques: How do you copy file from one host to other?

Ans : We can use below commands to transfer file from one host to another host machine

  • scp
  • rsync
  • ftp
  • sftp

Ques: What is the use of “$?” in unix ?

Ans : It tell us the exit status of last command. It it return with value “0″ (zero) then it is successful  else it will failed.

Ques: How to check type of file in unix ?

Ans : By using “file” command in unix with file name as input parameter.

$>file -i process.log process.log: text/plain; charset=us-ascii

If the file is zipped, following will be the result

$> file –i process.log.zip process.log.zip: application/x-zip

Ques: How to tar and zip file in one command ?

Ans :  By using tar with -cvzf option. See below example :-
$ tar -cvzf xyz_tutorial.tar.gz /root/xyz/tutorial
/root/xyz/tutorial/
/root/xyz/tutorial/index.html
/root/xyz/tutorial/send_mail.ksh
/root/xyz/tutorial/data.txt
/root/xyz/tutorial/log/send_mail.log

Check here for Tar command example in unix

Ques: How to find and remove files in unix?

Ans : 

To find and remove files such as .log we will need to combine rm command .

find . -type f -name “*.log” -exec rm -f {} ;

Check here for find command with exec

Ques: How to find file occupying large space in current directory?

Ans : we need to combine multiple command .

find . -type f | xargs du -sk | sort -n | tail

Check here for find command example in unix

Ques: How to execute command in background ?

Ans : By adding “&”  at the end of command.

Also check below

Top unix interview question with answer : Part -1
Top unix interview question with answer : Part -3

So in above article ,we have gone through some of the commonly asked unix interview question with answer .

The Author

Alisha Lamba

Hello Friends , I am Alisha Lamba .I love to write article on latest technologies like Informatica , ETL , data warehouse , SQL-PL SQL
Copyright 2015 - Tutorial Corner Frontier Theme