Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

01 - Mithun Technologies-Linux-Interview-Questions&Answers - 2021

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

LINUX COMMANDS INTERVIEW

QUESTIONS
Mithun Technologies, +91 99809 23226, devopstrainingblr@gmail.com

MITHUN SOFTWARE SOLUTIONS


Bangalore
Mithun Technologies Linux Interview Questions Author Mithun Technologies 1
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

Linux Commands Interview Questions

1) What command is used to count the total number of lines, words, and characters
contained in a file?
A. countw

B. wcount

C. wc

D. count p

E. None of the above


Ans)

2)What command is used to remove files?


A. dm

B. rm

C. delete

D. erase

E. None of the above


Ans)

3)What command is used to remove the directory?


A. rdir

B. remove

C. rd

D. rmdir

E. None of the above

Ans)

4)What command is used with vi editor to delete a single character?


A. x

B. y

C. a

D. z

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 1


Mithun Technologies Linux Interview Questions Author Mithun Technologies 2
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

Ans)

5)Which of the following command can you execute to count the number of lines in a file?
A. lc

B. wc - l

C. cl

D. count

E. None of the above

Ans)

6) Which of the following is not a communication command?


A. grep

B. mail

C. mesg

D. write

E. None of the above


Ans) grep

7) What command is used to display the characteristics of a process?


A. au

B. ps

C. du

D. pid

E. None of the above


Ans)

8) What command is used to list contents of directories?


A. tar

B. dir

C. lp

D. ls

E. None of the above

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 2


Mithun Technologies Linux Interview Questions Author Mithun Technologies 3
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

Ans) ls

9) Command used to create an empty file.


A. mtfile
B. touch
C. intouch
D. file
Ans) touch

10) ........command is used to show the logger or user


A. ?
B. Who
C. No of
D. ???

Ans)who

11. What command clears the contents of your terminal display?


Ans)

12. what is the command to create the ssh key?


Ans)

13. What do you type in to move to the parent directory?


Ans)

14. What command is used to change directories?


Ans)

15. What command is used to get the ip address of all interfaces on a server?
Ans)

16. What command is used to change ownership of a file?


Ans)

17. What command is used to copy a file?


Ans)

18. What command(s) shows you disk partitions and percentage of disk space
used?
Ans)

19. What command shows you how long it has been since the server was
rebooted?
Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 3


Mithun Technologies Linux Interview Questions Author Mithun Technologies 4
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

20. What command shows you what directory you are in?
Ans)

21. What command creates an empty directory?


Ans)

22. What command displays your current username?


Ans)

23. What command shows you CPU and memory utilization for running
processes?
Ans)

24. What command allows you to open and view a file one page at a time?
Ans)

25. Which command(s) show users that are logged in?


Ans)

26. What command is used to change a file name?


Ans)

27. What is the command to switch to the root user account?


Ans)

28. What command is used to change the permissions of a file?


Ans)

29. What is the command to change your password?


Ans)

30. What command is used to display your previous commands?


Ans)

Test - 2
1) What can you type at a command line to determine which shell you are using?
Ans)

2) What is RPM?
Ans)

3) What is apt-get?
Ans)

4) What is the command to create user in Linux server?


Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 4


Mithun Technologies Linux Interview Questions Author Mithun Technologies 5
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

5) What is the difference between rm and rmdir commands?


Ans)

6) What is the command to display the user information like (users login name, real
name, terminal name,shell)
Ans)

7) What is the command to download any software from internet?


Ans)

8) What is the command to display the jobs that you are running in the background
and in the foreground?
Ans)

9) How to check the status if one service?


Ans)

10) What is the command which will gives the description about any command?
Ans)

Test 3

Explain the file system hierarchy in Linux system?


Ans)

What is mkdir command and what is the -v, -p and -m options with mkdir command?
Ans)

What is ls -ltr? In this what is l,t and r?


Ans)

How to list all hidden files and hidden directories?


Ans)ls -a | grep '^\.'
ls -ld .*

How to display only directories?


Ans) ls -d */ --> It will display only directories.
ls -l | grep '^d'
ls -l | grep d

How to display only files?


Ans) ls -l | egrep -v '^d'

What is cd -?
Ans)

What is cd ~?
Ans)

What is cd?
Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 5


Mithun Technologies Linux Interview Questions Author Mithun Technologies 6
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

Which user account is created on Linux while installation?


