0% found this document useful (0 votes)
253 views30 pages

Linux Realtime Scenario Based Interview Questions and Answers

The document is a compilation of Linux real-time scenario-based interview questions and answers, covering various topics such as user management, file system operations, networking, and process management. It includes practical commands and explanations for tasks like setting user password policies, checking kernel routing tables, and managing file permissions. The content is structured as a Q&A format, providing insights into common Linux administration challenges and solutions.

Uploaded by

Prashant Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
253 views30 pages

Linux Realtime Scenario Based Interview Questions and Answers

The document is a compilation of Linux real-time scenario-based interview questions and answers, covering various topics such as user management, file system operations, networking, and process management. It includes practical commands and explanations for tasks like setting user password policies, checking kernel routing tables, and managing file permissions. The content is structured as a Q&A format, providing insights into common Linux administration challenges and solutions.

Uploaded by

Prashant Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q1. HOW TO SET A USERNAME AND PASSWORD TO NEVER EXPIRES? ........................................... 8

Q2. WHY /ETC/PASSWD AND /ETE/SHADOW FILE CANNOT BE MERGED INTO 1 FILE? .................... 8

Q3. TO LIST, ALL THE FILES OPENED BY PARTICULAR PID? .............................................................. 8

Q4. WE ARE UNABLE TO UNMOUNT THE FILE SYSTEM. WHAT ARE THE REASON BEHIND IT ? ......... 8

Q5. WHAT COULD BE THE REASON IT SERVER TAKE MORE TIME AFTER REBOOT? .......................... 9

Q6. WE ARE TRYING TO CREATE THE FILE UNDER ANY PARTITION BUT WE ARE GETTING
PERMISSION DENIED ALERT. WHAT COULD BE THE REASON? HOWEVER SPACE ISSUE AND NO
PERMISSION ISSUE? ..................................................................................................................... 9

Q7. HOW TO CHECK KERNEL ROUTING TABLE INFORMATION? ...................................................... 9

Q8. HOW TO SET STICKY BIT AND WHAT IS THE DIFFERENCE B/W SMALLS AND CAPITAL S? ......... 10

STICKY BIT A SPECIAL PERMISSION APPLIED ON A FILE AND DIRECTORY, SO ROOT AND OWNER OF
THE FILE OR DIRECTORY CAN DELETE IT.EVEN IF OTHERS HAVING FULL PERMISSIONS.................. 10

Q9. WHICH FILE IS USED TO SPECIFY DEFAULT GATEWAY? .......................................................... 10

Q10. IN RHEL 7,HOW TO SWITCH BETWEEN TWO RUNLEVELS?.................................................... 11

Q11. IF YOU HAVE MADE CHANGES TO YOUR NFS EXPORTS AND WANT TO APPLY THEM
IMMEDIATELY, YOU WOULD USE? .............................................................................................. 11

Q12. WHAT IS NICE VALUE AND HOW TO SET NICE VALUE FOR PARTICULAR PROCESS? ............... 11

Q13. WHAT IS THE DIFFERENCE B/W FTP AND TFTP? ................................................................... 11

Q15. HOW WILL YOU ROLLBACK THE PACKAGES AFTER PATCHING? ............................................ 11

Q16. WHAT IS RSYNC AND WHAT IS THE SYNTAX FOR RSYNC? .................................................... 12

Q17.HOW TO REDUCE THE FILE SYSTEM IN LINUX ? FS REDUCTION CAN BE HAPPENED ONLINE OR
NOT? ......................................................................................................................................... 12

Q18. HOW TO SET THE NUMBERING OF LINES FOR FILE BY USING VI EDITOR? ............................. 13

:SE NU ....................................................................................................................................... 13

Q19. HOW TO SCAN THE DISK IN LINUX? .................................................................................... 13

pg. 1
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q20. ETC/FSTAB FILE IS HAVING HOW MANY FEILDS AND DESCRIBE THE MEANING OF EACH FIELD?
.................................................................................................................................................. 13

Q21. WHAT IS THE DIFFERENCE B/W SOFT LINK AND HARD LINK? HOW TO CREATE IT? ............... 13

Q22. CAN WE CREATE THE SOFT LINK ACCROSS THE PARTITION? (YES/NO) PLEASE DESCRIBE YOUR
ANSWER? .................................................................................................................................. 13

Q23. WHAT IS THE LOCATION OF NFS SHARED INFO? .................................................................. 13

Q24. HOW TO CHECK IT ANY PARTICULAR PORT IS LISTENING OR NOT? ...................................... 13

Q25. WHAT IS CONCEPT BEHIND JOURNALLING? WHAT IS THE PROS AND CONS ? ....................... 14

JOURNALING HAS A DEDICATED AREA IN THE FILE SYSTEM, WHERE ALL THE CHANGES ARE
TRACKED. WHEN THE SYSTEM CRASHED, JOURNALING WILL HELPING OUT OF THERE. ................ 14

