Saturday, May 13, 2023

Top 30 UNIX command Interview Questions asked in Investment Banks

UNIX Interview Questions and Answers
UNIX or Linux operating system has become a default Server operating system and for whichever programming job you give interview you find some UNIX command interview questions there. These UNIX command interview questions are mostly asked during Java development and Support role interviews on various investment banks mostly because most of the electronic trading systems or stock trading system works on Unix servers. As we know that high volume low latency systems that want to take advantage of a little bit of volatility in the market for Equity, Futures, and options or Foreign exchange trading need a stable server-side operating system and Redhat Linux is doing a great job there.


Unix and Linux Command Interview Questions and AnswersWith the advent of Algorithmic trading this speed factor becomes more important so getting someone who has good knowledge of operating systems and commands on which this trading system runs is definitely required. but these UNIX command interview questions are equally applicable for any job interview which requires some work on Unix Operating System.

With the growing use of Linux in form of RedHat, Solaris, and IBM AIX its must keep you familiar with essential Linux commands available on various platforms. 

Long back I had once asked one of my friends why are you preparing Unix Command interview questions if you going for a Java Interview and he told me that this job doesn't only require knowledge of Java but also knowledge of Unix, Linux, SQL and other scripting languages, which is quite true. 

After that, I thought to collect various UNIX command interview questions asked to Java developers or trading system support interviews and this is the result of that compilation. 

This list of UNIX command interview questions is by means complete and it would be great if you guys contribute some genuine and good Unix Command Interview questions and answers asked during interviews. I have divided the questions into three categories for the sake of managing and keeping this list of Unix Interview questions up to date.





Beginners UNIX Interview Questions Answers

1. Write a command to list all the links from a directory?
In this UNIX command interview questions interviewer is generally checking whether user knows basic use of "ls" "grep" and regular expression etc. You can write command like:
ls -lrt | grep "^l"



2. Create a read-only file in your home directory?
This is a simple UNIX command interview questions where you need to create a file and change its parameter to read-only by using chmod command you can also change your umask to create read-only file.

$ touch file
$ chmod 400 file
3. How will you find which operating system your system is running on in UNIX?
By using command "uname -a" in UNIX



4. How will you run a process in background? How will you bring that into foreground and how will you kill that process?
For running a process in background use "&" in command line. For bringing it back in foreground use command "fg jobid" and for getting job id you use command jobs, for killing that process find PID and use kill -9 PID command. This is indeed a good Unix Command interview questions because many of programmer not familiar with background process in UNIX.



5. How do you know if a remote host is alive or not?
You can check these by using either ping or telnet command in UNIX. This question is most asked in various Unix command Interview because its most basic networking test anybody wants to do it.



6. How do you see command line history in UNIX?
Very useful indeed, use history command along with grep command in UNIX to find any relevant command you have already executed. Purpose of this Unix Command Interview Questions is probably to check how familiar candidate is from available tools in UNIX operation system.



7. How do you copy file from one host to other?
Many options but you can say by using "scp" command. You can also use rsync command to answer this UNIX interview question or even sftp would be ok.




8. How do you find which process is taking how much CPU?
By using "top" command in UNIX, there could be multiple follow-up UNIX command interview questions based upon response of this because “TOP” command has various interactive options to sort result based upon various parameter.



9. How do you check how much space left in current drive ?
By using "df" command in UNIX. For example "df -h ." will list how full your current drive is. This is part of anyone day to day activity so I think this Unix Interview question will be to check anyone who claims to working in UNIX but not really working on it.



10. What is the difference between Swapping and Paging?
Swapping:
Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems.

Paging:
Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly.


Intermediate UNIX Interview Questions Answers

1. What is the difference between ps -ef and ps -auxwww?
UNIX interview questions answers, UNIX Linux questionsThis is indeed a good Unix Interview Command Question and I have faced this issue while ago where one culprit process was not visible by execute ps –ef command and we are wondering which process is holding the file.
ps -ef will omit process with very long command line while ps -auxwww will list those process as well.