Ans) root user

What is the use of file command?


Ans)

How to check the RAM size?


Ans) Using free command

How to check the server resources utilisation?


Ans) Using top command

How to check the CPU and Memory statistics?


Ans) Using vmstat command

How to search the files with various conditions like empty files, based on size...?
Ans)

How to set the permissions for files or directories?


Ans) Using chmod command

What is Umask?
Ans) Default file and directory permissions.

How to set the umask permanently for aa user?


Ans) vim ~/.bashrc

How to check open ports on local system?


Ans) netstat -tunlp

How to check open ports on remote server?


Ans) nmap -A serverIp

How to check which services are enable across reboot?


Ans) chkconfig --list

What is load average in Linux?


Ans) Load average is defined as the average sum of the number of process waiting in the ru queue
and number of process currently executing over the period of 1, 5and 15 minutes.using the 'top' and
'uptime' command we find the load average of a Linux server.

What is partial backup?


Ans)

when you select single partition for single folder for backup on your server.
Ans)

How can we review boot message?


Ans) dmesg command

What are the fields in the/etc/passwd file?


Ans) user:pass:uid:gid:comment for user:user's home dir:user's login shell.

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 6


Mithun Technologies Linux Interview Questions Author Mithun Technologies 7
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

How to check which RPM provides/etc/shadow file?


Ans) rpm -gf /etc/passwd

In which file the password are saved for each user?


Ans)

In which file user information is saved?


Ans)

What is Inode? What is the use?


Ans)

/etc/resolve.config
Explain and if we not declared here what will happen?
Ans)

What is Vcpu,if vcpu % more than 1 what will happen?


Ans)

How you will find out memory details and explain about swap memory?
Ans)

Write a command for 5 days older files with extension of .log , those files want to move it
different directory?
Ans)

What is Inode? What is the use of Inode?


Ans)

Booting process? Explain about run levels? what is default run levels?
Ans)

How will you find out top ten process?


Ans)

How to check open files in sever?


Ans) By using lsof command

Directory special permissions?


Ans)

What is sticky bit?


Ans)

What is NFS?
Ans)

What it gives/displays if you execute mount -a?


Ans)

I have a file in some location. How to find that file. in that file how to display the

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 7


Mithun Technologies Linux Interview Questions Author Mithun Technologies 8
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

particular content(already I know the content) ?


Ans)

How to find a port that is enable or not?


Ans)

What is SSL?
Ans)

What is GRUB?
Ans)

Explain soft link and hard link? What is the difference? When you use?
Ans)

What is the first statement in shell scripting?


Ans)

Explan about Process and threads?


Ans)

What is zombie proces?


Ans)

How will you find out what are the files using by particular process?
Ans)

What is zone file?


Ans)

How can you prevent anyone from scheduling a cronjob?


A) Delete the file /etc/cron.deny
B) Create an empty file called /etc/cron.deny
C) Create two empty files: /etc/cron.deny and /etc/cron.allow
D) Create an empty file called /etc/cron.allow

Ans) D

Using command substitution, how would you display the value of the present working
directory?
A) echo $(pwd)
B) echo pwd
C) $pwd
D) pwd|echo

Ans) A

Explanation: The echo command can be used to display the contents of variables. The present
working directory is held in the pwd variable. echo $(pwd) will display the contents of the pwd
variable. Other commands that would work are echo $ PWD and echo “$PWD”.
Reference: http://www.bolthole.com/solaris/ksh-beforeyoustart.html
Incorrect Answers:

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 8


Mithun Technologies Linux Interview Questions Author Mithun Technologies 9
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

B:echo pwd would display the text ‘pwd’.


C:$pwd doesn’t do anything although $PWD would work.
D:pwd | echo doesn’t do anything.

Which file contains the default environment variables when using the bash shell?

A) ~/.profile
B) /bash
C) /etc/profile
D) ~/bash

Ans) C

Explanation:
The /etc/profile file contains the system default environment variables for the bash shell.

What is Crontab?
Ans)

Whats is vmstat and memstat?


Ans)

How to change run levels?


Ans)

What is Linux Loader?


Ans)

Otherethan LILO , we have LOADLIN (LOAD LINux) and GRUB (GRand Unified Bootloader).

What is stateless Linux server?


Ans)

A process is identified by a unique


a)pid
b)id
c)processid
d)proid

Ans)

