300 Linux Interview Questions and Answers [2024]

In this article we are going to cover Linux Interview Questions and Answers, Linux Scenario based interview questions and answers, Linux Troubleshooting Interview questions and answers.

You notice a sudden spike in server CPU utilization. How would you troubleshoot and identify the root cause?
Ans:- I would check CPU usage using `top` or `htop`, identify the culprit process with `ps` or `pidstat`, analyze logs for events, and optimize or scale resources accordingly.

A critical application on your Linux server is unresponsive. Walk me through the steps you would take to diagnose and resolve the issue.
Ans:- I’d use `ps` and `top` to identify the hung process, check logs for errors, restart the application or services, and monitor for improvements.

You need to deploy a new version of a web application on a Linux server without causing downtime. Explain the steps you would take to achieve a zero-downtime deployment.
Ans:- Implement a load balancer, deploy the new version on one server at a time, validate each step, and update the load balancer to include new servers.

A team member accidentally deleted important files on a Linux server. How would you recover the lost data?
Ans:- I’d use file recovery tools like `extundelete` or `photorec`, avoid writing new data to prevent overwriting, and restore from backups if available.

Your Linux server is running out of disk space. What steps would you take to identify and resolve the issue, considering both short-term and long-term solutions?
Ans:- Identify large files with `du` and `df`, remove unnecessary files, implement log rotation, and consider long-term solutions like additional storage.

Explain how you would set up and configure a basic firewall on a Linux server to enhance its security.
Ans:- Use `iptables` or `firewalld` to set up rules, allow only necessary ports and services, and regularly review and update firewall rules.

Your team is working on a collaborative project, and you want to implement version control using Git on a Linux server. How would you set up and manage the Git repository?
Ans:- Initialize a Git repository with `git init`, add and commit files, push to a central repository, and collaborate using branches and pull requests.

You want to monitor the performance of your Linux server over time. What tools and techniques would you use for performance monitoring and analysis?
Ans:- Use tools like `sar`, `vmstat`, and `iostat` for monitoring, set up alerts for abnormal behavior, and consider long-term solutions like Prometheus.

You are responsible for securing a Linux server. Outline the security measures and best practices you would implement to protect against potential threats.
Ans:- Keep the system and software updated, configure a firewall, implement strong user authentication, regularly audit and review system logs, and apply the principle of least privilege.

When you login you get “$” prompt, what is the prompt for root?
Ans:- #

Explain the difference between grep and egrep?
Ans:-

Grep and egrep are both tools used to search text for patterns, but they differ in how they interpret those patterns:

  • grep:
    • Stands for “Global Regular Expression Print”
    • Uses Basic Regular Expressions (BRE) by default.
    • In BRE, special characters like +, ?, |, (), and {} only have a special meaning if preceded by a backslash ().
    • This means you need to escape these characters to use them for their special functions in your search pattern.
  • egrep:
    • Stands for “Extended Global Regular Expression Print” (deprecated)
    • Or grep -E (preferred way)
    • Uses Extended Regular Expressions (ERE).
    • In ERE, these same special characters inherently have their special meaning without needing to be escaped.
    • This allows for more concise and readable patterns.

For example, to search for lines containing either “error” or “warn” with grep, you’d need to escape the pipe (|) character:

grep "error\|warn" your_file.txt

With egrep or grep -E, you can simply use the pipe character directly:

grep -E "error|warn" your_file.txt

Here’s a table summarizing the key differences:

Featuregrepegrep (grep -E)
Default Regex FlavorBasic (BRE)Extended (ERE)
Special Character EscapeNeeded ()Not Needed
FunctionalityBasic text searchMore powerful patterns
  • Use grep for simple searches or when you’re not sure if your pattern needs special characters.
  • Use egrep (or grep -E) for more complex searches that leverage the power of extended regular expressions.

What is the port # for DNS, NTP and NFS?
Ans:- 53,123 and 111/2049

What is the configuration file name of DNS and where is it located?
Ans:- /etc/named.conf

How many new directories will be created after running the following command
mkdir {a..c}{1..3}
Ans:- 9

Your PC is configured with a DNS server address but not the default gateway. Can the PC access internet?
Ans:- No

What is the difference between IP and Gateway?
Ans:- Both IP and Gateway are important concepts in computer networking,

IP Address (Internet Protocol Address):

Think of it as a unique identification tag assigned to each device on a network.
It’s like a house address in the digital world, allowing devices to find and communicate with each other.
IP addresses are typically written in a format like 192.168.1.100, consisting of four numbers separated by periods.

Gateway (Default Gateway):
Acts like a traffic director for your network.
It’s usually your router, a device that connects your local network (like your home Wi-Fi) to the wider internet.
When a device on your network wants to access something outside your local network (like a website), it sends the data to the gateway.
The gateway then knows how to route that data to the correct destination on the internet.
The Gateway also has an IP address, but it’s a specific IP within your local network.

