This curated repository of 50+ Linux programming viva and technical interview questions is designed specifically for BCA, B.Tech, MCA students, and system engineering job seekers. Click on any question to reveal the comprehensive explanation.
Shell is a interface between user and the kernel. Even though there can be only one kernel; a system can have many shells running simultaneously. Whenever a user enters a command through keyboard the shell communicates with the kernel to execute it and then display the output to the user.
Input arguments into bash programming are passed when you execute the script from the command line (e.g. ./myscript.sh arg1 arg2). The arguments are stored in positional variables: $0 is the script name itself, $1 is the first argument, $2 is the second, $# is the count of arguments, and $@ represents all arguments together.
$? gives the exit status of the last command that was executed. A value of 0 indicates successful termination, while any non-zero integer (1 to 255) indicates a failure or error code.
0 – Standard Input (stdin): Default stream from keyboard.
1 – Standard Output (stdout): Default stream to screen display.
2 – Standard Error (stderr): Error diagnostics stream to screen display.
$$ returns the Process ID (PID) of the currently executing shell/script, whereas $! shows the PID of the most recent background job launched by the shell.
The Shebang (#!/bin/bash) is a magic byte sequence at line 1 that tells the Linux kernel which interpreter executable should be launched to parse the script commands.
1. Command Mode: For cursor navigation, cut (dd), copy (yy), and paste (p).
2. Insert Mode: For typing raw text into the document (entered via 'i', 'a', 'o').
3. Ex / Last-line Mode: For saving (:w), quitting (:q), and search/replace (entered via ':').
In Command mode, type :%s/old_word/new_word/g and press Enter. To ask for interactive confirmation for each replacement, append 'c': :%s/old_word/new_word/gc.
if [ condition ]
then
# Execute statements when condition is TRUE
echo "Condition satisfied"
else
echo "Condition failed"
fi
# Standard list/range syntax
for var in 1 2 3 4 5
do
echo "Value: $var"
done
# C-style syntax
for (( i=1; i<=5; i++ ))
do
echo "Count: $i"
done
until [ condition ]
do
statement 1
statement 2
done
while [ condition ]
do
statement 1
statement 2
done
# Declare array
declare -a myarray=('Tutorials Studio' 'Veewom Technology' 'Quizer Studio')
# Access specific element (index 0)
echo ${myarray[0]}
# Print all elements
echo ${myarray[@]}
# Print number of elements
echo ${#myarray[@]}
fork() clones the calling process to create a child process with a duplicate address space. exec() (or execve()) replaces the currently running process image with an entirely new binary executable file from disk without creating a new process.
A Zombie process (defunct) is a process that has terminated via exit(), but its entry remains in the kernel process table because its parent process has not yet executed wait() or waitpid() to collect its exit status. You can resolve zombies by killing the parent process, causing init / systemd (PID 1) to adopt and reap them.
An Orphan process is an active child process whose parent died or exited before the child finished. In Linux, all orphan processes are immediately adopted by the ancestor process systemd (PID 1), which monitors them and reaps their exit codes.
Linux supports 5 major IPC mechanisms:
1. Anonymous Pipes (pipe()): Unidirectional data channel between related processes.
2. Named Pipes (FIFOs): Named file entries enabling communication between unrelated processes.
3. Shared Memory (shmget): Fastest IPC via direct RAM mapping without kernel copying.
4. Message Queues: Asynchronous message-type passing.
5. Sockets: Bidirectional communication locally or across the network.
A Signal is an asynchronous software interrupt sent to a process to notify it of an event (e.g., Ctrl+C sends SIGINT). The two signals that cannot be caught, blocked, or ignored are SIGKILL (9) and SIGSTOP (19).
A Mutex (Mutual Exclusion lock) is a synchronization primitive used in multithreaded programming to prevent Race Conditions. Only one thread can lock the mutex at a time; other threads attempting to access the critical section are put to sleep until the holding thread unlocks it via pthread_mutex_unlock().
Join the open student and developer community board in Class 37: Linux Programming Discussion Forum.
Continue to Class 37: Linux Discussion Forum → Previous: ← Lab Practicals | Full Syllabus