Which of the following is the BEST way to set up SSH(Secure Shell) for communicating
between Systems without needing passwords?

A)Use ssh-keygen for generating public-private keys.


B)Disable passwords on specific accounts that will use SSH.
C)Both A and B
D)None of the above

Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 9


Mithun Technologies Linux Interview Questions Author Mithun Technologies 10
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

Given a file, replace all occurrence of word "mithun" with "manan" from 5th line till end in
only those lines that contains word "ruthvik"
Ans)
Given file is mithuntechnologies.txt
sed -n `5,$p` mithuntechnologies.txt | sed '/ ruthvik/s/ mithun/manan/

1) In Ubuntu server I have fired a command “cat /etc/lsb-release”, what it will gives me?
Ans) It will give the version of the software and release name like below.

LSB: Linux Standard Base tools

2) The command uname –a what it will gives me?


Ans) uname command will print the system information like kernel, hardware, operation system
info…etc

uname -a : it will print all information like kernel-name, kernel-release, node hostname…etc

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 10


Mithun Technologies Linux Interview Questions Author Mithun Technologies 11
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

3) Let say that I have one shell script, I wanted to be executed whenever the system boot
time, it should not be executing at any other time, it exacted only boot time. In this scenario
what will do?
Ans)

4) What is the difference between bash_profile and bashrc file in user home directory?
Ans)

5) What is Login Shell and Non Login shell


Ans)

6) Can you explain me the contents in /etc/shadow file?


Ans)
• The /etc/shadow file stores user account information. Like username, password, last
password changes etc.
• Password is stored in encrypted format.
• All fields are separated by a colon (:) symbol.

#cat /etc/shadow

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 11


Mithun Technologies Linux Interview Questions Author Mithun Technologies 12
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

7) How is your knowledge on Linux File System?


Ans)

8) Have you worked on /srv directory?


Ans)

9) What is the difference between /bin and /sbin directory?


Ans)

10) What configuration we have to set to do for normal user and root user differentiation?
Ans)

11) There is some settings which makes doesn’t show some advanced commands to
normal user? What are those settings?
Ans)

12) What is PATH and what does it do?


Ans)

13)Which lang u prefer?


Ans)

14)Difference between $* and $@


Ans)

15)Explain about Cron Job?


Ans)

16)How to check one software where is installed in Linux machine? Suppose take Jenkins.
Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 12


Mithun Technologies Linux Interview Questions Author Mithun Technologies 13
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

17)How to set the path which is accessible by the all the users?
Ans)

18)How to create the user?


Ans) We can create the user by using the command ‘useradd’
useradd <<User Name>>
useradd mithun

Here mithun is the username.

19)How to create the group?


Ans) We can create the group by using the command ‘groupadd’
groupadd <<Group Name>>
groupadd devopsteam

20)How to add user to group?


Ans) using usermod commnd we can add the user to group as follows.
usermod –g <<Group Name>> <<User Name>>

21)How to check CPU utilization?


Ans) We can check the cpu utilization using top command or mpstat command.

22)What is load average?


Ans) In UNIX computing, the system load is a measure of the amount of computational work that
a computer system performs. The load average represents the average system load over a period
of time. It conventionally appears in the form of three numbers which represent the system load
during the last 1, 5 and 15 minute periods.

Using below command we can find the load average.


uptime
top
cat /proc/loadavg
w
23)What is the difference between load average and cpu load?
Ans)

24)What is load average?


Ans) Below commands will give the load average values.

#cat /proc/loadavg

#w

#uptime

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 13


Mithun Technologies Linux Interview Questions Author Mithun Technologies 14
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

#top

load average 3.00 in prod server, but things are running fine? What is this?
Ans) On multi-processor system, the load is relative to the number of processor cores available. The
"100% utilization" mark is 1.00 on a single-core system, 2.00, on a dual-core, 4.00 on a quad-core,
etc.

A load of 1.00 is 100% CPU utilization on single-core box. On a dual-core box, a load of 2.00 is 100%
CPU utilization.

25)What is Inode?
Ans) Inode is a data structure that contains information of a file.
The inode contains a list of all the blocks in which a file is stored, the owner information
for that file, permissions, and all other attributes that are set for the file. In a sense, you
could say that a file really is the inode, and names are attached to these inodes to make
it easier for humans to work with them.

26)What is Sticky bit?