2. How do you find how many cpu are in your system and their details?
By looking into file /etc/cpuinfo for example you can use below command:
cat /proc/cpuinfo



3. What is the difference between HardLink and SoftLink in UNIX?
I have discussed this Unix Command Interview questions  in my blog post difference between Soft link and Hard link in Unix



4. What is the Zombie process in UNIX? How do you find Zombie process in UNIX?
When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status. To be able to get this information, the parent calls 'wait()'; In the interval between the child terminating and the parent calling 'wait()', the child is said to be a 'zombie' (If you do 'ps', the child will have a 'Z' in its status field to indicate this.)
Zombie : The process is dead but have not been removed from the process table.



5. What is the "chmod" command? What do you understand by this line “r-- -w- --x?
chmod command is used to change permission of a file or directory in UNIX. The line you see shows the permission for three different set of people : user, group and others. User is the currently logged in user, while group is for all other member which are part of certain group and others means anyone other than user and group member. Each group has three permissions rwx stands for read, write and execute and they are written as user_group_others. So in above line, user has only read permission, group members has write permissions and other people has only execute permission. If it is a directory then you need execute permission to go inside that directory. See here for more detailed answer.



6. There is a file somewhere in your system which contains word "UnixCommandInterviewQuestions” How will find that file in Unix?
By using find command in UNIX for details see here 10 example of using find command in Unix



7. In a file word UNIX is appearing many times? How will you count number?
grep -c "Unix" filename


8. How do you set environment variable which will be accessible form sub shell?
By using export command,  for example export count=1 will be available on all sub shell.



9. How do you check if a particular process is listening on a particular port on remote host?
By using telnet command for example “telnet hostname port”, if it able to successfully connect then some process is listening on that port. To read more about telnet read networking command in UNIX



10. How do you find whether your system is 32 bit or 64 bit ?
Either by using "uname -a" command or by using "arch" command.



Advanced UNIX Interview Questions and Answers

1. How do you find which processes are using a particular file?
By using lsof command in UNIX. It wills list down PID of all the process which is using a particular file.


2. How do you find which remote hosts are connecting to your host on a particular port say 10123?
By using netstat command execute netstat -a | grep "port" and it will list the entire host which is connected to this host on port 10123.



3. What is nohup in UNIX?
nohup is a special command which is used to run process in background, but it is slightly different than & which is normally used for putting a process in background. An UNIX process started with nohup will not stop even if the user who has stared log off from system. While background process started with & will stop as soon as user logoff.



4. What is ephemeral port in UNIX?
Ephemeral ports are port used by Operating system for client sockets. There is a specific range on which OS can open any port specified by ephemeral port range.



5. If one process is inserting data into your MySQL database? How will you check how many rows inserted into every second?
Purpose of this Unix Command Interview is asking about watch command in UNIX which is repeatedly execute command provided with specified delay.



6. There is a file Unix_Test.txt which contains words Unix, how will you replace all Unix to UNIX?
You can answer this Unix Command Interview question by using SED command in UNIX for example you can execute following command to replace all Unix word to UNIX
sed s/Unix/UNIX/g fileName



7. You have a tab separated file which contains Name, Address and Phone Number, list down all Phone Number without there name and Addresses?
To answer this Unix Command Interview question you can either you AWK or CUT command here. CUT use tab as default separator so you can use
cut -f3 filename



8. Your application home directory is full? How will you find which directory is taking how much space?
By using disk usage (DU) command in Unix for example du –sh . | grep G  will list down all the directory which has GIGS in Size.


9. How do you find for how many days your Server is up?
By using uptime command in UNIX



10. You have an IP address in your network how will you find hostname and vice versa?
This is a standard UNIX command interview question asked by everybody and I guess everybody knows its answer as well. By using nslookup command in UNIX, you can read more about convert IP Address to hostname in Unix here.


I hope these UNIX command interview questions and answers would be useful for a quick glance before going for any UNIX or Java job interview. Please share any interesting UNIX command interview you have come across and I will add it to this list. If you are going for any Unix interview on a brokerage firm or stock trading company or any Investment bank you can have a quick look here, though most of the questions you might already know but it's good to review it. if you like this you can see my other UNIX command tutorial for beginners as well 