Q26. WHILE DOING PATCHING SUPPOSE ONE PACKAGE IS NOT ALLOWING YOU TO DO PATCH.
WHICH COMMAND WOULD YOU EXECUTE AND HOW WILL YOU TROUBLESHOOT? ..................... 14

Q27. DIFFERENCE B/W DF AND DU COMMAND? ......................................................................... 14

Q28. WHAT IS THE BOOTING PROCESS OF LINUX? ....................................................................... 14

Q29. WHAT IS THE MEANING OF PCPU AND JCPU IN W COMMAND? .......................................... 15

Q30. WHAT HAPPENS WHEN YOU TYPE AN URL IN THE BROWSER AND PRESS ENTER? ................ 16

Q31. DIFFERENCE B/W RPM AND YUM ? HOW TO CHECK THE PACKAGE FOR PARTICULAR
COMMAND? .............................................................................................................................. 16

Q32. WHAT IS ACL ? HOW TO SET ACL FOR PARTICULAR USER TO PROVIDE PARTICULAR
FILE/DIRECTORY ACCESS. ........................................................................................................... 16

Q33. WHAT IS INODE.................................................................................................................. 16

Q34. CAN WE SCHEDULE 2 SEC IN CRONTAB. .............................................................................. 17

Q35. IN PRODUCTION ENV, ANY SERVER IS REBOOTED AUTOMATICALLY. HOW WILL YOU
TROUBLESHOOT THAT SERVER IS REBOOTED BY SOMEONE OR ITS REBOOTED AUTOMATICALLY, IF
AUTOMATICALLY THEN HOW AND WHERE WILL YOU CHECK THE LOGS? ..................................... 17

Q36. WHICH COMMAND IS USED TO CHANGE THE USER PASSWORD EXPIRATION LIMIT? ............ 17

Q38. HOW TO EXTRACT A SINGLE FILE FROM TAR ARCHIVE? ....................................................... 17

pg. 2
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q39. WHICH COMMAND IS USED TO SEE THE MEMORY? ............................................................ 17

Q40 - WHICH COMMAND IS USED TO SEE THE ARCHITECTURE OF A LINUX SERVER? .................... 17

Q41 - HOW SEARCH TEXT WITHIN MULTIPLE FILES? ........................................................... 18

# FIND ./ -TYPE F -NAME “*.LOGS” -EXEC GREP ‘ERROR’ {} ; ............................................... 18

Q42 - HOW TO DELETE A LOGS WHICH IS 30 DAYS OLDER? ................................................ 18

Q43 - HOW TO DELETE A LOGS WHOSE OWNERSHIP CHANGED 45 MIN BEFORE FROM ROOT TO
HADOOP? .................................................................................................................................. 18

Q44 - USER IS RUNNING IS-1 COMMAND IN SERVER, BUT HE IS NOT GETTING ANY OUTPUT. WHAT
COULD BE THE ISSUE? ................................................................................................................ 19

Q45 - WHAT IS RUN QUEUE AND WHICH COMMAND USED TO CHECK RUN QUEUE? .................... 19

Q46 - WHICH FILE IS USE TO CHANGE DEFAULT RUNLEVEL? WHAT HAPPENS WHEN YOU CHANGED
THE DEFAULT RUNLEVEL TO 6? ................................................................................................... 19

Q47 - WHAT IS THE DIFFERENCE BETWEEN YUM UPDATE AND UPGRADE? .................................. 20

- # APT-GET UPDATE ALL ............................................................................................................ 20

- # YUM UPDATE ALL .................................................................................................................. 20

- WHEN RUNNING THIS COMMAND, YUM WILL BEGIN BY CHECKING ITS REPOSITORY FOR AN
UPDATED VERSION OF THE SOFTWARE YOUR SYSTEM CURRENTLY HAS INSTALLED. .................... 20

.................................................................................................................................................. 20

.................................................................................................................................................. 20

pg. 3
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

- YUM UPGRADE AND YUM UPDATE PERFORM THE SAME FUNCTION THAT UPDATE TO THE
LATEST CURRENT VERSION OF PACKAGE..................................................................................... 20

- BUT THE DIFFERENCE IS UPGRADE WILL DELETE OBSOLETE PACKAGE WHILE UPDATE WILL
PRESERVE THEM ........................................................................................................................ 20

Q48 - HOW TO DOWNGRADE A PACKAGE? ................................................................................. 20

Q49 - WHAT IS FILESYSTEM IN LINUX OR WINDOWS OS ?WHAT ARE THE TYPES OF FILESYSTEM IN
LINUX OR WINDOWS? • LINUX: EXT2, EXT3, EXT4, XFS, JFS ? ....................................................... 21

Q50 - HOW TO REMOVE DUPLICATE PACKAGES? ........................................................................ 21

# PACKAGE-CLEANUP --DUPES .................................................................................................... 21

Q51 - WHAT IS THE DIFFERENCE B/W TCP AND UDP PROTOCOL? ..................................... 21