Ans) A Sticky bit is a permission bit that is set on a file or a directory that lets only the
owner of the file/directory or the root user to delete or rename the file. No other user is
given privileges to delete the file created by some other user.

To set the sticky bit for file or directory will follow like below.
chmod +o file/directory

example:
chmod o+devops.txt
chmod 1777 devops.txt

After setting Sticky Bit to a file/folder, if you see ‘T’ in the file permission area that indicates the
file/folder does not have executable permissions for others on that particular file/folder.

27)How to check process is in waiting state or not?

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 14


Mithun Technologies Linux Interview Questions Author Mithun Technologies 15
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

Ans) In Linux a process can be in any of the below states.

R running or runnable (on run queue)


D uninterruptible sleep (usually IO)
S interruptible sleep (waiting for an event to complete)
Z defunct/zombie, terminated but not reaped by its parent
T stopped, either by a job control signal or because
it is being traced
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)

A process starts its life in an R "running" state and finishes after its parent reaps it from the Z "zombie"
state.

With help of top or ps command we can find the process is in which state.

28)What is process?
Ans) A process is an instance of a program that is being executed. Processes are also frequently
referred to as tasks. OR A process is the execution context of a running program.

29)What is thread?
Ans) Threads are "light weight processes" (LWPs).

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 15


Mithun Technologies Linux Interview Questions Author Mithun Technologies 16
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

30)On what process the server will shutdown?


Ans)

31)How to find the empty directories in the current directory and need to delete?
Ans) find . -type d -empty -delete

32)How to find the empty files in current directory?


Ans) find . -type f -empty

33)How to find the empty lines in particular file and need to remove?
Ans) With help of sed command.

34)What is the umask?


Ans) UMASK (User Mask) is the default permission given when a new file or directory is created
on a Linux machine. At the point when user create a file or directory under Linux or UNIX, It
create with a default set of permissions. Most of the Linux distros give 022 (0022) as default
UMASK. In other words, it is a system default permissions for newly created files/folders in the
machine.

35)What is max value of giving to umask?


Ans) The minimum and maximum UMASK value for a folder is 000 and 777
The minimum and maximum UMASK value for a file is 000 and 666

36)What is the default permissions to a file?


Ans) It will depends on umask value. By default umask value is 022, so the default file permission
ins 644 (rw-r--r--).

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 16


Mithun Technologies Linux Interview Questions Author Mithun Technologies 17
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

What is the default permissions to a directory?


Ans) It will depends on umask value. By default umask value is 022, so the default directory
permission ins 755 (rwxr-xr-x).

37)what is chmod?
Ans) chmod (change mode) is used to set the permissions for files and directories.

38)How to check ports in linux?


Ans) Using netstat command we can find the all the port numbers in linux server as follows.
netsat -a : It will Shows both listening and non-listening (for TCP this means established
connections) sockets.

#netstat -a | grep LISTENING | grep 8080

What do the following commands do?


tee
awk
tr
cut
tac
curl
wget
watch
tail

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 17


Mithun Technologies Linux Interview Questions Author Mithun Technologies 18
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

What does a & after a command do?


Ans) The symbol & makes the command to run in a the background.
sh mithun.sh &

A background process will not stay alive after the shell session is closed. SIGHUP terminates all
running processes. By default anyway. If your command is long-running or runs indefinitely you
need to prefix it with nohup so it remains running after you disconnect from the session, as follows.

nohup sh mithun.sh &

What is a packet filter and how does it work?


Ans) Packet filtering is a firewall technique used to control network access by monitoring outgoing
and incoming packets and allowing them to pass or halt based on the source and destination
Internet Protocol (IP) addresses, protocols and ports.

Network layer firewalls define packet filtering rule sets, which provide highly efficient security
mechanisms.

Packet filtering is also known as static filtering.

What is swap and what is it used for?


Ans) A computer has sufficient amount of physical memory but most of times we need more so
we swap some memory on disk. Swap space is a space on hard disk which is a substitute of physical
memory. It is used as virtual memory which contains process memory image. Whenever our
computer run short of physical memory it uses it’s virtual memory and stores information in
memory on disk. Swap space helps the computer’s operating system in pretending that it have
more RAM than it actually has. It is also called as swap file.This interchange of data between
virtual memory and real memory is called as swapping and space on disk as “swap space”.

Virtual memory is a combination of RAM and disk space that running processes can use. Swap
space is the portion of virtual memory that is on the hard disk, used when RAM is full.