Some of my favorite interview questions post , you may find interesting
  1. Top 20 Core Java Interview Questions and Answers
  2. Top 20 FIX Protocol Interview Questions and Answers
  3. Top 10 Serialization Interview Questions and Answers
  4. Top 10 Singleton Interview question in Java
  5. Top 20 Tibco Rendezvous Interview Questions

Enjoy :)

44 comments :

Anonymous said...

"ephemeral port in UNIX" Exactly this question was asked me on one of leading broker firms interview apparently they had some port clashing due to this and there Fixed Income trading system was not responding because of port clash.

Anonymous said...

The answer to question 2 in the intermediate section is wrong.

Corrected version below:

2. How do you find how many cpu(s) are in your system and their details?

By looking into file /proc/cpuinfo for example you can use below command:
cat /proc/cpuinfo

Javin @ FIX Protocol and Electroinc Trading said...

@Anonymous1, Thanks for sharing your experience. ephemeral port is indeed something to be aware of , specially the range on which they are allowed.

Javin @ FIX Protocol and Electroinc Trading said...

@Anonymous, Thanks for pointing that out , Yes cpuinfo and meminfo files resides in /proc and not in /etc , it was typo. Thanks again.

Anonymous said...

.. Question #9 under Beginners is incorrect.
'df -h' would show the entire system's disk usage/free space - 'du -sh' would show the current directory. (and all subdirectories)

Anonymous said...

Sorry to say but I would much rather get somebody on board who knows how to use info or man pages or google to find the answers to these questions then to know every details about unix commands from their head. Especially when they apply for a java job.

Unknown said...

Answer to question about CPU(s) number is wrong, because it will work only in Linux, it doesn't cover other Unices, ie. Solaris doesn't have a /proc/cpuinfo.
"10. How do you find whether your system is 32 bit or 64 bit ?" Again, not all Unices have arch command.
It has to be noted, that most of the answers still are right, however one has to be aware of:
top has been reported to print false values on Solaris, it is better to use prstat. ps behaves differently on Solaris than on Linux and some switches don't work.
Otherwise, bravo. Very nice summary.

Anonymous said...

Useful. However, how can "9. How do you find for how many days your Server is up?" be an advanced question??

Javin @ FIX Protocol Tutorials said...

@Anonymous1, It was indeed current drive instead of current directory. thanks for pointing that out and by the way you showed the way to do same thing for current directory also :)

Javin @ Electroinc Trading and FIX Protocol said...

@Anonymous2, yeah for Java jobs , Java is more important than Unix but anybody wants to hire someone who is good on all technology which is been using in project but of-course compromise can be made on supporting technology but not on primary.

Javin @ FIX Protocol and Electroinc Trading said...

@Trochej , Thanks for your valuable comment. I haven't worked on Solaris but your points are well valid. I read somewhere that even worse is "killall process-name" command which instead of killing named process kill all process on Solaris.

Javin @ Electroinc Trading and FIX Protocol said...

@Anonymous, yeah that question doesn't require much information but only information which it requires is to know "uptime" command which people often don't know.

Anonymous said...

impressive list of unix interview question , you can also include interview questions related to chmod, tar and date command in unix.

Anonymous said...

In one of Unix interview they asked me how to remove Ctrl+M Character, I surprised with this unix interview question, it was more to convert file from dos to unix. would be great if you could provide answer of this unix question.

Anonymous said...

Thanks a lot for sharing the knowlege could you kindly shar interview questions for SQL like joint,having,so on .....

Thank you

Anonymous said...

Hi,

could share the flow of fix protocol for fix server, rate engin wall street books it would be greate.

thanks

Anonymous said...

Bonus points if the answer to "2. Create a read-only file in your home directory?" included && --like this:

touch file && chmod 400 file

That way the chmod command would only be executed if touch was successful....

--GAM