Q52 - HOW TO LIST DIRECTORY INSIDE A DIRECTORY BY USING FIND COMMAND? ........ 21

Q53 - WHAT IS DIFF BETWEEN ARCHIVE AND COMPRESSED FILE TAR AND .GZ?............. 22

Q54 - NORMAL USER IS TRYING TO DO TELNET TO OTHER SERVER, BUT ITS GETTING
TIMEOUT ERROR PROMP. WHAT COULD BE THE REASON? ................................................ 22

Q55 - WHAT IS RAID? HOW TO CREATE RAID 3? .......................................................................... 22

Q56 - WHAT IS THE DIFFERENCE B/W EXT2, EXT3,EXT4 AND XIS? ................................................ 23

Q57 – HOW JOURNALING FEATURE WORKS IN EXT3, EXT4, XFS FILESYSTEMS? ............................ 23

Q57 - CAN WE BUILD A SERVER WITHOUT CREATING A SWAP PARTITION. IF YES, THAN WHAT
COULD BE THE CONSEQUENCES? ................................................................................................ 24

Q58 - WHAT IS THE DIFFERENCE BETWEEN INCREMENTAL AND DIFF BACKUP? ............................ 26

Q59 – HOW TO CHECK A FILE IS OPENED WITH IT’S PROCESS ID? ................................................. 26

Q60 - HOW TO LIST, ALL THE FILES OPENED BY PARTICULAR PID ? .............................................. 26

Q61 - HOW TO FIND OUT PORT NUMBER USED BY DAEMON ? ................................................... 26

Q62 – HOW TO TROUBLESHOOT I/O RELATED ISSUE? ................................................................. 27

Q63 - WHICH COMMAND CAN BE USED TO DISPLAY SYSTEM SUMMARY INFORMATION AND
CURRENT UTILIZATION? ............................................................................................................. 28

pg. 4
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

# TOP......................................................................................................................................... 28

Q63 - TO DISPLAY PROCESS DETAILS FOR SPECIFIC USER? ............................................................ 28

# TOP -U <USERNAME> .............................................................................................................. 28

Q64 - HOW TO KILL THE PROCESS USING TOP COMMAND? ......................................................... 28

Q66 - HOW TO KILL THE PROCESS? ............................................................................................. 28

# KILL -9 <PID> ........................................................................................................................... 28

NOTE: THERE ARE 64 SIGNAL ..................................................................................................... 28

Q67 - HOW TO TROUBLESHOOT NETWORK ISSUE ? .................................................................... 28

Q68 - HOW TO CAPTURE NETWORK TRAFFIC BETWEEN SOURCE AND DESTINATION IP? ............. 28

Q69 - HOW TO CAPTURE NETWORK TRAFFIC FOR DESTINATION PORT 443? HOW TO READ TO
CAPTURED FILE?......................................................................................................................... 29

Q70 - HOW TO DIAGNOSE PERFORMANCE ISSUE WITH STORAGE DEVICES? ................................ 29

Q71 - HOW TO DISPLAY DISK I/O STATISTICS? ............................................................................ 29

Q72 - HOW TO DISPLAY CPU STATISTICS? ................................................................................... 29

Q73 - IF A PROGRAM IS NOT STARTING DUE TO DEPENDENCIES NOT AVAILABLE? ....................... 29

Q74 - HOW TO SHOW STATS OF ALL PROTOCOLS? ...................................................................... 30

Q75 - HOW TO SEE KERNEL ROUTING TABLE? ............................................................................. 30

Q76 - IF YOUR LINUX SERVER IS RUNNING OUT OF MEMORY OR JUST WANT TO FIND OUT HOW
MUCH MEMORY AVAILABLE OUT OF AVAILABLE MEMORY ?....................................................... 30

Q77 - TO DOWNLOAD A PACKAGE WITH ITS DEPENDENCIES IN RHEL 9? ...................................... 30

pg. 5
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

pg. 6
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

pg. 7
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q1. How to set a username and password to never expires?

Set the maximum password age to unlimited:


# chage -M -1 <user>
"Maximum number of days between password change" is set to "-1", indicating unlimited

Q2. Why /etc/passwd and /ete/shadow file cannot be merged into 1 file?
The existence of the two files is a consequence of that /etc/passwd is a text file that can be
read by other applications (as finger, ident or ls for example) so an attacker could gain access
to the information of the file that included the hashed password.

To enhance security, the hashed password that used to be in the file was moved to other file
called /etc/shadow that accessible only by root.

Q3. To list, all the files opened by particular PID?


lsof -p <PID>

Q4. We are unable to unmount the file system. What are the reason behind it ?
#1. you are in the same directory, identify by pwd.
#2. Some users are present in the directory and using its content.
fuser -cu /dev
fuser -vm /dev

pg. 8
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

#3. Mounted Subdirectories