Here’s an analogy:

Imagine your house is a local network. Each person living in the house (your devices) has a unique room number (IP address). The front door (gateway) is the designated exit point to go outside (internet). When someone wants to visit a friend (access a website) outside the neighborhood (local network), they use the front door and tell the person at the door (gateway) the friend’s address (website URL). The person at the door (gateway) then directs them (routes the data) on how to get there using the wider road network (internet).

Can you assign one static IP to 2 computers, if not then why?
Ans:- No because it will create IP conflict

How to change IPs address to static?
Ans:- ifconfig x.x.x.x

You are trying to ping a server by hostname and you get an error message, “ping: unknown host …”. What could be the reason and how to solve the problem so you can ping it by hostname?
Ans:- Check for /etc/hosts or DNS to see if it has hostname to IP entry

Explain the difference between relative and absolute path?
Ans:- Absolute path starts from / where relative path is your current directory

List 3 different methods of adding user? Ans:- useradd Command, adduser Command and Editing /etc/passwd and /etc/shadow Files.

What is the command to change file/directory ownership and group?
Ans:- chown and chgrp

List any 3 type of filesystem?
Ans:- ext4,NTFS and FAT

When you login you get a message on the screen. What is the name of that file and where is it located?
Ans:- /etc/motd

What is /bin directory used for?
Ans:- The /bin directory in Linux contains essential binary executable files that are necessary for the system to boot and operate, such as basic system commands like ls, cp, mv, and mkdir.

What are the different types of DNS Server
Ans:- Master and secondary

How to change a user password?
Ans:- passwd username

What is the version of Redhat Linux you have experience with?
Ans:-
9

List any 4 linux distributions?
Ans:-
Redhat, CentOS, Ubuntu and SUSE

How to logoff from the system?
Ans:-
exit

Give any 3 examples of operating systems?
Ans:-
Windows, Linux and MAC

How to create a directory?
Ans:-
mkdir

Where are the zone files located for DNS service?
Ans:-
/var/named/zonefiles

How to check kernel version?
Ans:-
uname –a

Which directory has all the configuration files?
Ans:-
/etc

How to become root user from a regular user?
Ans:-
su –

How many mega bytes in 1 giga bytes? Ans:- 1024 megabytes

What is the purpose of having different network ports?
Ans:-
So the communication of each application goes through a dedicated port

How to display first column of a file?
Ans:-
cat filename | awk ‘{print $1}’

What is the name of DNS rpm package?
Ans:-
bind

What is the difference between nslookup and dig commands?
Ans:-
nslookup and dig are both command-line tools used for querying DNS (Domain Name System) servers to obtain information about domain names, IP addresses, and other DNS records.

nslookup:

nslookup has been traditionally available in most Unix-like operating systems including Linux. nslookup provides a more user-friendly interactive mode by default. nslookup has fewer options compared to dig and may not provide as much control over the query process. nslookup is generally considered easier to use for basic DNS queries due to its interactive mode. It’s more straightforward for users who are less familiar with DNS.

dig (Domain Information Groper):

dig is a newer and more versatile tool, and it’s becoming the standard for DNS queries. dig provides more detailed and customizable output. dig offers more options and flexibility for performing DNS queries. It allows you to specify the DNS record type explicitly and customize the query parameters. dig may have a steeper learning curve for beginners because of its more extensive set of options and its non-interactive mode.

How to check your user id and group id?
Ans:-
id

How to check a file’s permission?
Ans:-
ls –l

What is the difference between “kill” and “kill -9” command?
Ans:-

kill:

Sends the SIGTERM signal by default. Requests the process to terminate gracefully. Allows the process to perform cleanup operations before exiting. Gives the process a chance to shut down cleanly.

kill -9:

Sends the SIGKILL signal. Forces the process to terminate immediately. Does not allow the process to perform any cleanup operations. Does not give the process a chance to shut down cleanly.

It’s recommended to first try sending the SIGTERM signal (kill) to allow the process to gracefully terminate. If the process does not respond to SIGTERM or if it’s stuck and cannot terminate gracefully, then kill -9 can be used as a last resort to forcefully terminate the process.

What is subnet? Ans:- A subnet in Linux is a subdivision of an IP network. It allows for efficient organization and management of network resources by grouping devices based on shared characteristics.

You are troubleshooting an issue with Redhat support and they have asked you to send the contents of /etc directory. How and which method you will use to transfer the contents?
Ans:-
tar (compress) the entire /etc directory and ftp

What is root home directory?
Ans:-
/root

What is rsyslogd deamon and its purpose? Ans:- The rsyslogd daemon in Linux is a system logging service responsible for collecting, processing, and forwarding log messages generated by various system processes and applications. Its purpose is to centralize and manage system logs efficiently, allowing administrators to monitor system health, troubleshoot issues, and analyze system behavior.