Anonymous said...

this is an excellent post...thank you much for taking the time to put it up

Anonymous said...

ok let me contribute some more
1) how you enable ip forwarding in Linux
2) what is mx record in dns
3) name some of the dns records
4) what is a port number for ssh , dns ,smtp ,snmp
5) what is exit status
6) how you assign a ip address to a network adapter in linux
7)suppose you are going to install a software or update a patch on 1000 Servers how will you accomplish this .define procedure
8) what is run level 3 , run level 5
9) what is init process
10) define linux boot process
11) how you create swap memory
12) how do you check the amount of memory space on system
13) what is a zombie process
14) define crontab entries
15) how you change run level in linux
16) how do you know which packages are intsalled on a linux system
17) how do you know if a specific package is installed on the system

i will post later and will appreciate if somebody answers all of the above questions just to tally my answers.

Anonymous said...

Most of these questions are incorrect for Solaris (which is also a true Unix). Maybe it's a better idea to rename this blog post to "Top 30 Linux command Interview Questions".

daddy_phantom said...

Intermediate #7: "In a file [the] word UNIX is appearing many times? How will you count [the] number?"

Even with case insensitive "-ci", as someone else suggested, you would still only get a count of the "lines" where the word "unix" appeared, not the "count". If you want to know how many times "UNIX" (any case) actually appears, I would suggest something like this:

$ tr "[:space:][:punct:]" "\n" < filename | grep -ci unix

Just saying... good list by the way

Anonymous said...

nohup : enabling the command to keep running after the user who issues the command has logged out

Sehthil said...

Can any one please share UNIX or Linux Interview question for System admin ? I am looking for some real tricky UNIX question which can be testing. Would be great if one can share from IB like Citibank, Barclays, Goldman Sachs, Standarad Charted, Morgan Stanley or RBS.

Senthil

Muskan said...

How can I download all these UNIX interview questions and answers in PDF format ? Can you please shared pdf download link for these UNIX and Linux questions, Thanks in advance

Anonymous said...

I got asked 'what is the difference between init 6 and reboot? I was apparently the only candidate ever to have answered correctly. I got the job. :-)

Anonymous said...

Actually it is quite a good interview question if the person understands the difference between 'top' and 'prstat' commands and why one may become a CPU hog (guess which one). This will give an idea if the person has been exposed to some really, really large OS images .. or have only been exposed to your average single-socket Linux box.

But it depends what type of environment you want him to work in. For most Linux environments you never have to worry about the fact that 'top' has an build-in weakness if there are really MANY processes to iterate over. It is not a problem you're likely to encounter anyways.

Anonymous said...

In Advanced UNIX Interview Question,
Answer 3: What is nohup?
nohup is a command, which is used to start any service or run any long running command, so that process doesn't die, when user logout from machine. We used to start our Java Services using nohup command so that it keeps running, even after you log out from shell.

Anonymous said...

Please refer the below link for UNIX Basic Questions and Answers..

http://tecz.org/interview-questions/85-unix-basic-questions.html

Anonymous said...

QNo. 7 under Advanced UNIX question can also be written in AWK as :

awk '$1=="";$2==""{ printf "Phone number which has empty Name and Address is %s\n", $1}' filename

Bill Broadley said...

Instead of command line trivia I prefer to ask a question that gives an interviewee enough room to maneuver. One with a long enough answer so you can determine if the user understands the entire system and whose response will let you know their level of expertise.

Something like "In as much detail as possible explain what happens when you say ssh hostname". Ideally mentioning shell, searching the path, execing a binary, libraries, page faults, parsing options, dns, netmask, gateway, routing, tcp handshake, ssh negotiation, etc. A good answer will take some time, but you'll learn quite a bit about the interviewee in the process.

Bill Broadley said...

#8 is terrible. Numerous problems with the answer: 1) -s is summary so you only get one line of output, likely mean du -h 2) grep G will show any filename with G in it. 3) you'll miss any directory with a size of TB (not unusual these days).

I suggest du -s * | sort -n, granted this command will break in directories with a large number of entries.