Check with the mount command or look in /proc/mounts to identify if there are nested
mounts:
mount | grep /path/to/mountpoint
Unmount any subdirectories first before attempting to unmount the parent file system.

#4. Lazy Umount


Umount -l /path/to/mountpoint

Q5. What could be the reason it server take more time after reboot?
Filesystem got corrupted and its ext2, ext2 is not having journaling feature.
Note: Journaling provide the facility to take the backup if anything goes wrong.

Q6. we are trying to create the file under any partition but we are getting permission
denied alert. What could be the reason? However space issue and no permission
issue?
#1 I am running out of inode
#2 sometimes, df command report that there is enough free space but system claims file-
system is full.
#3 you need to check for the inode which identify the file and its attributes on a file system
using following command.
df -i
df -I /ftpusers/
#4 if 100% of your inodes used, try following options:
Find unwanted files and delete pf move to another server.
Find unwanted large files and delete or move to another server.

Q7. How to check kernel routing table Information?


There are 3 commands are their to check routing table information
Comamnd-1: route -n
Comamnd-2: netstat -rn
Command-3: ip route

pg. 9
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q8. How to set sticky bit and what is the difference b/w smalls and capital S?
Sticky bit a special permission applied on a file and directory, so root and owner of the
file or directory can delete it.Even if others having full permissions.

Symbolic Way:
chmod o+t /opt/dump/
or
chmod +t /opt/dump/

Numeric Way:
chmod 1747 /opt/dump/

to make the setuid executable you have to say:


chmod 4700 executable

s - setuid and executable


S – setuid and non-executable

Q9. Which file is used to specify default gateway?

Using nmcli (NetworkManager Command Line Interface):


sudo nmcli connection modify eth0 ipv4.gateway 192.168.1.1
sudo nmcli connection up eth0

Editing Connection Profiles:


/etc/NetworkManager/system-connections/
[ipv4]
method=manual
addresses1=192.168.1.100/24
gateway=192.168.1.1
dns=8.8.8.8;8.8.4.4;
systemctl restart NetworkManager

Edit the Global Network Configuration File:


/etc/sysconfig/network
GATEWAY=192.168.1.1

Edit the Interface Configuration File


/etc/sysconfig/network-scripts/ifcfg-eth0
GATEWAY=192.168.1.1
systemctl restart network

pg. 10
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q10. In RHEL 7,how to switch between two runlevels?


# systemctl isolate multi-user.target
# systemctl isolate runlevel3.target

Changing the default runlevel

# systemctl set-default multi-user.target


# systemctl get-default

Q11. If you have made changes to your NFS exports and want to apply them
immediately, you would use?
exportfs -rv

Edit /etc/exports
Run exportfs -rv
Check the Exported File Systems: exportfs -v

Q12. What is nice value and how to set nice value for particular process?
Nice value is the priority of a process and to set a nice value use the below command

Priority range: -20 to 19 (more negative value, you are on top and more positive means your
are on the bottom )

nice -n 5 <command>
nice -n -1 pwd

Q13. What is the difference b/w FTP and TFTP?


Software size: tftp is lightweight
Protocol: FTP uses tcp & tfpt uses udp
Port: ftp uses 20 & 21while tfpt uses 69
Commands: ftp has lots of commands & messages while tftp has five commands.
Authentication: tftp required no authentication

Q14. How to extend the file system in Linux ?

# lvextend -L +1G /dev/data_vg/data_lv


# resize2fs /dev/data_vg/data_lv (ext filesystem)
The purpose of resize2fs is extend the filesystem means things to be organize.

# xfs_growfs /mount/point (xfs filesystem)


Note that for XFS, you need to specify the mount point rather than the device.

Q15. How will you rollback the packages after patching?


# yum install vsftpd

pg. 11
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

# yum history
# yum history info 8
# yum history undo 8

Q16. What is rsync and what is the syntax for rsync?


rsync is very good command for backing up/mirroring a directory tree of files from one
server to another and keeping the two machine “in sync”
# rsync <option> <encryption> <source dir> <des IP>:/<location of des dir>
# rsync -rv -e ssh/data 192.168.10.10:/root/

Q17.How to reduce the file system in linux ? FS reduction can be happened online or
not?
#1. Check the size of lv using df -hT
#2. Unmount the LV using unmount command
#3. Organize the data in LV by using e2fsck command, reason why data is spreading across
the disk not
# e2fsck -f /dev/data_vg/data_lv
#4. update the file system by using resize2fs below command
# resize2fs dev/data_vg/data_lv (where 300M is the approximate total size of LV after
reduction)
#5. Now reduce the size by using below command
# lvreduce -L -200M dev/data_vg/data_lv
#6. Mount filesystem & verify it with df -hT
Note: No, we can not reduce online. for this we need to take the proper approval on
downtime by going with change management (raised ticket)

pg. 12
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q18. How to set the numbering of lines for file by using vi editor?
:se nu

Q19. How to SCAN the disk in linux?