Your company has terminated a server administrator. What is first thing as an administrator you should do to enhance the security?
Ans:-
Change root password

How to check the computer name or host name in Linux?
Ans:-
hostname

Which permission allows a user to run an executable with the permissions of the owner of that file?
Ans:-
First 3 bits should have x

What is the command to untar a tarred file?
Ans:-
untar

What is /proc directory used for?
Ans:-
The /proc directory in Linux is a virtual filesystem that provides access to kernel-related information and processes as files. It allows users and system utilities to interactively retrieve and manipulate system information, such as CPU, memory, and process details, using standard file operations.

What is the purpose of nsswitch.conf file
Ans:-
It tells the system where to go to resolve hostnames

List 3 basic commands to navigate the filesystem?
Ans:-
cd, pwd and ls

Which service/daemon should be running on the server that allows you to connect remotely?
Ans:-
sshd

What is the purpose of firewall? Ans:- A firewall is used to control incoming and outgoing network traffic based on predetermined security rules. It acts as a barrier between a trusted internal network and untrusted external networks, enhancing network security by filtering and blocking unauthorized access and malicious traffic.

List any 3 IT components?
Ans:-
Hardware, OS and Applications

Which directory has all the commands we use, e.g. ls, cd etc.?
Ans:-
/usr/bin or /bin

What is the difference between memory, virtual memory and cache?
Ans:-
Memory, virtual memory, and cache all play a role in how your computer manages data, but they serve different purposes.

Memory (RAM):

This is the main working memory of the computer. It’s where the operating system, programs, and currently used data are stored for the CPU to access quickly. RAM is very fast, designed for the CPU to access data rapidly during program execution. RAM is typically limited in size (gigabytes) compared to other storage options. RAM is volatile, meaning data is lost when the computer is turned off.

Virtual Memory:

A technique that expands the capacity of RAM by using hard disk space. It allows the computer to run programs larger than the available physical RAM. Much slower than RAM because accessing data on a hard disk is slower than RAM. Virtually unlimited, as it’s limited by the storage capacity of the hard disk. Data on the hard disk persists even after the computer is turned off.

Cache:

A small, extremely fast memory that stores frequently accessed data or instructions from RAM. The CPU checks the cache first for needed data before accessing the slower RAM. The fastest type of memory in the system. Very small (kilobytes or megabytes) compared to RAM. Cache is volatile, similar to RAM. Data is lost when the computer is powered off.

Here’s an analogy:

Think of memory (RAM) as your desk, where you can work on the documents and tools you need right now. Virtual memory is like having a filing cabinet next to your desk. If you need something that isn’t currently on your desk, you can quickly access it from the filing cabinet. The cache is like a small notepad on your desk where you jot down things you’re using constantly for easy reference.

Which of the following is correct?
a. Hardware  Operating System  Users
b. Operating System  Users  Hardware
c. Database  Hardware  Users
Ans:- a. Hardware  Operating System  Users

Which of the following is a communication command?
o grep
o mail
o touch
o cd
Ans:- Mail

How to rename a file or directory?
Ans:-
mv

How to change a hostname in Linux?
Ans:-
Run hostnamectl command or edit the /etc/hostname file and update the hostname to the desired value. Additionally, edit the /etc/hosts file to reflect the new hostname.

How to check network interfaces in Linux?
Ans:-
ifconfig

Why is “tail –f logfilename” command used most often and what does it do?
Ans:-
It will output all incoming logs in real time

What type of hardware have you worked on?
Ans:-
You should get yourself familiar with Dell, HP and UCS hardware by going online and check the vendor websites

How to sort a file in reverse order?
Ans:-
cat filename | sort –r

What is the name of operating system that runs Unix?
Ans:-
Solaris, HP-UX etc.

List all byte sizes from smallest to largest?
Ans:-
Bit (b) Byte (B) Kilobyte (KB) Megabyte (MB) Gigabyte (GB)

How to check the total number of partition in Linux?
Ans:-
fdisk -l

How to access a linux system from a linux system?
Ans:-
ssh

Explain the procedure of bonding 2 NICs or interfaces together?
Ans:-

What is the exact command syntax to list the 5th column of a file and cut the first 3 letters?
Ans:-
cat filename | awk ‘{print $5}’ | cut –c1-3

What is /etc/hosts file used for?
Ans:-
To resolve hostnames with IP address

List any 3 options of ‘df’ command and what they are used for?
Ans:-
-h (human-readable): This option displays disk space usage in a format easier for humans to understand. By default, df shows sizes in kilobytes (KB). With -h, it uses SI unit suffixes like KB, MB, GB, and TB, making it more intuitive.

-m (megabytes): This option displays disk space usage in megabytes (MB). This can be useful if you specifically want the information in megabytes for easy comparison with other storage values.

