List of most common Interview questions on linux.
Question 1: Explain LILO?
Ans: LILO (Linux Loader) is the boot loader for Linux operating system to load it into the main memory so that it can begin its operations. Bootloader here is a small program that manages a dual boot. LILO resides in MBR (Master Boot Record).
Question 2 : What is Swap space?
Ans: Swap space is the amount of physical memory that is allocated for use by Linux to hold some concurrent running programs temporarily. This condition usually occurs when Ram does not have enough memory to support all concurrent running programs. This memory management involves the swapping of memory to and from physical storage.
There are different commands and tools available to manage the Swap space usage.
Question 3: How can you determine the total memory used by LINUX?
Ans: It is always required to keep a check on the memory usage in order to find out whether the user is able to access the server or the resources are adequate. There are roughly 5 methods that determine the total memory used by the Linux.
- Free command: This is the most simple and easy to use the command to check memory usage. For example: ‘$ free –m’, the option ‘m’ displays all the data in MBs.
- /proc/meminfo: The next way to determine the memory usage is to read /proc/meminfo file. For example: ‘$ cat /proc/meminfo’
- Vmstat: This command basically lays out the memory usage statistics. For example: ‘$ vmstat –s’
- Top command: This command determines the total memory usage as well as also monitors the RAM usage.
- Htop: This command also displays the memory usage along with other details.
Question 5: Explain the 3 kinds of file permissions under LINUX?
Ans: Every file and directory in Linux are assigned three types of owners namely ‘User’, ‘Group’, and ‘Others’. Find the three kinds of permissions defined for all the three owners
- Read: This permission allows you to open and read the file as well as list the contents of the directory.
- Write: This permission allows you to modify the contents of the file as well as allows adding, removing and renaming files stored in the directories.
- Execute: User can access and run the file in the directory. You cannot run a file unless the execute permission is set.
Question 6: How permissions are granted under LINUX?
Ans: A system administrator or the owner of the file can grant permissions using the ‘chmod’ command. Following symbols are used while writing permissions
- ‘+’ for adding permission
- ‘-‘ for denying permission
Permissions also includes single letter which denotes
u : user; g: group; o: other; a: all; r: read; w: write; x: execute.
Question 7: What is vi editor?
The 3 different kinds of modes in vi editor are enlisted below
- Command Mode/ Regular Mode
- Insertion Mode/ Edit Mode
- Ex Mode/ Replacement Mode
Question 8 :
- pwd: It is a built-in command which stands for ‘print working directory’. It displays the current working location, working path starting with / and directory of the user. Basically, it displays the full path to the directory you are currently in.
- Is: This command list out all the files in the directed folder.
- cd: This stands for ‘change directory’. This command is used to change to the directory you want to work from the present directory. We just need to type cd followed by the directory name to access that particular directory.
- mkdir: This command is used to create an entirely new directory.
- rmdir: This command is used to remove a directory from the system.
Ans: As the name suggests, the shell script is the script written for the shell. This is a program file or says a flat text file where certain Linux commands are executed one after another. Although the execution speed is slow, Shell script is easy to debug and can also simplify everyday automation processes.
Linux file content commands?
Ans: There are many commands present in Linux which are used to look at the contents of the file.
Some of them are enlisted below
- head: Displays the beginning of the file
- tail: Displays the last part of the file
- cat: Concatenate files and print on the standard output.
- more: Displays the content in pager form and is used to view text in the terminal window one page or screen at a time.
- less: Displays the content in pager form and allows backward and single line movement.
Question 11: Grep commands?
Ans: Grep stands for ‘global regular expression print’. This command is used for matching a regular expression against text in a file. This command performs pattern-based searching and only the matching lines are displayed as output. It makes use of options and parameters that are specified along with the command line.
For example: Suppose we need to locate the phrase “our orders” in HTML file named as “order-listing.html”. Then the command will be as follows:
$ grep “our orders” order-listing.html
The grep command outputs the entire matching line to the terminal.
Question 12: Linux networking and troubleshooting commands?
Ans: Every computer is connected to network internally or externally for the purpose of exchanging information. Network troubleshooting and configuration are essential parts of and network administration. The networking commands enable you to quickly troubleshoot connection issues with another system, check the response of another host, etc.
Network administrator maintains system network which includes network configuration and troubleshooting. Mentioned below are few commands along with their description:
Mentioned below are few commands along with their description
- Hostname: To view the hostname (domain and IP address) of the machine and to set the hostname.
- Ping: To check if the remote server is reachable or not.
- ifconfig: To display and manipulate route and network interfaces. It displays network configuration. ‘ip’ is the replacement of ifconfig command.
- netstat: It displays network connections, routing tables, interface statistics. ‘ss’ is the replacement of netstat command which is used to get more information.
- Traceroute: It is network troubleshooting utility which is used to find the number of hops required for a particular packet to reach the destination.
- Tracepath: It is same as traceroute with a difference that it does not require root privileges.
- Dig: This command is used to query the DNS name servers for any task related to DNS lookup.
- nslookup: To find DNS related query.
- Route: It shows the details of the route table and manipulates IP routing table.
- mtr: This command combines ping and track path into a single command.
- Ifplugstatus: This command tells us whether the network cable is plugged in or not.
What is BASH?
BASH is short for Bourne Again SHell. It was written by Steve Bourne as a replacement to the original Bourne Shell (represented by /bin/sh). It combines all the features from the original version of Bourne Shell, plus additional functions to make it easier and more convenient to use. It has since been adapted as the default shell for most systems running Linux.
Question 14: What is a swap space?
Swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently. This happens when RAM does not have enough memory to hold all programs that are executing.
Question 15: What does Sar provide? Where are Sar logs stored?
Sar collects, reports, or saves system activity information, sar serves to log and evaluate a variety of information regarding system activity. With performance problems, sar also permits retroactive analysis of the load values for various sub-systems (CPUs, memory, disks, interrupts, network interfaces and so forth) and limitation of problems in this manner. If CPU utilization is near 100 % (user + nice + system), the workload sampled is CPU-bound.
By default, log files of Sar command is located at /var/log/sa/sadd file, where dd parameter indicates the current day
Question 16: How to reduce or shrink the size of LVM partition?
- Unmount the filesystem using unmount command,
- Use resize2fs command , e.g. resiz2fs /dev/mapper/myvg-mylv 10G
- Now use the lvreduce command as lvreduce -L 10G /dev/mapper/myvg-mylv
The above Command will shrink the size LVM partition and fixes the filesystem size to 10GB.Most in-depth, industry-led curriculum in linux.
Question 17: How shadow passwords are given by in Linux?
pwconv command is used for giving shadow passwords. Shadow passwords are given for better system security. The pwconv command creates the file /etc/shadow and changes all passwords to ‘x’ in the /etc/passwd file.
First, entries in the shadowed file which don’t exist in the main file are removed. Then, shadowed entries which don’t have `x’ as the password in the main file are updated. Any missing shadowed entries are added. Finally, passwords in the main file are replaced with `x’. These programs can be used for initial conversion as well to update the shadowed file if the main file is edited by hand.
Question 18: Maximum how long can a Linux filename be?
Question 19: Which combination of keys is used to exit from terminal?
Ctrl + d
Question 20: Command(s) is/are used to get help about a command in Linux?
Question 21: list all the files in your current directory(including hidden)?
Question 22: Command is/are used to remove directory in Linux?
B. rm -r
Question 23: Which key combination is used to see all the hidden files in Nautilus file manager?
Ctrl + h
Question 24: Command used to create file in Linux?
- example : touch filename
- example : cat filename < “data”
- example: echo “data” > filename
Question 25: How is everything stored as in linux
Question 26: Valid login shell in Linux?
- C shell
- Bash Shell
- Z shell
Question 27: Command used to record session in Linux?
Question 28: Alternative to echo command?
Question 29: Command used to change password of your Linux system?
Question 30: Command used see the list of users who are currently logged-in?
Question 31: Which directory in Linux contains all the config file of the system?
Question 32: Which command is used to know last shutdown/reboot date and time?
Question 33: Which of the following command is used to count number of lines in a file?
Question 34: Command(s) is/are used to reboot a Linux system?
- A. shutdown -h
- init 6
Question 35: Total no of run levels in a Linux system?
Question 36: Command is used to copy entire directory?
Question 37: Suppose I am in /etc directory and I want to go to my home directory which command should I use?
- cd ~
Question 38:what is the purpose of -i in rm -i command?
It will ask for confirmation before every deletion.
Question 39: mv command can be used to ?
- Move the file to different directory.
- Renaming a file
Question 40:command is used to display content of a file in octal format?
Question 41: command do you use to know the purpose of a command?
Question 42: What is the process id of init process?
Question 43:Command is used to show process hierarchy in tree format?
Question 44:Command is used to see the content of tar(backup.tar) file without extracting it?
tar -tvf backup.tar
Question 45:Command is used to execute the last command you have executed?
Both A and B
Question 46:What is the purpose of id command?
Print effective and real UID and GID
Question 47:Command is used to print the login shell of an user?
Question 48:Command return the exit status of last command?
Question 49:which command is used to print the current working directory?
Both A and B
Question 50: ppid(parent process id) of daemon process in Linux ?