#echo “- - -” /sys/class/scsi_host/host0,host1/scan
The three dashes act as wildcards to rescan everything: channel, SCSI target ID, LUN

Q20. etc/fstab file is having how many feilds and describe the meaning of each field?
#1=Device Name
#2=Mount point
#3=Type of Filesystem
#4=Mount Option
#5=Dumping
#6=Checking sequence
Q21. What is the difference b/w SOFT link and HARD link? How to create it?

Note: soft link can be created for file/directory but you can only hard link to files, not
directories.

Q22. Can we create the SOFT link accross the partition? (yes/No) Please describe your
answer?
Yes, you can create a soft link (symbolic link) across different partitions in Linux
because its a shortcut file and inode number source and link file is different.

Q23. What is the location of NFS shared info?


# /etc/fstab

Q24. How to check it any particular port is listening or not?


# netstat -anp | grep 80

pg. 13
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q25. What is concept behind journalling? What is the pros and cons ?
Journaling has a dedicated area in the file system, where all the changes are tracked.
When the system crashed, journaling will helping out of there.
The possibility of the file system corruption is less because of journaling

Q26. While doing patching suppose one package is not allowing you to do patch.
Which command would you execute and how will you troubleshoot?
# rpm -ivh vsftpd --nodeps

Q27. Difference b/w df and du command?


du stands for “Disk Usage” means this command displays the disk usage (space consuming)
of the current directory and all its subdirectories.

df stands for “disk free” provide the details of various file system metadata.

Q28. What is the BOOTING process of Linux?

pg. 14
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q29. What is the meaning of pcpu and jcpu in w command?

Understanding JCPU:
For user jane, JCPU is 1:15. This means that all the processes run in this session (since 14:10)
have used 1 minute and 15 seconds of CPU time in total.
PCPU is 0.10s, which means the currently running process (vim) has used 0.10 seconds of
CPU time.
Understanding PCPU:

pg. 15
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

For user admin, PCPU is 0.30s, meaning the top command currently running has used 0.30
seconds of CPU time.
JCPU is 2:20, indicating that the total CPU time for all processes in this session (since 14:15) is
2 minutes and 20 seconds.

Q30. What happens when you type an URL in the browser and press enter?

Step1: URL Parsing:


The browser parses the URL to determine the protocol (https), domain name
(www.google.com), and possibly a path (/somepath).

Step2: DNS lookup:


It might find www.example.com cached from a previous visit or request it from a DNS
server. It gets the IP address 93.184.216.34.
If requested URL is not in the cache, ISP’s DNS server initiate a DNS query to find the IP
address of the server that host.

Step3: TCP Connection: Browser established a tcp connection with server


SYN, SYN-ACK, ACK handshake with the server at 93.184.216.34.

Step4: TLS/SSL Handshaking:Secure connection established using SSL/TLS.


For HTTPS connections, a TLS/SSL handshake occurs to establish a secure connection.
The client and server exchange encryption keys and authenticate each other using
certificates.

Step5: HTTP request & response & Browser rendering the webpage:
The browser sends an HTTP GET reques
Server process the request by Finds the index.html file and prepares the response.
The server sends an HTTP response
The browser renders the page

Q31. Difference b/w RPM and YUM ? How to check the package for particular
command?
RPM is the lower-level package management tool that directly interacts with .rpm packages,
while YUM is a higher-level tool that simplifies package management by handling
dependencies and utilizing RPM underneath.

Q32. What is ACL ? How to set ACL for particular user to provide particular
file/directory access.

Q33. What is inode.


In Linux and other Unix-like operating systems, an inode (index node) is a data structure
that stores metadata about a file or directory.
This metadata includes information such as:

pg. 16
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

- File type (regular file, directory, symbolic link, etc.)


- File size
- Permissions (read, write, execute) for user, group, and others
- Timestamps (creation, modification, access)
- File owner and group
- Pointers to the data blocks of the file on disk
e.g., Creating a File:
When you create a new file named example.txt in your Linux system, the filesystem
allocates an inode to store metadata about example.txt. This inode will contain information
such as the file type, size (initially zero if empty), permissions, timestamps, and pointers to
the data blocks.
e.g., Deleting a File:
When you delete example.txt, the filesystem marks the inode and its associated data blocks
as available for reuse. The actual data isn't immediately erased but is marked as available
until overwritten, ensuring that filesystem performance remains efficient.

Q34. Can we schedule 2 sec in crontab.


- No, it’s no possible
- Crontab only support 60 sec or 1 min.
- ***** (left to right)
- Minute (0 - 59)
- Hour (0 - 23)
- Day of Month (1 - 31)
- Month (1 - 12) or Jan, feb, mar..etc
- Day of week (0 - 6) (Sunday=0 or 7) or sun, mon, tue, wed
- command to be executed

Q35. In production env, any server is rebooted automatically. how will you
troubleshoot that server is rebooted by someone or its rebooted automatically, if
automatically then how and where will you check the logs?
# last reboot | less
# /var/log/acpi
# /var/log/{messages, syslog, dmesg}