-T (file system type): This option lists the type of file system used for each partition, such as ext4, xfs, or NTFS. This can be helpful for identifying the file system format used on different partitions.

What is the command to change file/directory permissions?
Ans:-
chmod

What is the purpose of pipe (|)?
Ans:-
To combine multiple commands

What is /etc directory used for?
Ans:-
For configuration files

Which command is used to list files in a directory?
Ans:-
ls –l

There is a command which gives you information about other commands, please explain that command and what is it used for?
Ans:-
man

How to delete a file and a directory?
Ans:-
rm filename and rmdir dirname

What is the difference between “tail” and “tail -10”?
Ans:-
None

List 4 commands to display or read a file contents?
Ans:-
cat, more, less, vi

Which command is used to read the top 5 lines of a file?
Ans:-
head -5 filename

What are the different commands or methods to write to a file?
Ans:-
echo > filename and vi filename

What is swap space and how to check swap space?
Ans:-
Swap space is a virtual memory management technique in Linux that utilizes disk space to temporarily store inactive or less frequently used portions of your computer’s RAM.

Checking Swap Space:

free: This command provides a basic overview of memory usage, including information about total and used swap space. swapon -s: This will list the swap devices or files along with their size and usage status.

What is inode and how to find an inode of a file?
Ans:-
In Linux, an inode (index node) is a data structure that stores important information about a file, but it doesn’t store the actual file content itself. It acts like an index entry for a file, keeping track of its location and other essential details.

There are 2 ways to find inode: ls -i <filename>: displays the inode number along with other file information. stat <filename>: display detailed information about a file, including its inode number.

Which file to edit for kernel tuning?
Ans:-
/etc/sysctl.conf

What is the latest version of Redhat?
Ans:-
Red Hat Enterprise Linux 9.4

Name the command to find specific word from a file?
Ans:-
grep word filename

You have scheduled a job using crontab but it does not run at the time you specified, what could be the reason and how would you troubleshoot?
Ans:-
Check your system time
Check your crontab entry
Check /var/log/messages

How to check system hardware information?
Ans:-
dmidecode

How to check network interface MAC address?
Ans:-
ifconfig

If I don’t want others to read my file1, how to do that?
Ans:-
Remove r from the last 3 bits of file permission

What is the purpose of “uniq” and “sed” command?
Ans:-
Both uniq and sed are command-line tools in Linux used for manipulating text data.

uniq: Filters out duplicate lines from a text file. sed: Powerful stream editor used for text manipulation.

Which command is used to list the contents of a directory in the most recent time and in reverse order, meaning the most updated file should be listed on the bottom?
Ans:-
ls –ltr

What is the difference between tar, gzip and gunzip?
Ans:-
tar:

Stands for Tape ARchiver. It’s a powerful archiving tool used to create collections of files and directories into a single archive file (often with a .tar extension). tar itself doesn’t compress the files. It simply bundles them together into an archive for easier storage, management, or distribution.

gzip:

Stands for GNU zip. It’s a file compression utility that reduces the size of a single file by applying compression algorithms. Compressed files typically have a .gz extension. gzip works independently on individual files.

gunzip:

The decompression counterpart of gzip. It uncompresses files that were previously compressed with gzip. After using gunzip, the original file (without the .gz extension) is restored.

What are the different ways to install and OS?
Ans:-
DVD, DVD iso and network boot

How to view difference between two files?
Ans:-
diff file1 and file2

You noticed that one of the Linux servers has no disk space left, how would you troubleshoot that issue?
Ans:-
If running LVM then add more disk and extend LVM
If not running LVM then add more disk, create a new partition and
link the new partition to an existing filesystem

How to check Redhat version release?
Ans:-
uname –a or /etc/redhat-release

What is the difference between TCP and UDP?
Ans:-
TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both fundamental protocols used for communication over networks in Linux and other operating systems.

TCP:

Connection-oriented protocol. Offers reliable data delivery. It includes mechanisms like error checking, packet sequencing, and retransmission. Implements flow control mechanisms to regulate the data flow between sender and receiver. Has higher overhead due to connection establishment, error checking, and flow control mechanisms. This can add some latency to communication. Ideal for applications requiring reliable and ordered data delivery, such as file transfers, web browsing, email, or remote logins (SSH).

UDP:

Connectionless protocol. Less reliable. It transmits data packets without error checking or retransmission guarantees. Lacks built-in flow control. Lower overhead due to its simpler design without connection setup or complex reliability features. This makes it faster for sending short bursts of data. Well-suited for real-time applications where speed is a priority and occasional data loss is tolerable, such as live streaming (audio/video), online gaming, or DNS lookups.

What is a zombie process?
Ans:-
A zombie process in Linux is a process that has finished execution but still has an entry in the system’s process table. These processes are essentially “dead” as they have no memory or resources allocated to them, but they occupy a slot in the process table.

