UNIX Flashcards

1
Q

Write command to list all the links from a directory?

A

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is difference between ps -ef and ps -auxwww?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you find how many cpu are in your system and there details?

A

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

cat /proc/cpuinfo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is difference between HardLink and SoftLink in UNIX?

A

I have discussed this Unix Command Interview questions in my blog post difference between Soft link and Hard link in Unix

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Zombie process in UNIX? How do you find Zombie process in UNIX?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is “chmod” command? What do you understand by this line “r– -w- –x?

A

The chmod (abbreviated from change mode) is a Unix command that lets a user tell the system how much (or little) access it should permit to a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

There is a file some where in your system which contains word “UnixCommandInterviewQuestions” How will find that file in Unix?

A

Find command with many options.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In a file word UNIX is appearing many times? How will you count number?

A

grep -c “Unix” filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you set environment variable which will be accessible form sub shell?

A

By using export for example export count=1 will be available on all sub shell.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you check if a particular process is listening on a particular port on remote host?

A

By using telnet command for example “telnet hostname port”, if it able to successfully connect then some process is listening on that port.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Create a read-only file in your home directory?

A

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
read more about file and directory permission in unix and linux here.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How will you find which operating system your system is running on in UNIX?

A

By using command “uname -a” in UNIX

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How will you run a process in background? How will you bring that into foreground and how will you kill that process?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you know if a remote host is alive or not?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you see command line history in UNIX?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you copy file from one host to other?

A

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.

17
Q

How do you find which process is taking how much CPU?

A

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.

18
Q

How do you check how much space left in current drive ?

A

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.

19
Q

What is the difference between Swapping and Paging?

A

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.