Q36. Which command is used to change the user password expiration limit?
# chage -E date <username>

Q38. How to extract a single file from tar archive?


# tar -xvft xyz.tar | grep filename

Q39. Which command is used to see the memory?


# free -g
# free -m

Q40 - Which command is used to see the architecture of a linux server?


# uname -a

pg. 17
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

# arch

Q41 - How Search text within multiple files?


# find ./ -type f -name “*.logs” -exec grep ‘error’ {} \;

Q42 - How to delete a logs which is 30 days older?


# find /tmp/logs -name “*.logs” -mtime +30 -exec ls -ltrh {} \;
# find /tmp/logs -name “*.logs” -mtime +30 -exec rm -f {} \;

Note:
- atime is Access time, which updated whenever file’s data is accessed (read, write or any
other access) & this could be done by system process, interactively by CLI or by a script.

- mtime is modification time, which updated whenever file’s content changes. This time
stamp is not updated by a change of file permission (chown command)

- ctime is change time, which updated whenever file ownership, access permission or file
contents are modified. ctime is updated when inode data changes.

e.g.,
atime: Updated when a file is read.
mtime: Updated when a file's content is modified.
ctime: Updated when a file's metadata (or content) is changed.

- Here, Access, Modify, and Change timestamps are all the same because the file was just
created.
# touch example.txt
# stat example.txt

- Accessing the File:


# cat example.txt
# stat example.txt
Here, only the Access timestamp has changed to reflect the time the file was read.

- Modify the File:


# echo "Hello, World!" > example.txt
# stat example.txt
Now, both Modify and Change timestamps have been updated because the content of the file
was modified.

Changing File Metadata:


# chmod 755 example.txt
# stat example.txt
The Change timestamp has been updated because the file's permissions were modified, but
Access and Modify remain the same.

Q43 - How to delete a logs whose ownership changed 45 min before from root to
Hadoop?
# find /opt/Hadoop/Hadoop-0.9/logs -type f -name ‘*.xml’ -cmin +45 -exec ls -ltrh {} \;

pg. 18
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

# find /opt/Hadoop/Hadoop-0.9/logs -type f -name ‘*.xml’ -cmin +45 -exec rm -f {} \;

Q44 - User is running is-1 command in server, but he is not getting any output. What
could be the issue?
- ls list files or directory
- coreutil package
- It means your disk is having some issue might file system got corrupt.
- fsck – file system check
- umount the disk partition /dev/sda1
- # fsck <option> <filesystem>
- # fsck -p /dev/sda1

Q45 - what is run queue and which command used to check run queue?
- run-queue: number of active (running) and queued processes.
- # sar
- Package – sysstat
- # apt install sysstat
- # yum install sysstat && start sysstat service
- # zipper in sysstat
- # sar -q 1 (every sec it will refresh)

Q46 - Which file is use to change default runlevel? What happens when you changed
the default runlevel to 6?
- # /etc/inittab (SysVinit systems)
- # /etc/system/system/default.target (systemd)
- keep on rebooting

pg. 19
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q47 - What is the difference between yum update and upgrade?


- # apt-get update all
- # yum update all
- When running this command, yum will begin by checking its repository for an
updated version of the software your system currently has installed.
UPDATE & ROLLBACK PACKAGE
# sudo yum update sudo
# sudo yum history
# yum history undo <transaction_ID> -y

- yum upgrade and yum update perform the same function that update to the latest
current version of package.

- But the difference is upgrade will delete obsolete package while update will preserve
them

UPGRADE COMMAND

Q48 - How to downgrade a package?

- RHEL 6 & 7

pg. 20
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

# yum history list all


# yum history info <transaction_ID>
# yum history undo 8

- RHEL 8 & 9
# dnf history list
# dnf history info <transaction_ID>

Q49 - What is filesystem in Linux or Windows OS ?What are the types of filesystem in
Linux or Windows? • Linux: EXT2, EXt3, EXT4, XFS, JFS ?
Linux: EXT2/3/4, XFS, JFS
Window: FAT32, exFAT, NTFS

Q50 - how to remove duplicate packages?


# package-cleanup --dupes

Q51 - What is the difference b/w TCP and UDP protocol?

Q52 - How to List directory inside a directory by using find command?


- ls -d */
- find . -maxdepth 1 -type d
- find . -maxdepth 3 -type d

pg. 21
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q53 - What is diff between archive and compressed file tar and .gz?
- tar puts multiple files into single file (tar)
- gzip compresses one file (only)
- So, to get a compressed archive , you combine the two , first use tar to get all files into
single file (archive.tar), then gzip it (archive.tar.gz)

Q54 - Normal user is trying to do telnet to other server, but its getting timeout error promp. What
could be the reason?

Q55 - What is RAID? How to create RAID 3?


Redundant Array of Independent disks

pg. 22
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