How do you search for a pattern/word in a file and then replace it in an entire file?
Ans:-
sed command

Explain the purpose of “touch” command?
Ans:-
To create an empty file

If a command hangs, how to stop it and get the prompt back?
Ans:-
Ctrl C

Which command is used to count words or lines?
Ans:-
wc

How to check the number of users logged in?
Ans:-
who

What is the command to view the calendar of 2011?
Ans:-
cal 2011

Which command is used to view disk space?
Ans:-
df –h

How to create a new group in Linux?
Ans:-
groupadd

What is the command to send a message to everyone who is logged into the system?
Ans:-
wall

Which command is used to check total number of disks?
Ans:-
fdisk –l

What is an mail server record in DNS?
Ans:-
MX

What does the following command line do?
ps -ef | awk ‘{print $1}’ | sort | uniq
Ans:- List the first column of all running processes, sort them and remove duplicates

You get a call that when a user goes to www.yourwebsite.com it fails and gets an error, how do you troubleshoot?
Ans:-
Check for user internet
Check to see if user computer has DNS for hostname lookup
Check to see if the server is up that is running that website
Check to see if the server’s web service is running
Check for DNS availability which is resolving that website

List 4 different directories in /?
Ans:-
/etc, /bin, /tmp, /home

What is the output of the following command:
$tail -10 filename | head -1
Ans:- It will show the first line from the last 10 lines of a file

What are the different fields in /etc/passwd file?
Ans:-
Username Password User ID (UID) Group ID (GID) GECOS (General Ended Comment) Home Directory Login Shell

Which command is used to list the processes?
Ans:-
ps –ef

What is the difference between “hostname” and “uname” commands?
Ans:-
Hostname will give you system name and uname will give you OS
information

How to check system load?
Ans:-
top and uptime command

How to schedule jobs?
Ans:-
crontab and at

What is the 3rd field when setting up crontab?
Ans:-
Day of the month

What is the command to create a new user?
Ans:-
useradd

What is the “init #” for system reboot?
Ans:-
6

How to restart a service?
Ans:-
systemctl restart servicename

How to shutdown a system?
Ans:-
shutdown or init 0

What is “ftp” command used for?
Ans:-
To transfer files from one computer to another

Explain cron job syntax? First is minute, second is..?
Ans:-
Min, house, day of the month, month, day of the week and command

How to delete a package in Linux?
Ans:-
rpm –e packagename

What is the file name where user password information is saved?
Ans:-
/etc/shadow

Which command you would use to find the location of chmod command?
Ans:-
which chmod

Which command is used to check if the other computer is online?
Ans:-
ping othercomputer

Please explain about LAN, MAN and WAN?
Ans:-

LAN, MAN, and WAN are all network types that connect devices and allow them to communicate with each other.

LAN (Local Area Network):

A LAN is a small network that connects devices in a limited geographical area, typically a single building, home, office, or school campus. LANs are known for their high speeds and low latency (delay) due to the short distances involved. Common LAN technologies include Ethernet cables or Wi-Fi. Devices on a LAN can easily share resources like printers, files, and applications.

MAN (Metropolitan Area Network):

A MAN covers a larger geographical area than a LAN, typically encompassing a city or town. It can interconnect several LANs within a metropolitan area. MAN speeds are generally faster than WANs but slower than LANs. Technologies like fiber optic cables or microwave links are often used for MANs. MANs can be used by businesses or organizations spread across a city to share resources and provide high-bandwidth connectivity.

WAN (Wide Area Network):

A WAN spans the widest geographical area, potentially covering entire countries, continents, or even the entire globe. WANs connect geographically distant LANs and MANs. WAN speeds are typically the slowest among the three due to the vast distances involved. Technologies like satellite connections, leased lines, or the internet itself can be used for WANs. WANs are essential for communication and resource sharing between geographically dispersed locations.

How to list hidden files in a directory?
Ans:-
ls –la

What is the difference between telnet and ssh?
Ans:-
ssh is secure where telnet is not

How to run a calculator on Linux and exit out of it?
Ans:-
bc and quit

List any 4 commands to monitor system?
Ans:-
top, df –h, iostat, dmesg

You are notified that your server is down, list the steps you will take to troubleshoot?
Ans:-
Check the system physically
Login through system console
Ping the system
Reboot or boot if possible

What is difference between static and DHCP IP?
Ans:-
The key difference between static and DHCP IP addresses in Linux lies in how they are assigned and managed:

Static IP:

A static IP address is a fixed IP address you manually configure on your Linux system. It remains the same even after reboots or network changes. Static IPs are typically configured through network interface configuration files (e.g., /etc/network/interfaces on Ubuntu/Debian). Provides more control over your network configuration, useful for specific server setups or devices needing a persistent IP. Can be more secure in some scenarios, as the IP doesn’t change, potentially aiding in firewall rules or access controls. Requires manual configuration on each device, which can be cumbersome for large networks. Not ideal for devices that move around the network or require dynamic IP assignment.