What is the sticky bit?


Ans) A Sticky bit is a permission bit that is set on a file or a directory that lets only the owner of
the file/directory or the root user to delete or rename the file. No other user is given privileges to
delete the file created by some other user.

What is the difference between hardlinks and symlinks? What happens when you remove
the source to a symlink/hardlink?
Ans)

What is an inode and what fields are stored in an inode?


Ans)

How to force/trigger a file system check on next reboot?


Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 18


Mithun Technologies Linux Interview Questions Author Mithun Technologies 19
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

What is SNMP and what is it used for?


Ans)

What is a runlevel and how to get the current runlevel?


Ans)

What is SSH port forwarding?


Ans)

What is the difference between local and remote port forwarding?


Ans)

What steps to add a user to a system without using useradd/adduser?


Ans)

What is MAJOR and MINOR numbers of special files?


Ans)

Describe a scenario when you get a "filesystem is full" error, but 'df' shows there is free
space.
Ans)

Describe a scenario when deleting a file, but 'df' not showing the space being freed.
Ans)

Describe how 'ps' works.


Ans)

What happens to a child process that dies and has no parent process to wait for it and what’s
bad about this?
Ans)

How to know which process listens on a specific port?


Ans)

What key combination can you press to suspend a running job and place it in the
background?
Ans) ctrl + z
You can suspend a currently running job by using the Ctrl + z keystroke. This will stop the job,
but it won’t end it. The job will be available to be resumed. Note: you can only stop jobs that were
started in your current shell.

Which of these tools can provide the most information about DNS queries?
A. dig
B. nslookup

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 19


Mithun Technologies Linux Interview Questions Author Mithun Technologies 20
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

C. host
D. named-checkconf
E. named-checkzone

Ans) A

https://vceguide.com/which-file-contains-a-list-of-filesystems-that-can-be-currently-mounted-
on-the-system/

How to know user is root user or sudo user?


Ans) If UID is 0 we can consider user is root user, otherwise we can consider not root user, it may
be normal user or system user.

How to create users in linux and how to give sudo permissions to user?
Ans) Using useradd command we can create a user.
Using visudo command we can give sudo access.. add user into /etc/sudoers file to provide the
sudo access.

How to display last 10 commands which we have used in Linux?


Ans) history 10

Write script/command to delete last word from every line in a file.


Ans)
awk '{gsub("[a-zA-Z0-9]*$", "");print}' <filename>

To replace last word with hello in every line


Ans)
awk '{gsub("[a-zA-Z0-9]*", "hello");print}' <filename>

Write a script/command to find the files with more than 1gb size.
Ans)
find <path for directory> -size +1G -type f

What is Swap Space?


Ans)

What is the maximum length for a file name in Linux?


Ans)

Which partition stores the system configuration files in Linux system?


Ans)

Which command is used to uncompress gzip files?


Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 20


Mithun Technologies Linux Interview Questions Author Mithun Technologies 21
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

What is the difference between soft and hard mounting points?


Ans)

What are the file permissions in Linux?


Ans)
Some more questions are from sed, find and awk .

How to check Memory stats and CPU stats as a Linux admin?


Ans)

How to reduce or shrink the size of LVM partition?


Ans)

How can you enhance the security of password file?


Ans)

What is the difference between Cron and Anacron?


Ans)

What command is used to check the number of files, disk space and each user’s defined quota?
Ans)

How can you manage memory in linux machines?


Ans)

What is the name and path of the main system log?


Ans)

How to manage logical volumes?


Ans)

Explain /proc filesystem?


Ans)

What are the fields in the/etc/passwd file?


Ans)

How do you terminate an ongoing process?


Ans)

How can you know the execution time of a command?


Ans)

How can you append one file to another in Linux?


Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 21


Mithun Technologies Linux Interview Questions Author Mithun Technologies 22
+91-9980923226 devopstrainingblr@gmail.com Web site http://mithuntechnologies.com

How you can run a Linux program in the background simultaneously when you start your Linux
Server?
Ans)

Difference in soft link and hard link?


Ans)

How to find a particular word from a file?


Ans)

What is stop command?


Ans)

How to stop particular process using Linux command?


Ans)

Can we delete content in a file by using SED command? How to do?


Ans)

© All rights Reserved by Mithun Technologies devopstrainingblr@gmail.com 22

You might also like