RAID 0: BEST FOR HIGH-SPEED STORAGE WITH NO REDUNDANCY.


RAID 1: IDEAL FOR SYSTEMS REQUIRING SIMPLE , ROBUST REDUNDANCY.
RAID 5: GOOD FOR A BALANCE BETWEEN PERFORMANCE, REDUNDANCY, AND STORAGE EFFICIENCY.
RAID 6: PROVIDES HIGHER REDUNDANCY AT THE COST OF ADDITIONAL DISKS.
RAID 10: COMBINES THE BENEFITS OF RAID 0 AND RAID 1, OFFERING BOTH PERFORMANCE AND
REDUNDANCY.

Q56 - What is the difference b/w EXT2, EXT3,EXT4 and xis?

Q57 – How Journaling feature works in ext3, ext4, xfs filesystems?


Types of Journaling:
Metadata Journaling: Only the file system metadata changes are logged. This is faster but
offers less protection for actual file data.

pg. 23
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Full Data Journaling: Both file system metadata and actual file data are logged. This provides
the highest level of data integrity at the cost of increased write overhead.
Ordered Journaling: Metadata is logged, and data blocks are written to disk before their
associated metadata is committed to the journal. This is a compromise between performance
and data integrity.

ext3 how works (metadata and file data journal)


- When a file write operation occurs, the changes are first recorded in the journal.
- In ordered mode, the actual data blocks are written to their final locations on disk.
- After the data blocks are written, the metadata changes are committed to the journal.
- Upon a crash, ext3 can replay the journal to complete or roll back incomplete operations,
ensuring the file system's integrity.

ext4 how works (metadata and file data journal)


- Both metadata and file data are journaled.
- Write operations first log metadata (and data, if in journal mode) to the journal.
- In ordered mode, data blocks are written to their final locations before the metadata is
marked as committed in the journal.
- Ext4 can replay the journal on reboot to complete or roll back operations, similar to ext3,
but with improved performance and scalability.

xfs how works (metadata journal)


XFS journals only metadata changes. The file data itself is not journaled but written directly
to disk.
Metadata changes are first logged in the journal.
Data blocks are written to their final locations on disk.
Metadata changes are then committed to the main file system after being written to the
journal.
In case of a crash, XFS replays the metadata journal to ensure that the file system remains
consistent. Data blocks, which are not journaled, rely on the integrity mechanisms of the
storage hardware.

Q57 - Can we build a server without creating a swap partition. If yes, than what could
be the consequences?
Yes, you can build a server without creating a swap partition. However, doing so can
have several consequences that might affect the performance and stability of your
server, depending on its workload and available physical memory (RAM). Here are
some key points to consider:

Consequences of Not Having a Swap Partition


Out-of-Memory (OOM) Issues:
Behavior: Without swap space, when your server's physical memory (RAM) is fully utilized,
the system will have no additional memory to allocate for processes.
Result: The Linux kernel's OOM killer will start terminating processes to free up memory,
which can lead to unexpected application crashes and system instability.
Reduced Memory Management Flexibility:

pg. 24
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Behavior: Swap space provides additional flexibility in memory management, allowing the
system to offload inactive pages from RAM to disk.
Result: Without swap, all active and inactive memory pages must remain in RAM, which can
lead to inefficient memory usage and reduced performance, especially under heavy load.
Performance Degradation:
Behavior: Swap space can act as a buffer during short-term spikes in memory usage,
allowing the system to continue operating smoothly.
Result: Without swap, the server may experience performance degradation when memory
usage approaches the limit, as there is no fallback to handle temporary memory pressure.
Impact on Caching:
Behavior: Swap space allows the system to free up RAM for file system caching by moving
less frequently accessed data to disk.
Result: Without swap, there is less available RAM for caching, which can degrade file system
performance, especially for disk-intensive applications.
System Stability and Reliability:
Behavior: Swap space provides a safety net for memory usage, helping to prevent abrupt
application terminations.
Result: Without swap, the server is more prone to memory-related crashes, which can
impact the reliability and uptime of critical services.

When Swap Memory Comes into Action


Physical RAM Exhaustion:
Scenario: When the physical RAM is fully utilized by active processes and there is no more
free RAM available.
Action: The Linux kernel starts moving inactive pages from RAM to swap space to free up
RAM for active processes. This helps to ensure that the system continues running even
when RAM is exhausted.
Memory Pressure:
Scenario: During periods of high memory usage, such as when running memory-intensive
applications or a large number of applications simultaneously.
Action: The kernel proactively moves less frequently accessed pages to swap space to
relieve memory pressure and to make more RAM available for active and high-priority tasks.
Idle or Inactive Data:
Scenario: When certain data in RAM has not been accessed for a while and the system
needs more memory for active processes.
Action: The kernel identifies idle or inactive pages and swaps them out to disk. This process
is part of efficient memory management to ensure that frequently accessed data remains in
faster physical RAM.
System Hibernation:
Scenario: When a system is put into hibernation (suspend-to-disk).
Action: The entire contents of RAM are written to swap space. Upon resuming from
hibernation, the data is read back into RAM, restoring the system state as it was before
hibernation.
Avoiding Out-of-Memory (OOM) Situations:
Scenario: When the system is under severe memory stress and all available RAM is used up,
potentially leading to an out-of-memory condition.