DHCP IP (Dynamic Host Configuration Protocol):

A DHCP IP address is assigned automatically by a DHCP server on your network. The DHCP server leases an IP address to your device for a specific time period. Minimal configuration required on the client side. You might just need to enable DHCP on the network interface settings. Automatic assignment simplifies network management, especially for large deployments. Devices can obtain IPs dynamically, useful for laptops or mobile devices moving around the network. You have less control over the specific IP address assigned to your device. Requires a functioning DHCP server on the network for devices to obtain IPs.

How to write in vi editor mode?
Ans:-
i = insert, a = insert in next space, o = insert in new line

What is the difference between “crontab” and “at” jobs?
Ans:-
crontab is for repetitive jobs where at is for one time job

What is vCenter server in VMWare?
Ans:-
vCenter Server, a core component of VMware vSphere, is a centralized management platform for virtualized environments.

What is “dmidecode” command used for?
Ans:-
To get system information

What is the difference between SAN and NAS?
Ans:-
SAN (Storage Area Network) and NAS (Network Attached Storage) are both network-based storage solutions used to provide shared storage to multiple servers or devices. However, they differ in their approach, design, and use cases.

SAN:

Focuses on high-performance block-level storage access. Typically uses dedicated high-speed network connections like Fibre Channel for low latency and high bandwidth. Generally offers high scalability by allowing you to add more storage devices to the network as needed. Traditionally required more complex security configuration due to block-level access. Generally more expensive than NAS due to the specialized hardware and network infrastructure required. Ideal for high-performance applications like virtualization environments, databases, and video editing where fast and reliable storage access is critical.

NAS:

Focuses on ease of use and file-level access. Connects to the network using standard Ethernet, making it simpler to set up and integrate into existing networks. Scalability can vary depending on the specific NAS model. Some offer good scalability by adding additional NAS units, while others might have limitations. Often provides user authentication and access controls at the file level, making security management potentially easier. Typically more affordable, making them a good choice for budget-conscious users and smaller deployments. Well-suited for file sharing, backups, and general storage needs. They are often used in homes, small offices, and for specific departments within an organization.

What is the location of system logs? E.g. messages
Ans:-
/var/log directory

How to setup an alias and what is it used for?
alias aliasname=”command”
Ans:- It is used to created short-cuts for long commands

What is the purpose of “netstat” command?
Ans:-
The netstat command in Linux is a powerful tool for network troubleshooting, configuration, and monitoring. It displays information and statistics about network connections, routing tables, and various network interfaces.

What are terminal control keys, list any 3?
Ans:-
Crtl C, D and Z

Which command(s) you would run if you need to find out how many processes are running on your system?
Ans:-
ps –ef | wc –l

What are the different types of shells?
Ans:-
sh, bash, ksh, csh etc.

How to delete a line when in vi editor mode?
Ans:-
dd

Which is the core of the operating system?
a) Shell
b) Kernel
c) Commands
d) Script
Ans:- b) Kernel

Which among the following interacts directly with system hardware?
a) Shell
b) Commands
c) Kernel
d) Applications
Ans:- c) Kernel

How to save and quit from vi editor?
Ans:-
Shift ZZ or :wq!

What is the difference between a process and daemon?
Ans:-
Both processes and daemons are fundamental concepts in Linux related to running programs.

Process:

A process is a single instance of a program that is currently running on the system. It has allocated resources like memory and CPU time. Processes can be started in various ways, like running a program from the terminal or by a service manager. There can be multiple instances of the same program running concurrently, each being a separate process. Processes can be interactive (e.g., waiting for user input in a terminal) or non-interactive (e.t., running calculations in the background). Examples: When you open a text editor or web browser, those are separate processes.

Daemon:

A daemon (sometimes called a service) is a special type of process that runs in the background for extended periods, often without user interaction. Daemons are typically started during system boot and continue to run until the system is shut down. They usually don’t have a controlling terminal and are not associated with any specific user. Daemons often provide essential system services like managing network connections, logging activity, or managing hardware. Examples: Common daemons include sshd (secure shell daemon), crond (cron daemon for scheduling tasks), and syslogd (system logging daemon).

What is the process or daemon name for NTP?
Ans:-
ntpd

What are a few commands you would run if your system is running slow?
Ans:-
top, iostat, df –h, netstat etc.

How to install a package in Redhat Linux?
Ans:-
yum install packagename

What is the difference between “ifconfig” and “ipconfig” commands?
Ans:-
ifconfig for Linux and ipconfig for Windows

What is the first line written in a shell script?
Ans:-
Define shell
e.g. #!/bin/bash

Where is the network (Ethernet) file located, please provide exact directory location and file name?
Ans:-
/etc/sysconfig/network-scripts/ifcfg-nic