Anonymous said...

Questions asked at L& T Infotech for Production support role.


Display 10 most CPU intensive processes or Display process sorted on CPU usage.
top command

2. How to get the last 10 lines of a file (easy)
tail -10 filename

3. How to zip and unzip files in unix? (easy)
gzip and gunzip
bzip2 and bunzip2
zip and unzip (explain with syntax)

4. How do you display line nos. in files( easy)
cat -n filename or
nl
pr(Paginating output) pr -n

5. How do you fire a shell script? (easy)
sh file.sh
bash file.sh
or
chmod +x file.sh // Give execute permission
./file.sh

6. How do you save and exit from vi editor? (easy)
:wq

7. How do you create a new file? (This is a generic question & rather tricky. I hope one of the
answer suffices!)
vi input mode press [i] and type :x
cat > foo
touch emp.lst // creates a file if it doesn't exist

8. Name some shell scripts used for monitoring? (Generic no specific answer)
Check alert log files for error messages, Checking disk usage so on.

Anonymous said...

There is one more way to find all open files owned by a process, apart from lsof, you can do ls /proc/pid/fd, it will give you open file descriptors.

Daniel said...

Some comments:

Beginner 1: "find directory -maxdepth 1 -type l" is nicer and easily extensible.

Beginner 3: wrong, this only gives kernel version, which in _some_ cases give the distribution (==operating system). "lsb_release -a" would be much preferred, even though a truly universal command does not exist.

Beginner 4: Ctrl+z "bg" is more often used in the context.

Beginner 6: In most shells, up arrow or Ctrl+r is much more useful. "history | grep" is only used in corner cases today.

Beginner 10 and Advanced 9 can just swap places directly.

Intermediate 6: "contains word", I guess you mean that the _filename_ contains the word. As it stands the answer should be "grep -R".

Intermediate 7: Case matters: Unix->UNIX in the answer.

Intermediate 8: "export" is not universal (tcsh, etc).

Advanced 6: Should be "sed -i" (for GNU sed, at least, otherwise use temp files (perhaps follow-up question about making unique temp files (mktemp))).

Advanced 7: There are many more possibilities, e.g. sed, Perl. "cut" is nicest, but change the word "either".

Anonymous said...

here few more questions -
1. How to create file system in UNIX ?
2. Explain LVM and it's use?
3. How to mount and unmount drives ?
4. How to configure a process to start on boot ?
5. How to add / modify users ?
6. How to check mail queue ?
7. Where are system log files located ?

Unknown said...

The output of uname -a command
[dsadm@lnappu022 ~]$ uname -a
Linux lnappu022 2.6.18-407.el5 #1 SMP Fri Oct 16 12:04:40 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
[dsadm@lnappu022 ~]$

Phanidhar said...

When i have used "lsof" command, that shooted a message like

lsof: WARNING: /usr/eee/.lsof_server1 was updated.

What is the mean by it? why it is shooting warning?

devil said...

Thanks . It is good article but I checked with RHCE linux this command only showing data replacement .

sed s/Unix/UNIX/g fileName

But once I run the command "sed -i s/Unix/UNIX/g fileName" . It was working .Please correct me if I am going wrong .Thanks in advance.

Unknown said...

It is good article. Keep it up.

kpreddy said...

its really very good article Tqq

Anonymous said...

The given answer for:
7. In a file word UNIX is appearing many times? How will you count number?
wont work in all cases as it counts each line only once even if it contains multiple occurrence of the word.
"grep -o "Unix" | wc -l" can be used instead

Pocket Full Of Sunshine......!! said...

i think you can open file in vi and remove m character not sure though

Welcome to all said...

thank you .its very useful to me. i have one doubt? how to installing the mysql in centos7.
because i tried lot of time .could you tell me about slove my problem?

abhijit said...

for Q. No. 7 don't think grep -c 'UNIX' will count only the first instance. instead using that we can use grep -oi 'UNIX' | wc -l, it will cont the only UNIX how many times are there

Post a Comment