Linux Interview Questions and Answers

bookmark

Categories

Linux


Linux Interview Questions and Answers Online Training

Enroll Today

Top Linux Interview Questions and Answers - 2021 [UPDATED]

Are you looking for Linux Interview Questions and Answers? Than you are at the Right Place. Browse through Popular and Most Asked Interview Questions for Linux.  There is a Huge Demand for Linux Professionals in the Market. These Questions are suitable for both Freshers and Experienced Professionals and are based on Trending Topics and as per Current Industry Requirements.

Master These Topics and Increase your Chances in cracking Linux Interviews like a pro and Secure your Dream Job Today.

Linux Interview Questions and Answers

  • 101 Questions

Its unique identification code for files and directories, its was generate automatically while create new file and directories ls -i filename ls -ldi directoryname

Read, Write and Execute Owner, Group Owners and Others

Set User ID = 4 Set Group ID = 2 Stickybit = 1

Pstree -P 7. What is use of “top” command and how to sort Memory and User wise? Its used to real time monitor hardware utilization of linux machine. Press M to sort Memory wise result Press U to sort User wise result

Service network restart

Static IP Address Dynamic IP Address

Open and Edit this file #vi /etc/sysconfig/network-scripts/devicename For enable ONBOOT = yes For disable ONBOOT =no

/etc/sysconfig/network-scripts

cd/var/lib/mlocate updatedb

The following commands are used to exit from vi editors. 1. :wq saves the current work and exits the VI. 2. :q! exits the VI without saving current work.

1. gzip = Compress File 2. gunzip = Uncompress File

Its Master Boot Recorder to help booting operating system.

Temporary Mount Permanent Mount

Linux uses swap space to increase the amount of virtual memory available to a host. It can use one or more dedicated swap partitions or a swap file on a regular filesystem or logical volume.

What are types can set SWAP? Temporary set Permanent set

PV = Physical Volume VG = Volume Group LVM = Logical Volume

LVM is used to create logical partitions and during run time we can resize particular partition without data loss. Empty partitions only can do LVM creation.

#lvcreate -L partitionsize -n userdefinename volumegroupname

RPM = Redhat Package Manager YUM = Yellow Dog Updated Modifier

BIOS ? MBR ? Boot Loader ? Kernal ? Runlevel

Forward lookup zone Reverse lookup zone

IP Tables Selinux TCPwrappers

#iptables -F Service iptables save

Its one type of firewall in linux To block particular service in a Protocol

/etc/selinux/config

The Lightweight Directory Access Protocol (LDAP) is a set of open protocols used to access centrally stored information over a network.

yum remove packagename

service postfix restart 50.What is command for FTP service on and restart? chkconfig vsftpd on service vsftpd restart

Kernel is the heart of operating system. It interacts with shell and executes the machine level language.

At the beginning of the session if I will use SCRIPT command then the details of the input and output commands will be saved in a file called typescript and we can view it any time using “cat typescript” command. This is very useful to track what user is doing what. HISTORY command will not work because it shows data only for the current session.

There are multiple way to create files in unix, but the simple way to create a file is using “cat” and “Touch” command Syntax: cat > File name touch file name

To check process which are running in my machine I can use two commands. (a) TOP and (b) PS

Top command gives the dynamic view of the processes are running in the server and generally the dynamic change happens in every 3 second. Whereas PS commands gives the static view of the processes.

Yes TOP command it self has a command prompt. Type K then it will ask you for the PID of the process to kill. Hit the PID and enter, it will kill the process.

cat command creates a file and we can save some data inside the file but touch command by default will create a blank file.

Say I want to create a directory D1 and inside that D2 and inside that D3. Is it possible? If yes how ? Yes creating multiple directories is possible. In this scenario the below command works. Mkdir –p D1/D2/D3

Use PWD command to check which directory you are in.

Yes every command in Unix is a C program in the backend. When we type a command and hit enter the program runs in the backend and gives you the output. We can view the C program as well as below. type ->hit enter, it will give you a path where the program the command is located. You can view the program by doing cat and the path name. it will open a C program file in decrypted mode.

Using ls command. I can view the directories and files of the system.

Using ls –a command I can view the hidden files of the sytem

No there is no such command called “ll”. It’s just the alias of ls command. We can check it by typing alias command.

Description of shell is huge, but yes commonly we explain it as the interpreter between the user and the machine.

rm –r* will remove all the file entries in the current directory. It is not advisable to use this command in real time environment. Specifically in production. Because we have huge files which are necessary to be accessed by other users.

The second name of a file is called a link, it’s assigned to create another link to the current file.

Absolute path refers to the path starting from the root directory and the path continues with a sequence starting from Root. Whereas relative path is the current path.

type hostname command or else you can use ifconfig as well.

you can use ping –t command for this. Ping –t or

cat >> file name and hit enter. You can append lines below the existing lines of the file. And do a ctrl D to save and exit.

FIFO is first in first out and LIFO is last in last out.

PATH is an environmental variable which contains the path of the command files and we can change the paths inside the PATH variable.

first use PS –ef command and get the PID of the process you want to kill. Then use kill -9 command to kill the process.

Use Free –m or free –G command to check the memory size of a linux machine.

Use du command to check the disk utilization.

use df –h command, it will show the disk free of linux machine.

use users command. It will how the details of the users logged in to the system.

I will ue grep command here. And the syntax will be as below. Grep -i “India” Mantu.txt Grep command is used for pattern earching.

A admin while giving permission to the users usually give normal access permission but few of the user having special permission then normal user, they are called super user.

sudo su – 81. How can I change the permission of a file? Using chmod command I can change the permissions of a file.

Use the below command to give all read, write and execute permission. chmod 777

collection of more than one process is called as a process group in unix.the function getpgrp returns the process group id.

there are 64 numbers which can be used with kill command but generaly we use kill -9

There are multiple type of files available in unix, few of among them are : Regular file Image file Binary file Linked file

cmp command compares the two files byte by byte and gives the output what is not common in between them. Diff command through the output which is not matching between the two file immediately rather comparing bit by bit.

Pipe symbol interlinks two commands. It stores the output of the first command and give it to the second command as input. Cat emp.lst | mantu.txt

Open the file using vi Then go to command prompt and type set number. The numbers will be set before every line of the file.

We can use man . it will show you all the possible way to use the command.

head command is used to view the top portions of the file. Say if I want to view top 5 lines of a file then I can use the below command. Cat | head -5

tail command is used to view the bottom of the lines of a file. Say if I want to view bottom 5 lines of a file then I can use the below command. Cat | tail -5

Grep and sed are the main command used for pattern searching.

Open the file with vi. Use /pattern name , then hit enter, it will show you the matching patterns in VI.

Use dd in command mode to delete one line of a file in vi.

Use cp command while copying a file in unix. cp

Scp stands for secure copy in unix. The files which get copied by using scp command are decrypted so we need not be worry of hacking of the file system.

We can move a file or rename a file using this command. General purpose of using mv command is to use it for reaming purpose.

Touch command is used to change the access and modification time of the file.

We use “&” symbol to execute a job in back ground. When we execute a job or process in unix it starts executing in the prompt itself and we can’t do other stuffs in the command prompt at that time. So until unless the process gets executed we have to seat idle. So for continuous interaction with the command prompt we prefer executing the jobs or processes in back ground.

you change any attributes of the file to read only. The command is: chattr +i filename And to disable it: chattr -i filename

first use PS –ef command and get the PID of the process you want to kill. Then use kill -9 command to kill the process.

Use Free –m or free –G command to check the memory size of a linux machine.

Use du command to check the disk utilization.