Why do we use “last” command?
Ans:-
To see who has logged in the system whether active or logged off

What is RHEL Linux stands for?
Ans:-
Red Hat Enterprise Linux (RHEL)

To view your command history, which command is used and how to run a specific command?
Ans:-
history and history #

What is NTP and briefly explain how does it work and where is the config files and related commands of NTP?
Ans:-
NTP stands for Network Time Protocol. It’s a widely used protocol for synchronizing the system time of computers across a network. This ensures all devices have consistent and accurate time, which is crucial for various tasks like logging, file timestamps, and coordinated activities.

How NTP Works:

Clients and Servers: NTP operates using a hierarchical client-server model. NTP servers act as reliable time sources, while NTP clients (like your Linux system) connect to these servers to synchronize their clocks. Time Requests and Responses: Clients periodically send time requests to NTP servers. Servers respond with timestamps indicating the current time according to their reference clock. Accounting for Delays: NTP accounts for network delays by considering the time it takes for the request and response to travel between the client and server. It uses algorithms to estimate the one-way travel time and adjust the clock accordingly. Stratum Levels: NTP servers are organized in a hierarchy with different stratum levels. Stratum 1 servers are reference clocks like atomic clocks, while higher stratum levels (stratum 2, 3, etc.) rely on lower strata for time synchronization.

Configuration File:

The primary configuration file for NTP in Linux is /etc/ntp.conf. This file defines various settings like server addresses, pool options, logging levels, and more.

Commands:

The ntpd daemon (service) is responsible for NTP functionality. Common commands for managing NTP include:

  • systemctl status ntpd: Checks the status of the NTP service (running/stopped).
  • systemctl start ntpd: Starts the NTP service.
  • systemctl stop ntpd: Stops the NTP service.
  • ntpq -p: Queries the NTP daemon for information about configured servers and synchronization status.

How to disable firewall in Linux?
Ans:-
sudo ufw disable

How to configure mail server relay for sendmail service?
Ans:-
Edit /etc/mail/sendmail.mc file and add SMART_HOST entry

Where is samba log file located?
Ans:-
/var/log/samba

What is mkfs command used for?
Ans:-
To create a new filesystem

If you create a new group, which file does it get created in?
Ans:-
/etc/group

Which file has DNS server information (e.g. DNS resolution)?
Ans:-
/etc/resolv.conf

What are the commands you would run if you need to find out the version and build date of a package (e.g. http)?
Ans:-
rpm –qi http

On the file permissions? What are the first 3 bits for and who is it for?
Ans:-
Read, write and execute. They are used for the owner of the file

How to create a soft link?
Ans:-
ln –s

How to write a script to delete messages in a log file older than 30 days automatically?
Ans:-
Here’s a shell script to delete messages in a log file older than 30 days automatically:

#!/bin/bash

# Define the log file path (replace with your actual log file path)
LOG_FILE="/var/log/your_logfile.log"

# Set the number of days to keep logs (change 30 to your desired days)
DAYS_TO_KEEP=30

# Calculate the date threshold for log deletion
THRESHOLD_DATE=$(date -d "-${DAYS_TO_KEEP} days" +%Y-%m-%d)

# Backup the log file (optional, uncomment if desired)
# cp "${LOG_FILE}" "${LOG_FILE}.$(date +%Y-%m-%d)"

# Use grep to filter log entries older than the threshold date
# and redirect output to a temporary file
grep -v "^<${THRESHOLD_DATE}>" "${LOG_FILE}" > /tmp/log_filtered.log

# Move the filtered log content back to the original file
mv /tmp/log_filtered.log "${LOG_FILE}"

# Truncate the log file to remove remaining data
truncate -s 0 "${LOG_FILE}"

echo "Log file '${LOG_FILE}' cleaned up. Logs older than ${DAYS_TO_KEEP} days removed."

How to quit out of “man” command?
Ans:-
q

Which command is used to partition disk in Linux?
Ans:-
fdisk

What is the difference between “shutdown” and “halt” command?
Ans:-

shutdown (with systemd):

This is the recommended command for shutting down the system. It gracefully halts the system, allowing running processes to stop cleanly and notifying logged-in users about the impending shutdown. You can specify a timeframe for shutdown (e.g., shutdown +10), or use options like -h (halt) or -P (poweroff) to specify the desired power state. Internally, shutdown with systemd likely calls the systemctl poweroff command.

halt:

This command traditionally halted the system, stopping all processes but not necessarily powering it off. In systemd-based systems, halt often behaves the same as shutdown -h, initiating a clean shutdown and halt.

What is the exact syntax of mounting NFS share on a client and also how to un-mount?
Ans:-
Syntax of mounting NFS share:

sudo mount -t nfs <server_ip_or_hostname>:<share_directory> <mount_point>

Syntax to un-mount NFS share:

sudo umount <mount_point>