pg. 25
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Action: Swap space provides an additional buffer to prevent immediate OOM conditions.
Without swap, the Linux kernel’s OOM killer might start terminating processes to free up
RAM.

Q58 - What is the difference between incremental and diff backup?

- Incremental backups only back up the data that has changed since the last backup,
whether it was a full backup or an incremental backup. It captures changes made
since the last backup, regardless of type.
- Incremental backup are introduced as a way to increase backup speed and decrease
storage space that it takes to do a full backup.
- Primary disadvantage of Incremental backup is that they can be time consuming to restore
the backup.
- Secondary disadvantage of Incremental backup is that, if any of the backup media happens
to be missing or damage then you will experience incomplete data recovery.

e.g., Backup
Monday: Full backup
Tuesday: Incremental backup since after Monday full backup
Wednesday: Incremental backup since after Tuesday backup

e.g., Restore from Wednesday backup

First, restore Monday full backup


Second, you would have to retore the Tuesday full backup
Lastly, we would have to restore the Wednesday backup

- A Differential backup capture changes made since the last full backup. Unlike incremental
backups, which capture changes since the last backup of any type, differentials always start
from the last full backup.
- The advantage of Differential backup offer over the incremental backups is shorter restore
time.

Q59 – How to check a file is opened with it’s process id?


lsof stands for “list open files” to help you to find all opened files and processes along with
the one who open them.

Q60 - How to list, all the files opened by particular PID ?


# lsof -p <PID>
# lsof -p 4271 | wc -l

Q61 - How to find out port number used by daemon ?

# sudo netstat -tuln | grep <daemon_name>


# lsof -I -P | grep 4271

pg. 26
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q62 – How to troubleshoot I/O related issue?


- List I/O statistics of all the PID
# pidstat -d

- To displace I/O stats for particular PID


# pidstat -p 180 -d

- if you are doing real-time troubleshooting for some process, then you can monitor the
below example is to monitor every 5 seconds.
# pidstat -p 180 -d 5

- Check system logs


# sudo dmesg | grep -i error
# sudo journalctl -p err

pg. 27
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q63 - Which command can be used to display system summary information and
current utilization?
# top

Q63 - To display process details for specific user?


# top -u <username>

Q64 - How to kill the process using top command?


# top-kill
Execute top & press k and it will prompt you to enter PID to be killed.

Q65 - How to find out the PID and process details of application?
# ps -ef | grep <process name>

Q66 - How to kill the process?


# kill -9 <PID>
Note: There are 64 signal

Q67 - How to Troubleshoot network issue ?


- you can use tcpdump to capture the network packets on a network interface
- To capture the packets on particular network interface
# tcpdump -i $interface -w /tmp/capture
- To read captured logs
# tcpdump -r /tmp/capture

Q68 - How to capture network traffic between source and destination IP?
# tcpdump -v src <IP of source machine> and dst host <IP of Destination Machine>
# tcpdump -v src 10.10.10.11 and dst host 10.10.10.12 -w capture

pg. 28
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q69 - How to Capture network traffic for destination port 443? How to read to
captured file?
# tcpdump dst port 443 -w <filename>
# tcpdump -r <filename>

Q70 - How to diagnose performance issue with storage devices?


- iostat stands for input-output statistics and offen used to diagnose performance issue with
storage devices. you can monitor CPU, Devices & Network file systemutilization report with
iostat.
Q71 - How to display disk I/O statistics?
# iostate -d
Q72 - How to display CPU statistics?

Q73 - If a program is not starting due to dependencies not available?


- ldd stands for list dynamic dependencies to show shared libraries needed by the library. ldd
command can be handy to diagnose the application startup problem.
- If some programme is not starting due to the dependencies not available then you can ldd to
find out the shared libraries its looking for.
# ldd /bin/sh

Scenario 1: Program Not Starting Due to Missing Libraries


If you have a program called myprogram that is not starting due to missing dependencies,
you can use ldd to identify the missing libraries.
# ldd /path/to/myprogram
If you see lines indicating "not found," like:
You need to install library by yum or dnf
# dnf install <llibexample>

pg. 29
Interview Question || Linux Realtime Scenario Based Interview Questions and Answers

Q74 - How to show stats of all protocols?

Q75 - How to see kernel routing table?

# netstat -r

Q76 - If your Linux server is running out of memory or just want to find out how much
memory available out of available memory ?
# free -g
# free -m

Q77 - To download a package with its dependencies in RHEL 9?


# dnf download --downloadonly --resolve --downloaddir=/parth/to/download <package>

pg. 30

You might also like