What experience do you have with scripting, explain?
Ans:-
if-the, do-while, case, for loop scripts

How to get information on all the packages installed on the system?
Ans:-
rpm –qa

Explain VMWare?
Ans:-
Search online

You are tasked to examine a log file in order to find out why a particular application keep crashing. Log file is very lengthy, which command can you use to simplify the log search using a search string?
Ans:-
grep for error, warning, failure etc. in /var/log/messages file

What is /etc/fstab file and explain each column of this file?
Ans:-
The /etc/fstab file in Linux is crucial for the system’s startup process. It’s a configuration file that tells the operating system which partitions or disks to mount automatically at boot time and how to mount them.

Columns:

File system: This column specifies the device or partition to be mounted. It can be identified by device name (e.g., /dev/sda1) or other identifiers like UUID (Universally Unique Identifier) or label. Mount point: This column defines the directory where the file system will be mounted. It creates a point of access for the file system within the overall directory structure. File system type: This column specifies the type of file system the partition uses. Common examples include ext4, xfs, vfat (for FAT32), NTFS (for Windows partitions). The kernel needs this information to understand how to access the data on the partition. Mount options (optional): This column lists comma-separated options that control how the file system is mounted. Dump: This column (often unused these days) was traditionally used by the dump backup utility to determine if a specific partition should be included in routine backups. A value of 0 indicates no dump. Fsck (file system check): This column (also sometimes unused) specifies the order in which the fsck file system checker should check partitions during boot. A lower number indicates an earlier check.

What the latest version of Windows server?
Ans:-
Microsoft Windows Server 2022

What is the exact command to list only the first 2 lines of history output?
Ans:-
history | head -2

How to upgrade Linux from 7.3 to 7.4?
Ans:-
yum install update

How to tell which shell you are in or running?
Ans:-
$0

You have tried to “cd” into a directory but you have been denied. You are not the owner of that directory, what permissions do you need and where? Ans:-

  • – – – – – – r – x

What is CNAME record in DNS?
Ans:-
Entry for hostname to hostname

What is the name of VMWare operating system?
Ans:-
ESXi

What is the client name used to connect to ESXi or vCenter server?
Ans:-
vSphere client

You get a call from a user saying that I cannot write to a file because it says, permission denied. The file is owned by that user, how do you troubleshoot?
Ans:-
Give write permission on the first 3 bits

What is the latest version of VMWare?
Ans:-
VMware ESXi 8.0

What is the name of firewall daemon in Linux?
Ans:-
firewalld

Which command syntax you can use to list only the 20th line of a file?
Ans:-
head -n 20 filename | tail -n 1

What is the difference between run level 3 and 5?
Ans:-
3 = Boot system with networking, 5 = boot system with networking
and GUI

List a few commands that are used in troubleshooting network related issue?
Ans:-
netstat, tcpdump etc.

What is the difference between domain and nameserver?
Ans:-

Domain:

A domain name is a human-readable address that identifies a website or computer on the internet. It acts like a memorable alias instead of using an IP address (a long string of numbers). For example, “[invalid URL removed]” is a domain name, easier to remember than its numerical IP address. You can register a domain name through a domain registrar and point it to your web server.

Nameserver (DNS Server):

A nameserver (often called a DNS server, referring to Domain Name System) is a computer program or server responsible for translating domain names into IP addresses. When you type a domain name in your web browser, it contacts a nameserver to lookup the corresponding IP address. Nameservers are distributed across the internet, working together to form a hierarchical system. In Linux, you can configure your system to use specific nameservers for DNS resolution.

You open up a file and it has 3000 lines and it scrolled up really fast, which command you will use to view it one page at a time?
Ans:-
more or less

How to start a new shell. E.g. start a new ksh shell?
Ans:-
Simply type ksh, or bash

How to kill a process?
Ans:-
kill processID

How to check scheduled jobs?
Ans:-
crontab –l

How to check system memory and CPU usage?
Ans:-
free and top

Which utility could you use to repair the corrupted file system?
Ans:-
fsck

What is the command to make a service start at boot?
Ans:-
systemctl enable servicename

How to combine 2 files into 1? E.g. you 3 lines in file “A” and 5 lines in file “B”, which command syntax to use that will combine into one file of 3+5 = 8 lines
Ans:-
cat fileA >> fileB

What is echo command used for?
Ans:-
To output to a screen

What does the following command do?
echo This year the summer will be great > file1
Ans:- It will create a new file “file1” with the content as “This year
the summer will be great”

Which file to modify to allow users to run root commands?
Ans:-
/etc/sudoers

You need to modify httpd.conf file but you cannot find it, Which command line tool you can use to find file?
Ans:-
find / -name “httpd.conf”

Your system crashed and being restarted, but a message appears, indicating that the operating system cannot be found. What is the most likely cause of the problem?
Ans:-
The /boot file is most likely corrupted

FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap